babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static get LogCache(): string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static set LogLevels(level: number);
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static get Now(): number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  486. /**
  487. * Returns client's state
  488. */
  489. get readyState(): number;
  490. /**
  491. * Returns client's status
  492. */
  493. get status(): number;
  494. /**
  495. * Returns client's status as a text
  496. */
  497. get statusText(): string;
  498. /**
  499. * Returns client's response
  500. */
  501. get response(): any;
  502. /**
  503. * Returns client's response url
  504. */
  505. get responseURL(): string;
  506. /**
  507. * Returns client's response as text
  508. */
  509. get responseText(): string;
  510. /**
  511. * Gets or sets the expected response type
  512. */
  513. get responseType(): XMLHttpRequestResponseType;
  514. set responseType(value: XMLHttpRequestResponseType);
  515. /** @hidden */
  516. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  517. /** @hidden */
  518. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  519. /**
  520. * Cancels any network activity
  521. */
  522. abort(): void;
  523. /**
  524. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  525. * @param body defines an optional request body
  526. */
  527. send(body?: Document | BodyInit | null): void;
  528. /**
  529. * Sets the request method, request URL
  530. * @param method defines the method to use (GET, POST, etc..)
  531. * @param url defines the url to connect with
  532. */
  533. open(method: string, url: string): void;
  534. /**
  535. * Sets the value of a request header.
  536. * @param name The name of the header whose value is to be set
  537. * @param value The value to set as the body of the header
  538. */
  539. setRequestHeader(name: string, value: string): void;
  540. /**
  541. * Get the string containing the text of a particular header's value.
  542. * @param name The name of the header
  543. * @returns The string containing the text of the given header name
  544. */
  545. getResponseHeader(name: string): Nullable<string>;
  546. }
  547. }
  548. declare module "babylonjs/Misc/fileRequest" {
  549. import { Observable } from "babylonjs/Misc/observable";
  550. /**
  551. * File request interface
  552. */
  553. export interface IFileRequest {
  554. /**
  555. * Raised when the request is complete (success or error).
  556. */
  557. onCompleteObservable: Observable<IFileRequest>;
  558. /**
  559. * Aborts the request for a file.
  560. */
  561. abort: () => void;
  562. }
  563. }
  564. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  565. /**
  566. * Define options used to create a render target texture
  567. */
  568. export class RenderTargetCreationOptions {
  569. /**
  570. * Specifies is mipmaps must be generated
  571. */
  572. generateMipMaps?: boolean;
  573. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  574. generateDepthBuffer?: boolean;
  575. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  576. generateStencilBuffer?: boolean;
  577. /** Defines texture type (int by default) */
  578. type?: number;
  579. /** Defines sampling mode (trilinear by default) */
  580. samplingMode?: number;
  581. /** Defines format (RGBA by default) */
  582. format?: number;
  583. }
  584. }
  585. declare module "babylonjs/Engines/constants" {
  586. /** Defines the cross module used constants to avoid circular dependncies */
  587. export class Constants {
  588. /** Defines that alpha blending is disabled */
  589. static readonly ALPHA_DISABLE: number;
  590. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  591. static readonly ALPHA_ADD: number;
  592. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  593. static readonly ALPHA_COMBINE: number;
  594. /** Defines that alpha blending is DEST - SRC * DEST */
  595. static readonly ALPHA_SUBTRACT: number;
  596. /** Defines that alpha blending is SRC * DEST */
  597. static readonly ALPHA_MULTIPLY: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  599. static readonly ALPHA_MAXIMIZED: number;
  600. /** Defines that alpha blending is SRC + DEST */
  601. static readonly ALPHA_ONEONE: number;
  602. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_PREMULTIPLIED: number;
  604. /**
  605. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  606. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  607. */
  608. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  609. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  610. static readonly ALPHA_INTERPOLATE: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  613. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_SCREENMODE: number;
  616. /**
  617. * Defines that alpha blending is SRC + DST
  618. * Alpha will be set to SRC ALPHA + DST ALPHA
  619. */
  620. static readonly ALPHA_ONEONE_ONEONE: number;
  621. /**
  622. * Defines that alpha blending is SRC * DST ALPHA + DST
  623. * Alpha will be set to 0
  624. */
  625. static readonly ALPHA_ALPHATOCOLOR: number;
  626. /**
  627. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  628. */
  629. static readonly ALPHA_REVERSEONEMINUS: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  632. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  633. */
  634. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  635. /**
  636. * Defines that alpha blending is SRC + DST
  637. * Alpha will be set to SRC ALPHA
  638. */
  639. static readonly ALPHA_ONEONE_ONEZERO: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. * Alpha will be set to DST ALPHA
  643. */
  644. static readonly ALPHA_EXCLUSION: number;
  645. /** Defines that alpha blending equation a SUM */
  646. static readonly ALPHA_EQUATION_ADD: number;
  647. /** Defines that alpha blending equation a SUBSTRACTION */
  648. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  649. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  650. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  651. /** Defines that alpha blending equation a MAX operation */
  652. static readonly ALPHA_EQUATION_MAX: number;
  653. /** Defines that alpha blending equation a MIN operation */
  654. static readonly ALPHA_EQUATION_MIN: number;
  655. /**
  656. * Defines that alpha blending equation a DARKEN operation:
  657. * It takes the min of the src and sums the alpha channels.
  658. */
  659. static readonly ALPHA_EQUATION_DARKEN: number;
  660. /** Defines that the ressource is not delayed*/
  661. static readonly DELAYLOADSTATE_NONE: number;
  662. /** Defines that the ressource was successfully delay loaded */
  663. static readonly DELAYLOADSTATE_LOADED: number;
  664. /** Defines that the ressource is currently delay loading */
  665. static readonly DELAYLOADSTATE_LOADING: number;
  666. /** Defines that the ressource is delayed and has not started loading */
  667. static readonly DELAYLOADSTATE_NOTLOADED: number;
  668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  669. static readonly NEVER: number;
  670. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  671. static readonly ALWAYS: number;
  672. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  673. static readonly LESS: number;
  674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  675. static readonly EQUAL: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  677. static readonly LEQUAL: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  679. static readonly GREATER: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  681. static readonly GEQUAL: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  683. static readonly NOTEQUAL: number;
  684. /** Passed to stencilOperation to specify that stencil value must be kept */
  685. static readonly KEEP: number;
  686. /** Passed to stencilOperation to specify that stencil value must be replaced */
  687. static readonly REPLACE: number;
  688. /** Passed to stencilOperation to specify that stencil value must be incremented */
  689. static readonly INCR: number;
  690. /** Passed to stencilOperation to specify that stencil value must be decremented */
  691. static readonly DECR: number;
  692. /** Passed to stencilOperation to specify that stencil value must be inverted */
  693. static readonly INVERT: number;
  694. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  695. static readonly INCR_WRAP: number;
  696. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  697. static readonly DECR_WRAP: number;
  698. /** Texture is not repeating outside of 0..1 UVs */
  699. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  700. /** Texture is repeating outside of 0..1 UVs */
  701. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  702. /** Texture is repeating and mirrored */
  703. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  704. /** ALPHA */
  705. static readonly TEXTUREFORMAT_ALPHA: number;
  706. /** LUMINANCE */
  707. static readonly TEXTUREFORMAT_LUMINANCE: number;
  708. /** LUMINANCE_ALPHA */
  709. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  710. /** RGB */
  711. static readonly TEXTUREFORMAT_RGB: number;
  712. /** RGBA */
  713. static readonly TEXTUREFORMAT_RGBA: number;
  714. /** RED */
  715. static readonly TEXTUREFORMAT_RED: number;
  716. /** RED (2nd reference) */
  717. static readonly TEXTUREFORMAT_R: number;
  718. /** RG */
  719. static readonly TEXTUREFORMAT_RG: number;
  720. /** RED_INTEGER */
  721. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  722. /** RED_INTEGER (2nd reference) */
  723. static readonly TEXTUREFORMAT_R_INTEGER: number;
  724. /** RG_INTEGER */
  725. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  726. /** RGB_INTEGER */
  727. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  728. /** RGBA_INTEGER */
  729. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  730. /** UNSIGNED_BYTE */
  731. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  732. /** UNSIGNED_BYTE (2nd reference) */
  733. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  734. /** FLOAT */
  735. static readonly TEXTURETYPE_FLOAT: number;
  736. /** HALF_FLOAT */
  737. static readonly TEXTURETYPE_HALF_FLOAT: number;
  738. /** BYTE */
  739. static readonly TEXTURETYPE_BYTE: number;
  740. /** SHORT */
  741. static readonly TEXTURETYPE_SHORT: number;
  742. /** UNSIGNED_SHORT */
  743. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  744. /** INT */
  745. static readonly TEXTURETYPE_INT: number;
  746. /** UNSIGNED_INT */
  747. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  748. /** UNSIGNED_SHORT_4_4_4_4 */
  749. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  750. /** UNSIGNED_SHORT_5_5_5_1 */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  752. /** UNSIGNED_SHORT_5_6_5 */
  753. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  754. /** UNSIGNED_INT_2_10_10_10_REV */
  755. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  756. /** UNSIGNED_INT_24_8 */
  757. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  758. /** UNSIGNED_INT_10F_11F_11F_REV */
  759. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  760. /** UNSIGNED_INT_5_9_9_9_REV */
  761. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  762. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  763. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  764. /** nearest is mag = nearest and min = nearest and no mip */
  765. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  766. /** mag = nearest and min = nearest and mip = none */
  767. static readonly TEXTURE_NEAREST_NEAREST: number;
  768. /** Bilinear is mag = linear and min = linear and no mip */
  769. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  770. /** mag = linear and min = linear and mip = none */
  771. static readonly TEXTURE_LINEAR_LINEAR: number;
  772. /** Trilinear is mag = linear and min = linear and mip = linear */
  773. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  774. /** Trilinear is mag = linear and min = linear and mip = linear */
  775. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  776. /** mag = nearest and min = nearest and mip = nearest */
  777. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  778. /** mag = nearest and min = linear and mip = nearest */
  779. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  780. /** mag = nearest and min = linear and mip = linear */
  781. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  782. /** mag = nearest and min = linear and mip = none */
  783. static readonly TEXTURE_NEAREST_LINEAR: number;
  784. /** nearest is mag = nearest and min = nearest and mip = linear */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  786. /** mag = linear and min = nearest and mip = nearest */
  787. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  788. /** mag = linear and min = nearest and mip = linear */
  789. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  790. /** Bilinear is mag = linear and min = linear and mip = nearest */
  791. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  792. /** mag = linear and min = nearest and mip = none */
  793. static readonly TEXTURE_LINEAR_NEAREST: number;
  794. /** Explicit coordinates mode */
  795. static readonly TEXTURE_EXPLICIT_MODE: number;
  796. /** Spherical coordinates mode */
  797. static readonly TEXTURE_SPHERICAL_MODE: number;
  798. /** Planar coordinates mode */
  799. static readonly TEXTURE_PLANAR_MODE: number;
  800. /** Cubic coordinates mode */
  801. static readonly TEXTURE_CUBIC_MODE: number;
  802. /** Projection coordinates mode */
  803. static readonly TEXTURE_PROJECTION_MODE: number;
  804. /** Skybox coordinates mode */
  805. static readonly TEXTURE_SKYBOX_MODE: number;
  806. /** Inverse Cubic coordinates mode */
  807. static readonly TEXTURE_INVCUBIC_MODE: number;
  808. /** Equirectangular coordinates mode */
  809. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  810. /** Equirectangular Fixed coordinates mode */
  811. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  812. /** Equirectangular Fixed Mirrored coordinates mode */
  813. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  814. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  815. static readonly SCALEMODE_FLOOR: number;
  816. /** Defines that texture rescaling will look for the nearest power of 2 size */
  817. static readonly SCALEMODE_NEAREST: number;
  818. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  819. static readonly SCALEMODE_CEILING: number;
  820. /**
  821. * The dirty texture flag value
  822. */
  823. static readonly MATERIAL_TextureDirtyFlag: number;
  824. /**
  825. * The dirty light flag value
  826. */
  827. static readonly MATERIAL_LightDirtyFlag: number;
  828. /**
  829. * The dirty fresnel flag value
  830. */
  831. static readonly MATERIAL_FresnelDirtyFlag: number;
  832. /**
  833. * The dirty attribute flag value
  834. */
  835. static readonly MATERIAL_AttributesDirtyFlag: number;
  836. /**
  837. * The dirty misc flag value
  838. */
  839. static readonly MATERIAL_MiscDirtyFlag: number;
  840. /**
  841. * The all dirty flag value
  842. */
  843. static readonly MATERIAL_AllDirtyFlag: number;
  844. /**
  845. * Returns the triangle fill mode
  846. */
  847. static readonly MATERIAL_TriangleFillMode: number;
  848. /**
  849. * Returns the wireframe mode
  850. */
  851. static readonly MATERIAL_WireFrameFillMode: number;
  852. /**
  853. * Returns the point fill mode
  854. */
  855. static readonly MATERIAL_PointFillMode: number;
  856. /**
  857. * Returns the point list draw mode
  858. */
  859. static readonly MATERIAL_PointListDrawMode: number;
  860. /**
  861. * Returns the line list draw mode
  862. */
  863. static readonly MATERIAL_LineListDrawMode: number;
  864. /**
  865. * Returns the line loop draw mode
  866. */
  867. static readonly MATERIAL_LineLoopDrawMode: number;
  868. /**
  869. * Returns the line strip draw mode
  870. */
  871. static readonly MATERIAL_LineStripDrawMode: number;
  872. /**
  873. * Returns the triangle strip draw mode
  874. */
  875. static readonly MATERIAL_TriangleStripDrawMode: number;
  876. /**
  877. * Returns the triangle fan draw mode
  878. */
  879. static readonly MATERIAL_TriangleFanDrawMode: number;
  880. /**
  881. * Stores the clock-wise side orientation
  882. */
  883. static readonly MATERIAL_ClockWiseSideOrientation: number;
  884. /**
  885. * Stores the counter clock-wise side orientation
  886. */
  887. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  888. /**
  889. * Nothing
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_NothingTrigger: number;
  893. /**
  894. * On pick
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnPickTrigger: number;
  898. /**
  899. * On left pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnLeftPickTrigger: number;
  903. /**
  904. * On right pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnRightPickTrigger: number;
  908. /**
  909. * On center pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnCenterPickTrigger: number;
  913. /**
  914. * On pick down
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickDownTrigger: number;
  918. /**
  919. * On double pick
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnDoublePickTrigger: number;
  923. /**
  924. * On pick up
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickUpTrigger: number;
  928. /**
  929. * On pick out.
  930. * This trigger will only be raised if you also declared a OnPickDown
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickOutTrigger: number;
  934. /**
  935. * On long press
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnLongPressTrigger: number;
  939. /**
  940. * On pointer over
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPointerOverTrigger: number;
  944. /**
  945. * On pointer out
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOutTrigger: number;
  949. /**
  950. * On every frame
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnEveryFrameTrigger: number;
  954. /**
  955. * On intersection enter
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnIntersectionEnterTrigger: number;
  959. /**
  960. * On intersection exit
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionExitTrigger: number;
  964. /**
  965. * On key down
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnKeyDownTrigger: number;
  969. /**
  970. * On key up
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyUpTrigger: number;
  974. /**
  975. * Billboard mode will only apply to Y axis
  976. */
  977. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  978. /**
  979. * Billboard mode will apply to all axes
  980. */
  981. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  982. /**
  983. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  986. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  987. * Test order :
  988. * Is the bounding sphere outside the frustum ?
  989. * If not, are the bounding box vertices outside the frustum ?
  990. * It not, then the cullable object is in the frustum.
  991. */
  992. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  993. /** Culling strategy : Bounding Sphere Only.
  994. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  995. * It's also less accurate than the standard because some not visible objects can still be selected.
  996. * Test : is the bounding sphere outside the frustum ?
  997. * If not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1000. /** Culling strategy : Optimistic Inclusion.
  1001. * This in an inclusion test first, then the standard exclusion test.
  1002. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1003. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1004. * Anyway, it's as accurate as the standard strategy.
  1005. * Test :
  1006. * Is the cullable object bounding sphere center in the frustum ?
  1007. * If not, apply the default culling strategy.
  1008. */
  1009. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1010. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1011. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1012. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1013. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1014. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1015. * Test :
  1016. * Is the cullable object bounding sphere center in the frustum ?
  1017. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1020. /**
  1021. * No logging while loading
  1022. */
  1023. static readonly SCENELOADER_NO_LOGGING: number;
  1024. /**
  1025. * Minimal logging while loading
  1026. */
  1027. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1028. /**
  1029. * Summary logging while loading
  1030. */
  1031. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1032. /**
  1033. * Detailled logging while loading
  1034. */
  1035. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1036. }
  1037. }
  1038. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1039. import { Nullable } from "babylonjs/types";
  1040. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1041. /**
  1042. * This represents the required contract to create a new type of texture loader.
  1043. */
  1044. export interface IInternalTextureLoader {
  1045. /**
  1046. * Defines wether the loader supports cascade loading the different faces.
  1047. */
  1048. supportCascades: boolean;
  1049. /**
  1050. * This returns if the loader support the current file information.
  1051. * @param extension defines the file extension of the file being loaded
  1052. * @returns true if the loader can load the specified file
  1053. */
  1054. canLoad(extension: string): boolean;
  1055. /**
  1056. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1057. * @param data contains the texture data
  1058. * @param texture defines the BabylonJS internal texture
  1059. * @param createPolynomials will be true if polynomials have been requested
  1060. * @param onLoad defines the callback to trigger once the texture is ready
  1061. * @param onError defines the callback to trigger in case of error
  1062. */
  1063. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1064. /**
  1065. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1066. * @param data contains the texture data
  1067. * @param texture defines the BabylonJS internal texture
  1068. * @param callback defines the method to call once ready to upload
  1069. */
  1070. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1071. }
  1072. }
  1073. declare module "babylonjs/Engines/IPipelineContext" {
  1074. /**
  1075. * Class used to store and describe the pipeline context associated with an effect
  1076. */
  1077. export interface IPipelineContext {
  1078. /**
  1079. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1080. */
  1081. isAsync: boolean;
  1082. /**
  1083. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1084. */
  1085. isReady: boolean;
  1086. /** @hidden */
  1087. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1088. }
  1089. }
  1090. declare module "babylonjs/Meshes/dataBuffer" {
  1091. /**
  1092. * Class used to store gfx data (like WebGLBuffer)
  1093. */
  1094. export class DataBuffer {
  1095. /**
  1096. * Gets or sets the number of objects referencing this buffer
  1097. */
  1098. references: number;
  1099. /** Gets or sets the size of the underlying buffer */
  1100. capacity: number;
  1101. /**
  1102. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1103. */
  1104. is32Bits: boolean;
  1105. /**
  1106. * Gets the underlying buffer
  1107. */
  1108. get underlyingResource(): any;
  1109. }
  1110. }
  1111. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1112. /** @hidden */
  1113. export interface IShaderProcessor {
  1114. attributeProcessor?: (attribute: string) => string;
  1115. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1116. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1117. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1118. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1119. lineProcessor?: (line: string, isFragment: boolean) => string;
  1120. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1121. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1122. }
  1123. }
  1124. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1125. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1126. /** @hidden */
  1127. export interface ProcessingOptions {
  1128. defines: string[];
  1129. indexParameters: any;
  1130. isFragment: boolean;
  1131. shouldUseHighPrecisionShader: boolean;
  1132. supportsUniformBuffers: boolean;
  1133. shadersRepository: string;
  1134. includesShadersStore: {
  1135. [key: string]: string;
  1136. };
  1137. processor?: IShaderProcessor;
  1138. version: string;
  1139. platformName: string;
  1140. lookForClosingBracketForUniformBuffer?: boolean;
  1141. }
  1142. }
  1143. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1144. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1145. /** @hidden */
  1146. export class ShaderCodeNode {
  1147. line: string;
  1148. children: ShaderCodeNode[];
  1149. additionalDefineKey?: string;
  1150. additionalDefineValue?: string;
  1151. isValid(preprocessors: {
  1152. [key: string]: string;
  1153. }): boolean;
  1154. process(preprocessors: {
  1155. [key: string]: string;
  1156. }, options: ProcessingOptions): string;
  1157. }
  1158. }
  1159. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1160. /** @hidden */
  1161. export class ShaderCodeCursor {
  1162. private _lines;
  1163. lineIndex: number;
  1164. get currentLine(): string;
  1165. get canRead(): boolean;
  1166. set lines(value: string[]);
  1167. }
  1168. }
  1169. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1170. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1171. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1172. /** @hidden */
  1173. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1174. process(preprocessors: {
  1175. [key: string]: string;
  1176. }, options: ProcessingOptions): string;
  1177. }
  1178. }
  1179. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1180. /** @hidden */
  1181. export class ShaderDefineExpression {
  1182. isTrue(preprocessors: {
  1183. [key: string]: string;
  1184. }): boolean;
  1185. }
  1186. }
  1187. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1188. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1189. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1190. /** @hidden */
  1191. export class ShaderCodeTestNode extends ShaderCodeNode {
  1192. testExpression: ShaderDefineExpression;
  1193. isValid(preprocessors: {
  1194. [key: string]: string;
  1195. }): boolean;
  1196. }
  1197. }
  1198. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1199. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1200. /** @hidden */
  1201. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1202. define: string;
  1203. not: boolean;
  1204. constructor(define: string, not?: boolean);
  1205. isTrue(preprocessors: {
  1206. [key: string]: string;
  1207. }): boolean;
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1211. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1212. /** @hidden */
  1213. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1214. leftOperand: ShaderDefineExpression;
  1215. rightOperand: ShaderDefineExpression;
  1216. isTrue(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1225. leftOperand: ShaderDefineExpression;
  1226. rightOperand: ShaderDefineExpression;
  1227. isTrue(preprocessors: {
  1228. [key: string]: string;
  1229. }): boolean;
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1233. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1234. /** @hidden */
  1235. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1236. define: string;
  1237. operand: string;
  1238. testValue: string;
  1239. constructor(define: string, operand: string, testValue: string);
  1240. isTrue(preprocessors: {
  1241. [key: string]: string;
  1242. }): boolean;
  1243. }
  1244. }
  1245. declare module "babylonjs/Offline/IOfflineProvider" {
  1246. /**
  1247. * Class used to enable access to offline support
  1248. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1249. */
  1250. export interface IOfflineProvider {
  1251. /**
  1252. * Gets a boolean indicating if scene must be saved in the database
  1253. */
  1254. enableSceneOffline: boolean;
  1255. /**
  1256. * Gets a boolean indicating if textures must be saved in the database
  1257. */
  1258. enableTexturesOffline: boolean;
  1259. /**
  1260. * Open the offline support and make it available
  1261. * @param successCallback defines the callback to call on success
  1262. * @param errorCallback defines the callback to call on error
  1263. */
  1264. open(successCallback: () => void, errorCallback: () => void): void;
  1265. /**
  1266. * Loads an image from the offline support
  1267. * @param url defines the url to load from
  1268. * @param image defines the target DOM image
  1269. */
  1270. loadImage(url: string, image: HTMLImageElement): void;
  1271. /**
  1272. * Loads a file from offline support
  1273. * @param url defines the URL to load from
  1274. * @param sceneLoaded defines a callback to call on success
  1275. * @param progressCallBack defines a callback to call when progress changed
  1276. * @param errorCallback defines a callback to call on error
  1277. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1278. */
  1279. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1280. }
  1281. }
  1282. declare module "babylonjs/Misc/filesInputStore" {
  1283. /**
  1284. * Class used to help managing file picking and drag'n'drop
  1285. * File Storage
  1286. */
  1287. export class FilesInputStore {
  1288. /**
  1289. * List of files ready to be loaded
  1290. */
  1291. static FilesToLoad: {
  1292. [key: string]: File;
  1293. };
  1294. }
  1295. }
  1296. declare module "babylonjs/Misc/retryStrategy" {
  1297. import { WebRequest } from "babylonjs/Misc/webRequest";
  1298. /**
  1299. * Class used to define a retry strategy when error happens while loading assets
  1300. */
  1301. export class RetryStrategy {
  1302. /**
  1303. * Function used to defines an exponential back off strategy
  1304. * @param maxRetries defines the maximum number of retries (3 by default)
  1305. * @param baseInterval defines the interval between retries
  1306. * @returns the strategy function to use
  1307. */
  1308. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1309. }
  1310. }
  1311. declare module "babylonjs/Misc/baseError" {
  1312. /**
  1313. * @ignore
  1314. * Application error to support additional information when loading a file
  1315. */
  1316. export abstract class BaseError extends Error {
  1317. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1318. }
  1319. }
  1320. declare module "babylonjs/Misc/fileTools" {
  1321. import { WebRequest } from "babylonjs/Misc/webRequest";
  1322. import { Nullable } from "babylonjs/types";
  1323. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1324. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1325. import { BaseError } from "babylonjs/Misc/baseError";
  1326. /** @ignore */
  1327. export class LoadFileError extends BaseError {
  1328. request?: WebRequest;
  1329. file?: File;
  1330. /**
  1331. * Creates a new LoadFileError
  1332. * @param message defines the message of the error
  1333. * @param request defines the optional web request
  1334. * @param file defines the optional file
  1335. */
  1336. constructor(message: string, object?: WebRequest | File);
  1337. }
  1338. /** @ignore */
  1339. export class RequestFileError extends BaseError {
  1340. request: WebRequest;
  1341. /**
  1342. * Creates a new LoadFileError
  1343. * @param message defines the message of the error
  1344. * @param request defines the optional web request
  1345. */
  1346. constructor(message: string, request: WebRequest);
  1347. }
  1348. /** @ignore */
  1349. export class ReadFileError extends BaseError {
  1350. file: File;
  1351. /**
  1352. * Creates a new ReadFileError
  1353. * @param message defines the message of the error
  1354. * @param file defines the optional file
  1355. */
  1356. constructor(message: string, file: File);
  1357. }
  1358. /**
  1359. * @hidden
  1360. */
  1361. export class FileTools {
  1362. /**
  1363. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1364. */
  1365. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1366. /**
  1367. * Gets or sets the base URL to use to load assets
  1368. */
  1369. static BaseUrl: string;
  1370. /**
  1371. * Default behaviour for cors in the application.
  1372. * It can be a string if the expected behavior is identical in the entire app.
  1373. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1374. */
  1375. static CorsBehavior: string | ((url: string | string[]) => string);
  1376. /**
  1377. * Gets or sets a function used to pre-process url before using them to load assets
  1378. */
  1379. static PreprocessUrl: (url: string) => string;
  1380. /**
  1381. * Removes unwanted characters from an url
  1382. * @param url defines the url to clean
  1383. * @returns the cleaned url
  1384. */
  1385. private static _CleanUrl;
  1386. /**
  1387. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1388. * @param url define the url we are trying
  1389. * @param element define the dom element where to configure the cors policy
  1390. */
  1391. static SetCorsBehavior(url: string | string[], element: {
  1392. crossOrigin: string | null;
  1393. }): void;
  1394. /**
  1395. * Loads an image as an HTMLImageElement.
  1396. * @param input url string, ArrayBuffer, or Blob to load
  1397. * @param onLoad callback called when the image successfully loads
  1398. * @param onError callback called when the image fails to load
  1399. * @param offlineProvider offline provider for caching
  1400. * @param mimeType optional mime type
  1401. * @returns the HTMLImageElement of the loaded image
  1402. */
  1403. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1404. /**
  1405. * Reads a file from a File object
  1406. * @param file defines the file to load
  1407. * @param onSuccess defines the callback to call when data is loaded
  1408. * @param onProgress defines the callback to call during loading process
  1409. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1410. * @param onError defines the callback to call when an error occurs
  1411. * @returns a file request object
  1412. */
  1413. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1414. /**
  1415. * Loads a file from a url
  1416. * @param url url to load
  1417. * @param onSuccess callback called when the file successfully loads
  1418. * @param onProgress callback called while file is loading (if the server supports this mode)
  1419. * @param offlineProvider defines the offline provider for caching
  1420. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1421. * @param onError callback called when the file fails to load
  1422. * @returns a file request object
  1423. */
  1424. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1425. /**
  1426. * Loads a file
  1427. * @param url url to load
  1428. * @param onSuccess callback called when the file successfully loads
  1429. * @param onProgress callback called while file is loading (if the server supports this mode)
  1430. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1431. * @param onError callback called when the file fails to load
  1432. * @param onOpened callback called when the web request is opened
  1433. * @returns a file request object
  1434. */
  1435. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1436. /**
  1437. * Checks if the loaded document was accessed via `file:`-Protocol.
  1438. * @returns boolean
  1439. */
  1440. static IsFileURL(): boolean;
  1441. }
  1442. }
  1443. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1444. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1445. import { WebRequest } from "babylonjs/Misc/webRequest";
  1446. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1447. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1448. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1449. /** @hidden */
  1450. export class ShaderProcessor {
  1451. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1452. private static _ProcessPrecision;
  1453. private static _ExtractOperation;
  1454. private static _BuildSubExpression;
  1455. private static _BuildExpression;
  1456. private static _MoveCursorWithinIf;
  1457. private static _MoveCursor;
  1458. private static _EvaluatePreProcessors;
  1459. private static _PreparePreProcessors;
  1460. private static _ProcessShaderConversion;
  1461. private static _ProcessIncludes;
  1462. /**
  1463. * Loads a file from a url
  1464. * @param url url to load
  1465. * @param onSuccess callback called when the file successfully loads
  1466. * @param onProgress callback called while file is loading (if the server supports this mode)
  1467. * @param offlineProvider defines the offline provider for caching
  1468. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1469. * @param onError callback called when the file fails to load
  1470. * @returns a file request object
  1471. * @hidden
  1472. */
  1473. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1474. }
  1475. }
  1476. declare module "babylonjs/Maths/math.like" {
  1477. import { float, int, DeepImmutable } from "babylonjs/types";
  1478. /**
  1479. * @hidden
  1480. */
  1481. export interface IColor4Like {
  1482. r: float;
  1483. g: float;
  1484. b: float;
  1485. a: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IColor3Like {
  1491. r: float;
  1492. g: float;
  1493. b: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IVector4Like {
  1499. x: float;
  1500. y: float;
  1501. z: float;
  1502. w: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector3Like {
  1508. x: float;
  1509. y: float;
  1510. z: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector2Like {
  1516. x: float;
  1517. y: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IMatrixLike {
  1523. toArray(): DeepImmutable<Float32Array>;
  1524. updateFlag: int;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IViewportLike {
  1530. x: float;
  1531. y: float;
  1532. width: float;
  1533. height: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IPlaneLike {
  1539. normal: IVector3Like;
  1540. d: float;
  1541. normalize(): void;
  1542. }
  1543. }
  1544. declare module "babylonjs/Materials/iEffectFallbacks" {
  1545. import { Effect } from "babylonjs/Materials/effect";
  1546. /**
  1547. * Interface used to define common properties for effect fallbacks
  1548. */
  1549. export interface IEffectFallbacks {
  1550. /**
  1551. * Removes the defines that should be removed when falling back.
  1552. * @param currentDefines defines the current define statements for the shader.
  1553. * @param effect defines the current effect we try to compile
  1554. * @returns The resulting defines with defines of the current rank removed.
  1555. */
  1556. reduce(currentDefines: string, effect: Effect): string;
  1557. /**
  1558. * Removes the fallback from the bound mesh.
  1559. */
  1560. unBindMesh(): void;
  1561. /**
  1562. * Checks to see if more fallbacks are still availible.
  1563. */
  1564. hasMoreFallbacks: boolean;
  1565. }
  1566. }
  1567. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1568. /**
  1569. * Class used to evalaute queries containing `and` and `or` operators
  1570. */
  1571. export class AndOrNotEvaluator {
  1572. /**
  1573. * Evaluate a query
  1574. * @param query defines the query to evaluate
  1575. * @param evaluateCallback defines the callback used to filter result
  1576. * @returns true if the query matches
  1577. */
  1578. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1579. private static _HandleParenthesisContent;
  1580. private static _SimplifyNegation;
  1581. }
  1582. }
  1583. declare module "babylonjs/Misc/tags" {
  1584. /**
  1585. * Class used to store custom tags
  1586. */
  1587. export class Tags {
  1588. /**
  1589. * Adds support for tags on the given object
  1590. * @param obj defines the object to use
  1591. */
  1592. static EnableFor(obj: any): void;
  1593. /**
  1594. * Removes tags support
  1595. * @param obj defines the object to use
  1596. */
  1597. static DisableFor(obj: any): void;
  1598. /**
  1599. * Gets a boolean indicating if the given object has tags
  1600. * @param obj defines the object to use
  1601. * @returns a boolean
  1602. */
  1603. static HasTags(obj: any): boolean;
  1604. /**
  1605. * Gets the tags available on a given object
  1606. * @param obj defines the object to use
  1607. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1608. * @returns the tags
  1609. */
  1610. static GetTags(obj: any, asString?: boolean): any;
  1611. /**
  1612. * Adds tags to an object
  1613. * @param obj defines the object to use
  1614. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1615. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1616. */
  1617. static AddTagsTo(obj: any, tagsString: string): void;
  1618. /**
  1619. * @hidden
  1620. */
  1621. static _AddTagTo(obj: any, tag: string): void;
  1622. /**
  1623. * Removes specific tags from a specific object
  1624. * @param obj defines the object to use
  1625. * @param tagsString defines the tags to remove
  1626. */
  1627. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1628. /**
  1629. * @hidden
  1630. */
  1631. static _RemoveTagFrom(obj: any, tag: string): void;
  1632. /**
  1633. * Defines if tags hosted on an object match a given query
  1634. * @param obj defines the object to use
  1635. * @param tagsQuery defines the tag query
  1636. * @returns a boolean
  1637. */
  1638. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1639. }
  1640. }
  1641. declare module "babylonjs/Maths/math.scalar" {
  1642. /**
  1643. * Scalar computation library
  1644. */
  1645. export class Scalar {
  1646. /**
  1647. * Two pi constants convenient for computation.
  1648. */
  1649. static TwoPi: number;
  1650. /**
  1651. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1652. * @param a number
  1653. * @param b number
  1654. * @param epsilon (default = 1.401298E-45)
  1655. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1656. */
  1657. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1658. /**
  1659. * Returns a string : the upper case translation of the number i to hexadecimal.
  1660. * @param i number
  1661. * @returns the upper case translation of the number i to hexadecimal.
  1662. */
  1663. static ToHex(i: number): string;
  1664. /**
  1665. * Returns -1 if value is negative and +1 is value is positive.
  1666. * @param value the value
  1667. * @returns the value itself if it's equal to zero.
  1668. */
  1669. static Sign(value: number): number;
  1670. /**
  1671. * Returns the value itself if it's between min and max.
  1672. * Returns min if the value is lower than min.
  1673. * Returns max if the value is greater than max.
  1674. * @param value the value to clmap
  1675. * @param min the min value to clamp to (default: 0)
  1676. * @param max the max value to clamp to (default: 1)
  1677. * @returns the clamped value
  1678. */
  1679. static Clamp(value: number, min?: number, max?: number): number;
  1680. /**
  1681. * the log2 of value.
  1682. * @param value the value to compute log2 of
  1683. * @returns the log2 of value.
  1684. */
  1685. static Log2(value: number): number;
  1686. /**
  1687. * Loops the value, so that it is never larger than length and never smaller than 0.
  1688. *
  1689. * This is similar to the modulo operator but it works with floating point numbers.
  1690. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1691. * With t = 5 and length = 2.5, the result would be 0.0.
  1692. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1693. * @param value the value
  1694. * @param length the length
  1695. * @returns the looped value
  1696. */
  1697. static Repeat(value: number, length: number): number;
  1698. /**
  1699. * Normalize the value between 0.0 and 1.0 using min and max values
  1700. * @param value value to normalize
  1701. * @param min max to normalize between
  1702. * @param max min to normalize between
  1703. * @returns the normalized value
  1704. */
  1705. static Normalize(value: number, min: number, max: number): number;
  1706. /**
  1707. * Denormalize the value from 0.0 and 1.0 using min and max values
  1708. * @param normalized value to denormalize
  1709. * @param min max to denormalize between
  1710. * @param max min to denormalize between
  1711. * @returns the denormalized value
  1712. */
  1713. static Denormalize(normalized: number, min: number, max: number): number;
  1714. /**
  1715. * Calculates the shortest difference between two given angles given in degrees.
  1716. * @param current current angle in degrees
  1717. * @param target target angle in degrees
  1718. * @returns the delta
  1719. */
  1720. static DeltaAngle(current: number, target: number): number;
  1721. /**
  1722. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1723. * @param tx value
  1724. * @param length length
  1725. * @returns The returned value will move back and forth between 0 and length
  1726. */
  1727. static PingPong(tx: number, length: number): number;
  1728. /**
  1729. * Interpolates between min and max with smoothing at the limits.
  1730. *
  1731. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1732. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1733. * @param from from
  1734. * @param to to
  1735. * @param tx value
  1736. * @returns the smooth stepped value
  1737. */
  1738. static SmoothStep(from: number, to: number, tx: number): number;
  1739. /**
  1740. * Moves a value current towards target.
  1741. *
  1742. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1743. * Negative values of maxDelta pushes the value away from target.
  1744. * @param current current value
  1745. * @param target target value
  1746. * @param maxDelta max distance to move
  1747. * @returns resulting value
  1748. */
  1749. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1750. /**
  1751. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1752. *
  1753. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1754. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1755. * @param current current value
  1756. * @param target target value
  1757. * @param maxDelta max distance to move
  1758. * @returns resulting angle
  1759. */
  1760. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1761. /**
  1762. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1763. * @param start start value
  1764. * @param end target value
  1765. * @param amount amount to lerp between
  1766. * @returns the lerped value
  1767. */
  1768. static Lerp(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1771. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1772. * @param start start value
  1773. * @param end target value
  1774. * @param amount amount to lerp between
  1775. * @returns the lerped value
  1776. */
  1777. static LerpAngle(start: number, end: number, amount: number): number;
  1778. /**
  1779. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1780. * @param a start value
  1781. * @param b target value
  1782. * @param value value between a and b
  1783. * @returns the inverseLerp value
  1784. */
  1785. static InverseLerp(a: number, b: number, value: number): number;
  1786. /**
  1787. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1788. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1789. * @param value1 spline value
  1790. * @param tangent1 spline value
  1791. * @param value2 spline value
  1792. * @param tangent2 spline value
  1793. * @param amount input value
  1794. * @returns hermite result
  1795. */
  1796. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1797. /**
  1798. * Returns a random float number between and min and max values
  1799. * @param min min value of random
  1800. * @param max max value of random
  1801. * @returns random value
  1802. */
  1803. static RandomRange(min: number, max: number): number;
  1804. /**
  1805. * This function returns percentage of a number in a given range.
  1806. *
  1807. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1808. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1809. * @param number to convert to percentage
  1810. * @param min min range
  1811. * @param max max range
  1812. * @returns the percentage
  1813. */
  1814. static RangeToPercent(number: number, min: number, max: number): number;
  1815. /**
  1816. * This function returns number that corresponds to the percentage in a given range.
  1817. *
  1818. * PercentToRange(0.34,0,100) will return 34.
  1819. * @param percent to convert to number
  1820. * @param min min range
  1821. * @param max max range
  1822. * @returns the number
  1823. */
  1824. static PercentToRange(percent: number, min: number, max: number): number;
  1825. /**
  1826. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1827. * @param angle The angle to normalize in radian.
  1828. * @return The converted angle.
  1829. */
  1830. static NormalizeRadians(angle: number): number;
  1831. }
  1832. }
  1833. declare module "babylonjs/Maths/math.constants" {
  1834. /**
  1835. * Constant used to convert a value to gamma space
  1836. * @ignorenaming
  1837. */
  1838. export const ToGammaSpace: number;
  1839. /**
  1840. * Constant used to convert a value to linear space
  1841. * @ignorenaming
  1842. */
  1843. export const ToLinearSpace = 2.2;
  1844. /**
  1845. * Constant used to define the minimal number value in Babylon.js
  1846. * @ignorenaming
  1847. */
  1848. let Epsilon: number;
  1849. export { Epsilon };
  1850. }
  1851. declare module "babylonjs/Maths/math.viewport" {
  1852. /**
  1853. * Class used to represent a viewport on screen
  1854. */
  1855. export class Viewport {
  1856. /** viewport left coordinate */
  1857. x: number;
  1858. /** viewport top coordinate */
  1859. y: number;
  1860. /**viewport width */
  1861. width: number;
  1862. /** viewport height */
  1863. height: number;
  1864. /**
  1865. * Creates a Viewport object located at (x, y) and sized (width, height)
  1866. * @param x defines viewport left coordinate
  1867. * @param y defines viewport top coordinate
  1868. * @param width defines the viewport width
  1869. * @param height defines the viewport height
  1870. */
  1871. constructor(
  1872. /** viewport left coordinate */
  1873. x: number,
  1874. /** viewport top coordinate */
  1875. y: number,
  1876. /**viewport width */
  1877. width: number,
  1878. /** viewport height */
  1879. height: number);
  1880. /**
  1881. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1882. * @param renderWidth defines the rendering width
  1883. * @param renderHeight defines the rendering height
  1884. * @returns a new Viewport
  1885. */
  1886. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1887. /**
  1888. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1889. * @param renderWidth defines the rendering width
  1890. * @param renderHeight defines the rendering height
  1891. * @param ref defines the target viewport
  1892. * @returns the current viewport
  1893. */
  1894. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1895. /**
  1896. * Returns a new Viewport copied from the current one
  1897. * @returns a new Viewport
  1898. */
  1899. clone(): Viewport;
  1900. }
  1901. }
  1902. declare module "babylonjs/Misc/arrayTools" {
  1903. /**
  1904. * Class containing a set of static utilities functions for arrays.
  1905. */
  1906. export class ArrayTools {
  1907. /**
  1908. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1909. * @param size the number of element to construct and put in the array
  1910. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1911. * @returns a new array filled with new objects
  1912. */
  1913. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1914. }
  1915. }
  1916. declare module "babylonjs/Maths/math.vector" {
  1917. import { Viewport } from "babylonjs/Maths/math.viewport";
  1918. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1919. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1920. /**
  1921. * Class representing a vector containing 2 coordinates
  1922. */
  1923. export class Vector2 {
  1924. /** defines the first coordinate */
  1925. x: number;
  1926. /** defines the second coordinate */
  1927. y: number;
  1928. /**
  1929. * Creates a new Vector2 from the given x and y coordinates
  1930. * @param x defines the first coordinate
  1931. * @param y defines the second coordinate
  1932. */
  1933. constructor(
  1934. /** defines the first coordinate */
  1935. x?: number,
  1936. /** defines the second coordinate */
  1937. y?: number);
  1938. /**
  1939. * Gets a string with the Vector2 coordinates
  1940. * @returns a string with the Vector2 coordinates
  1941. */
  1942. toString(): string;
  1943. /**
  1944. * Gets class name
  1945. * @returns the string "Vector2"
  1946. */
  1947. getClassName(): string;
  1948. /**
  1949. * Gets current vector hash code
  1950. * @returns the Vector2 hash code as a number
  1951. */
  1952. getHashCode(): number;
  1953. /**
  1954. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1955. * @param array defines the source array
  1956. * @param index defines the offset in source array
  1957. * @returns the current Vector2
  1958. */
  1959. toArray(array: FloatArray, index?: number): Vector2;
  1960. /**
  1961. * Copy the current vector to an array
  1962. * @returns a new array with 2 elements: the Vector2 coordinates.
  1963. */
  1964. asArray(): number[];
  1965. /**
  1966. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1967. * @param source defines the source Vector2
  1968. * @returns the current updated Vector2
  1969. */
  1970. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1971. /**
  1972. * Sets the Vector2 coordinates with the given floats
  1973. * @param x defines the first coordinate
  1974. * @param y defines the second coordinate
  1975. * @returns the current updated Vector2
  1976. */
  1977. copyFromFloats(x: number, y: number): Vector2;
  1978. /**
  1979. * Sets the Vector2 coordinates with the given floats
  1980. * @param x defines the first coordinate
  1981. * @param y defines the second coordinate
  1982. * @returns the current updated Vector2
  1983. */
  1984. set(x: number, y: number): Vector2;
  1985. /**
  1986. * Add another vector with the current one
  1987. * @param otherVector defines the other vector
  1988. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1989. */
  1990. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1991. /**
  1992. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1993. * @param otherVector defines the other vector
  1994. * @param result defines the target vector
  1995. * @returns the unmodified current Vector2
  1996. */
  1997. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1998. /**
  1999. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2000. * @param otherVector defines the other vector
  2001. * @returns the current updated Vector2
  2002. */
  2003. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2004. /**
  2005. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2006. * @param otherVector defines the other vector
  2007. * @returns a new Vector2
  2008. */
  2009. addVector3(otherVector: Vector3): Vector2;
  2010. /**
  2011. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2012. * @param otherVector defines the other vector
  2013. * @returns a new Vector2
  2014. */
  2015. subtract(otherVector: Vector2): Vector2;
  2016. /**
  2017. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2018. * @param otherVector defines the other vector
  2019. * @param result defines the target vector
  2020. * @returns the unmodified current Vector2
  2021. */
  2022. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2023. /**
  2024. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2025. * @param otherVector defines the other vector
  2026. * @returns the current updated Vector2
  2027. */
  2028. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2029. /**
  2030. * Multiplies in place the current Vector2 coordinates by the given ones
  2031. * @param otherVector defines the other vector
  2032. * @returns the current updated Vector2
  2033. */
  2034. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2035. /**
  2036. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2037. * @param otherVector defines the other vector
  2038. * @returns a new Vector2
  2039. */
  2040. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2041. /**
  2042. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2043. * @param otherVector defines the other vector
  2044. * @param result defines the target vector
  2045. * @returns the unmodified current Vector2
  2046. */
  2047. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2048. /**
  2049. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2050. * @param x defines the first coordinate
  2051. * @param y defines the second coordinate
  2052. * @returns a new Vector2
  2053. */
  2054. multiplyByFloats(x: number, y: number): Vector2;
  2055. /**
  2056. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2057. * @param otherVector defines the other vector
  2058. * @returns a new Vector2
  2059. */
  2060. divide(otherVector: Vector2): Vector2;
  2061. /**
  2062. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2063. * @param otherVector defines the other vector
  2064. * @param result defines the target vector
  2065. * @returns the unmodified current Vector2
  2066. */
  2067. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2068. /**
  2069. * Divides the current Vector2 coordinates by the given ones
  2070. * @param otherVector defines the other vector
  2071. * @returns the current updated Vector2
  2072. */
  2073. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2074. /**
  2075. * Gets a new Vector2 with current Vector2 negated coordinates
  2076. * @returns a new Vector2
  2077. */
  2078. negate(): Vector2;
  2079. /**
  2080. * Negate this vector in place
  2081. * @returns this
  2082. */
  2083. negateInPlace(): Vector2;
  2084. /**
  2085. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2086. * @param result defines the Vector3 object where to store the result
  2087. * @returns the current Vector2
  2088. */
  2089. negateToRef(result: Vector2): Vector2;
  2090. /**
  2091. * Multiply the Vector2 coordinates by scale
  2092. * @param scale defines the scaling factor
  2093. * @returns the current updated Vector2
  2094. */
  2095. scaleInPlace(scale: number): Vector2;
  2096. /**
  2097. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2098. * @param scale defines the scaling factor
  2099. * @returns a new Vector2
  2100. */
  2101. scale(scale: number): Vector2;
  2102. /**
  2103. * Scale the current Vector2 values by a factor to a given Vector2
  2104. * @param scale defines the scale factor
  2105. * @param result defines the Vector2 object where to store the result
  2106. * @returns the unmodified current Vector2
  2107. */
  2108. scaleToRef(scale: number, result: Vector2): Vector2;
  2109. /**
  2110. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2111. * @param scale defines the scale factor
  2112. * @param result defines the Vector2 object where to store the result
  2113. * @returns the unmodified current Vector2
  2114. */
  2115. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2116. /**
  2117. * Gets a boolean if two vectors are equals
  2118. * @param otherVector defines the other vector
  2119. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2120. */
  2121. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2122. /**
  2123. * Gets a boolean if two vectors are equals (using an epsilon value)
  2124. * @param otherVector defines the other vector
  2125. * @param epsilon defines the minimal distance to consider equality
  2126. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2127. */
  2128. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2129. /**
  2130. * Gets a new Vector2 from current Vector2 floored values
  2131. * @returns a new Vector2
  2132. */
  2133. floor(): Vector2;
  2134. /**
  2135. * Gets a new Vector2 from current Vector2 floored values
  2136. * @returns a new Vector2
  2137. */
  2138. fract(): Vector2;
  2139. /**
  2140. * Gets the length of the vector
  2141. * @returns the vector length (float)
  2142. */
  2143. length(): number;
  2144. /**
  2145. * Gets the vector squared length
  2146. * @returns the vector squared length (float)
  2147. */
  2148. lengthSquared(): number;
  2149. /**
  2150. * Normalize the vector
  2151. * @returns the current updated Vector2
  2152. */
  2153. normalize(): Vector2;
  2154. /**
  2155. * Gets a new Vector2 copied from the Vector2
  2156. * @returns a new Vector2
  2157. */
  2158. clone(): Vector2;
  2159. /**
  2160. * Gets a new Vector2(0, 0)
  2161. * @returns a new Vector2
  2162. */
  2163. static Zero(): Vector2;
  2164. /**
  2165. * Gets a new Vector2(1, 1)
  2166. * @returns a new Vector2
  2167. */
  2168. static One(): Vector2;
  2169. /**
  2170. * Gets a new Vector2 set from the given index element of the given array
  2171. * @param array defines the data source
  2172. * @param offset defines the offset in the data source
  2173. * @returns a new Vector2
  2174. */
  2175. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2176. /**
  2177. * Sets "result" from the given index element of the given array
  2178. * @param array defines the data source
  2179. * @param offset defines the offset in the data source
  2180. * @param result defines the target vector
  2181. */
  2182. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2183. /**
  2184. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2185. * @param value1 defines 1st point of control
  2186. * @param value2 defines 2nd point of control
  2187. * @param value3 defines 3rd point of control
  2188. * @param value4 defines 4th point of control
  2189. * @param amount defines the interpolation factor
  2190. * @returns a new Vector2
  2191. */
  2192. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2193. /**
  2194. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2195. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2196. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2197. * @param value defines the value to clamp
  2198. * @param min defines the lower limit
  2199. * @param max defines the upper limit
  2200. * @returns a new Vector2
  2201. */
  2202. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2203. /**
  2204. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2205. * @param value1 defines the 1st control point
  2206. * @param tangent1 defines the outgoing tangent
  2207. * @param value2 defines the 2nd control point
  2208. * @param tangent2 defines the incoming tangent
  2209. * @param amount defines the interpolation factor
  2210. * @returns a new Vector2
  2211. */
  2212. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2213. /**
  2214. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2215. * @param start defines the start vector
  2216. * @param end defines the end vector
  2217. * @param amount defines the interpolation factor
  2218. * @returns a new Vector2
  2219. */
  2220. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2221. /**
  2222. * Gets the dot product of the vector "left" and the vector "right"
  2223. * @param left defines first vector
  2224. * @param right defines second vector
  2225. * @returns the dot product (float)
  2226. */
  2227. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2228. /**
  2229. * Returns a new Vector2 equal to the normalized given vector
  2230. * @param vector defines the vector to normalize
  2231. * @returns a new Vector2
  2232. */
  2233. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2234. /**
  2235. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2236. * @param left defines 1st vector
  2237. * @param right defines 2nd vector
  2238. * @returns a new Vector2
  2239. */
  2240. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2241. /**
  2242. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2243. * @param left defines 1st vector
  2244. * @param right defines 2nd vector
  2245. * @returns a new Vector2
  2246. */
  2247. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2248. /**
  2249. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2250. * @param vector defines the vector to transform
  2251. * @param transformation defines the matrix to apply
  2252. * @returns a new Vector2
  2253. */
  2254. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2255. /**
  2256. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2257. * @param vector defines the vector to transform
  2258. * @param transformation defines the matrix to apply
  2259. * @param result defines the target vector
  2260. */
  2261. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2262. /**
  2263. * Determines if a given vector is included in a triangle
  2264. * @param p defines the vector to test
  2265. * @param p0 defines 1st triangle point
  2266. * @param p1 defines 2nd triangle point
  2267. * @param p2 defines 3rd triangle point
  2268. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2269. */
  2270. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2271. /**
  2272. * Gets the distance between the vectors "value1" and "value2"
  2273. * @param value1 defines first vector
  2274. * @param value2 defines second vector
  2275. * @returns the distance between vectors
  2276. */
  2277. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2278. /**
  2279. * Returns the squared distance between the vectors "value1" and "value2"
  2280. * @param value1 defines first vector
  2281. * @param value2 defines second vector
  2282. * @returns the squared distance between vectors
  2283. */
  2284. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2285. /**
  2286. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2287. * @param value1 defines first vector
  2288. * @param value2 defines second vector
  2289. * @returns a new Vector2
  2290. */
  2291. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2292. /**
  2293. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2294. * @param p defines the middle point
  2295. * @param segA defines one point of the segment
  2296. * @param segB defines the other point of the segment
  2297. * @returns the shortest distance
  2298. */
  2299. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2300. }
  2301. /**
  2302. * Class used to store (x,y,z) vector representation
  2303. * A Vector3 is the main object used in 3D geometry
  2304. * It can represent etiher the coordinates of a point the space, either a direction
  2305. * Reminder: js uses a left handed forward facing system
  2306. */
  2307. export class Vector3 {
  2308. /**
  2309. * Defines the first coordinates (on X axis)
  2310. */
  2311. x: number;
  2312. /**
  2313. * Defines the second coordinates (on Y axis)
  2314. */
  2315. y: number;
  2316. /**
  2317. * Defines the third coordinates (on Z axis)
  2318. */
  2319. z: number;
  2320. private static _UpReadOnly;
  2321. private static _ZeroReadOnly;
  2322. /**
  2323. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2324. * @param x defines the first coordinates (on X axis)
  2325. * @param y defines the second coordinates (on Y axis)
  2326. * @param z defines the third coordinates (on Z axis)
  2327. */
  2328. constructor(
  2329. /**
  2330. * Defines the first coordinates (on X axis)
  2331. */
  2332. x?: number,
  2333. /**
  2334. * Defines the second coordinates (on Y axis)
  2335. */
  2336. y?: number,
  2337. /**
  2338. * Defines the third coordinates (on Z axis)
  2339. */
  2340. z?: number);
  2341. /**
  2342. * Creates a string representation of the Vector3
  2343. * @returns a string with the Vector3 coordinates.
  2344. */
  2345. toString(): string;
  2346. /**
  2347. * Gets the class name
  2348. * @returns the string "Vector3"
  2349. */
  2350. getClassName(): string;
  2351. /**
  2352. * Creates the Vector3 hash code
  2353. * @returns a number which tends to be unique between Vector3 instances
  2354. */
  2355. getHashCode(): number;
  2356. /**
  2357. * Creates an array containing three elements : the coordinates of the Vector3
  2358. * @returns a new array of numbers
  2359. */
  2360. asArray(): number[];
  2361. /**
  2362. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2363. * @param array defines the destination array
  2364. * @param index defines the offset in the destination array
  2365. * @returns the current Vector3
  2366. */
  2367. toArray(array: FloatArray, index?: number): Vector3;
  2368. /**
  2369. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2370. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2371. */
  2372. toQuaternion(): Quaternion;
  2373. /**
  2374. * Adds the given vector to the current Vector3
  2375. * @param otherVector defines the second operand
  2376. * @returns the current updated Vector3
  2377. */
  2378. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2379. /**
  2380. * Adds the given coordinates to the current Vector3
  2381. * @param x defines the x coordinate of the operand
  2382. * @param y defines the y coordinate of the operand
  2383. * @param z defines the z coordinate of the operand
  2384. * @returns the current updated Vector3
  2385. */
  2386. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2387. /**
  2388. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2389. * @param otherVector defines the second operand
  2390. * @returns the resulting Vector3
  2391. */
  2392. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2393. /**
  2394. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2395. * @param otherVector defines the second operand
  2396. * @param result defines the Vector3 object where to store the result
  2397. * @returns the current Vector3
  2398. */
  2399. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2400. /**
  2401. * Subtract the given vector from the current Vector3
  2402. * @param otherVector defines the second operand
  2403. * @returns the current updated Vector3
  2404. */
  2405. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2406. /**
  2407. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2408. * @param otherVector defines the second operand
  2409. * @returns the resulting Vector3
  2410. */
  2411. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2412. /**
  2413. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2414. * @param otherVector defines the second operand
  2415. * @param result defines the Vector3 object where to store the result
  2416. * @returns the current Vector3
  2417. */
  2418. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2419. /**
  2420. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2421. * @param x defines the x coordinate of the operand
  2422. * @param y defines the y coordinate of the operand
  2423. * @param z defines the z coordinate of the operand
  2424. * @returns the resulting Vector3
  2425. */
  2426. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2427. /**
  2428. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2429. * @param x defines the x coordinate of the operand
  2430. * @param y defines the y coordinate of the operand
  2431. * @param z defines the z coordinate of the operand
  2432. * @param result defines the Vector3 object where to store the result
  2433. * @returns the current Vector3
  2434. */
  2435. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2436. /**
  2437. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2438. * @returns a new Vector3
  2439. */
  2440. negate(): Vector3;
  2441. /**
  2442. * Negate this vector in place
  2443. * @returns this
  2444. */
  2445. negateInPlace(): Vector3;
  2446. /**
  2447. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2448. * @param result defines the Vector3 object where to store the result
  2449. * @returns the current Vector3
  2450. */
  2451. negateToRef(result: Vector3): Vector3;
  2452. /**
  2453. * Multiplies the Vector3 coordinates by the float "scale"
  2454. * @param scale defines the multiplier factor
  2455. * @returns the current updated Vector3
  2456. */
  2457. scaleInPlace(scale: number): Vector3;
  2458. /**
  2459. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2460. * @param scale defines the multiplier factor
  2461. * @returns a new Vector3
  2462. */
  2463. scale(scale: number): Vector3;
  2464. /**
  2465. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2466. * @param scale defines the multiplier factor
  2467. * @param result defines the Vector3 object where to store the result
  2468. * @returns the current Vector3
  2469. */
  2470. scaleToRef(scale: number, result: Vector3): Vector3;
  2471. /**
  2472. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2473. * @param scale defines the scale factor
  2474. * @param result defines the Vector3 object where to store the result
  2475. * @returns the unmodified current Vector3
  2476. */
  2477. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2478. /**
  2479. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2480. * @param otherVector defines the second operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2484. /**
  2485. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2486. * @param otherVector defines the second operand
  2487. * @param epsilon defines the minimal distance to define values as equals
  2488. * @returns true if both vectors are distant less than epsilon
  2489. */
  2490. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2491. /**
  2492. * Returns true if the current Vector3 coordinates equals the given floats
  2493. * @param x defines the x coordinate of the operand
  2494. * @param y defines the y coordinate of the operand
  2495. * @param z defines the z coordinate of the operand
  2496. * @returns true if both vectors are equals
  2497. */
  2498. equalsToFloats(x: number, y: number, z: number): boolean;
  2499. /**
  2500. * Multiplies the current Vector3 coordinates by the given ones
  2501. * @param otherVector defines the second operand
  2502. * @returns the current updated Vector3
  2503. */
  2504. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2505. /**
  2506. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2507. * @param otherVector defines the second operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2511. /**
  2512. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2513. * @param otherVector defines the second operand
  2514. * @param result defines the Vector3 object where to store the result
  2515. * @returns the current Vector3
  2516. */
  2517. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2518. /**
  2519. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2520. * @param x defines the x coordinate of the operand
  2521. * @param y defines the y coordinate of the operand
  2522. * @param z defines the z coordinate of the operand
  2523. * @returns the new Vector3
  2524. */
  2525. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2526. /**
  2527. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2528. * @param otherVector defines the second operand
  2529. * @returns the new Vector3
  2530. */
  2531. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2532. /**
  2533. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2534. * @param otherVector defines the second operand
  2535. * @param result defines the Vector3 object where to store the result
  2536. * @returns the current Vector3
  2537. */
  2538. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2539. /**
  2540. * Divides the current Vector3 coordinates by the given ones.
  2541. * @param otherVector defines the second operand
  2542. * @returns the current updated Vector3
  2543. */
  2544. divideInPlace(otherVector: Vector3): Vector3;
  2545. /**
  2546. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2547. * @param other defines the second operand
  2548. * @returns the current updated Vector3
  2549. */
  2550. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2551. /**
  2552. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2553. * @param other defines the second operand
  2554. * @returns the current updated Vector3
  2555. */
  2556. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2557. /**
  2558. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2559. * @param x defines the x coordinate of the operand
  2560. * @param y defines the y coordinate of the operand
  2561. * @param z defines the z coordinate of the operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2565. /**
  2566. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2567. * @param x defines the x coordinate of the operand
  2568. * @param y defines the y coordinate of the operand
  2569. * @param z defines the z coordinate of the operand
  2570. * @returns the current updated Vector3
  2571. */
  2572. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2573. /**
  2574. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2575. * Check if is non uniform within a certain amount of decimal places to account for this
  2576. * @param epsilon the amount the values can differ
  2577. * @returns if the the vector is non uniform to a certain number of decimal places
  2578. */
  2579. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2580. /**
  2581. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2582. */
  2583. get isNonUniform(): boolean;
  2584. /**
  2585. * Gets a new Vector3 from current Vector3 floored values
  2586. * @returns a new Vector3
  2587. */
  2588. floor(): Vector3;
  2589. /**
  2590. * Gets a new Vector3 from current Vector3 floored values
  2591. * @returns a new Vector3
  2592. */
  2593. fract(): Vector3;
  2594. /**
  2595. * Gets the length of the Vector3
  2596. * @returns the length of the Vector3
  2597. */
  2598. length(): number;
  2599. /**
  2600. * Gets the squared length of the Vector3
  2601. * @returns squared length of the Vector3
  2602. */
  2603. lengthSquared(): number;
  2604. /**
  2605. * Normalize the current Vector3.
  2606. * Please note that this is an in place operation.
  2607. * @returns the current updated Vector3
  2608. */
  2609. normalize(): Vector3;
  2610. /**
  2611. * Reorders the x y z properties of the vector in place
  2612. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2613. * @returns the current updated vector
  2614. */
  2615. reorderInPlace(order: string): this;
  2616. /**
  2617. * Rotates the vector around 0,0,0 by a quaternion
  2618. * @param quaternion the rotation quaternion
  2619. * @param result vector to store the result
  2620. * @returns the resulting vector
  2621. */
  2622. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2623. /**
  2624. * Rotates a vector around a given point
  2625. * @param quaternion the rotation quaternion
  2626. * @param point the point to rotate around
  2627. * @param result vector to store the result
  2628. * @returns the resulting vector
  2629. */
  2630. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2631. /**
  2632. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2633. * The cross product is then orthogonal to both current and "other"
  2634. * @param other defines the right operand
  2635. * @returns the cross product
  2636. */
  2637. cross(other: Vector3): Vector3;
  2638. /**
  2639. * Normalize the current Vector3 with the given input length.
  2640. * Please note that this is an in place operation.
  2641. * @param len the length of the vector
  2642. * @returns the current updated Vector3
  2643. */
  2644. normalizeFromLength(len: number): Vector3;
  2645. /**
  2646. * Normalize the current Vector3 to a new vector
  2647. * @returns the new Vector3
  2648. */
  2649. normalizeToNew(): Vector3;
  2650. /**
  2651. * Normalize the current Vector3 to the reference
  2652. * @param reference define the Vector3 to update
  2653. * @returns the updated Vector3
  2654. */
  2655. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2656. /**
  2657. * Creates a new Vector3 copied from the current Vector3
  2658. * @returns the new Vector3
  2659. */
  2660. clone(): Vector3;
  2661. /**
  2662. * Copies the given vector coordinates to the current Vector3 ones
  2663. * @param source defines the source Vector3
  2664. * @returns the current updated Vector3
  2665. */
  2666. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Copies the given floats to the current Vector3 coordinates
  2669. * @param x defines the x coordinate of the operand
  2670. * @param y defines the y coordinate of the operand
  2671. * @param z defines the z coordinate of the operand
  2672. * @returns the current updated Vector3
  2673. */
  2674. copyFromFloats(x: number, y: number, z: number): Vector3;
  2675. /**
  2676. * Copies the given floats to the current Vector3 coordinates
  2677. * @param x defines the x coordinate of the operand
  2678. * @param y defines the y coordinate of the operand
  2679. * @param z defines the z coordinate of the operand
  2680. * @returns the current updated Vector3
  2681. */
  2682. set(x: number, y: number, z: number): Vector3;
  2683. /**
  2684. * Copies the given float to the current Vector3 coordinates
  2685. * @param v defines the x, y and z coordinates of the operand
  2686. * @returns the current updated Vector3
  2687. */
  2688. setAll(v: number): Vector3;
  2689. /**
  2690. * Get the clip factor between two vectors
  2691. * @param vector0 defines the first operand
  2692. * @param vector1 defines the second operand
  2693. * @param axis defines the axis to use
  2694. * @param size defines the size along the axis
  2695. * @returns the clip factor
  2696. */
  2697. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2698. /**
  2699. * Get angle between two vectors
  2700. * @param vector0 angle between vector0 and vector1
  2701. * @param vector1 angle between vector0 and vector1
  2702. * @param normal direction of the normal
  2703. * @return the angle between vector0 and vector1
  2704. */
  2705. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2706. /**
  2707. * Returns a new Vector3 set from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @returns the new Vector3
  2711. */
  2712. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2713. /**
  2714. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2715. * @param array defines the source array
  2716. * @param offset defines the offset in the source array
  2717. * @returns the new Vector3
  2718. * @deprecated Please use FromArray instead.
  2719. */
  2720. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2721. /**
  2722. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2723. * @param array defines the source array
  2724. * @param offset defines the offset in the source array
  2725. * @param result defines the Vector3 where to store the result
  2726. */
  2727. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2728. /**
  2729. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2730. * @param array defines the source array
  2731. * @param offset defines the offset in the source array
  2732. * @param result defines the Vector3 where to store the result
  2733. * @deprecated Please use FromArrayToRef instead.
  2734. */
  2735. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2736. /**
  2737. * Sets the given vector "result" with the given floats.
  2738. * @param x defines the x coordinate of the source
  2739. * @param y defines the y coordinate of the source
  2740. * @param z defines the z coordinate of the source
  2741. * @param result defines the Vector3 where to store the result
  2742. */
  2743. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2744. /**
  2745. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2746. * @returns a new empty Vector3
  2747. */
  2748. static Zero(): Vector3;
  2749. /**
  2750. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2751. * @returns a new unit Vector3
  2752. */
  2753. static One(): Vector3;
  2754. /**
  2755. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2756. * @returns a new up Vector3
  2757. */
  2758. static Up(): Vector3;
  2759. /**
  2760. * Gets a up Vector3 that must not be updated
  2761. */
  2762. static get UpReadOnly(): DeepImmutable<Vector3>;
  2763. /**
  2764. * Gets a zero Vector3 that must not be updated
  2765. */
  2766. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2767. /**
  2768. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2769. * @returns a new down Vector3
  2770. */
  2771. static Down(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2774. * @returns a new forward Vector3
  2775. */
  2776. static Forward(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2779. * @returns a new forward Vector3
  2780. */
  2781. static Backward(): Vector3;
  2782. /**
  2783. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2784. * @returns a new right Vector3
  2785. */
  2786. static Right(): Vector3;
  2787. /**
  2788. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2789. * @returns a new left Vector3
  2790. */
  2791. static Left(): Vector3;
  2792. /**
  2793. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2794. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2795. * @param vector defines the Vector3 to transform
  2796. * @param transformation defines the transformation matrix
  2797. * @returns the transformed Vector3
  2798. */
  2799. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2800. /**
  2801. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2802. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2803. * @param vector defines the Vector3 to transform
  2804. * @param transformation defines the transformation matrix
  2805. * @param result defines the Vector3 where to store the result
  2806. */
  2807. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2808. /**
  2809. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2810. * This method computes tranformed coordinates only, not transformed direction vectors
  2811. * @param x define the x coordinate of the source vector
  2812. * @param y define the y coordinate of the source vector
  2813. * @param z define the z coordinate of the source vector
  2814. * @param transformation defines the transformation matrix
  2815. * @param result defines the Vector3 where to store the result
  2816. */
  2817. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2818. /**
  2819. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2820. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2821. * @param vector defines the Vector3 to transform
  2822. * @param transformation defines the transformation matrix
  2823. * @returns the new Vector3
  2824. */
  2825. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2826. /**
  2827. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2828. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2829. * @param vector defines the Vector3 to transform
  2830. * @param transformation defines the transformation matrix
  2831. * @param result defines the Vector3 where to store the result
  2832. */
  2833. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2834. /**
  2835. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2836. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2837. * @param x define the x coordinate of the source vector
  2838. * @param y define the y coordinate of the source vector
  2839. * @param z define the z coordinate of the source vector
  2840. * @param transformation defines the transformation matrix
  2841. * @param result defines the Vector3 where to store the result
  2842. */
  2843. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2844. /**
  2845. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2846. * @param value1 defines the first control point
  2847. * @param value2 defines the second control point
  2848. * @param value3 defines the third control point
  2849. * @param value4 defines the fourth control point
  2850. * @param amount defines the amount on the spline to use
  2851. * @returns the new Vector3
  2852. */
  2853. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2854. /**
  2855. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2856. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2857. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2858. * @param value defines the current value
  2859. * @param min defines the lower range value
  2860. * @param max defines the upper range value
  2861. * @returns the new Vector3
  2862. */
  2863. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2864. /**
  2865. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2866. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2867. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2868. * @param value defines the current value
  2869. * @param min defines the lower range value
  2870. * @param max defines the upper range value
  2871. * @param result defines the Vector3 where to store the result
  2872. */
  2873. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2874. /**
  2875. * Checks if a given vector is inside a specific range
  2876. * @param v defines the vector to test
  2877. * @param min defines the minimum range
  2878. * @param max defines the maximum range
  2879. */
  2880. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2881. /**
  2882. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2883. * @param value1 defines the first control point
  2884. * @param tangent1 defines the first tangent vector
  2885. * @param value2 defines the second control point
  2886. * @param tangent2 defines the second tangent vector
  2887. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2888. * @returns the new Vector3
  2889. */
  2890. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2891. /**
  2892. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2893. * @param start defines the start value
  2894. * @param end defines the end value
  2895. * @param amount max defines amount between both (between 0 and 1)
  2896. * @returns the new Vector3
  2897. */
  2898. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2899. /**
  2900. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2901. * @param start defines the start value
  2902. * @param end defines the end value
  2903. * @param amount max defines amount between both (between 0 and 1)
  2904. * @param result defines the Vector3 where to store the result
  2905. */
  2906. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2907. /**
  2908. * Returns the dot product (float) between the vectors "left" and "right"
  2909. * @param left defines the left operand
  2910. * @param right defines the right operand
  2911. * @returns the dot product
  2912. */
  2913. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2914. /**
  2915. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2916. * The cross product is then orthogonal to both "left" and "right"
  2917. * @param left defines the left operand
  2918. * @param right defines the right operand
  2919. * @returns the cross product
  2920. */
  2921. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2922. /**
  2923. * Sets the given vector "result" with the cross product of "left" and "right"
  2924. * The cross product is then orthogonal to both "left" and "right"
  2925. * @param left defines the left operand
  2926. * @param right defines the right operand
  2927. * @param result defines the Vector3 where to store the result
  2928. */
  2929. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2930. /**
  2931. * Returns a new Vector3 as the normalization of the given vector
  2932. * @param vector defines the Vector3 to normalize
  2933. * @returns the new Vector3
  2934. */
  2935. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2936. /**
  2937. * Sets the given vector "result" with the normalization of the given first vector
  2938. * @param vector defines the Vector3 to normalize
  2939. * @param result defines the Vector3 where to store the result
  2940. */
  2941. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2942. /**
  2943. * Project a Vector3 onto screen space
  2944. * @param vector defines the Vector3 to project
  2945. * @param world defines the world matrix to use
  2946. * @param transform defines the transform (view x projection) matrix to use
  2947. * @param viewport defines the screen viewport to use
  2948. * @returns the new Vector3
  2949. */
  2950. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2951. /** @hidden */
  2952. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2953. /**
  2954. * Unproject from screen space to object space
  2955. * @param source defines the screen space Vector3 to use
  2956. * @param viewportWidth defines the current width of the viewport
  2957. * @param viewportHeight defines the current height of the viewport
  2958. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2959. * @param transform defines the transform (view x projection) matrix to use
  2960. * @returns the new Vector3
  2961. */
  2962. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2963. /**
  2964. * Unproject from screen space to object space
  2965. * @param source defines the screen space Vector3 to use
  2966. * @param viewportWidth defines the current width of the viewport
  2967. * @param viewportHeight defines the current height of the viewport
  2968. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2969. * @param view defines the view matrix to use
  2970. * @param projection defines the projection matrix to use
  2971. * @returns the new Vector3
  2972. */
  2973. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2974. /**
  2975. * Unproject from screen space to object space
  2976. * @param source defines the screen space Vector3 to use
  2977. * @param viewportWidth defines the current width of the viewport
  2978. * @param viewportHeight defines the current height of the viewport
  2979. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2980. * @param view defines the view matrix to use
  2981. * @param projection defines the projection matrix to use
  2982. * @param result defines the Vector3 where to store the result
  2983. */
  2984. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2985. /**
  2986. * Unproject from screen space to object space
  2987. * @param sourceX defines the screen space x coordinate to use
  2988. * @param sourceY defines the screen space y coordinate to use
  2989. * @param sourceZ defines the screen space z coordinate to use
  2990. * @param viewportWidth defines the current width of the viewport
  2991. * @param viewportHeight defines the current height of the viewport
  2992. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2993. * @param view defines the view matrix to use
  2994. * @param projection defines the projection matrix to use
  2995. * @param result defines the Vector3 where to store the result
  2996. */
  2997. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2998. /**
  2999. * Gets the minimal coordinate values between two Vector3
  3000. * @param left defines the first operand
  3001. * @param right defines the second operand
  3002. * @returns the new Vector3
  3003. */
  3004. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3005. /**
  3006. * Gets the maximal coordinate values between two Vector3
  3007. * @param left defines the first operand
  3008. * @param right defines the second operand
  3009. * @returns the new Vector3
  3010. */
  3011. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3012. /**
  3013. * Returns the distance between the vectors "value1" and "value2"
  3014. * @param value1 defines the first operand
  3015. * @param value2 defines the second operand
  3016. * @returns the distance
  3017. */
  3018. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3019. /**
  3020. * Returns the squared distance between the vectors "value1" and "value2"
  3021. * @param value1 defines the first operand
  3022. * @param value2 defines the second operand
  3023. * @returns the squared distance
  3024. */
  3025. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3026. /**
  3027. * Returns a new Vector3 located at the center between "value1" and "value2"
  3028. * @param value1 defines the first operand
  3029. * @param value2 defines the second operand
  3030. * @returns the new Vector3
  3031. */
  3032. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3033. /**
  3034. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3035. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3036. * to something in order to rotate it from its local system to the given target system
  3037. * Note: axis1, axis2 and axis3 are normalized during this operation
  3038. * @param axis1 defines the first axis
  3039. * @param axis2 defines the second axis
  3040. * @param axis3 defines the third axis
  3041. * @returns a new Vector3
  3042. */
  3043. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3044. /**
  3045. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3046. * @param axis1 defines the first axis
  3047. * @param axis2 defines the second axis
  3048. * @param axis3 defines the third axis
  3049. * @param ref defines the Vector3 where to store the result
  3050. */
  3051. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3052. }
  3053. /**
  3054. * Vector4 class created for EulerAngle class conversion to Quaternion
  3055. */
  3056. export class Vector4 {
  3057. /** x value of the vector */
  3058. x: number;
  3059. /** y value of the vector */
  3060. y: number;
  3061. /** z value of the vector */
  3062. z: number;
  3063. /** w value of the vector */
  3064. w: number;
  3065. /**
  3066. * Creates a Vector4 object from the given floats.
  3067. * @param x x value of the vector
  3068. * @param y y value of the vector
  3069. * @param z z value of the vector
  3070. * @param w w value of the vector
  3071. */
  3072. constructor(
  3073. /** x value of the vector */
  3074. x: number,
  3075. /** y value of the vector */
  3076. y: number,
  3077. /** z value of the vector */
  3078. z: number,
  3079. /** w value of the vector */
  3080. w: number);
  3081. /**
  3082. * Returns the string with the Vector4 coordinates.
  3083. * @returns a string containing all the vector values
  3084. */
  3085. toString(): string;
  3086. /**
  3087. * Returns the string "Vector4".
  3088. * @returns "Vector4"
  3089. */
  3090. getClassName(): string;
  3091. /**
  3092. * Returns the Vector4 hash code.
  3093. * @returns a unique hash code
  3094. */
  3095. getHashCode(): number;
  3096. /**
  3097. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3098. * @returns the resulting array
  3099. */
  3100. asArray(): number[];
  3101. /**
  3102. * Populates the given array from the given index with the Vector4 coordinates.
  3103. * @param array array to populate
  3104. * @param index index of the array to start at (default: 0)
  3105. * @returns the Vector4.
  3106. */
  3107. toArray(array: FloatArray, index?: number): Vector4;
  3108. /**
  3109. * Adds the given vector to the current Vector4.
  3110. * @param otherVector the vector to add
  3111. * @returns the updated Vector4.
  3112. */
  3113. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3114. /**
  3115. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3116. * @param otherVector the vector to add
  3117. * @returns the resulting vector
  3118. */
  3119. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3120. /**
  3121. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3122. * @param otherVector the vector to add
  3123. * @param result the vector to store the result
  3124. * @returns the current Vector4.
  3125. */
  3126. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3127. /**
  3128. * Subtract in place the given vector from the current Vector4.
  3129. * @param otherVector the vector to subtract
  3130. * @returns the updated Vector4.
  3131. */
  3132. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3133. /**
  3134. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3135. * @param otherVector the vector to add
  3136. * @returns the new vector with the result
  3137. */
  3138. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3139. /**
  3140. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3141. * @param otherVector the vector to subtract
  3142. * @param result the vector to store the result
  3143. * @returns the current Vector4.
  3144. */
  3145. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3146. /**
  3147. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3148. */
  3149. /**
  3150. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3151. * @param x value to subtract
  3152. * @param y value to subtract
  3153. * @param z value to subtract
  3154. * @param w value to subtract
  3155. * @returns new vector containing the result
  3156. */
  3157. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3158. /**
  3159. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3160. * @param x value to subtract
  3161. * @param y value to subtract
  3162. * @param z value to subtract
  3163. * @param w value to subtract
  3164. * @param result the vector to store the result in
  3165. * @returns the current Vector4.
  3166. */
  3167. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3168. /**
  3169. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3170. * @returns a new vector with the negated values
  3171. */
  3172. negate(): Vector4;
  3173. /**
  3174. * Negate this vector in place
  3175. * @returns this
  3176. */
  3177. negateInPlace(): Vector4;
  3178. /**
  3179. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3180. * @param result defines the Vector3 object where to store the result
  3181. * @returns the current Vector4
  3182. */
  3183. negateToRef(result: Vector4): Vector4;
  3184. /**
  3185. * Multiplies the current Vector4 coordinates by scale (float).
  3186. * @param scale the number to scale with
  3187. * @returns the updated Vector4.
  3188. */
  3189. scaleInPlace(scale: number): Vector4;
  3190. /**
  3191. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3192. * @param scale the number to scale with
  3193. * @returns a new vector with the result
  3194. */
  3195. scale(scale: number): Vector4;
  3196. /**
  3197. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3198. * @param scale the number to scale with
  3199. * @param result a vector to store the result in
  3200. * @returns the current Vector4.
  3201. */
  3202. scaleToRef(scale: number, result: Vector4): Vector4;
  3203. /**
  3204. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3205. * @param scale defines the scale factor
  3206. * @param result defines the Vector4 object where to store the result
  3207. * @returns the unmodified current Vector4
  3208. */
  3209. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3210. /**
  3211. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3212. * @param otherVector the vector to compare against
  3213. * @returns true if they are equal
  3214. */
  3215. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3216. /**
  3217. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3218. * @param otherVector vector to compare against
  3219. * @param epsilon (Default: very small number)
  3220. * @returns true if they are equal
  3221. */
  3222. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3223. /**
  3224. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3225. * @param x x value to compare against
  3226. * @param y y value to compare against
  3227. * @param z z value to compare against
  3228. * @param w w value to compare against
  3229. * @returns true if equal
  3230. */
  3231. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3232. /**
  3233. * Multiplies in place the current Vector4 by the given one.
  3234. * @param otherVector vector to multiple with
  3235. * @returns the updated Vector4.
  3236. */
  3237. multiplyInPlace(otherVector: Vector4): Vector4;
  3238. /**
  3239. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3240. * @param otherVector vector to multiple with
  3241. * @returns resulting new vector
  3242. */
  3243. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3244. /**
  3245. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3246. * @param otherVector vector to multiple with
  3247. * @param result vector to store the result
  3248. * @returns the current Vector4.
  3249. */
  3250. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3251. /**
  3252. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3253. * @param x x value multiply with
  3254. * @param y y value multiply with
  3255. * @param z z value multiply with
  3256. * @param w w value multiply with
  3257. * @returns resulting new vector
  3258. */
  3259. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3260. /**
  3261. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3262. * @param otherVector vector to devide with
  3263. * @returns resulting new vector
  3264. */
  3265. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3266. /**
  3267. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3268. * @param otherVector vector to devide with
  3269. * @param result vector to store the result
  3270. * @returns the current Vector4.
  3271. */
  3272. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3273. /**
  3274. * Divides the current Vector3 coordinates by the given ones.
  3275. * @param otherVector vector to devide with
  3276. * @returns the updated Vector3.
  3277. */
  3278. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3279. /**
  3280. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3281. * @param other defines the second operand
  3282. * @returns the current updated Vector4
  3283. */
  3284. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3285. /**
  3286. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3287. * @param other defines the second operand
  3288. * @returns the current updated Vector4
  3289. */
  3290. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3291. /**
  3292. * Gets a new Vector4 from current Vector4 floored values
  3293. * @returns a new Vector4
  3294. */
  3295. floor(): Vector4;
  3296. /**
  3297. * Gets a new Vector4 from current Vector3 floored values
  3298. * @returns a new Vector4
  3299. */
  3300. fract(): Vector4;
  3301. /**
  3302. * Returns the Vector4 length (float).
  3303. * @returns the length
  3304. */
  3305. length(): number;
  3306. /**
  3307. * Returns the Vector4 squared length (float).
  3308. * @returns the length squared
  3309. */
  3310. lengthSquared(): number;
  3311. /**
  3312. * Normalizes in place the Vector4.
  3313. * @returns the updated Vector4.
  3314. */
  3315. normalize(): Vector4;
  3316. /**
  3317. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3318. * @returns this converted to a new vector3
  3319. */
  3320. toVector3(): Vector3;
  3321. /**
  3322. * Returns a new Vector4 copied from the current one.
  3323. * @returns the new cloned vector
  3324. */
  3325. clone(): Vector4;
  3326. /**
  3327. * Updates the current Vector4 with the given one coordinates.
  3328. * @param source the source vector to copy from
  3329. * @returns the updated Vector4.
  3330. */
  3331. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3332. /**
  3333. * Updates the current Vector4 coordinates with the given floats.
  3334. * @param x float to copy from
  3335. * @param y float to copy from
  3336. * @param z float to copy from
  3337. * @param w float to copy from
  3338. * @returns the updated Vector4.
  3339. */
  3340. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3341. /**
  3342. * Updates the current Vector4 coordinates with the given floats.
  3343. * @param x float to set from
  3344. * @param y float to set from
  3345. * @param z float to set from
  3346. * @param w float to set from
  3347. * @returns the updated Vector4.
  3348. */
  3349. set(x: number, y: number, z: number, w: number): Vector4;
  3350. /**
  3351. * Copies the given float to the current Vector3 coordinates
  3352. * @param v defines the x, y, z and w coordinates of the operand
  3353. * @returns the current updated Vector3
  3354. */
  3355. setAll(v: number): Vector4;
  3356. /**
  3357. * Returns a new Vector4 set from the starting index of the given array.
  3358. * @param array the array to pull values from
  3359. * @param offset the offset into the array to start at
  3360. * @returns the new vector
  3361. */
  3362. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3363. /**
  3364. * Updates the given vector "result" from the starting index of the given array.
  3365. * @param array the array to pull values from
  3366. * @param offset the offset into the array to start at
  3367. * @param result the vector to store the result in
  3368. */
  3369. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3370. /**
  3371. * Updates the given vector "result" from the starting index of the given Float32Array.
  3372. * @param array the array to pull values from
  3373. * @param offset the offset into the array to start at
  3374. * @param result the vector to store the result in
  3375. */
  3376. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3377. /**
  3378. * Updates the given vector "result" coordinates from the given floats.
  3379. * @param x float to set from
  3380. * @param y float to set from
  3381. * @param z float to set from
  3382. * @param w float to set from
  3383. * @param result the vector to the floats in
  3384. */
  3385. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3386. /**
  3387. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3388. * @returns the new vector
  3389. */
  3390. static Zero(): Vector4;
  3391. /**
  3392. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3393. * @returns the new vector
  3394. */
  3395. static One(): Vector4;
  3396. /**
  3397. * Returns a new normalized Vector4 from the given one.
  3398. * @param vector the vector to normalize
  3399. * @returns the vector
  3400. */
  3401. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3402. /**
  3403. * Updates the given vector "result" from the normalization of the given one.
  3404. * @param vector the vector to normalize
  3405. * @param result the vector to store the result in
  3406. */
  3407. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3408. /**
  3409. * Returns a vector with the minimum values from the left and right vectors
  3410. * @param left left vector to minimize
  3411. * @param right right vector to minimize
  3412. * @returns a new vector with the minimum of the left and right vector values
  3413. */
  3414. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3415. /**
  3416. * Returns a vector with the maximum values from the left and right vectors
  3417. * @param left left vector to maximize
  3418. * @param right right vector to maximize
  3419. * @returns a new vector with the maximum of the left and right vector values
  3420. */
  3421. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3422. /**
  3423. * Returns the distance (float) between the vectors "value1" and "value2".
  3424. * @param value1 value to calulate the distance between
  3425. * @param value2 value to calulate the distance between
  3426. * @return the distance between the two vectors
  3427. */
  3428. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3429. /**
  3430. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3431. * @param value1 value to calulate the distance between
  3432. * @param value2 value to calulate the distance between
  3433. * @return the distance between the two vectors squared
  3434. */
  3435. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3436. /**
  3437. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3438. * @param value1 value to calulate the center between
  3439. * @param value2 value to calulate the center between
  3440. * @return the center between the two vectors
  3441. */
  3442. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3443. /**
  3444. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3445. * This methods computes transformed normalized direction vectors only.
  3446. * @param vector the vector to transform
  3447. * @param transformation the transformation matrix to apply
  3448. * @returns the new vector
  3449. */
  3450. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3451. /**
  3452. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3453. * This methods computes transformed normalized direction vectors only.
  3454. * @param vector the vector to transform
  3455. * @param transformation the transformation matrix to apply
  3456. * @param result the vector to store the result in
  3457. */
  3458. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3459. /**
  3460. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3461. * This methods computes transformed normalized direction vectors only.
  3462. * @param x value to transform
  3463. * @param y value to transform
  3464. * @param z value to transform
  3465. * @param w value to transform
  3466. * @param transformation the transformation matrix to apply
  3467. * @param result the vector to store the results in
  3468. */
  3469. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3470. /**
  3471. * Creates a new Vector4 from a Vector3
  3472. * @param source defines the source data
  3473. * @param w defines the 4th component (default is 0)
  3474. * @returns a new Vector4
  3475. */
  3476. static FromVector3(source: Vector3, w?: number): Vector4;
  3477. }
  3478. /**
  3479. * Class used to store quaternion data
  3480. * @see https://en.wikipedia.org/wiki/Quaternion
  3481. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3482. */
  3483. export class Quaternion {
  3484. /** defines the first component (0 by default) */
  3485. x: number;
  3486. /** defines the second component (0 by default) */
  3487. y: number;
  3488. /** defines the third component (0 by default) */
  3489. z: number;
  3490. /** defines the fourth component (1.0 by default) */
  3491. w: number;
  3492. /**
  3493. * Creates a new Quaternion from the given floats
  3494. * @param x defines the first component (0 by default)
  3495. * @param y defines the second component (0 by default)
  3496. * @param z defines the third component (0 by default)
  3497. * @param w defines the fourth component (1.0 by default)
  3498. */
  3499. constructor(
  3500. /** defines the first component (0 by default) */
  3501. x?: number,
  3502. /** defines the second component (0 by default) */
  3503. y?: number,
  3504. /** defines the third component (0 by default) */
  3505. z?: number,
  3506. /** defines the fourth component (1.0 by default) */
  3507. w?: number);
  3508. /**
  3509. * Gets a string representation for the current quaternion
  3510. * @returns a string with the Quaternion coordinates
  3511. */
  3512. toString(): string;
  3513. /**
  3514. * Gets the class name of the quaternion
  3515. * @returns the string "Quaternion"
  3516. */
  3517. getClassName(): string;
  3518. /**
  3519. * Gets a hash code for this quaternion
  3520. * @returns the quaternion hash code
  3521. */
  3522. getHashCode(): number;
  3523. /**
  3524. * Copy the quaternion to an array
  3525. * @returns a new array populated with 4 elements from the quaternion coordinates
  3526. */
  3527. asArray(): number[];
  3528. /**
  3529. * Check if two quaternions are equals
  3530. * @param otherQuaternion defines the second operand
  3531. * @return true if the current quaternion and the given one coordinates are strictly equals
  3532. */
  3533. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3534. /**
  3535. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3536. * @param otherQuaternion defines the other quaternion
  3537. * @param epsilon defines the minimal distance to consider equality
  3538. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3539. */
  3540. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3541. /**
  3542. * Clone the current quaternion
  3543. * @returns a new quaternion copied from the current one
  3544. */
  3545. clone(): Quaternion;
  3546. /**
  3547. * Copy a quaternion to the current one
  3548. * @param other defines the other quaternion
  3549. * @returns the updated current quaternion
  3550. */
  3551. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3552. /**
  3553. * Updates the current quaternion with the given float coordinates
  3554. * @param x defines the x coordinate
  3555. * @param y defines the y coordinate
  3556. * @param z defines the z coordinate
  3557. * @param w defines the w coordinate
  3558. * @returns the updated current quaternion
  3559. */
  3560. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3561. /**
  3562. * Updates the current quaternion from the given float coordinates
  3563. * @param x defines the x coordinate
  3564. * @param y defines the y coordinate
  3565. * @param z defines the z coordinate
  3566. * @param w defines the w coordinate
  3567. * @returns the updated current quaternion
  3568. */
  3569. set(x: number, y: number, z: number, w: number): Quaternion;
  3570. /**
  3571. * Adds two quaternions
  3572. * @param other defines the second operand
  3573. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3574. */
  3575. add(other: DeepImmutable<Quaternion>): Quaternion;
  3576. /**
  3577. * Add a quaternion to the current one
  3578. * @param other defines the quaternion to add
  3579. * @returns the current quaternion
  3580. */
  3581. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3582. /**
  3583. * Subtract two quaternions
  3584. * @param other defines the second operand
  3585. * @returns a new quaternion as the subtraction result of the given one from the current one
  3586. */
  3587. subtract(other: Quaternion): Quaternion;
  3588. /**
  3589. * Multiplies the current quaternion by a scale factor
  3590. * @param value defines the scale factor
  3591. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3592. */
  3593. scale(value: number): Quaternion;
  3594. /**
  3595. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3596. * @param scale defines the scale factor
  3597. * @param result defines the Quaternion object where to store the result
  3598. * @returns the unmodified current quaternion
  3599. */
  3600. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3601. /**
  3602. * Multiplies in place the current quaternion by a scale factor
  3603. * @param value defines the scale factor
  3604. * @returns the current modified quaternion
  3605. */
  3606. scaleInPlace(value: number): Quaternion;
  3607. /**
  3608. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3609. * @param scale defines the scale factor
  3610. * @param result defines the Quaternion object where to store the result
  3611. * @returns the unmodified current quaternion
  3612. */
  3613. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3614. /**
  3615. * Multiplies two quaternions
  3616. * @param q1 defines the second operand
  3617. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3618. */
  3619. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3620. /**
  3621. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3622. * @param q1 defines the second operand
  3623. * @param result defines the target quaternion
  3624. * @returns the current quaternion
  3625. */
  3626. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3627. /**
  3628. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3629. * @param q1 defines the second operand
  3630. * @returns the currentupdated quaternion
  3631. */
  3632. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3633. /**
  3634. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3635. * @param ref defines the target quaternion
  3636. * @returns the current quaternion
  3637. */
  3638. conjugateToRef(ref: Quaternion): Quaternion;
  3639. /**
  3640. * Conjugates in place (1-q) the current quaternion
  3641. * @returns the current updated quaternion
  3642. */
  3643. conjugateInPlace(): Quaternion;
  3644. /**
  3645. * Conjugates in place (1-q) the current quaternion
  3646. * @returns a new quaternion
  3647. */
  3648. conjugate(): Quaternion;
  3649. /**
  3650. * Gets length of current quaternion
  3651. * @returns the quaternion length (float)
  3652. */
  3653. length(): number;
  3654. /**
  3655. * Normalize in place the current quaternion
  3656. * @returns the current updated quaternion
  3657. */
  3658. normalize(): Quaternion;
  3659. /**
  3660. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3661. * @param order is a reserved parameter and is ignore for now
  3662. * @returns a new Vector3 containing the Euler angles
  3663. */
  3664. toEulerAngles(order?: string): Vector3;
  3665. /**
  3666. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3667. * @param result defines the vector which will be filled with the Euler angles
  3668. * @param order is a reserved parameter and is ignore for now
  3669. * @returns the current unchanged quaternion
  3670. */
  3671. toEulerAnglesToRef(result: Vector3): Quaternion;
  3672. /**
  3673. * Updates the given rotation matrix with the current quaternion values
  3674. * @param result defines the target matrix
  3675. * @returns the current unchanged quaternion
  3676. */
  3677. toRotationMatrix(result: Matrix): Quaternion;
  3678. /**
  3679. * Updates the current quaternion from the given rotation matrix values
  3680. * @param matrix defines the source matrix
  3681. * @returns the current updated quaternion
  3682. */
  3683. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3684. /**
  3685. * Creates a new quaternion from a rotation matrix
  3686. * @param matrix defines the source matrix
  3687. * @returns a new quaternion created from the given rotation matrix values
  3688. */
  3689. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3690. /**
  3691. * Updates the given quaternion with the given rotation matrix values
  3692. * @param matrix defines the source matrix
  3693. * @param result defines the target quaternion
  3694. */
  3695. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3696. /**
  3697. * Returns the dot product (float) between the quaternions "left" and "right"
  3698. * @param left defines the left operand
  3699. * @param right defines the right operand
  3700. * @returns the dot product
  3701. */
  3702. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3703. /**
  3704. * Checks if the two quaternions are close to each other
  3705. * @param quat0 defines the first quaternion to check
  3706. * @param quat1 defines the second quaternion to check
  3707. * @returns true if the two quaternions are close to each other
  3708. */
  3709. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3710. /**
  3711. * Creates an empty quaternion
  3712. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3713. */
  3714. static Zero(): Quaternion;
  3715. /**
  3716. * Inverse a given quaternion
  3717. * @param q defines the source quaternion
  3718. * @returns a new quaternion as the inverted current quaternion
  3719. */
  3720. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3721. /**
  3722. * Inverse a given quaternion
  3723. * @param q defines the source quaternion
  3724. * @param result the quaternion the result will be stored in
  3725. * @returns the result quaternion
  3726. */
  3727. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3728. /**
  3729. * Creates an identity quaternion
  3730. * @returns the identity quaternion
  3731. */
  3732. static Identity(): Quaternion;
  3733. /**
  3734. * Gets a boolean indicating if the given quaternion is identity
  3735. * @param quaternion defines the quaternion to check
  3736. * @returns true if the quaternion is identity
  3737. */
  3738. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3739. /**
  3740. * Creates a quaternion from a rotation around an axis
  3741. * @param axis defines the axis to use
  3742. * @param angle defines the angle to use
  3743. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3744. */
  3745. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3746. /**
  3747. * Creates a rotation around an axis and stores it into the given quaternion
  3748. * @param axis defines the axis to use
  3749. * @param angle defines the angle to use
  3750. * @param result defines the target quaternion
  3751. * @returns the target quaternion
  3752. */
  3753. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3754. /**
  3755. * Creates a new quaternion from data stored into an array
  3756. * @param array defines the data source
  3757. * @param offset defines the offset in the source array where the data starts
  3758. * @returns a new quaternion
  3759. */
  3760. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3761. /**
  3762. * Create a quaternion from Euler rotation angles
  3763. * @param x Pitch
  3764. * @param y Yaw
  3765. * @param z Roll
  3766. * @returns the new Quaternion
  3767. */
  3768. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3769. /**
  3770. * Updates a quaternion from Euler rotation angles
  3771. * @param x Pitch
  3772. * @param y Yaw
  3773. * @param z Roll
  3774. * @param result the quaternion to store the result
  3775. * @returns the updated quaternion
  3776. */
  3777. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3778. /**
  3779. * Create a quaternion from Euler rotation vector
  3780. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3781. * @returns the new Quaternion
  3782. */
  3783. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3784. /**
  3785. * Updates a quaternion from Euler rotation vector
  3786. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3787. * @param result the quaternion to store the result
  3788. * @returns the updated quaternion
  3789. */
  3790. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3791. /**
  3792. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3793. * @param yaw defines the rotation around Y axis
  3794. * @param pitch defines the rotation around X axis
  3795. * @param roll defines the rotation around Z axis
  3796. * @returns the new quaternion
  3797. */
  3798. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3799. /**
  3800. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3801. * @param yaw defines the rotation around Y axis
  3802. * @param pitch defines the rotation around X axis
  3803. * @param roll defines the rotation around Z axis
  3804. * @param result defines the target quaternion
  3805. */
  3806. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3807. /**
  3808. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3809. * @param alpha defines the rotation around first axis
  3810. * @param beta defines the rotation around second axis
  3811. * @param gamma defines the rotation around third axis
  3812. * @returns the new quaternion
  3813. */
  3814. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3815. /**
  3816. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3817. * @param alpha defines the rotation around first axis
  3818. * @param beta defines the rotation around second axis
  3819. * @param gamma defines the rotation around third axis
  3820. * @param result defines the target quaternion
  3821. */
  3822. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3823. /**
  3824. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3825. * @param axis1 defines the first axis
  3826. * @param axis2 defines the second axis
  3827. * @param axis3 defines the third axis
  3828. * @returns the new quaternion
  3829. */
  3830. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3831. /**
  3832. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3833. * @param axis1 defines the first axis
  3834. * @param axis2 defines the second axis
  3835. * @param axis3 defines the third axis
  3836. * @param ref defines the target quaternion
  3837. */
  3838. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3839. /**
  3840. * Interpolates between two quaternions
  3841. * @param left defines first quaternion
  3842. * @param right defines second quaternion
  3843. * @param amount defines the gradient to use
  3844. * @returns the new interpolated quaternion
  3845. */
  3846. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3847. /**
  3848. * Interpolates between two quaternions and stores it into a target quaternion
  3849. * @param left defines first quaternion
  3850. * @param right defines second quaternion
  3851. * @param amount defines the gradient to use
  3852. * @param result defines the target quaternion
  3853. */
  3854. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3855. /**
  3856. * Interpolate between two quaternions using Hermite interpolation
  3857. * @param value1 defines first quaternion
  3858. * @param tangent1 defines the incoming tangent
  3859. * @param value2 defines second quaternion
  3860. * @param tangent2 defines the outgoing tangent
  3861. * @param amount defines the target quaternion
  3862. * @returns the new interpolated quaternion
  3863. */
  3864. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3865. }
  3866. /**
  3867. * Class used to store matrix data (4x4)
  3868. */
  3869. export class Matrix {
  3870. private static _updateFlagSeed;
  3871. private static _identityReadOnly;
  3872. private _isIdentity;
  3873. private _isIdentityDirty;
  3874. private _isIdentity3x2;
  3875. private _isIdentity3x2Dirty;
  3876. /**
  3877. * Gets the update flag of the matrix which is an unique number for the matrix.
  3878. * It will be incremented every time the matrix data change.
  3879. * You can use it to speed the comparison between two versions of the same matrix.
  3880. */
  3881. updateFlag: number;
  3882. private readonly _m;
  3883. /**
  3884. * Gets the internal data of the matrix
  3885. */
  3886. get m(): DeepImmutable<Float32Array>;
  3887. /** @hidden */
  3888. _markAsUpdated(): void;
  3889. /** @hidden */
  3890. private _updateIdentityStatus;
  3891. /**
  3892. * Creates an empty matrix (filled with zeros)
  3893. */
  3894. constructor();
  3895. /**
  3896. * Check if the current matrix is identity
  3897. * @returns true is the matrix is the identity matrix
  3898. */
  3899. isIdentity(): boolean;
  3900. /**
  3901. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3902. * @returns true is the matrix is the identity matrix
  3903. */
  3904. isIdentityAs3x2(): boolean;
  3905. /**
  3906. * Gets the determinant of the matrix
  3907. * @returns the matrix determinant
  3908. */
  3909. determinant(): number;
  3910. /**
  3911. * Returns the matrix as a Float32Array
  3912. * @returns the matrix underlying array
  3913. */
  3914. toArray(): DeepImmutable<Float32Array>;
  3915. /**
  3916. * Returns the matrix as a Float32Array
  3917. * @returns the matrix underlying array.
  3918. */
  3919. asArray(): DeepImmutable<Float32Array>;
  3920. /**
  3921. * Inverts the current matrix in place
  3922. * @returns the current inverted matrix
  3923. */
  3924. invert(): Matrix;
  3925. /**
  3926. * Sets all the matrix elements to zero
  3927. * @returns the current matrix
  3928. */
  3929. reset(): Matrix;
  3930. /**
  3931. * Adds the current matrix with a second one
  3932. * @param other defines the matrix to add
  3933. * @returns a new matrix as the addition of the current matrix and the given one
  3934. */
  3935. add(other: DeepImmutable<Matrix>): Matrix;
  3936. /**
  3937. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3938. * @param other defines the matrix to add
  3939. * @param result defines the target matrix
  3940. * @returns the current matrix
  3941. */
  3942. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3943. /**
  3944. * Adds in place the given matrix to the current matrix
  3945. * @param other defines the second operand
  3946. * @returns the current updated matrix
  3947. */
  3948. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3949. /**
  3950. * Sets the given matrix to the current inverted Matrix
  3951. * @param other defines the target matrix
  3952. * @returns the unmodified current matrix
  3953. */
  3954. invertToRef(other: Matrix): Matrix;
  3955. /**
  3956. * add a value at the specified position in the current Matrix
  3957. * @param index the index of the value within the matrix. between 0 and 15.
  3958. * @param value the value to be added
  3959. * @returns the current updated matrix
  3960. */
  3961. addAtIndex(index: number, value: number): Matrix;
  3962. /**
  3963. * mutiply the specified position in the current Matrix by a value
  3964. * @param index the index of the value within the matrix. between 0 and 15.
  3965. * @param value the value to be added
  3966. * @returns the current updated matrix
  3967. */
  3968. multiplyAtIndex(index: number, value: number): Matrix;
  3969. /**
  3970. * Inserts the translation vector (using 3 floats) in the current matrix
  3971. * @param x defines the 1st component of the translation
  3972. * @param y defines the 2nd component of the translation
  3973. * @param z defines the 3rd component of the translation
  3974. * @returns the current updated matrix
  3975. */
  3976. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3977. /**
  3978. * Adds the translation vector (using 3 floats) in the current matrix
  3979. * @param x defines the 1st component of the translation
  3980. * @param y defines the 2nd component of the translation
  3981. * @param z defines the 3rd component of the translation
  3982. * @returns the current updated matrix
  3983. */
  3984. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3985. /**
  3986. * Inserts the translation vector in the current matrix
  3987. * @param vector3 defines the translation to insert
  3988. * @returns the current updated matrix
  3989. */
  3990. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3991. /**
  3992. * Gets the translation value of the current matrix
  3993. * @returns a new Vector3 as the extracted translation from the matrix
  3994. */
  3995. getTranslation(): Vector3;
  3996. /**
  3997. * Fill a Vector3 with the extracted translation from the matrix
  3998. * @param result defines the Vector3 where to store the translation
  3999. * @returns the current matrix
  4000. */
  4001. getTranslationToRef(result: Vector3): Matrix;
  4002. /**
  4003. * Remove rotation and scaling part from the matrix
  4004. * @returns the updated matrix
  4005. */
  4006. removeRotationAndScaling(): Matrix;
  4007. /**
  4008. * Multiply two matrices
  4009. * @param other defines the second operand
  4010. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4011. */
  4012. multiply(other: DeepImmutable<Matrix>): Matrix;
  4013. /**
  4014. * Copy the current matrix from the given one
  4015. * @param other defines the source matrix
  4016. * @returns the current updated matrix
  4017. */
  4018. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4019. /**
  4020. * Populates the given array from the starting index with the current matrix values
  4021. * @param array defines the target array
  4022. * @param offset defines the offset in the target array where to start storing values
  4023. * @returns the current matrix
  4024. */
  4025. copyToArray(array: Float32Array, offset?: number): Matrix;
  4026. /**
  4027. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4028. * @param other defines the second operand
  4029. * @param result defines the matrix where to store the multiplication
  4030. * @returns the current matrix
  4031. */
  4032. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4033. /**
  4034. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4035. * @param other defines the second operand
  4036. * @param result defines the array where to store the multiplication
  4037. * @param offset defines the offset in the target array where to start storing values
  4038. * @returns the current matrix
  4039. */
  4040. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4041. /**
  4042. * Check equality between this matrix and a second one
  4043. * @param value defines the second matrix to compare
  4044. * @returns true is the current matrix and the given one values are strictly equal
  4045. */
  4046. equals(value: DeepImmutable<Matrix>): boolean;
  4047. /**
  4048. * Clone the current matrix
  4049. * @returns a new matrix from the current matrix
  4050. */
  4051. clone(): Matrix;
  4052. /**
  4053. * Returns the name of the current matrix class
  4054. * @returns the string "Matrix"
  4055. */
  4056. getClassName(): string;
  4057. /**
  4058. * Gets the hash code of the current matrix
  4059. * @returns the hash code
  4060. */
  4061. getHashCode(): number;
  4062. /**
  4063. * Decomposes the current Matrix into a translation, rotation and scaling components
  4064. * @param scale defines the scale vector3 given as a reference to update
  4065. * @param rotation defines the rotation quaternion given as a reference to update
  4066. * @param translation defines the translation vector3 given as a reference to update
  4067. * @returns true if operation was successful
  4068. */
  4069. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4070. /**
  4071. * Gets specific row of the matrix
  4072. * @param index defines the number of the row to get
  4073. * @returns the index-th row of the current matrix as a new Vector4
  4074. */
  4075. getRow(index: number): Nullable<Vector4>;
  4076. /**
  4077. * Sets the index-th row of the current matrix to the vector4 values
  4078. * @param index defines the number of the row to set
  4079. * @param row defines the target vector4
  4080. * @returns the updated current matrix
  4081. */
  4082. setRow(index: number, row: Vector4): Matrix;
  4083. /**
  4084. * Compute the transpose of the matrix
  4085. * @returns the new transposed matrix
  4086. */
  4087. transpose(): Matrix;
  4088. /**
  4089. * Compute the transpose of the matrix and store it in a given matrix
  4090. * @param result defines the target matrix
  4091. * @returns the current matrix
  4092. */
  4093. transposeToRef(result: Matrix): Matrix;
  4094. /**
  4095. * Sets the index-th row of the current matrix with the given 4 x float values
  4096. * @param index defines the row index
  4097. * @param x defines the x component to set
  4098. * @param y defines the y component to set
  4099. * @param z defines the z component to set
  4100. * @param w defines the w component to set
  4101. * @returns the updated current matrix
  4102. */
  4103. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4104. /**
  4105. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4106. * @param scale defines the scale factor
  4107. * @returns a new matrix
  4108. */
  4109. scale(scale: number): Matrix;
  4110. /**
  4111. * Scale the current matrix values by a factor to a given result matrix
  4112. * @param scale defines the scale factor
  4113. * @param result defines the matrix to store the result
  4114. * @returns the current matrix
  4115. */
  4116. scaleToRef(scale: number, result: Matrix): Matrix;
  4117. /**
  4118. * Scale the current matrix values by a factor and add the result to a given matrix
  4119. * @param scale defines the scale factor
  4120. * @param result defines the Matrix to store the result
  4121. * @returns the current matrix
  4122. */
  4123. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4124. /**
  4125. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4126. * @param ref matrix to store the result
  4127. */
  4128. toNormalMatrix(ref: Matrix): void;
  4129. /**
  4130. * Gets only rotation part of the current matrix
  4131. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4132. */
  4133. getRotationMatrix(): Matrix;
  4134. /**
  4135. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4136. * @param result defines the target matrix to store data to
  4137. * @returns the current matrix
  4138. */
  4139. getRotationMatrixToRef(result: Matrix): Matrix;
  4140. /**
  4141. * Toggles model matrix from being right handed to left handed in place and vice versa
  4142. */
  4143. toggleModelMatrixHandInPlace(): void;
  4144. /**
  4145. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4146. */
  4147. toggleProjectionMatrixHandInPlace(): void;
  4148. /**
  4149. * Creates a matrix from an array
  4150. * @param array defines the source array
  4151. * @param offset defines an offset in the source array
  4152. * @returns a new Matrix set from the starting index of the given array
  4153. */
  4154. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4155. /**
  4156. * Copy the content of an array into a given matrix
  4157. * @param array defines the source array
  4158. * @param offset defines an offset in the source array
  4159. * @param result defines the target matrix
  4160. */
  4161. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4162. /**
  4163. * Stores an array into a matrix after having multiplied each component by a given factor
  4164. * @param array defines the source array
  4165. * @param offset defines the offset in the source array
  4166. * @param scale defines the scaling factor
  4167. * @param result defines the target matrix
  4168. */
  4169. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4170. /**
  4171. * Gets an identity matrix that must not be updated
  4172. */
  4173. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4174. /**
  4175. * Stores a list of values (16) inside a given matrix
  4176. * @param initialM11 defines 1st value of 1st row
  4177. * @param initialM12 defines 2nd value of 1st row
  4178. * @param initialM13 defines 3rd value of 1st row
  4179. * @param initialM14 defines 4th value of 1st row
  4180. * @param initialM21 defines 1st value of 2nd row
  4181. * @param initialM22 defines 2nd value of 2nd row
  4182. * @param initialM23 defines 3rd value of 2nd row
  4183. * @param initialM24 defines 4th value of 2nd row
  4184. * @param initialM31 defines 1st value of 3rd row
  4185. * @param initialM32 defines 2nd value of 3rd row
  4186. * @param initialM33 defines 3rd value of 3rd row
  4187. * @param initialM34 defines 4th value of 3rd row
  4188. * @param initialM41 defines 1st value of 4th row
  4189. * @param initialM42 defines 2nd value of 4th row
  4190. * @param initialM43 defines 3rd value of 4th row
  4191. * @param initialM44 defines 4th value of 4th row
  4192. * @param result defines the target matrix
  4193. */
  4194. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4195. /**
  4196. * Creates new matrix from a list of values (16)
  4197. * @param initialM11 defines 1st value of 1st row
  4198. * @param initialM12 defines 2nd value of 1st row
  4199. * @param initialM13 defines 3rd value of 1st row
  4200. * @param initialM14 defines 4th value of 1st row
  4201. * @param initialM21 defines 1st value of 2nd row
  4202. * @param initialM22 defines 2nd value of 2nd row
  4203. * @param initialM23 defines 3rd value of 2nd row
  4204. * @param initialM24 defines 4th value of 2nd row
  4205. * @param initialM31 defines 1st value of 3rd row
  4206. * @param initialM32 defines 2nd value of 3rd row
  4207. * @param initialM33 defines 3rd value of 3rd row
  4208. * @param initialM34 defines 4th value of 3rd row
  4209. * @param initialM41 defines 1st value of 4th row
  4210. * @param initialM42 defines 2nd value of 4th row
  4211. * @param initialM43 defines 3rd value of 4th row
  4212. * @param initialM44 defines 4th value of 4th row
  4213. * @returns the new matrix
  4214. */
  4215. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4216. /**
  4217. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4218. * @param scale defines the scale vector3
  4219. * @param rotation defines the rotation quaternion
  4220. * @param translation defines the translation vector3
  4221. * @returns a new matrix
  4222. */
  4223. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4224. /**
  4225. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4226. * @param scale defines the scale vector3
  4227. * @param rotation defines the rotation quaternion
  4228. * @param translation defines the translation vector3
  4229. * @param result defines the target matrix
  4230. */
  4231. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4232. /**
  4233. * Creates a new identity matrix
  4234. * @returns a new identity matrix
  4235. */
  4236. static Identity(): Matrix;
  4237. /**
  4238. * Creates a new identity matrix and stores the result in a given matrix
  4239. * @param result defines the target matrix
  4240. */
  4241. static IdentityToRef(result: Matrix): void;
  4242. /**
  4243. * Creates a new zero matrix
  4244. * @returns a new zero matrix
  4245. */
  4246. static Zero(): Matrix;
  4247. /**
  4248. * Creates a new rotation matrix for "angle" radians around the X axis
  4249. * @param angle defines the angle (in radians) to use
  4250. * @return the new matrix
  4251. */
  4252. static RotationX(angle: number): Matrix;
  4253. /**
  4254. * Creates a new matrix as the invert of a given matrix
  4255. * @param source defines the source matrix
  4256. * @returns the new matrix
  4257. */
  4258. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4259. /**
  4260. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4261. * @param angle defines the angle (in radians) to use
  4262. * @param result defines the target matrix
  4263. */
  4264. static RotationXToRef(angle: number, result: Matrix): void;
  4265. /**
  4266. * Creates a new rotation matrix for "angle" radians around the Y axis
  4267. * @param angle defines the angle (in radians) to use
  4268. * @return the new matrix
  4269. */
  4270. static RotationY(angle: number): Matrix;
  4271. /**
  4272. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4273. * @param angle defines the angle (in radians) to use
  4274. * @param result defines the target matrix
  4275. */
  4276. static RotationYToRef(angle: number, result: Matrix): void;
  4277. /**
  4278. * Creates a new rotation matrix for "angle" radians around the Z axis
  4279. * @param angle defines the angle (in radians) to use
  4280. * @return the new matrix
  4281. */
  4282. static RotationZ(angle: number): Matrix;
  4283. /**
  4284. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4285. * @param angle defines the angle (in radians) to use
  4286. * @param result defines the target matrix
  4287. */
  4288. static RotationZToRef(angle: number, result: Matrix): void;
  4289. /**
  4290. * Creates a new rotation matrix for "angle" radians around the given axis
  4291. * @param axis defines the axis to use
  4292. * @param angle defines the angle (in radians) to use
  4293. * @return the new matrix
  4294. */
  4295. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4296. /**
  4297. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4298. * @param axis defines the axis to use
  4299. * @param angle defines the angle (in radians) to use
  4300. * @param result defines the target matrix
  4301. */
  4302. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4303. /**
  4304. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4305. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4306. * @param from defines the vector to align
  4307. * @param to defines the vector to align to
  4308. * @param result defines the target matrix
  4309. */
  4310. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4311. /**
  4312. * Creates a rotation matrix
  4313. * @param yaw defines the yaw angle in radians (Y axis)
  4314. * @param pitch defines the pitch angle in radians (X axis)
  4315. * @param roll defines the roll angle in radians (X axis)
  4316. * @returns the new rotation matrix
  4317. */
  4318. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4319. /**
  4320. * Creates a rotation matrix and stores it in a given matrix
  4321. * @param yaw defines the yaw angle in radians (Y axis)
  4322. * @param pitch defines the pitch angle in radians (X axis)
  4323. * @param roll defines the roll angle in radians (X axis)
  4324. * @param result defines the target matrix
  4325. */
  4326. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4327. /**
  4328. * Creates a scaling matrix
  4329. * @param x defines the scale factor on X axis
  4330. * @param y defines the scale factor on Y axis
  4331. * @param z defines the scale factor on Z axis
  4332. * @returns the new matrix
  4333. */
  4334. static Scaling(x: number, y: number, z: number): Matrix;
  4335. /**
  4336. * Creates a scaling matrix and stores it in a given matrix
  4337. * @param x defines the scale factor on X axis
  4338. * @param y defines the scale factor on Y axis
  4339. * @param z defines the scale factor on Z axis
  4340. * @param result defines the target matrix
  4341. */
  4342. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4343. /**
  4344. * Creates a translation matrix
  4345. * @param x defines the translation on X axis
  4346. * @param y defines the translation on Y axis
  4347. * @param z defines the translationon Z axis
  4348. * @returns the new matrix
  4349. */
  4350. static Translation(x: number, y: number, z: number): Matrix;
  4351. /**
  4352. * Creates a translation matrix and stores it in a given matrix
  4353. * @param x defines the translation on X axis
  4354. * @param y defines the translation on Y axis
  4355. * @param z defines the translationon Z axis
  4356. * @param result defines the target matrix
  4357. */
  4358. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4359. /**
  4360. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4361. * @param startValue defines the start value
  4362. * @param endValue defines the end value
  4363. * @param gradient defines the gradient factor
  4364. * @returns the new matrix
  4365. */
  4366. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4367. /**
  4368. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4369. * @param startValue defines the start value
  4370. * @param endValue defines the end value
  4371. * @param gradient defines the gradient factor
  4372. * @param result defines the Matrix object where to store data
  4373. */
  4374. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4375. /**
  4376. * Builds a new matrix whose values are computed by:
  4377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4380. * @param startValue defines the first matrix
  4381. * @param endValue defines the second matrix
  4382. * @param gradient defines the gradient between the two matrices
  4383. * @returns the new matrix
  4384. */
  4385. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4386. /**
  4387. * Update a matrix to values which are computed by:
  4388. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4389. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4390. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4391. * @param startValue defines the first matrix
  4392. * @param endValue defines the second matrix
  4393. * @param gradient defines the gradient between the two matrices
  4394. * @param result defines the target matrix
  4395. */
  4396. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4397. /**
  4398. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4399. * This function works in left handed mode
  4400. * @param eye defines the final position of the entity
  4401. * @param target defines where the entity should look at
  4402. * @param up defines the up vector for the entity
  4403. * @returns the new matrix
  4404. */
  4405. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4406. /**
  4407. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4408. * This function works in left handed mode
  4409. * @param eye defines the final position of the entity
  4410. * @param target defines where the entity should look at
  4411. * @param up defines the up vector for the entity
  4412. * @param result defines the target matrix
  4413. */
  4414. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4415. /**
  4416. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4417. * This function works in right handed mode
  4418. * @param eye defines the final position of the entity
  4419. * @param target defines where the entity should look at
  4420. * @param up defines the up vector for the entity
  4421. * @returns the new matrix
  4422. */
  4423. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4424. /**
  4425. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4426. * This function works in right handed mode
  4427. * @param eye defines the final position of the entity
  4428. * @param target defines where the entity should look at
  4429. * @param up defines the up vector for the entity
  4430. * @param result defines the target matrix
  4431. */
  4432. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4433. /**
  4434. * Create a left-handed orthographic projection matrix
  4435. * @param width defines the viewport width
  4436. * @param height defines the viewport height
  4437. * @param znear defines the near clip plane
  4438. * @param zfar defines the far clip plane
  4439. * @returns a new matrix as a left-handed orthographic projection matrix
  4440. */
  4441. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4442. /**
  4443. * Store a left-handed orthographic projection to a given matrix
  4444. * @param width defines the viewport width
  4445. * @param height defines the viewport height
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @param result defines the target matrix
  4449. */
  4450. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4451. /**
  4452. * Create a left-handed orthographic projection matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @returns a new matrix as a left-handed orthographic projection matrix
  4460. */
  4461. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4462. /**
  4463. * Stores a left-handed orthographic projection into a given matrix
  4464. * @param left defines the viewport left coordinate
  4465. * @param right defines the viewport right coordinate
  4466. * @param bottom defines the viewport bottom coordinate
  4467. * @param top defines the viewport top coordinate
  4468. * @param znear defines the near clip plane
  4469. * @param zfar defines the far clip plane
  4470. * @param result defines the target matrix
  4471. */
  4472. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4473. /**
  4474. * Creates a right-handed orthographic projection matrix
  4475. * @param left defines the viewport left coordinate
  4476. * @param right defines the viewport right coordinate
  4477. * @param bottom defines the viewport bottom coordinate
  4478. * @param top defines the viewport top coordinate
  4479. * @param znear defines the near clip plane
  4480. * @param zfar defines the far clip plane
  4481. * @returns a new matrix as a right-handed orthographic projection matrix
  4482. */
  4483. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4484. /**
  4485. * Stores a right-handed orthographic projection into a given matrix
  4486. * @param left defines the viewport left coordinate
  4487. * @param right defines the viewport right coordinate
  4488. * @param bottom defines the viewport bottom coordinate
  4489. * @param top defines the viewport top coordinate
  4490. * @param znear defines the near clip plane
  4491. * @param zfar defines the far clip plane
  4492. * @param result defines the target matrix
  4493. */
  4494. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4495. /**
  4496. * Creates a left-handed perspective projection matrix
  4497. * @param width defines the viewport width
  4498. * @param height defines the viewport height
  4499. * @param znear defines the near clip plane
  4500. * @param zfar defines the far clip plane
  4501. * @returns a new matrix as a left-handed perspective projection matrix
  4502. */
  4503. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4504. /**
  4505. * Creates a left-handed perspective projection matrix
  4506. * @param fov defines the horizontal field of view
  4507. * @param aspect defines the aspect ratio
  4508. * @param znear defines the near clip plane
  4509. * @param zfar defines the far clip plane
  4510. * @returns a new matrix as a left-handed perspective projection matrix
  4511. */
  4512. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4513. /**
  4514. * Stores a left-handed perspective projection into a given matrix
  4515. * @param fov defines the horizontal field of view
  4516. * @param aspect defines the aspect ratio
  4517. * @param znear defines the near clip plane
  4518. * @param zfar defines the far clip plane
  4519. * @param result defines the target matrix
  4520. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4521. */
  4522. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4523. /**
  4524. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4525. * @param fov defines the horizontal field of view
  4526. * @param aspect defines the aspect ratio
  4527. * @param znear defines the near clip plane
  4528. * @param zfar not used as infinity is used as far clip
  4529. * @param result defines the target matrix
  4530. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4531. */
  4532. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4533. /**
  4534. * Creates a right-handed perspective projection matrix
  4535. * @param fov defines the horizontal field of view
  4536. * @param aspect defines the aspect ratio
  4537. * @param znear defines the near clip plane
  4538. * @param zfar defines the far clip plane
  4539. * @returns a new matrix as a right-handed perspective projection matrix
  4540. */
  4541. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4542. /**
  4543. * Stores a right-handed perspective projection into a given matrix
  4544. * @param fov defines the horizontal field of view
  4545. * @param aspect defines the aspect ratio
  4546. * @param znear defines the near clip plane
  4547. * @param zfar defines the far clip plane
  4548. * @param result defines the target matrix
  4549. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4550. */
  4551. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4552. /**
  4553. * Stores a right-handed perspective projection into a given matrix
  4554. * @param fov defines the horizontal field of view
  4555. * @param aspect defines the aspect ratio
  4556. * @param znear defines the near clip plane
  4557. * @param zfar not used as infinity is used as far clip
  4558. * @param result defines the target matrix
  4559. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4560. */
  4561. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4562. /**
  4563. * Stores a perspective projection for WebVR info a given matrix
  4564. * @param fov defines the field of view
  4565. * @param znear defines the near clip plane
  4566. * @param zfar defines the far clip plane
  4567. * @param result defines the target matrix
  4568. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4569. */
  4570. static PerspectiveFovWebVRToRef(fov: {
  4571. upDegrees: number;
  4572. downDegrees: number;
  4573. leftDegrees: number;
  4574. rightDegrees: number;
  4575. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4576. /**
  4577. * Computes a complete transformation matrix
  4578. * @param viewport defines the viewport to use
  4579. * @param world defines the world matrix
  4580. * @param view defines the view matrix
  4581. * @param projection defines the projection matrix
  4582. * @param zmin defines the near clip plane
  4583. * @param zmax defines the far clip plane
  4584. * @returns the transformation matrix
  4585. */
  4586. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4587. /**
  4588. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4589. * @param matrix defines the matrix to use
  4590. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4591. */
  4592. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4593. /**
  4594. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4595. * @param matrix defines the matrix to use
  4596. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4597. */
  4598. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4599. /**
  4600. * Compute the transpose of a given matrix
  4601. * @param matrix defines the matrix to transpose
  4602. * @returns the new matrix
  4603. */
  4604. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4605. /**
  4606. * Compute the transpose of a matrix and store it in a target matrix
  4607. * @param matrix defines the matrix to transpose
  4608. * @param result defines the target matrix
  4609. */
  4610. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4611. /**
  4612. * Computes a reflection matrix from a plane
  4613. * @param plane defines the reflection plane
  4614. * @returns a new matrix
  4615. */
  4616. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4617. /**
  4618. * Computes a reflection matrix from a plane
  4619. * @param plane defines the reflection plane
  4620. * @param result defines the target matrix
  4621. */
  4622. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4623. /**
  4624. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4625. * @param xaxis defines the value of the 1st axis
  4626. * @param yaxis defines the value of the 2nd axis
  4627. * @param zaxis defines the value of the 3rd axis
  4628. * @param result defines the target matrix
  4629. */
  4630. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4631. /**
  4632. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4633. * @param quat defines the quaternion to use
  4634. * @param result defines the target matrix
  4635. */
  4636. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4637. }
  4638. /**
  4639. * @hidden
  4640. */
  4641. export class TmpVectors {
  4642. static Vector2: Vector2[];
  4643. static Vector3: Vector3[];
  4644. static Vector4: Vector4[];
  4645. static Quaternion: Quaternion[];
  4646. static Matrix: Matrix[];
  4647. }
  4648. }
  4649. declare module "babylonjs/Maths/math.path" {
  4650. import { DeepImmutable, Nullable } from "babylonjs/types";
  4651. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4652. /**
  4653. * Defines potential orientation for back face culling
  4654. */
  4655. export enum Orientation {
  4656. /**
  4657. * Clockwise
  4658. */
  4659. CW = 0,
  4660. /** Counter clockwise */
  4661. CCW = 1
  4662. }
  4663. /** Class used to represent a Bezier curve */
  4664. export class BezierCurve {
  4665. /**
  4666. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4667. * @param t defines the time
  4668. * @param x1 defines the left coordinate on X axis
  4669. * @param y1 defines the left coordinate on Y axis
  4670. * @param x2 defines the right coordinate on X axis
  4671. * @param y2 defines the right coordinate on Y axis
  4672. * @returns the interpolated value
  4673. */
  4674. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4675. }
  4676. /**
  4677. * Defines angle representation
  4678. */
  4679. export class Angle {
  4680. private _radians;
  4681. /**
  4682. * Creates an Angle object of "radians" radians (float).
  4683. * @param radians the angle in radians
  4684. */
  4685. constructor(radians: number);
  4686. /**
  4687. * Get value in degrees
  4688. * @returns the Angle value in degrees (float)
  4689. */
  4690. degrees(): number;
  4691. /**
  4692. * Get value in radians
  4693. * @returns the Angle value in radians (float)
  4694. */
  4695. radians(): number;
  4696. /**
  4697. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4698. * @param a defines first vector
  4699. * @param b defines second vector
  4700. * @returns a new Angle
  4701. */
  4702. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4703. /**
  4704. * Gets a new Angle object from the given float in radians
  4705. * @param radians defines the angle value in radians
  4706. * @returns a new Angle
  4707. */
  4708. static FromRadians(radians: number): Angle;
  4709. /**
  4710. * Gets a new Angle object from the given float in degrees
  4711. * @param degrees defines the angle value in degrees
  4712. * @returns a new Angle
  4713. */
  4714. static FromDegrees(degrees: number): Angle;
  4715. }
  4716. /**
  4717. * This represents an arc in a 2d space.
  4718. */
  4719. export class Arc2 {
  4720. /** Defines the start point of the arc */
  4721. startPoint: Vector2;
  4722. /** Defines the mid point of the arc */
  4723. midPoint: Vector2;
  4724. /** Defines the end point of the arc */
  4725. endPoint: Vector2;
  4726. /**
  4727. * Defines the center point of the arc.
  4728. */
  4729. centerPoint: Vector2;
  4730. /**
  4731. * Defines the radius of the arc.
  4732. */
  4733. radius: number;
  4734. /**
  4735. * Defines the angle of the arc (from mid point to end point).
  4736. */
  4737. angle: Angle;
  4738. /**
  4739. * Defines the start angle of the arc (from start point to middle point).
  4740. */
  4741. startAngle: Angle;
  4742. /**
  4743. * Defines the orientation of the arc (clock wise/counter clock wise).
  4744. */
  4745. orientation: Orientation;
  4746. /**
  4747. * Creates an Arc object from the three given points : start, middle and end.
  4748. * @param startPoint Defines the start point of the arc
  4749. * @param midPoint Defines the midlle point of the arc
  4750. * @param endPoint Defines the end point of the arc
  4751. */
  4752. constructor(
  4753. /** Defines the start point of the arc */
  4754. startPoint: Vector2,
  4755. /** Defines the mid point of the arc */
  4756. midPoint: Vector2,
  4757. /** Defines the end point of the arc */
  4758. endPoint: Vector2);
  4759. }
  4760. /**
  4761. * Represents a 2D path made up of multiple 2D points
  4762. */
  4763. export class Path2 {
  4764. private _points;
  4765. private _length;
  4766. /**
  4767. * If the path start and end point are the same
  4768. */
  4769. closed: boolean;
  4770. /**
  4771. * Creates a Path2 object from the starting 2D coordinates x and y.
  4772. * @param x the starting points x value
  4773. * @param y the starting points y value
  4774. */
  4775. constructor(x: number, y: number);
  4776. /**
  4777. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4778. * @param x the added points x value
  4779. * @param y the added points y value
  4780. * @returns the updated Path2.
  4781. */
  4782. addLineTo(x: number, y: number): Path2;
  4783. /**
  4784. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4785. * @param midX middle point x value
  4786. * @param midY middle point y value
  4787. * @param endX end point x value
  4788. * @param endY end point y value
  4789. * @param numberOfSegments (default: 36)
  4790. * @returns the updated Path2.
  4791. */
  4792. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4793. /**
  4794. * Closes the Path2.
  4795. * @returns the Path2.
  4796. */
  4797. close(): Path2;
  4798. /**
  4799. * Gets the sum of the distance between each sequential point in the path
  4800. * @returns the Path2 total length (float).
  4801. */
  4802. length(): number;
  4803. /**
  4804. * Gets the points which construct the path
  4805. * @returns the Path2 internal array of points.
  4806. */
  4807. getPoints(): Vector2[];
  4808. /**
  4809. * Retreives the point at the distance aways from the starting point
  4810. * @param normalizedLengthPosition the length along the path to retreive the point from
  4811. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4812. */
  4813. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4814. /**
  4815. * Creates a new path starting from an x and y position
  4816. * @param x starting x value
  4817. * @param y starting y value
  4818. * @returns a new Path2 starting at the coordinates (x, y).
  4819. */
  4820. static StartingAt(x: number, y: number): Path2;
  4821. }
  4822. /**
  4823. * Represents a 3D path made up of multiple 3D points
  4824. */
  4825. export class Path3D {
  4826. /**
  4827. * an array of Vector3, the curve axis of the Path3D
  4828. */
  4829. path: Vector3[];
  4830. private _curve;
  4831. private _distances;
  4832. private _tangents;
  4833. private _normals;
  4834. private _binormals;
  4835. private _raw;
  4836. private _alignTangentsWithPath;
  4837. private readonly _pointAtData;
  4838. /**
  4839. * new Path3D(path, normal, raw)
  4840. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4841. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4842. * @param path an array of Vector3, the curve axis of the Path3D
  4843. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4844. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4845. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4846. */
  4847. constructor(
  4848. /**
  4849. * an array of Vector3, the curve axis of the Path3D
  4850. */
  4851. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4852. /**
  4853. * Returns the Path3D array of successive Vector3 designing its curve.
  4854. * @returns the Path3D array of successive Vector3 designing its curve.
  4855. */
  4856. getCurve(): Vector3[];
  4857. /**
  4858. * Returns the Path3D array of successive Vector3 designing its curve.
  4859. * @returns the Path3D array of successive Vector3 designing its curve.
  4860. */
  4861. getPoints(): Vector3[];
  4862. /**
  4863. * @returns the computed length (float) of the path.
  4864. */
  4865. length(): number;
  4866. /**
  4867. * Returns an array populated with tangent vectors on each Path3D curve point.
  4868. * @returns an array populated with tangent vectors on each Path3D curve point.
  4869. */
  4870. getTangents(): Vector3[];
  4871. /**
  4872. * Returns an array populated with normal vectors on each Path3D curve point.
  4873. * @returns an array populated with normal vectors on each Path3D curve point.
  4874. */
  4875. getNormals(): Vector3[];
  4876. /**
  4877. * Returns an array populated with binormal vectors on each Path3D curve point.
  4878. * @returns an array populated with binormal vectors on each Path3D curve point.
  4879. */
  4880. getBinormals(): Vector3[];
  4881. /**
  4882. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4883. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4884. */
  4885. getDistances(): number[];
  4886. /**
  4887. * Returns an interpolated point along this path
  4888. * @param position the position of the point along this path, from 0.0 to 1.0
  4889. * @returns a new Vector3 as the point
  4890. */
  4891. getPointAt(position: number): Vector3;
  4892. /**
  4893. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4894. * @param position the position of the point along this path, from 0.0 to 1.0
  4895. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4896. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4897. */
  4898. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4899. /**
  4900. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4901. * @param position the position of the point along this path, from 0.0 to 1.0
  4902. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4903. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4904. */
  4905. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4906. /**
  4907. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4908. * @param position the position of the point along this path, from 0.0 to 1.0
  4909. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4910. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4911. */
  4912. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4913. /**
  4914. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4915. * @param position the position of the point along this path, from 0.0 to 1.0
  4916. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4917. */
  4918. getDistanceAt(position: number): number;
  4919. /**
  4920. * Returns the array index of the previous point of an interpolated point along this path
  4921. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4922. * @returns the array index
  4923. */
  4924. getPreviousPointIndexAt(position: number): number;
  4925. /**
  4926. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4927. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4928. * @returns the sub position
  4929. */
  4930. getSubPositionAt(position: number): number;
  4931. /**
  4932. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4933. * @param target the vector of which to get the closest position to
  4934. * @returns the position of the closest virtual point on this path to the target vector
  4935. */
  4936. getClosestPositionTo(target: Vector3): number;
  4937. /**
  4938. * Returns a sub path (slice) of this path
  4939. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4940. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4941. * @returns a sub path (slice) of this path
  4942. */
  4943. slice(start?: number, end?: number): Path3D;
  4944. /**
  4945. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4946. * @param path path which all values are copied into the curves points
  4947. * @param firstNormal which should be projected onto the curve
  4948. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4949. * @returns the same object updated.
  4950. */
  4951. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4952. private _compute;
  4953. private _getFirstNonNullVector;
  4954. private _getLastNonNullVector;
  4955. private _normalVector;
  4956. /**
  4957. * Updates the point at data for an interpolated point along this curve
  4958. * @param position the position of the point along this curve, from 0.0 to 1.0
  4959. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4960. * @returns the (updated) point at data
  4961. */
  4962. private _updatePointAtData;
  4963. /**
  4964. * Updates the point at data from the specified parameters
  4965. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4966. * @param point the interpolated point
  4967. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4968. */
  4969. private _setPointAtData;
  4970. /**
  4971. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4972. */
  4973. private _updateInterpolationMatrix;
  4974. }
  4975. /**
  4976. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4977. * A Curve3 is designed from a series of successive Vector3.
  4978. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4979. */
  4980. export class Curve3 {
  4981. private _points;
  4982. private _length;
  4983. /**
  4984. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4985. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4986. * @param v1 (Vector3) the control point
  4987. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4988. * @param nbPoints (integer) the wanted number of points in the curve
  4989. * @returns the created Curve3
  4990. */
  4991. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4992. /**
  4993. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4994. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4995. * @param v1 (Vector3) the first control point
  4996. * @param v2 (Vector3) the second control point
  4997. * @param v3 (Vector3) the end point of the Cubic Bezier
  4998. * @param nbPoints (integer) the wanted number of points in the curve
  4999. * @returns the created Curve3
  5000. */
  5001. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5002. /**
  5003. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5004. * @param p1 (Vector3) the origin point of the Hermite Spline
  5005. * @param t1 (Vector3) the tangent vector at the origin point
  5006. * @param p2 (Vector3) the end point of the Hermite Spline
  5007. * @param t2 (Vector3) the tangent vector at the end point
  5008. * @param nbPoints (integer) the wanted number of points in the curve
  5009. * @returns the created Curve3
  5010. */
  5011. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5012. /**
  5013. * Returns a Curve3 object along a CatmullRom Spline curve :
  5014. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5015. * @param nbPoints (integer) the wanted number of points between each curve control points
  5016. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5017. * @returns the created Curve3
  5018. */
  5019. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5020. /**
  5021. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5022. * A Curve3 is designed from a series of successive Vector3.
  5023. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5024. * @param points points which make up the curve
  5025. */
  5026. constructor(points: Vector3[]);
  5027. /**
  5028. * @returns the Curve3 stored array of successive Vector3
  5029. */
  5030. getPoints(): Vector3[];
  5031. /**
  5032. * @returns the computed length (float) of the curve.
  5033. */
  5034. length(): number;
  5035. /**
  5036. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5037. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5038. * curveA and curveB keep unchanged.
  5039. * @param curve the curve to continue from this curve
  5040. * @returns the newly constructed curve
  5041. */
  5042. continue(curve: DeepImmutable<Curve3>): Curve3;
  5043. private _computeLength;
  5044. }
  5045. }
  5046. declare module "babylonjs/Animations/easing" {
  5047. /**
  5048. * This represents the main contract an easing function should follow.
  5049. * Easing functions are used throughout the animation system.
  5050. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5051. */
  5052. export interface IEasingFunction {
  5053. /**
  5054. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5055. * of the easing function.
  5056. * The link below provides some of the most common examples of easing functions.
  5057. * @see https://easings.net/
  5058. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5059. * @returns the corresponding value on the curve defined by the easing function
  5060. */
  5061. ease(gradient: number): number;
  5062. }
  5063. /**
  5064. * Base class used for every default easing function.
  5065. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5066. */
  5067. export class EasingFunction implements IEasingFunction {
  5068. /**
  5069. * Interpolation follows the mathematical formula associated with the easing function.
  5070. */
  5071. static readonly EASINGMODE_EASEIN: number;
  5072. /**
  5073. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5074. */
  5075. static readonly EASINGMODE_EASEOUT: number;
  5076. /**
  5077. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5078. */
  5079. static readonly EASINGMODE_EASEINOUT: number;
  5080. private _easingMode;
  5081. /**
  5082. * Sets the easing mode of the current function.
  5083. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5084. */
  5085. setEasingMode(easingMode: number): void;
  5086. /**
  5087. * Gets the current easing mode.
  5088. * @returns the easing mode
  5089. */
  5090. getEasingMode(): number;
  5091. /**
  5092. * @hidden
  5093. */
  5094. easeInCore(gradient: number): number;
  5095. /**
  5096. * Given an input gradient between 0 and 1, this returns the corresponding value
  5097. * of the easing function.
  5098. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5099. * @returns the corresponding value on the curve defined by the easing function
  5100. */
  5101. ease(gradient: number): number;
  5102. }
  5103. /**
  5104. * Easing function with a circle shape (see link below).
  5105. * @see https://easings.net/#easeInCirc
  5106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5107. */
  5108. export class CircleEase extends EasingFunction implements IEasingFunction {
  5109. /** @hidden */
  5110. easeInCore(gradient: number): number;
  5111. }
  5112. /**
  5113. * Easing function with a ease back shape (see link below).
  5114. * @see https://easings.net/#easeInBack
  5115. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5116. */
  5117. export class BackEase extends EasingFunction implements IEasingFunction {
  5118. /** Defines the amplitude of the function */
  5119. amplitude: number;
  5120. /**
  5121. * Instantiates a back ease easing
  5122. * @see https://easings.net/#easeInBack
  5123. * @param amplitude Defines the amplitude of the function
  5124. */
  5125. constructor(
  5126. /** Defines the amplitude of the function */
  5127. amplitude?: number);
  5128. /** @hidden */
  5129. easeInCore(gradient: number): number;
  5130. }
  5131. /**
  5132. * Easing function with a bouncing shape (see link below).
  5133. * @see https://easings.net/#easeInBounce
  5134. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5135. */
  5136. export class BounceEase extends EasingFunction implements IEasingFunction {
  5137. /** Defines the number of bounces */
  5138. bounces: number;
  5139. /** Defines the amplitude of the bounce */
  5140. bounciness: number;
  5141. /**
  5142. * Instantiates a bounce easing
  5143. * @see https://easings.net/#easeInBounce
  5144. * @param bounces Defines the number of bounces
  5145. * @param bounciness Defines the amplitude of the bounce
  5146. */
  5147. constructor(
  5148. /** Defines the number of bounces */
  5149. bounces?: number,
  5150. /** Defines the amplitude of the bounce */
  5151. bounciness?: number);
  5152. /** @hidden */
  5153. easeInCore(gradient: number): number;
  5154. }
  5155. /**
  5156. * Easing function with a power of 3 shape (see link below).
  5157. * @see https://easings.net/#easeInCubic
  5158. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5159. */
  5160. export class CubicEase extends EasingFunction implements IEasingFunction {
  5161. /** @hidden */
  5162. easeInCore(gradient: number): number;
  5163. }
  5164. /**
  5165. * Easing function with an elastic shape (see link below).
  5166. * @see https://easings.net/#easeInElastic
  5167. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5168. */
  5169. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5170. /** Defines the number of oscillations*/
  5171. oscillations: number;
  5172. /** Defines the amplitude of the oscillations*/
  5173. springiness: number;
  5174. /**
  5175. * Instantiates an elastic easing function
  5176. * @see https://easings.net/#easeInElastic
  5177. * @param oscillations Defines the number of oscillations
  5178. * @param springiness Defines the amplitude of the oscillations
  5179. */
  5180. constructor(
  5181. /** Defines the number of oscillations*/
  5182. oscillations?: number,
  5183. /** Defines the amplitude of the oscillations*/
  5184. springiness?: number);
  5185. /** @hidden */
  5186. easeInCore(gradient: number): number;
  5187. }
  5188. /**
  5189. * Easing function with an exponential shape (see link below).
  5190. * @see https://easings.net/#easeInExpo
  5191. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5192. */
  5193. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5194. /** Defines the exponent of the function */
  5195. exponent: number;
  5196. /**
  5197. * Instantiates an exponential easing function
  5198. * @see https://easings.net/#easeInExpo
  5199. * @param exponent Defines the exponent of the function
  5200. */
  5201. constructor(
  5202. /** Defines the exponent of the function */
  5203. exponent?: number);
  5204. /** @hidden */
  5205. easeInCore(gradient: number): number;
  5206. }
  5207. /**
  5208. * Easing function with a power shape (see link below).
  5209. * @see https://easings.net/#easeInQuad
  5210. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5211. */
  5212. export class PowerEase extends EasingFunction implements IEasingFunction {
  5213. /** Defines the power of the function */
  5214. power: number;
  5215. /**
  5216. * Instantiates an power base easing function
  5217. * @see https://easings.net/#easeInQuad
  5218. * @param power Defines the power of the function
  5219. */
  5220. constructor(
  5221. /** Defines the power of the function */
  5222. power?: number);
  5223. /** @hidden */
  5224. easeInCore(gradient: number): number;
  5225. }
  5226. /**
  5227. * Easing function with a power of 2 shape (see link below).
  5228. * @see https://easings.net/#easeInQuad
  5229. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5230. */
  5231. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5232. /** @hidden */
  5233. easeInCore(gradient: number): number;
  5234. }
  5235. /**
  5236. * Easing function with a power of 4 shape (see link below).
  5237. * @see https://easings.net/#easeInQuart
  5238. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5239. */
  5240. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5241. /** @hidden */
  5242. easeInCore(gradient: number): number;
  5243. }
  5244. /**
  5245. * Easing function with a power of 5 shape (see link below).
  5246. * @see https://easings.net/#easeInQuint
  5247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5248. */
  5249. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5250. /** @hidden */
  5251. easeInCore(gradient: number): number;
  5252. }
  5253. /**
  5254. * Easing function with a sin shape (see link below).
  5255. * @see https://easings.net/#easeInSine
  5256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5257. */
  5258. export class SineEase extends EasingFunction implements IEasingFunction {
  5259. /** @hidden */
  5260. easeInCore(gradient: number): number;
  5261. }
  5262. /**
  5263. * Easing function with a bezier shape (see link below).
  5264. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5265. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5266. */
  5267. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5268. /** Defines the x component of the start tangent in the bezier curve */
  5269. x1: number;
  5270. /** Defines the y component of the start tangent in the bezier curve */
  5271. y1: number;
  5272. /** Defines the x component of the end tangent in the bezier curve */
  5273. x2: number;
  5274. /** Defines the y component of the end tangent in the bezier curve */
  5275. y2: number;
  5276. /**
  5277. * Instantiates a bezier function
  5278. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5279. * @param x1 Defines the x component of the start tangent in the bezier curve
  5280. * @param y1 Defines the y component of the start tangent in the bezier curve
  5281. * @param x2 Defines the x component of the end tangent in the bezier curve
  5282. * @param y2 Defines the y component of the end tangent in the bezier curve
  5283. */
  5284. constructor(
  5285. /** Defines the x component of the start tangent in the bezier curve */
  5286. x1?: number,
  5287. /** Defines the y component of the start tangent in the bezier curve */
  5288. y1?: number,
  5289. /** Defines the x component of the end tangent in the bezier curve */
  5290. x2?: number,
  5291. /** Defines the y component of the end tangent in the bezier curve */
  5292. y2?: number);
  5293. /** @hidden */
  5294. easeInCore(gradient: number): number;
  5295. }
  5296. }
  5297. declare module "babylonjs/Maths/math.color" {
  5298. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5299. /**
  5300. * Class used to hold a RBG color
  5301. */
  5302. export class Color3 {
  5303. /**
  5304. * Defines the red component (between 0 and 1, default is 0)
  5305. */
  5306. r: number;
  5307. /**
  5308. * Defines the green component (between 0 and 1, default is 0)
  5309. */
  5310. g: number;
  5311. /**
  5312. * Defines the blue component (between 0 and 1, default is 0)
  5313. */
  5314. b: number;
  5315. /**
  5316. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5317. * @param r defines the red component (between 0 and 1, default is 0)
  5318. * @param g defines the green component (between 0 and 1, default is 0)
  5319. * @param b defines the blue component (between 0 and 1, default is 0)
  5320. */
  5321. constructor(
  5322. /**
  5323. * Defines the red component (between 0 and 1, default is 0)
  5324. */
  5325. r?: number,
  5326. /**
  5327. * Defines the green component (between 0 and 1, default is 0)
  5328. */
  5329. g?: number,
  5330. /**
  5331. * Defines the blue component (between 0 and 1, default is 0)
  5332. */
  5333. b?: number);
  5334. /**
  5335. * Creates a string with the Color3 current values
  5336. * @returns the string representation of the Color3 object
  5337. */
  5338. toString(): string;
  5339. /**
  5340. * Returns the string "Color3"
  5341. * @returns "Color3"
  5342. */
  5343. getClassName(): string;
  5344. /**
  5345. * Compute the Color3 hash code
  5346. * @returns an unique number that can be used to hash Color3 objects
  5347. */
  5348. getHashCode(): number;
  5349. /**
  5350. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5351. * @param array defines the array where to store the r,g,b components
  5352. * @param index defines an optional index in the target array to define where to start storing values
  5353. * @returns the current Color3 object
  5354. */
  5355. toArray(array: FloatArray, index?: number): Color3;
  5356. /**
  5357. * Returns a new Color4 object from the current Color3 and the given alpha
  5358. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5359. * @returns a new Color4 object
  5360. */
  5361. toColor4(alpha?: number): Color4;
  5362. /**
  5363. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5364. * @returns the new array
  5365. */
  5366. asArray(): number[];
  5367. /**
  5368. * Returns the luminance value
  5369. * @returns a float value
  5370. */
  5371. toLuminance(): number;
  5372. /**
  5373. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5374. * @param otherColor defines the second operand
  5375. * @returns the new Color3 object
  5376. */
  5377. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5378. /**
  5379. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5380. * @param otherColor defines the second operand
  5381. * @param result defines the Color3 object where to store the result
  5382. * @returns the current Color3
  5383. */
  5384. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5385. /**
  5386. * Determines equality between Color3 objects
  5387. * @param otherColor defines the second operand
  5388. * @returns true if the rgb values are equal to the given ones
  5389. */
  5390. equals(otherColor: DeepImmutable<Color3>): boolean;
  5391. /**
  5392. * Determines equality between the current Color3 object and a set of r,b,g values
  5393. * @param r defines the red component to check
  5394. * @param g defines the green component to check
  5395. * @param b defines the blue component to check
  5396. * @returns true if the rgb values are equal to the given ones
  5397. */
  5398. equalsFloats(r: number, g: number, b: number): boolean;
  5399. /**
  5400. * Multiplies in place each rgb value by scale
  5401. * @param scale defines the scaling factor
  5402. * @returns the updated Color3
  5403. */
  5404. scale(scale: number): Color3;
  5405. /**
  5406. * Multiplies the rgb values by scale and stores the result into "result"
  5407. * @param scale defines the scaling factor
  5408. * @param result defines the Color3 object where to store the result
  5409. * @returns the unmodified current Color3
  5410. */
  5411. scaleToRef(scale: number, result: Color3): Color3;
  5412. /**
  5413. * Scale the current Color3 values by a factor and add the result to a given Color3
  5414. * @param scale defines the scale factor
  5415. * @param result defines color to store the result into
  5416. * @returns the unmodified current Color3
  5417. */
  5418. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5419. /**
  5420. * Clamps the rgb values by the min and max values and stores the result into "result"
  5421. * @param min defines minimum clamping value (default is 0)
  5422. * @param max defines maximum clamping value (default is 1)
  5423. * @param result defines color to store the result into
  5424. * @returns the original Color3
  5425. */
  5426. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5427. /**
  5428. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5429. * @param otherColor defines the second operand
  5430. * @returns the new Color3
  5431. */
  5432. add(otherColor: DeepImmutable<Color3>): Color3;
  5433. /**
  5434. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5435. * @param otherColor defines the second operand
  5436. * @param result defines Color3 object to store the result into
  5437. * @returns the unmodified current Color3
  5438. */
  5439. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5440. /**
  5441. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5442. * @param otherColor defines the second operand
  5443. * @returns the new Color3
  5444. */
  5445. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5446. /**
  5447. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5448. * @param otherColor defines the second operand
  5449. * @param result defines Color3 object to store the result into
  5450. * @returns the unmodified current Color3
  5451. */
  5452. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5453. /**
  5454. * Copy the current object
  5455. * @returns a new Color3 copied the current one
  5456. */
  5457. clone(): Color3;
  5458. /**
  5459. * Copies the rgb values from the source in the current Color3
  5460. * @param source defines the source Color3 object
  5461. * @returns the updated Color3 object
  5462. */
  5463. copyFrom(source: DeepImmutable<Color3>): Color3;
  5464. /**
  5465. * Updates the Color3 rgb values from the given floats
  5466. * @param r defines the red component to read from
  5467. * @param g defines the green component to read from
  5468. * @param b defines the blue component to read from
  5469. * @returns the current Color3 object
  5470. */
  5471. copyFromFloats(r: number, g: number, b: number): Color3;
  5472. /**
  5473. * Updates the Color3 rgb values from the given floats
  5474. * @param r defines the red component to read from
  5475. * @param g defines the green component to read from
  5476. * @param b defines the blue component to read from
  5477. * @returns the current Color3 object
  5478. */
  5479. set(r: number, g: number, b: number): Color3;
  5480. /**
  5481. * Compute the Color3 hexadecimal code as a string
  5482. * @returns a string containing the hexadecimal representation of the Color3 object
  5483. */
  5484. toHexString(): string;
  5485. /**
  5486. * Computes a new Color3 converted from the current one to linear space
  5487. * @returns a new Color3 object
  5488. */
  5489. toLinearSpace(): Color3;
  5490. /**
  5491. * Converts current color in rgb space to HSV values
  5492. * @returns a new color3 representing the HSV values
  5493. */
  5494. toHSV(): Color3;
  5495. /**
  5496. * Converts current color in rgb space to HSV values
  5497. * @param result defines the Color3 where to store the HSV values
  5498. */
  5499. toHSVToRef(result: Color3): void;
  5500. /**
  5501. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5502. * @param convertedColor defines the Color3 object where to store the linear space version
  5503. * @returns the unmodified Color3
  5504. */
  5505. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5506. /**
  5507. * Computes a new Color3 converted from the current one to gamma space
  5508. * @returns a new Color3 object
  5509. */
  5510. toGammaSpace(): Color3;
  5511. /**
  5512. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5513. * @param convertedColor defines the Color3 object where to store the gamma space version
  5514. * @returns the unmodified Color3
  5515. */
  5516. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5517. private static _BlackReadOnly;
  5518. /**
  5519. * Convert Hue, saturation and value to a Color3 (RGB)
  5520. * @param hue defines the hue
  5521. * @param saturation defines the saturation
  5522. * @param value defines the value
  5523. * @param result defines the Color3 where to store the RGB values
  5524. */
  5525. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5526. /**
  5527. * Creates a new Color3 from the string containing valid hexadecimal values
  5528. * @param hex defines a string containing valid hexadecimal values
  5529. * @returns a new Color3 object
  5530. */
  5531. static FromHexString(hex: string): Color3;
  5532. /**
  5533. * Creates a new Color3 from the starting index of the given array
  5534. * @param array defines the source array
  5535. * @param offset defines an offset in the source array
  5536. * @returns a new Color3 object
  5537. */
  5538. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5539. /**
  5540. * Creates a new Color3 from integer values (< 256)
  5541. * @param r defines the red component to read from (value between 0 and 255)
  5542. * @param g defines the green component to read from (value between 0 and 255)
  5543. * @param b defines the blue component to read from (value between 0 and 255)
  5544. * @returns a new Color3 object
  5545. */
  5546. static FromInts(r: number, g: number, b: number): Color3;
  5547. /**
  5548. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5549. * @param start defines the start Color3 value
  5550. * @param end defines the end Color3 value
  5551. * @param amount defines the gradient value between start and end
  5552. * @returns a new Color3 object
  5553. */
  5554. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5555. /**
  5556. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5557. * @param left defines the start value
  5558. * @param right defines the end value
  5559. * @param amount defines the gradient factor
  5560. * @param result defines the Color3 object where to store the result
  5561. */
  5562. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5563. /**
  5564. * Returns a Color3 value containing a red color
  5565. * @returns a new Color3 object
  5566. */
  5567. static Red(): Color3;
  5568. /**
  5569. * Returns a Color3 value containing a green color
  5570. * @returns a new Color3 object
  5571. */
  5572. static Green(): Color3;
  5573. /**
  5574. * Returns a Color3 value containing a blue color
  5575. * @returns a new Color3 object
  5576. */
  5577. static Blue(): Color3;
  5578. /**
  5579. * Returns a Color3 value containing a black color
  5580. * @returns a new Color3 object
  5581. */
  5582. static Black(): Color3;
  5583. /**
  5584. * Gets a Color3 value containing a black color that must not be updated
  5585. */
  5586. static get BlackReadOnly(): DeepImmutable<Color3>;
  5587. /**
  5588. * Returns a Color3 value containing a white color
  5589. * @returns a new Color3 object
  5590. */
  5591. static White(): Color3;
  5592. /**
  5593. * Returns a Color3 value containing a purple color
  5594. * @returns a new Color3 object
  5595. */
  5596. static Purple(): Color3;
  5597. /**
  5598. * Returns a Color3 value containing a magenta color
  5599. * @returns a new Color3 object
  5600. */
  5601. static Magenta(): Color3;
  5602. /**
  5603. * Returns a Color3 value containing a yellow color
  5604. * @returns a new Color3 object
  5605. */
  5606. static Yellow(): Color3;
  5607. /**
  5608. * Returns a Color3 value containing a gray color
  5609. * @returns a new Color3 object
  5610. */
  5611. static Gray(): Color3;
  5612. /**
  5613. * Returns a Color3 value containing a teal color
  5614. * @returns a new Color3 object
  5615. */
  5616. static Teal(): Color3;
  5617. /**
  5618. * Returns a Color3 value containing a random color
  5619. * @returns a new Color3 object
  5620. */
  5621. static Random(): Color3;
  5622. }
  5623. /**
  5624. * Class used to hold a RBGA color
  5625. */
  5626. export class Color4 {
  5627. /**
  5628. * Defines the red component (between 0 and 1, default is 0)
  5629. */
  5630. r: number;
  5631. /**
  5632. * Defines the green component (between 0 and 1, default is 0)
  5633. */
  5634. g: number;
  5635. /**
  5636. * Defines the blue component (between 0 and 1, default is 0)
  5637. */
  5638. b: number;
  5639. /**
  5640. * Defines the alpha component (between 0 and 1, default is 1)
  5641. */
  5642. a: number;
  5643. /**
  5644. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5645. * @param r defines the red component (between 0 and 1, default is 0)
  5646. * @param g defines the green component (between 0 and 1, default is 0)
  5647. * @param b defines the blue component (between 0 and 1, default is 0)
  5648. * @param a defines the alpha component (between 0 and 1, default is 1)
  5649. */
  5650. constructor(
  5651. /**
  5652. * Defines the red component (between 0 and 1, default is 0)
  5653. */
  5654. r?: number,
  5655. /**
  5656. * Defines the green component (between 0 and 1, default is 0)
  5657. */
  5658. g?: number,
  5659. /**
  5660. * Defines the blue component (between 0 and 1, default is 0)
  5661. */
  5662. b?: number,
  5663. /**
  5664. * Defines the alpha component (between 0 and 1, default is 1)
  5665. */
  5666. a?: number);
  5667. /**
  5668. * Adds in place the given Color4 values to the current Color4 object
  5669. * @param right defines the second operand
  5670. * @returns the current updated Color4 object
  5671. */
  5672. addInPlace(right: DeepImmutable<Color4>): Color4;
  5673. /**
  5674. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5675. * @returns the new array
  5676. */
  5677. asArray(): number[];
  5678. /**
  5679. * Stores from the starting index in the given array the Color4 successive values
  5680. * @param array defines the array where to store the r,g,b components
  5681. * @param index defines an optional index in the target array to define where to start storing values
  5682. * @returns the current Color4 object
  5683. */
  5684. toArray(array: number[], index?: number): Color4;
  5685. /**
  5686. * Determines equality between Color4 objects
  5687. * @param otherColor defines the second operand
  5688. * @returns true if the rgba values are equal to the given ones
  5689. */
  5690. equals(otherColor: DeepImmutable<Color4>): boolean;
  5691. /**
  5692. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5693. * @param right defines the second operand
  5694. * @returns a new Color4 object
  5695. */
  5696. add(right: DeepImmutable<Color4>): Color4;
  5697. /**
  5698. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5699. * @param right defines the second operand
  5700. * @returns a new Color4 object
  5701. */
  5702. subtract(right: DeepImmutable<Color4>): Color4;
  5703. /**
  5704. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5705. * @param right defines the second operand
  5706. * @param result defines the Color4 object where to store the result
  5707. * @returns the current Color4 object
  5708. */
  5709. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5710. /**
  5711. * Creates a new Color4 with the current Color4 values multiplied by scale
  5712. * @param scale defines the scaling factor to apply
  5713. * @returns a new Color4 object
  5714. */
  5715. scale(scale: number): Color4;
  5716. /**
  5717. * Multiplies the current Color4 values by scale and stores the result in "result"
  5718. * @param scale defines the scaling factor to apply
  5719. * @param result defines the Color4 object where to store the result
  5720. * @returns the current unmodified Color4
  5721. */
  5722. scaleToRef(scale: number, result: Color4): Color4;
  5723. /**
  5724. * Scale the current Color4 values by a factor and add the result to a given Color4
  5725. * @param scale defines the scale factor
  5726. * @param result defines the Color4 object where to store the result
  5727. * @returns the unmodified current Color4
  5728. */
  5729. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5730. /**
  5731. * Clamps the rgb values by the min and max values and stores the result into "result"
  5732. * @param min defines minimum clamping value (default is 0)
  5733. * @param max defines maximum clamping value (default is 1)
  5734. * @param result defines color to store the result into.
  5735. * @returns the cuurent Color4
  5736. */
  5737. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5738. /**
  5739. * Multipy an Color4 value by another and return a new Color4 object
  5740. * @param color defines the Color4 value to multiply by
  5741. * @returns a new Color4 object
  5742. */
  5743. multiply(color: Color4): Color4;
  5744. /**
  5745. * Multipy a Color4 value by another and push the result in a reference value
  5746. * @param color defines the Color4 value to multiply by
  5747. * @param result defines the Color4 to fill the result in
  5748. * @returns the result Color4
  5749. */
  5750. multiplyToRef(color: Color4, result: Color4): Color4;
  5751. /**
  5752. * Creates a string with the Color4 current values
  5753. * @returns the string representation of the Color4 object
  5754. */
  5755. toString(): string;
  5756. /**
  5757. * Returns the string "Color4"
  5758. * @returns "Color4"
  5759. */
  5760. getClassName(): string;
  5761. /**
  5762. * Compute the Color4 hash code
  5763. * @returns an unique number that can be used to hash Color4 objects
  5764. */
  5765. getHashCode(): number;
  5766. /**
  5767. * Creates a new Color4 copied from the current one
  5768. * @returns a new Color4 object
  5769. */
  5770. clone(): Color4;
  5771. /**
  5772. * Copies the given Color4 values into the current one
  5773. * @param source defines the source Color4 object
  5774. * @returns the current updated Color4 object
  5775. */
  5776. copyFrom(source: Color4): Color4;
  5777. /**
  5778. * Copies the given float values into the current one
  5779. * @param r defines the red component to read from
  5780. * @param g defines the green component to read from
  5781. * @param b defines the blue component to read from
  5782. * @param a defines the alpha component to read from
  5783. * @returns the current updated Color4 object
  5784. */
  5785. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5786. /**
  5787. * Copies the given float values into the current one
  5788. * @param r defines the red component to read from
  5789. * @param g defines the green component to read from
  5790. * @param b defines the blue component to read from
  5791. * @param a defines the alpha component to read from
  5792. * @returns the current updated Color4 object
  5793. */
  5794. set(r: number, g: number, b: number, a: number): Color4;
  5795. /**
  5796. * Compute the Color4 hexadecimal code as a string
  5797. * @returns a string containing the hexadecimal representation of the Color4 object
  5798. */
  5799. toHexString(): string;
  5800. /**
  5801. * Computes a new Color4 converted from the current one to linear space
  5802. * @returns a new Color4 object
  5803. */
  5804. toLinearSpace(): Color4;
  5805. /**
  5806. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5807. * @param convertedColor defines the Color4 object where to store the linear space version
  5808. * @returns the unmodified Color4
  5809. */
  5810. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5811. /**
  5812. * Computes a new Color4 converted from the current one to gamma space
  5813. * @returns a new Color4 object
  5814. */
  5815. toGammaSpace(): Color4;
  5816. /**
  5817. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5818. * @param convertedColor defines the Color4 object where to store the gamma space version
  5819. * @returns the unmodified Color4
  5820. */
  5821. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5822. /**
  5823. * Creates a new Color4 from the string containing valid hexadecimal values
  5824. * @param hex defines a string containing valid hexadecimal values
  5825. * @returns a new Color4 object
  5826. */
  5827. static FromHexString(hex: string): Color4;
  5828. /**
  5829. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5830. * @param left defines the start value
  5831. * @param right defines the end value
  5832. * @param amount defines the gradient factor
  5833. * @returns a new Color4 object
  5834. */
  5835. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5836. /**
  5837. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5838. * @param left defines the start value
  5839. * @param right defines the end value
  5840. * @param amount defines the gradient factor
  5841. * @param result defines the Color4 object where to store data
  5842. */
  5843. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5844. /**
  5845. * Creates a new Color4 from a Color3 and an alpha value
  5846. * @param color3 defines the source Color3 to read from
  5847. * @param alpha defines the alpha component (1.0 by default)
  5848. * @returns a new Color4 object
  5849. */
  5850. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5851. /**
  5852. * Creates a new Color4 from the starting index element of the given array
  5853. * @param array defines the source array to read from
  5854. * @param offset defines the offset in the source array
  5855. * @returns a new Color4 object
  5856. */
  5857. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5858. /**
  5859. * Creates a new Color3 from integer values (< 256)
  5860. * @param r defines the red component to read from (value between 0 and 255)
  5861. * @param g defines the green component to read from (value between 0 and 255)
  5862. * @param b defines the blue component to read from (value between 0 and 255)
  5863. * @param a defines the alpha component to read from (value between 0 and 255)
  5864. * @returns a new Color3 object
  5865. */
  5866. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5867. /**
  5868. * Check the content of a given array and convert it to an array containing RGBA data
  5869. * If the original array was already containing count * 4 values then it is returned directly
  5870. * @param colors defines the array to check
  5871. * @param count defines the number of RGBA data to expect
  5872. * @returns an array containing count * 4 values (RGBA)
  5873. */
  5874. static CheckColors4(colors: number[], count: number): number[];
  5875. }
  5876. /**
  5877. * @hidden
  5878. */
  5879. export class TmpColors {
  5880. static Color3: Color3[];
  5881. static Color4: Color4[];
  5882. }
  5883. }
  5884. declare module "babylonjs/Animations/animationKey" {
  5885. /**
  5886. * Defines an interface which represents an animation key frame
  5887. */
  5888. export interface IAnimationKey {
  5889. /**
  5890. * Frame of the key frame
  5891. */
  5892. frame: number;
  5893. /**
  5894. * Value at the specifies key frame
  5895. */
  5896. value: any;
  5897. /**
  5898. * The input tangent for the cubic hermite spline
  5899. */
  5900. inTangent?: any;
  5901. /**
  5902. * The output tangent for the cubic hermite spline
  5903. */
  5904. outTangent?: any;
  5905. /**
  5906. * The animation interpolation type
  5907. */
  5908. interpolation?: AnimationKeyInterpolation;
  5909. }
  5910. /**
  5911. * Enum for the animation key frame interpolation type
  5912. */
  5913. export enum AnimationKeyInterpolation {
  5914. /**
  5915. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5916. */
  5917. STEP = 1
  5918. }
  5919. }
  5920. declare module "babylonjs/Animations/animationRange" {
  5921. /**
  5922. * Represents the range of an animation
  5923. */
  5924. export class AnimationRange {
  5925. /**The name of the animation range**/
  5926. name: string;
  5927. /**The starting frame of the animation */
  5928. from: number;
  5929. /**The ending frame of the animation*/
  5930. to: number;
  5931. /**
  5932. * Initializes the range of an animation
  5933. * @param name The name of the animation range
  5934. * @param from The starting frame of the animation
  5935. * @param to The ending frame of the animation
  5936. */
  5937. constructor(
  5938. /**The name of the animation range**/
  5939. name: string,
  5940. /**The starting frame of the animation */
  5941. from: number,
  5942. /**The ending frame of the animation*/
  5943. to: number);
  5944. /**
  5945. * Makes a copy of the animation range
  5946. * @returns A copy of the animation range
  5947. */
  5948. clone(): AnimationRange;
  5949. }
  5950. }
  5951. declare module "babylonjs/Animations/animationEvent" {
  5952. /**
  5953. * Composed of a frame, and an action function
  5954. */
  5955. export class AnimationEvent {
  5956. /** The frame for which the event is triggered **/
  5957. frame: number;
  5958. /** The event to perform when triggered **/
  5959. action: (currentFrame: number) => void;
  5960. /** Specifies if the event should be triggered only once**/
  5961. onlyOnce?: boolean | undefined;
  5962. /**
  5963. * Specifies if the animation event is done
  5964. */
  5965. isDone: boolean;
  5966. /**
  5967. * Initializes the animation event
  5968. * @param frame The frame for which the event is triggered
  5969. * @param action The event to perform when triggered
  5970. * @param onlyOnce Specifies if the event should be triggered only once
  5971. */
  5972. constructor(
  5973. /** The frame for which the event is triggered **/
  5974. frame: number,
  5975. /** The event to perform when triggered **/
  5976. action: (currentFrame: number) => void,
  5977. /** Specifies if the event should be triggered only once**/
  5978. onlyOnce?: boolean | undefined);
  5979. /** @hidden */
  5980. _clone(): AnimationEvent;
  5981. }
  5982. }
  5983. declare module "babylonjs/Behaviors/behavior" {
  5984. import { Nullable } from "babylonjs/types";
  5985. /**
  5986. * Interface used to define a behavior
  5987. */
  5988. export interface Behavior<T> {
  5989. /** gets or sets behavior's name */
  5990. name: string;
  5991. /**
  5992. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5993. */
  5994. init(): void;
  5995. /**
  5996. * Called when the behavior is attached to a target
  5997. * @param target defines the target where the behavior is attached to
  5998. */
  5999. attach(target: T): void;
  6000. /**
  6001. * Called when the behavior is detached from its target
  6002. */
  6003. detach(): void;
  6004. }
  6005. /**
  6006. * Interface implemented by classes supporting behaviors
  6007. */
  6008. export interface IBehaviorAware<T> {
  6009. /**
  6010. * Attach a behavior
  6011. * @param behavior defines the behavior to attach
  6012. * @returns the current host
  6013. */
  6014. addBehavior(behavior: Behavior<T>): T;
  6015. /**
  6016. * Remove a behavior from the current object
  6017. * @param behavior defines the behavior to detach
  6018. * @returns the current host
  6019. */
  6020. removeBehavior(behavior: Behavior<T>): T;
  6021. /**
  6022. * Gets a behavior using its name to search
  6023. * @param name defines the name to search
  6024. * @returns the behavior or null if not found
  6025. */
  6026. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6027. }
  6028. }
  6029. declare module "babylonjs/Misc/smartArray" {
  6030. /**
  6031. * Defines an array and its length.
  6032. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6033. */
  6034. export interface ISmartArrayLike<T> {
  6035. /**
  6036. * The data of the array.
  6037. */
  6038. data: Array<T>;
  6039. /**
  6040. * The active length of the array.
  6041. */
  6042. length: number;
  6043. }
  6044. /**
  6045. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6046. */
  6047. export class SmartArray<T> implements ISmartArrayLike<T> {
  6048. /**
  6049. * The full set of data from the array.
  6050. */
  6051. data: Array<T>;
  6052. /**
  6053. * The active length of the array.
  6054. */
  6055. length: number;
  6056. protected _id: number;
  6057. /**
  6058. * Instantiates a Smart Array.
  6059. * @param capacity defines the default capacity of the array.
  6060. */
  6061. constructor(capacity: number);
  6062. /**
  6063. * Pushes a value at the end of the active data.
  6064. * @param value defines the object to push in the array.
  6065. */
  6066. push(value: T): void;
  6067. /**
  6068. * Iterates over the active data and apply the lambda to them.
  6069. * @param func defines the action to apply on each value.
  6070. */
  6071. forEach(func: (content: T) => void): void;
  6072. /**
  6073. * Sorts the full sets of data.
  6074. * @param compareFn defines the comparison function to apply.
  6075. */
  6076. sort(compareFn: (a: T, b: T) => number): void;
  6077. /**
  6078. * Resets the active data to an empty array.
  6079. */
  6080. reset(): void;
  6081. /**
  6082. * Releases all the data from the array as well as the array.
  6083. */
  6084. dispose(): void;
  6085. /**
  6086. * Concats the active data with a given array.
  6087. * @param array defines the data to concatenate with.
  6088. */
  6089. concat(array: any): void;
  6090. /**
  6091. * Returns the position of a value in the active data.
  6092. * @param value defines the value to find the index for
  6093. * @returns the index if found in the active data otherwise -1
  6094. */
  6095. indexOf(value: T): number;
  6096. /**
  6097. * Returns whether an element is part of the active data.
  6098. * @param value defines the value to look for
  6099. * @returns true if found in the active data otherwise false
  6100. */
  6101. contains(value: T): boolean;
  6102. private static _GlobalId;
  6103. }
  6104. /**
  6105. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6106. * The data in this array can only be present once
  6107. */
  6108. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6109. private _duplicateId;
  6110. /**
  6111. * Pushes a value at the end of the active data.
  6112. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6113. * @param value defines the object to push in the array.
  6114. */
  6115. push(value: T): void;
  6116. /**
  6117. * Pushes a value at the end of the active data.
  6118. * If the data is already present, it won t be added again
  6119. * @param value defines the object to push in the array.
  6120. * @returns true if added false if it was already present
  6121. */
  6122. pushNoDuplicate(value: T): boolean;
  6123. /**
  6124. * Resets the active data to an empty array.
  6125. */
  6126. reset(): void;
  6127. /**
  6128. * Concats the active data with a given array.
  6129. * This ensures no dupplicate will be present in the result.
  6130. * @param array defines the data to concatenate with.
  6131. */
  6132. concatWithNoDuplicate(array: any): void;
  6133. }
  6134. }
  6135. declare module "babylonjs/Cameras/cameraInputsManager" {
  6136. import { Nullable } from "babylonjs/types";
  6137. import { Camera } from "babylonjs/Cameras/camera";
  6138. /**
  6139. * @ignore
  6140. * This is a list of all the different input types that are available in the application.
  6141. * Fo instance: ArcRotateCameraGamepadInput...
  6142. */
  6143. export var CameraInputTypes: {};
  6144. /**
  6145. * This is the contract to implement in order to create a new input class.
  6146. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6147. */
  6148. export interface ICameraInput<TCamera extends Camera> {
  6149. /**
  6150. * Defines the camera the input is attached to.
  6151. */
  6152. camera: Nullable<TCamera>;
  6153. /**
  6154. * Gets the class name of the current intput.
  6155. * @returns the class name
  6156. */
  6157. getClassName(): string;
  6158. /**
  6159. * Get the friendly name associated with the input class.
  6160. * @returns the input friendly name
  6161. */
  6162. getSimpleName(): string;
  6163. /**
  6164. * Attach the input controls to a specific dom element to get the input from.
  6165. * @param element Defines the element the controls should be listened from
  6166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6167. */
  6168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6169. /**
  6170. * Detach the current controls from the specified dom element.
  6171. * @param element Defines the element to stop listening the inputs from
  6172. */
  6173. detachControl(element: Nullable<HTMLElement>): void;
  6174. /**
  6175. * Update the current camera state depending on the inputs that have been used this frame.
  6176. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6177. */
  6178. checkInputs?: () => void;
  6179. }
  6180. /**
  6181. * Represents a map of input types to input instance or input index to input instance.
  6182. */
  6183. export interface CameraInputsMap<TCamera extends Camera> {
  6184. /**
  6185. * Accessor to the input by input type.
  6186. */
  6187. [name: string]: ICameraInput<TCamera>;
  6188. /**
  6189. * Accessor to the input by input index.
  6190. */
  6191. [idx: number]: ICameraInput<TCamera>;
  6192. }
  6193. /**
  6194. * This represents the input manager used within a camera.
  6195. * It helps dealing with all the different kind of input attached to a camera.
  6196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6197. */
  6198. export class CameraInputsManager<TCamera extends Camera> {
  6199. /**
  6200. * Defines the list of inputs attahed to the camera.
  6201. */
  6202. attached: CameraInputsMap<TCamera>;
  6203. /**
  6204. * Defines the dom element the camera is collecting inputs from.
  6205. * This is null if the controls have not been attached.
  6206. */
  6207. attachedElement: Nullable<HTMLElement>;
  6208. /**
  6209. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6210. */
  6211. noPreventDefault: boolean;
  6212. /**
  6213. * Defined the camera the input manager belongs to.
  6214. */
  6215. camera: TCamera;
  6216. /**
  6217. * Update the current camera state depending on the inputs that have been used this frame.
  6218. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6219. */
  6220. checkInputs: () => void;
  6221. /**
  6222. * Instantiate a new Camera Input Manager.
  6223. * @param camera Defines the camera the input manager blongs to
  6224. */
  6225. constructor(camera: TCamera);
  6226. /**
  6227. * Add an input method to a camera
  6228. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6229. * @param input camera input method
  6230. */
  6231. add(input: ICameraInput<TCamera>): void;
  6232. /**
  6233. * Remove a specific input method from a camera
  6234. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6235. * @param inputToRemove camera input method
  6236. */
  6237. remove(inputToRemove: ICameraInput<TCamera>): void;
  6238. /**
  6239. * Remove a specific input type from a camera
  6240. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6241. * @param inputType the type of the input to remove
  6242. */
  6243. removeByType(inputType: string): void;
  6244. private _addCheckInputs;
  6245. /**
  6246. * Attach the input controls to the currently attached dom element to listen the events from.
  6247. * @param input Defines the input to attach
  6248. */
  6249. attachInput(input: ICameraInput<TCamera>): void;
  6250. /**
  6251. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6252. * @param element Defines the dom element to collect the events from
  6253. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6254. */
  6255. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6256. /**
  6257. * Detach the current manager inputs controls from a specific dom element.
  6258. * @param element Defines the dom element to collect the events from
  6259. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6260. */
  6261. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6262. /**
  6263. * Rebuild the dynamic inputCheck function from the current list of
  6264. * defined inputs in the manager.
  6265. */
  6266. rebuildInputCheck(): void;
  6267. /**
  6268. * Remove all attached input methods from a camera
  6269. */
  6270. clear(): void;
  6271. /**
  6272. * Serialize the current input manager attached to a camera.
  6273. * This ensures than once parsed,
  6274. * the input associated to the camera will be identical to the current ones
  6275. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6276. */
  6277. serialize(serializedCamera: any): void;
  6278. /**
  6279. * Parses an input manager serialized JSON to restore the previous list of inputs
  6280. * and states associated to a camera.
  6281. * @param parsedCamera Defines the JSON to parse
  6282. */
  6283. parse(parsedCamera: any): void;
  6284. }
  6285. }
  6286. declare module "babylonjs/Meshes/buffer" {
  6287. import { Nullable, DataArray } from "babylonjs/types";
  6288. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6289. /**
  6290. * Class used to store data that will be store in GPU memory
  6291. */
  6292. export class Buffer {
  6293. private _engine;
  6294. private _buffer;
  6295. /** @hidden */
  6296. _data: Nullable<DataArray>;
  6297. private _updatable;
  6298. private _instanced;
  6299. private _divisor;
  6300. /**
  6301. * Gets the byte stride.
  6302. */
  6303. readonly byteStride: number;
  6304. /**
  6305. * Constructor
  6306. * @param engine the engine
  6307. * @param data the data to use for this buffer
  6308. * @param updatable whether the data is updatable
  6309. * @param stride the stride (optional)
  6310. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6311. * @param instanced whether the buffer is instanced (optional)
  6312. * @param useBytes set to true if the stride in in bytes (optional)
  6313. * @param divisor sets an optional divisor for instances (1 by default)
  6314. */
  6315. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6316. /**
  6317. * Create a new VertexBuffer based on the current buffer
  6318. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6319. * @param offset defines offset in the buffer (0 by default)
  6320. * @param size defines the size in floats of attributes (position is 3 for instance)
  6321. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6322. * @param instanced defines if the vertex buffer contains indexed data
  6323. * @param useBytes defines if the offset and stride are in bytes *
  6324. * @param divisor sets an optional divisor for instances (1 by default)
  6325. * @returns the new vertex buffer
  6326. */
  6327. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6328. /**
  6329. * Gets a boolean indicating if the Buffer is updatable?
  6330. * @returns true if the buffer is updatable
  6331. */
  6332. isUpdatable(): boolean;
  6333. /**
  6334. * Gets current buffer's data
  6335. * @returns a DataArray or null
  6336. */
  6337. getData(): Nullable<DataArray>;
  6338. /**
  6339. * Gets underlying native buffer
  6340. * @returns underlying native buffer
  6341. */
  6342. getBuffer(): Nullable<DataBuffer>;
  6343. /**
  6344. * Gets the stride in float32 units (i.e. byte stride / 4).
  6345. * May not be an integer if the byte stride is not divisible by 4.
  6346. * @returns the stride in float32 units
  6347. * @deprecated Please use byteStride instead.
  6348. */
  6349. getStrideSize(): number;
  6350. /**
  6351. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6352. * @param data defines the data to store
  6353. */
  6354. create(data?: Nullable<DataArray>): void;
  6355. /** @hidden */
  6356. _rebuild(): void;
  6357. /**
  6358. * Update current buffer data
  6359. * @param data defines the data to store
  6360. */
  6361. update(data: DataArray): void;
  6362. /**
  6363. * Updates the data directly.
  6364. * @param data the new data
  6365. * @param offset the new offset
  6366. * @param vertexCount the vertex count (optional)
  6367. * @param useBytes set to true if the offset is in bytes
  6368. */
  6369. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6370. /**
  6371. * Release all resources
  6372. */
  6373. dispose(): void;
  6374. }
  6375. /**
  6376. * Specialized buffer used to store vertex data
  6377. */
  6378. export class VertexBuffer {
  6379. /** @hidden */
  6380. _buffer: Buffer;
  6381. private _kind;
  6382. private _size;
  6383. private _ownsBuffer;
  6384. private _instanced;
  6385. private _instanceDivisor;
  6386. /**
  6387. * The byte type.
  6388. */
  6389. static readonly BYTE: number;
  6390. /**
  6391. * The unsigned byte type.
  6392. */
  6393. static readonly UNSIGNED_BYTE: number;
  6394. /**
  6395. * The short type.
  6396. */
  6397. static readonly SHORT: number;
  6398. /**
  6399. * The unsigned short type.
  6400. */
  6401. static readonly UNSIGNED_SHORT: number;
  6402. /**
  6403. * The integer type.
  6404. */
  6405. static readonly INT: number;
  6406. /**
  6407. * The unsigned integer type.
  6408. */
  6409. static readonly UNSIGNED_INT: number;
  6410. /**
  6411. * The float type.
  6412. */
  6413. static readonly FLOAT: number;
  6414. /**
  6415. * Gets or sets the instance divisor when in instanced mode
  6416. */
  6417. get instanceDivisor(): number;
  6418. set instanceDivisor(value: number);
  6419. /**
  6420. * Gets the byte stride.
  6421. */
  6422. readonly byteStride: number;
  6423. /**
  6424. * Gets the byte offset.
  6425. */
  6426. readonly byteOffset: number;
  6427. /**
  6428. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6429. */
  6430. readonly normalized: boolean;
  6431. /**
  6432. * Gets the data type of each component in the array.
  6433. */
  6434. readonly type: number;
  6435. /**
  6436. * Constructor
  6437. * @param engine the engine
  6438. * @param data the data to use for this vertex buffer
  6439. * @param kind the vertex buffer kind
  6440. * @param updatable whether the data is updatable
  6441. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6442. * @param stride the stride (optional)
  6443. * @param instanced whether the buffer is instanced (optional)
  6444. * @param offset the offset of the data (optional)
  6445. * @param size the number of components (optional)
  6446. * @param type the type of the component (optional)
  6447. * @param normalized whether the data contains normalized data (optional)
  6448. * @param useBytes set to true if stride and offset are in bytes (optional)
  6449. * @param divisor defines the instance divisor to use (1 by default)
  6450. */
  6451. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6452. /** @hidden */
  6453. _rebuild(): void;
  6454. /**
  6455. * Returns the kind of the VertexBuffer (string)
  6456. * @returns a string
  6457. */
  6458. getKind(): string;
  6459. /**
  6460. * Gets a boolean indicating if the VertexBuffer is updatable?
  6461. * @returns true if the buffer is updatable
  6462. */
  6463. isUpdatable(): boolean;
  6464. /**
  6465. * Gets current buffer's data
  6466. * @returns a DataArray or null
  6467. */
  6468. getData(): Nullable<DataArray>;
  6469. /**
  6470. * Gets underlying native buffer
  6471. * @returns underlying native buffer
  6472. */
  6473. getBuffer(): Nullable<DataBuffer>;
  6474. /**
  6475. * Gets the stride in float32 units (i.e. byte stride / 4).
  6476. * May not be an integer if the byte stride is not divisible by 4.
  6477. * @returns the stride in float32 units
  6478. * @deprecated Please use byteStride instead.
  6479. */
  6480. getStrideSize(): number;
  6481. /**
  6482. * Returns the offset as a multiple of the type byte length.
  6483. * @returns the offset in bytes
  6484. * @deprecated Please use byteOffset instead.
  6485. */
  6486. getOffset(): number;
  6487. /**
  6488. * Returns the number of components per vertex attribute (integer)
  6489. * @returns the size in float
  6490. */
  6491. getSize(): number;
  6492. /**
  6493. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6494. * @returns true if this buffer is instanced
  6495. */
  6496. getIsInstanced(): boolean;
  6497. /**
  6498. * Returns the instancing divisor, zero for non-instanced (integer).
  6499. * @returns a number
  6500. */
  6501. getInstanceDivisor(): number;
  6502. /**
  6503. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6504. * @param data defines the data to store
  6505. */
  6506. create(data?: DataArray): void;
  6507. /**
  6508. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6509. * This function will create a new buffer if the current one is not updatable
  6510. * @param data defines the data to store
  6511. */
  6512. update(data: DataArray): void;
  6513. /**
  6514. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6515. * Returns the directly updated WebGLBuffer.
  6516. * @param data the new data
  6517. * @param offset the new offset
  6518. * @param useBytes set to true if the offset is in bytes
  6519. */
  6520. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6521. /**
  6522. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6523. */
  6524. dispose(): void;
  6525. /**
  6526. * Enumerates each value of this vertex buffer as numbers.
  6527. * @param count the number of values to enumerate
  6528. * @param callback the callback function called for each value
  6529. */
  6530. forEach(count: number, callback: (value: number, index: number) => void): void;
  6531. /**
  6532. * Positions
  6533. */
  6534. static readonly PositionKind: string;
  6535. /**
  6536. * Normals
  6537. */
  6538. static readonly NormalKind: string;
  6539. /**
  6540. * Tangents
  6541. */
  6542. static readonly TangentKind: string;
  6543. /**
  6544. * Texture coordinates
  6545. */
  6546. static readonly UVKind: string;
  6547. /**
  6548. * Texture coordinates 2
  6549. */
  6550. static readonly UV2Kind: string;
  6551. /**
  6552. * Texture coordinates 3
  6553. */
  6554. static readonly UV3Kind: string;
  6555. /**
  6556. * Texture coordinates 4
  6557. */
  6558. static readonly UV4Kind: string;
  6559. /**
  6560. * Texture coordinates 5
  6561. */
  6562. static readonly UV5Kind: string;
  6563. /**
  6564. * Texture coordinates 6
  6565. */
  6566. static readonly UV6Kind: string;
  6567. /**
  6568. * Colors
  6569. */
  6570. static readonly ColorKind: string;
  6571. /**
  6572. * Matrix indices (for bones)
  6573. */
  6574. static readonly MatricesIndicesKind: string;
  6575. /**
  6576. * Matrix weights (for bones)
  6577. */
  6578. static readonly MatricesWeightsKind: string;
  6579. /**
  6580. * Additional matrix indices (for bones)
  6581. */
  6582. static readonly MatricesIndicesExtraKind: string;
  6583. /**
  6584. * Additional matrix weights (for bones)
  6585. */
  6586. static readonly MatricesWeightsExtraKind: string;
  6587. /**
  6588. * Deduces the stride given a kind.
  6589. * @param kind The kind string to deduce
  6590. * @returns The deduced stride
  6591. */
  6592. static DeduceStride(kind: string): number;
  6593. /**
  6594. * Gets the byte length of the given type.
  6595. * @param type the type
  6596. * @returns the number of bytes
  6597. */
  6598. static GetTypeByteLength(type: number): number;
  6599. /**
  6600. * Enumerates each value of the given parameters as numbers.
  6601. * @param data the data to enumerate
  6602. * @param byteOffset the byte offset of the data
  6603. * @param byteStride the byte stride of the data
  6604. * @param componentCount the number of components per element
  6605. * @param componentType the type of the component
  6606. * @param count the number of values to enumerate
  6607. * @param normalized whether the data is normalized
  6608. * @param callback the callback function called for each value
  6609. */
  6610. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6611. private static _GetFloatValue;
  6612. }
  6613. }
  6614. declare module "babylonjs/Collisions/intersectionInfo" {
  6615. import { Nullable } from "babylonjs/types";
  6616. /**
  6617. * @hidden
  6618. */
  6619. export class IntersectionInfo {
  6620. bu: Nullable<number>;
  6621. bv: Nullable<number>;
  6622. distance: number;
  6623. faceId: number;
  6624. subMeshId: number;
  6625. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6626. }
  6627. }
  6628. declare module "babylonjs/Maths/math.plane" {
  6629. import { DeepImmutable } from "babylonjs/types";
  6630. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6631. /**
  6632. * Represens a plane by the equation ax + by + cz + d = 0
  6633. */
  6634. export class Plane {
  6635. private static _TmpMatrix;
  6636. /**
  6637. * Normal of the plane (a,b,c)
  6638. */
  6639. normal: Vector3;
  6640. /**
  6641. * d component of the plane
  6642. */
  6643. d: number;
  6644. /**
  6645. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6646. * @param a a component of the plane
  6647. * @param b b component of the plane
  6648. * @param c c component of the plane
  6649. * @param d d component of the plane
  6650. */
  6651. constructor(a: number, b: number, c: number, d: number);
  6652. /**
  6653. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6654. */
  6655. asArray(): number[];
  6656. /**
  6657. * @returns a new plane copied from the current Plane.
  6658. */
  6659. clone(): Plane;
  6660. /**
  6661. * @returns the string "Plane".
  6662. */
  6663. getClassName(): string;
  6664. /**
  6665. * @returns the Plane hash code.
  6666. */
  6667. getHashCode(): number;
  6668. /**
  6669. * Normalize the current Plane in place.
  6670. * @returns the updated Plane.
  6671. */
  6672. normalize(): Plane;
  6673. /**
  6674. * Applies a transformation the plane and returns the result
  6675. * @param transformation the transformation matrix to be applied to the plane
  6676. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6677. */
  6678. transform(transformation: DeepImmutable<Matrix>): Plane;
  6679. /**
  6680. * Calcualtte the dot product between the point and the plane normal
  6681. * @param point point to calculate the dot product with
  6682. * @returns the dot product (float) of the point coordinates and the plane normal.
  6683. */
  6684. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6685. /**
  6686. * Updates the current Plane from the plane defined by the three given points.
  6687. * @param point1 one of the points used to contruct the plane
  6688. * @param point2 one of the points used to contruct the plane
  6689. * @param point3 one of the points used to contruct the plane
  6690. * @returns the updated Plane.
  6691. */
  6692. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6693. /**
  6694. * Checks if the plane is facing a given direction
  6695. * @param direction the direction to check if the plane is facing
  6696. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6697. * @returns True is the vector "direction" is the same side than the plane normal.
  6698. */
  6699. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6700. /**
  6701. * Calculates the distance to a point
  6702. * @param point point to calculate distance to
  6703. * @returns the signed distance (float) from the given point to the Plane.
  6704. */
  6705. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6706. /**
  6707. * Creates a plane from an array
  6708. * @param array the array to create a plane from
  6709. * @returns a new Plane from the given array.
  6710. */
  6711. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6712. /**
  6713. * Creates a plane from three points
  6714. * @param point1 point used to create the plane
  6715. * @param point2 point used to create the plane
  6716. * @param point3 point used to create the plane
  6717. * @returns a new Plane defined by the three given points.
  6718. */
  6719. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6720. /**
  6721. * Creates a plane from an origin point and a normal
  6722. * @param origin origin of the plane to be constructed
  6723. * @param normal normal of the plane to be constructed
  6724. * @returns a new Plane the normal vector to this plane at the given origin point.
  6725. * Note : the vector "normal" is updated because normalized.
  6726. */
  6727. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6728. /**
  6729. * Calculates the distance from a plane and a point
  6730. * @param origin origin of the plane to be constructed
  6731. * @param normal normal of the plane to be constructed
  6732. * @param point point to calculate distance to
  6733. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6734. */
  6735. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6736. }
  6737. }
  6738. declare module "babylonjs/Culling/boundingSphere" {
  6739. import { DeepImmutable } from "babylonjs/types";
  6740. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6741. import { Plane } from "babylonjs/Maths/math.plane";
  6742. /**
  6743. * Class used to store bounding sphere information
  6744. */
  6745. export class BoundingSphere {
  6746. /**
  6747. * Gets the center of the bounding sphere in local space
  6748. */
  6749. readonly center: Vector3;
  6750. /**
  6751. * Radius of the bounding sphere in local space
  6752. */
  6753. radius: number;
  6754. /**
  6755. * Gets the center of the bounding sphere in world space
  6756. */
  6757. readonly centerWorld: Vector3;
  6758. /**
  6759. * Radius of the bounding sphere in world space
  6760. */
  6761. radiusWorld: number;
  6762. /**
  6763. * Gets the minimum vector in local space
  6764. */
  6765. readonly minimum: Vector3;
  6766. /**
  6767. * Gets the maximum vector in local space
  6768. */
  6769. readonly maximum: Vector3;
  6770. private _worldMatrix;
  6771. private static readonly TmpVector3;
  6772. /**
  6773. * Creates a new bounding sphere
  6774. * @param min defines the minimum vector (in local space)
  6775. * @param max defines the maximum vector (in local space)
  6776. * @param worldMatrix defines the new world matrix
  6777. */
  6778. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6779. /**
  6780. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6781. * @param min defines the new minimum vector (in local space)
  6782. * @param max defines the new maximum vector (in local space)
  6783. * @param worldMatrix defines the new world matrix
  6784. */
  6785. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6786. /**
  6787. * Scale the current bounding sphere by applying a scale factor
  6788. * @param factor defines the scale factor to apply
  6789. * @returns the current bounding box
  6790. */
  6791. scale(factor: number): BoundingSphere;
  6792. /**
  6793. * Gets the world matrix of the bounding box
  6794. * @returns a matrix
  6795. */
  6796. getWorldMatrix(): DeepImmutable<Matrix>;
  6797. /** @hidden */
  6798. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6799. /**
  6800. * Tests if the bounding sphere is intersecting the frustum planes
  6801. * @param frustumPlanes defines the frustum planes to test
  6802. * @returns true if there is an intersection
  6803. */
  6804. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6805. /**
  6806. * Tests if the bounding sphere center is in between the frustum planes.
  6807. * Used for optimistic fast inclusion.
  6808. * @param frustumPlanes defines the frustum planes to test
  6809. * @returns true if the sphere center is in between the frustum planes
  6810. */
  6811. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6812. /**
  6813. * Tests if a point is inside the bounding sphere
  6814. * @param point defines the point to test
  6815. * @returns true if the point is inside the bounding sphere
  6816. */
  6817. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6818. /**
  6819. * Checks if two sphere intersct
  6820. * @param sphere0 sphere 0
  6821. * @param sphere1 sphere 1
  6822. * @returns true if the speres intersect
  6823. */
  6824. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6825. }
  6826. }
  6827. declare module "babylonjs/Culling/boundingBox" {
  6828. import { DeepImmutable } from "babylonjs/types";
  6829. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6830. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6831. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6832. import { Plane } from "babylonjs/Maths/math.plane";
  6833. /**
  6834. * Class used to store bounding box information
  6835. */
  6836. export class BoundingBox implements ICullable {
  6837. /**
  6838. * Gets the 8 vectors representing the bounding box in local space
  6839. */
  6840. readonly vectors: Vector3[];
  6841. /**
  6842. * Gets the center of the bounding box in local space
  6843. */
  6844. readonly center: Vector3;
  6845. /**
  6846. * Gets the center of the bounding box in world space
  6847. */
  6848. readonly centerWorld: Vector3;
  6849. /**
  6850. * Gets the extend size in local space
  6851. */
  6852. readonly extendSize: Vector3;
  6853. /**
  6854. * Gets the extend size in world space
  6855. */
  6856. readonly extendSizeWorld: Vector3;
  6857. /**
  6858. * Gets the OBB (object bounding box) directions
  6859. */
  6860. readonly directions: Vector3[];
  6861. /**
  6862. * Gets the 8 vectors representing the bounding box in world space
  6863. */
  6864. readonly vectorsWorld: Vector3[];
  6865. /**
  6866. * Gets the minimum vector in world space
  6867. */
  6868. readonly minimumWorld: Vector3;
  6869. /**
  6870. * Gets the maximum vector in world space
  6871. */
  6872. readonly maximumWorld: Vector3;
  6873. /**
  6874. * Gets the minimum vector in local space
  6875. */
  6876. readonly minimum: Vector3;
  6877. /**
  6878. * Gets the maximum vector in local space
  6879. */
  6880. readonly maximum: Vector3;
  6881. private _worldMatrix;
  6882. private static readonly TmpVector3;
  6883. /**
  6884. * @hidden
  6885. */
  6886. _tag: number;
  6887. /**
  6888. * Creates a new bounding box
  6889. * @param min defines the minimum vector (in local space)
  6890. * @param max defines the maximum vector (in local space)
  6891. * @param worldMatrix defines the new world matrix
  6892. */
  6893. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6894. /**
  6895. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6896. * @param min defines the new minimum vector (in local space)
  6897. * @param max defines the new maximum vector (in local space)
  6898. * @param worldMatrix defines the new world matrix
  6899. */
  6900. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6901. /**
  6902. * Scale the current bounding box by applying a scale factor
  6903. * @param factor defines the scale factor to apply
  6904. * @returns the current bounding box
  6905. */
  6906. scale(factor: number): BoundingBox;
  6907. /**
  6908. * Gets the world matrix of the bounding box
  6909. * @returns a matrix
  6910. */
  6911. getWorldMatrix(): DeepImmutable<Matrix>;
  6912. /** @hidden */
  6913. _update(world: DeepImmutable<Matrix>): void;
  6914. /**
  6915. * Tests if the bounding box is intersecting the frustum planes
  6916. * @param frustumPlanes defines the frustum planes to test
  6917. * @returns true if there is an intersection
  6918. */
  6919. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6920. /**
  6921. * Tests if the bounding box is entirely inside the frustum planes
  6922. * @param frustumPlanes defines the frustum planes to test
  6923. * @returns true if there is an inclusion
  6924. */
  6925. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6926. /**
  6927. * Tests if a point is inside the bounding box
  6928. * @param point defines the point to test
  6929. * @returns true if the point is inside the bounding box
  6930. */
  6931. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6932. /**
  6933. * Tests if the bounding box intersects with a bounding sphere
  6934. * @param sphere defines the sphere to test
  6935. * @returns true if there is an intersection
  6936. */
  6937. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6938. /**
  6939. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6940. * @param min defines the min vector to use
  6941. * @param max defines the max vector to use
  6942. * @returns true if there is an intersection
  6943. */
  6944. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6945. /**
  6946. * Tests if two bounding boxes are intersections
  6947. * @param box0 defines the first box to test
  6948. * @param box1 defines the second box to test
  6949. * @returns true if there is an intersection
  6950. */
  6951. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6952. /**
  6953. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6954. * @param minPoint defines the minimum vector of the bounding box
  6955. * @param maxPoint defines the maximum vector of the bounding box
  6956. * @param sphereCenter defines the sphere center
  6957. * @param sphereRadius defines the sphere radius
  6958. * @returns true if there is an intersection
  6959. */
  6960. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6961. /**
  6962. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6963. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6964. * @param frustumPlanes defines the frustum planes to test
  6965. * @return true if there is an inclusion
  6966. */
  6967. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6968. /**
  6969. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6970. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6971. * @param frustumPlanes defines the frustum planes to test
  6972. * @return true if there is an intersection
  6973. */
  6974. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6975. }
  6976. }
  6977. declare module "babylonjs/Collisions/collider" {
  6978. import { Nullable, IndicesArray } from "babylonjs/types";
  6979. import { Vector3 } from "babylonjs/Maths/math.vector";
  6980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6981. import { Plane } from "babylonjs/Maths/math.plane";
  6982. /** @hidden */
  6983. export class Collider {
  6984. /** Define if a collision was found */
  6985. collisionFound: boolean;
  6986. /**
  6987. * Define last intersection point in local space
  6988. */
  6989. intersectionPoint: Vector3;
  6990. /**
  6991. * Define last collided mesh
  6992. */
  6993. collidedMesh: Nullable<AbstractMesh>;
  6994. private _collisionPoint;
  6995. private _planeIntersectionPoint;
  6996. private _tempVector;
  6997. private _tempVector2;
  6998. private _tempVector3;
  6999. private _tempVector4;
  7000. private _edge;
  7001. private _baseToVertex;
  7002. private _destinationPoint;
  7003. private _slidePlaneNormal;
  7004. private _displacementVector;
  7005. /** @hidden */
  7006. _radius: Vector3;
  7007. /** @hidden */
  7008. _retry: number;
  7009. private _velocity;
  7010. private _basePoint;
  7011. private _epsilon;
  7012. /** @hidden */
  7013. _velocityWorldLength: number;
  7014. /** @hidden */
  7015. _basePointWorld: Vector3;
  7016. private _velocityWorld;
  7017. private _normalizedVelocity;
  7018. /** @hidden */
  7019. _initialVelocity: Vector3;
  7020. /** @hidden */
  7021. _initialPosition: Vector3;
  7022. private _nearestDistance;
  7023. private _collisionMask;
  7024. get collisionMask(): number;
  7025. set collisionMask(mask: number);
  7026. /**
  7027. * Gets the plane normal used to compute the sliding response (in local space)
  7028. */
  7029. get slidePlaneNormal(): Vector3;
  7030. /** @hidden */
  7031. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7032. /** @hidden */
  7033. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7034. /** @hidden */
  7035. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7036. /** @hidden */
  7037. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7038. /** @hidden */
  7039. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7040. /** @hidden */
  7041. _getResponse(pos: Vector3, vel: Vector3): void;
  7042. }
  7043. }
  7044. declare module "babylonjs/Culling/boundingInfo" {
  7045. import { DeepImmutable } from "babylonjs/types";
  7046. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7047. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7048. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7049. import { Plane } from "babylonjs/Maths/math.plane";
  7050. import { Collider } from "babylonjs/Collisions/collider";
  7051. /**
  7052. * Interface for cullable objects
  7053. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7054. */
  7055. export interface ICullable {
  7056. /**
  7057. * Checks if the object or part of the object is in the frustum
  7058. * @param frustumPlanes Camera near/planes
  7059. * @returns true if the object is in frustum otherwise false
  7060. */
  7061. isInFrustum(frustumPlanes: Plane[]): boolean;
  7062. /**
  7063. * Checks if a cullable object (mesh...) is in the camera frustum
  7064. * Unlike isInFrustum this cheks the full bounding box
  7065. * @param frustumPlanes Camera near/planes
  7066. * @returns true if the object is in frustum otherwise false
  7067. */
  7068. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7069. }
  7070. /**
  7071. * Info for a bounding data of a mesh
  7072. */
  7073. export class BoundingInfo implements ICullable {
  7074. /**
  7075. * Bounding box for the mesh
  7076. */
  7077. readonly boundingBox: BoundingBox;
  7078. /**
  7079. * Bounding sphere for the mesh
  7080. */
  7081. readonly boundingSphere: BoundingSphere;
  7082. private _isLocked;
  7083. private static readonly TmpVector3;
  7084. /**
  7085. * Constructs bounding info
  7086. * @param minimum min vector of the bounding box/sphere
  7087. * @param maximum max vector of the bounding box/sphere
  7088. * @param worldMatrix defines the new world matrix
  7089. */
  7090. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7091. /**
  7092. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7093. * @param min defines the new minimum vector (in local space)
  7094. * @param max defines the new maximum vector (in local space)
  7095. * @param worldMatrix defines the new world matrix
  7096. */
  7097. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7098. /**
  7099. * min vector of the bounding box/sphere
  7100. */
  7101. get minimum(): Vector3;
  7102. /**
  7103. * max vector of the bounding box/sphere
  7104. */
  7105. get maximum(): Vector3;
  7106. /**
  7107. * If the info is locked and won't be updated to avoid perf overhead
  7108. */
  7109. get isLocked(): boolean;
  7110. set isLocked(value: boolean);
  7111. /**
  7112. * Updates the bounding sphere and box
  7113. * @param world world matrix to be used to update
  7114. */
  7115. update(world: DeepImmutable<Matrix>): void;
  7116. /**
  7117. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7118. * @param center New center of the bounding info
  7119. * @param extend New extend of the bounding info
  7120. * @returns the current bounding info
  7121. */
  7122. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7123. /**
  7124. * Scale the current bounding info by applying a scale factor
  7125. * @param factor defines the scale factor to apply
  7126. * @returns the current bounding info
  7127. */
  7128. scale(factor: number): BoundingInfo;
  7129. /**
  7130. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7131. * @param frustumPlanes defines the frustum to test
  7132. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7133. * @returns true if the bounding info is in the frustum planes
  7134. */
  7135. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7136. /**
  7137. * Gets the world distance between the min and max points of the bounding box
  7138. */
  7139. get diagonalLength(): number;
  7140. /**
  7141. * Checks if a cullable object (mesh...) is in the camera frustum
  7142. * Unlike isInFrustum this cheks the full bounding box
  7143. * @param frustumPlanes Camera near/planes
  7144. * @returns true if the object is in frustum otherwise false
  7145. */
  7146. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7147. /** @hidden */
  7148. _checkCollision(collider: Collider): boolean;
  7149. /**
  7150. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7151. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7152. * @param point the point to check intersection with
  7153. * @returns if the point intersects
  7154. */
  7155. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7156. /**
  7157. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7158. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7159. * @param boundingInfo the bounding info to check intersection with
  7160. * @param precise if the intersection should be done using OBB
  7161. * @returns if the bounding info intersects
  7162. */
  7163. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7164. }
  7165. }
  7166. declare module "babylonjs/Maths/math.functions" {
  7167. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7168. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7169. /**
  7170. * Extracts minimum and maximum values from a list of indexed positions
  7171. * @param positions defines the positions to use
  7172. * @param indices defines the indices to the positions
  7173. * @param indexStart defines the start index
  7174. * @param indexCount defines the end index
  7175. * @param bias defines bias value to add to the result
  7176. * @return minimum and maximum values
  7177. */
  7178. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7179. minimum: Vector3;
  7180. maximum: Vector3;
  7181. };
  7182. /**
  7183. * Extracts minimum and maximum values from a list of positions
  7184. * @param positions defines the positions to use
  7185. * @param start defines the start index in the positions array
  7186. * @param count defines the number of positions to handle
  7187. * @param bias defines bias value to add to the result
  7188. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7189. * @return minimum and maximum values
  7190. */
  7191. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7192. minimum: Vector3;
  7193. maximum: Vector3;
  7194. };
  7195. }
  7196. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7197. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7198. /** @hidden */
  7199. export class WebGLDataBuffer extends DataBuffer {
  7200. private _buffer;
  7201. constructor(resource: WebGLBuffer);
  7202. get underlyingResource(): any;
  7203. }
  7204. }
  7205. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7206. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7207. import { Nullable } from "babylonjs/types";
  7208. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7209. /** @hidden */
  7210. export class WebGLPipelineContext implements IPipelineContext {
  7211. engine: ThinEngine;
  7212. program: Nullable<WebGLProgram>;
  7213. context?: WebGLRenderingContext;
  7214. vertexShader?: WebGLShader;
  7215. fragmentShader?: WebGLShader;
  7216. isParallelCompiled: boolean;
  7217. onCompiled?: () => void;
  7218. transformFeedback?: WebGLTransformFeedback | null;
  7219. vertexCompilationError: Nullable<string>;
  7220. fragmentCompilationError: Nullable<string>;
  7221. programLinkError: Nullable<string>;
  7222. programValidationError: Nullable<string>;
  7223. get isAsync(): boolean;
  7224. get isReady(): boolean;
  7225. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7226. }
  7227. }
  7228. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7229. import { FloatArray, Nullable } from "babylonjs/types";
  7230. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7231. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7232. module "babylonjs/Engines/thinEngine" {
  7233. interface ThinEngine {
  7234. /**
  7235. * Create an uniform buffer
  7236. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7237. * @param elements defines the content of the uniform buffer
  7238. * @returns the webGL uniform buffer
  7239. */
  7240. createUniformBuffer(elements: FloatArray): DataBuffer;
  7241. /**
  7242. * Create a dynamic uniform buffer
  7243. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7244. * @param elements defines the content of the uniform buffer
  7245. * @returns the webGL uniform buffer
  7246. */
  7247. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7248. /**
  7249. * Update an existing uniform buffer
  7250. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7251. * @param uniformBuffer defines the target uniform buffer
  7252. * @param elements defines the content to update
  7253. * @param offset defines the offset in the uniform buffer where update should start
  7254. * @param count defines the size of the data to update
  7255. */
  7256. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7257. /**
  7258. * Bind an uniform buffer to the current webGL context
  7259. * @param buffer defines the buffer to bind
  7260. */
  7261. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7262. /**
  7263. * Bind a buffer to the current webGL context at a given location
  7264. * @param buffer defines the buffer to bind
  7265. * @param location defines the index where to bind the buffer
  7266. */
  7267. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7268. /**
  7269. * Bind a specific block at a given index in a specific shader program
  7270. * @param pipelineContext defines the pipeline context to use
  7271. * @param blockName defines the block name
  7272. * @param index defines the index where to bind the block
  7273. */
  7274. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7275. }
  7276. }
  7277. }
  7278. declare module "babylonjs/Materials/uniformBuffer" {
  7279. import { Nullable, FloatArray } from "babylonjs/types";
  7280. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7281. import { Engine } from "babylonjs/Engines/engine";
  7282. import { Effect } from "babylonjs/Materials/effect";
  7283. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7284. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7285. import { Color3 } from "babylonjs/Maths/math.color";
  7286. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7287. /**
  7288. * Uniform buffer objects.
  7289. *
  7290. * Handles blocks of uniform on the GPU.
  7291. *
  7292. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7293. *
  7294. * For more information, please refer to :
  7295. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7296. */
  7297. export class UniformBuffer {
  7298. private _engine;
  7299. private _buffer;
  7300. private _data;
  7301. private _bufferData;
  7302. private _dynamic?;
  7303. private _uniformLocations;
  7304. private _uniformSizes;
  7305. private _uniformLocationPointer;
  7306. private _needSync;
  7307. private _noUBO;
  7308. private _currentEffect;
  7309. /** @hidden */
  7310. _alreadyBound: boolean;
  7311. private static _MAX_UNIFORM_SIZE;
  7312. private static _tempBuffer;
  7313. /**
  7314. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7315. * This is dynamic to allow compat with webgl 1 and 2.
  7316. * You will need to pass the name of the uniform as well as the value.
  7317. */
  7318. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7319. /**
  7320. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7321. * This is dynamic to allow compat with webgl 1 and 2.
  7322. * You will need to pass the name of the uniform as well as the value.
  7323. */
  7324. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7325. /**
  7326. * Lambda to Update a single float in a uniform buffer.
  7327. * This is dynamic to allow compat with webgl 1 and 2.
  7328. * You will need to pass the name of the uniform as well as the value.
  7329. */
  7330. updateFloat: (name: string, x: number) => void;
  7331. /**
  7332. * Lambda to Update a vec2 of float in a uniform buffer.
  7333. * This is dynamic to allow compat with webgl 1 and 2.
  7334. * You will need to pass the name of the uniform as well as the value.
  7335. */
  7336. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7337. /**
  7338. * Lambda to Update a vec3 of float in a uniform buffer.
  7339. * This is dynamic to allow compat with webgl 1 and 2.
  7340. * You will need to pass the name of the uniform as well as the value.
  7341. */
  7342. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7343. /**
  7344. * Lambda to Update a vec4 of float in a uniform buffer.
  7345. * This is dynamic to allow compat with webgl 1 and 2.
  7346. * You will need to pass the name of the uniform as well as the value.
  7347. */
  7348. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7349. /**
  7350. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7351. * This is dynamic to allow compat with webgl 1 and 2.
  7352. * You will need to pass the name of the uniform as well as the value.
  7353. */
  7354. updateMatrix: (name: string, mat: Matrix) => void;
  7355. /**
  7356. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7357. * This is dynamic to allow compat with webgl 1 and 2.
  7358. * You will need to pass the name of the uniform as well as the value.
  7359. */
  7360. updateVector3: (name: string, vector: Vector3) => void;
  7361. /**
  7362. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7363. * This is dynamic to allow compat with webgl 1 and 2.
  7364. * You will need to pass the name of the uniform as well as the value.
  7365. */
  7366. updateVector4: (name: string, vector: Vector4) => void;
  7367. /**
  7368. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7369. * This is dynamic to allow compat with webgl 1 and 2.
  7370. * You will need to pass the name of the uniform as well as the value.
  7371. */
  7372. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7373. /**
  7374. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7375. * This is dynamic to allow compat with webgl 1 and 2.
  7376. * You will need to pass the name of the uniform as well as the value.
  7377. */
  7378. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7379. /**
  7380. * Instantiates a new Uniform buffer objects.
  7381. *
  7382. * Handles blocks of uniform on the GPU.
  7383. *
  7384. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7385. *
  7386. * For more information, please refer to :
  7387. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7388. * @param engine Define the engine the buffer is associated with
  7389. * @param data Define the data contained in the buffer
  7390. * @param dynamic Define if the buffer is updatable
  7391. */
  7392. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7393. /**
  7394. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7395. * or just falling back on setUniformXXX calls.
  7396. */
  7397. get useUbo(): boolean;
  7398. /**
  7399. * Indicates if the WebGL underlying uniform buffer is in sync
  7400. * with the javascript cache data.
  7401. */
  7402. get isSync(): boolean;
  7403. /**
  7404. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7405. * Also, a dynamic UniformBuffer will disable cache verification and always
  7406. * update the underlying WebGL uniform buffer to the GPU.
  7407. * @returns if Dynamic, otherwise false
  7408. */
  7409. isDynamic(): boolean;
  7410. /**
  7411. * The data cache on JS side.
  7412. * @returns the underlying data as a float array
  7413. */
  7414. getData(): Float32Array;
  7415. /**
  7416. * The underlying WebGL Uniform buffer.
  7417. * @returns the webgl buffer
  7418. */
  7419. getBuffer(): Nullable<DataBuffer>;
  7420. /**
  7421. * std140 layout specifies how to align data within an UBO structure.
  7422. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7423. * for specs.
  7424. */
  7425. private _fillAlignment;
  7426. /**
  7427. * Adds an uniform in the buffer.
  7428. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7429. * for the layout to be correct !
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param size Data size, or data directly.
  7432. */
  7433. addUniform(name: string, size: number | number[]): void;
  7434. /**
  7435. * Adds a Matrix 4x4 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. * @param mat A 4x4 matrix.
  7438. */
  7439. addMatrix(name: string, mat: Matrix): void;
  7440. /**
  7441. * Adds a vec2 to the uniform buffer.
  7442. * @param name Name of the uniform, as used in the uniform block in the shader.
  7443. * @param x Define the x component value of the vec2
  7444. * @param y Define the y component value of the vec2
  7445. */
  7446. addFloat2(name: string, x: number, y: number): void;
  7447. /**
  7448. * Adds a vec3 to the uniform buffer.
  7449. * @param name Name of the uniform, as used in the uniform block in the shader.
  7450. * @param x Define the x component value of the vec3
  7451. * @param y Define the y component value of the vec3
  7452. * @param z Define the z component value of the vec3
  7453. */
  7454. addFloat3(name: string, x: number, y: number, z: number): void;
  7455. /**
  7456. * Adds a vec3 to the uniform buffer.
  7457. * @param name Name of the uniform, as used in the uniform block in the shader.
  7458. * @param color Define the vec3 from a Color
  7459. */
  7460. addColor3(name: string, color: Color3): void;
  7461. /**
  7462. * Adds a vec4 to the uniform buffer.
  7463. * @param name Name of the uniform, as used in the uniform block in the shader.
  7464. * @param color Define the rgb components from a Color
  7465. * @param alpha Define the a component of the vec4
  7466. */
  7467. addColor4(name: string, color: Color3, alpha: number): void;
  7468. /**
  7469. * Adds a vec3 to the uniform buffer.
  7470. * @param name Name of the uniform, as used in the uniform block in the shader.
  7471. * @param vector Define the vec3 components from a Vector
  7472. */
  7473. addVector3(name: string, vector: Vector3): void;
  7474. /**
  7475. * Adds a Matrix 3x3 to the uniform buffer.
  7476. * @param name Name of the uniform, as used in the uniform block in the shader.
  7477. */
  7478. addMatrix3x3(name: string): void;
  7479. /**
  7480. * Adds a Matrix 2x2 to the uniform buffer.
  7481. * @param name Name of the uniform, as used in the uniform block in the shader.
  7482. */
  7483. addMatrix2x2(name: string): void;
  7484. /**
  7485. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7486. */
  7487. create(): void;
  7488. /** @hidden */
  7489. _rebuild(): void;
  7490. /**
  7491. * Updates the WebGL Uniform Buffer on the GPU.
  7492. * If the `dynamic` flag is set to true, no cache comparison is done.
  7493. * Otherwise, the buffer will be updated only if the cache differs.
  7494. */
  7495. update(): void;
  7496. /**
  7497. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7498. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7499. * @param data Define the flattened data
  7500. * @param size Define the size of the data.
  7501. */
  7502. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7503. private _valueCache;
  7504. private _cacheMatrix;
  7505. private _updateMatrix3x3ForUniform;
  7506. private _updateMatrix3x3ForEffect;
  7507. private _updateMatrix2x2ForEffect;
  7508. private _updateMatrix2x2ForUniform;
  7509. private _updateFloatForEffect;
  7510. private _updateFloatForUniform;
  7511. private _updateFloat2ForEffect;
  7512. private _updateFloat2ForUniform;
  7513. private _updateFloat3ForEffect;
  7514. private _updateFloat3ForUniform;
  7515. private _updateFloat4ForEffect;
  7516. private _updateFloat4ForUniform;
  7517. private _updateMatrixForEffect;
  7518. private _updateMatrixForUniform;
  7519. private _updateVector3ForEffect;
  7520. private _updateVector3ForUniform;
  7521. private _updateVector4ForEffect;
  7522. private _updateVector4ForUniform;
  7523. private _updateColor3ForEffect;
  7524. private _updateColor3ForUniform;
  7525. private _updateColor4ForEffect;
  7526. private _updateColor4ForUniform;
  7527. /**
  7528. * Sets a sampler uniform on the effect.
  7529. * @param name Define the name of the sampler.
  7530. * @param texture Define the texture to set in the sampler
  7531. */
  7532. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7533. /**
  7534. * Directly updates the value of the uniform in the cache AND on the GPU.
  7535. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7536. * @param data Define the flattened data
  7537. */
  7538. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7539. /**
  7540. * Binds this uniform buffer to an effect.
  7541. * @param effect Define the effect to bind the buffer to
  7542. * @param name Name of the uniform block in the shader.
  7543. */
  7544. bindToEffect(effect: Effect, name: string): void;
  7545. /**
  7546. * Disposes the uniform buffer.
  7547. */
  7548. dispose(): void;
  7549. }
  7550. }
  7551. declare module "babylonjs/Misc/iInspectable" {
  7552. /**
  7553. * Enum that determines the text-wrapping mode to use.
  7554. */
  7555. export enum InspectableType {
  7556. /**
  7557. * Checkbox for booleans
  7558. */
  7559. Checkbox = 0,
  7560. /**
  7561. * Sliders for numbers
  7562. */
  7563. Slider = 1,
  7564. /**
  7565. * Vector3
  7566. */
  7567. Vector3 = 2,
  7568. /**
  7569. * Quaternions
  7570. */
  7571. Quaternion = 3,
  7572. /**
  7573. * Color3
  7574. */
  7575. Color3 = 4,
  7576. /**
  7577. * String
  7578. */
  7579. String = 5
  7580. }
  7581. /**
  7582. * Interface used to define custom inspectable properties.
  7583. * This interface is used by the inspector to display custom property grids
  7584. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7585. */
  7586. export interface IInspectable {
  7587. /**
  7588. * Gets the label to display
  7589. */
  7590. label: string;
  7591. /**
  7592. * Gets the name of the property to edit
  7593. */
  7594. propertyName: string;
  7595. /**
  7596. * Gets the type of the editor to use
  7597. */
  7598. type: InspectableType;
  7599. /**
  7600. * Gets the minimum value of the property when using in "slider" mode
  7601. */
  7602. min?: number;
  7603. /**
  7604. * Gets the maximum value of the property when using in "slider" mode
  7605. */
  7606. max?: number;
  7607. /**
  7608. * Gets the setp to use when using in "slider" mode
  7609. */
  7610. step?: number;
  7611. }
  7612. }
  7613. declare module "babylonjs/Misc/timingTools" {
  7614. /**
  7615. * Class used to provide helper for timing
  7616. */
  7617. export class TimingTools {
  7618. /**
  7619. * Polyfill for setImmediate
  7620. * @param action defines the action to execute after the current execution block
  7621. */
  7622. static SetImmediate(action: () => void): void;
  7623. }
  7624. }
  7625. declare module "babylonjs/Misc/instantiationTools" {
  7626. /**
  7627. * Class used to enable instatition of objects by class name
  7628. */
  7629. export class InstantiationTools {
  7630. /**
  7631. * Use this object to register external classes like custom textures or material
  7632. * to allow the laoders to instantiate them
  7633. */
  7634. static RegisteredExternalClasses: {
  7635. [key: string]: Object;
  7636. };
  7637. /**
  7638. * Tries to instantiate a new object from a given class name
  7639. * @param className defines the class name to instantiate
  7640. * @returns the new object or null if the system was not able to do the instantiation
  7641. */
  7642. static Instantiate(className: string): any;
  7643. }
  7644. }
  7645. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7646. /**
  7647. * Define options used to create a depth texture
  7648. */
  7649. export class DepthTextureCreationOptions {
  7650. /** Specifies whether or not a stencil should be allocated in the texture */
  7651. generateStencil?: boolean;
  7652. /** Specifies whether or not bilinear filtering is enable on the texture */
  7653. bilinearFiltering?: boolean;
  7654. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7655. comparisonFunction?: number;
  7656. /** Specifies if the created texture is a cube texture */
  7657. isCube?: boolean;
  7658. }
  7659. }
  7660. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7661. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7662. import { Nullable } from "babylonjs/types";
  7663. import { Scene } from "babylonjs/scene";
  7664. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7665. module "babylonjs/Engines/thinEngine" {
  7666. interface ThinEngine {
  7667. /**
  7668. * Creates a depth stencil cube texture.
  7669. * This is only available in WebGL 2.
  7670. * @param size The size of face edge in the cube texture.
  7671. * @param options The options defining the cube texture.
  7672. * @returns The cube texture
  7673. */
  7674. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7675. /**
  7676. * Creates a cube texture
  7677. * @param rootUrl defines the url where the files to load is located
  7678. * @param scene defines the current scene
  7679. * @param files defines the list of files to load (1 per face)
  7680. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7681. * @param onLoad defines an optional callback raised when the texture is loaded
  7682. * @param onError defines an optional callback raised if there is an issue to load the texture
  7683. * @param format defines the format of the data
  7684. * @param forcedExtension defines the extension to use to pick the right loader
  7685. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7686. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7687. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7688. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7689. * @returns the cube texture as an InternalTexture
  7690. */
  7691. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7692. /**
  7693. * Creates a cube texture
  7694. * @param rootUrl defines the url where the files to load is located
  7695. * @param scene defines the current scene
  7696. * @param files defines the list of files to load (1 per face)
  7697. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7698. * @param onLoad defines an optional callback raised when the texture is loaded
  7699. * @param onError defines an optional callback raised if there is an issue to load the texture
  7700. * @param format defines the format of the data
  7701. * @param forcedExtension defines the extension to use to pick the right loader
  7702. * @returns the cube texture as an InternalTexture
  7703. */
  7704. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7705. /**
  7706. * Creates a cube texture
  7707. * @param rootUrl defines the url where the files to load is located
  7708. * @param scene defines the current scene
  7709. * @param files defines the list of files to load (1 per face)
  7710. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7711. * @param onLoad defines an optional callback raised when the texture is loaded
  7712. * @param onError defines an optional callback raised if there is an issue to load the texture
  7713. * @param format defines the format of the data
  7714. * @param forcedExtension defines the extension to use to pick the right loader
  7715. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7716. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7717. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7718. * @returns the cube texture as an InternalTexture
  7719. */
  7720. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7721. /** @hidden */
  7722. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7723. /** @hidden */
  7724. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7725. /** @hidden */
  7726. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7727. /** @hidden */
  7728. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7729. /**
  7730. * @hidden
  7731. */
  7732. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7733. }
  7734. }
  7735. }
  7736. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7737. import { Nullable } from "babylonjs/types";
  7738. import { Scene } from "babylonjs/scene";
  7739. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7740. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7741. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7742. import { Observable } from "babylonjs/Misc/observable";
  7743. /**
  7744. * Class for creating a cube texture
  7745. */
  7746. export class CubeTexture extends BaseTexture {
  7747. private _delayedOnLoad;
  7748. /**
  7749. * Observable triggered once the texture has been loaded.
  7750. */
  7751. onLoadObservable: Observable<CubeTexture>;
  7752. /**
  7753. * The url of the texture
  7754. */
  7755. url: string;
  7756. /**
  7757. * Gets or sets the center of the bounding box associated with the cube texture.
  7758. * It must define where the camera used to render the texture was set
  7759. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7760. */
  7761. boundingBoxPosition: Vector3;
  7762. private _boundingBoxSize;
  7763. /**
  7764. * Gets or sets the size of the bounding box associated with the cube texture
  7765. * When defined, the cubemap will switch to local mode
  7766. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7767. * @example https://www.babylonjs-playground.com/#RNASML
  7768. */
  7769. set boundingBoxSize(value: Vector3);
  7770. /**
  7771. * Returns the bounding box size
  7772. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7773. */
  7774. get boundingBoxSize(): Vector3;
  7775. protected _rotationY: number;
  7776. /**
  7777. * Sets texture matrix rotation angle around Y axis in radians.
  7778. */
  7779. set rotationY(value: number);
  7780. /**
  7781. * Gets texture matrix rotation angle around Y axis radians.
  7782. */
  7783. get rotationY(): number;
  7784. /**
  7785. * Are mip maps generated for this texture or not.
  7786. */
  7787. get noMipmap(): boolean;
  7788. private _noMipmap;
  7789. private _files;
  7790. protected _forcedExtension: Nullable<string>;
  7791. private _extensions;
  7792. private _textureMatrix;
  7793. private _format;
  7794. private _createPolynomials;
  7795. /** @hidden */
  7796. _prefiltered: boolean;
  7797. /**
  7798. * Creates a cube texture from an array of image urls
  7799. * @param files defines an array of image urls
  7800. * @param scene defines the hosting scene
  7801. * @param noMipmap specifies if mip maps are not used
  7802. * @returns a cube texture
  7803. */
  7804. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7805. /**
  7806. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7807. * @param url defines the url of the prefiltered texture
  7808. * @param scene defines the scene the texture is attached to
  7809. * @param forcedExtension defines the extension of the file if different from the url
  7810. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7811. * @return the prefiltered texture
  7812. */
  7813. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7814. /**
  7815. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7816. * as prefiltered data.
  7817. * @param rootUrl defines the url of the texture or the root name of the six images
  7818. * @param scene defines the scene the texture is attached to
  7819. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7820. * @param noMipmap defines if mipmaps should be created or not
  7821. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7822. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7823. * @param onError defines a callback triggered in case of error during load
  7824. * @param format defines the internal format to use for the texture once loaded
  7825. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7826. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7827. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7828. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7829. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7830. * @return the cube texture
  7831. */
  7832. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7833. /**
  7834. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7835. */
  7836. get isPrefiltered(): boolean;
  7837. /**
  7838. * Get the current class name of the texture useful for serialization or dynamic coding.
  7839. * @returns "CubeTexture"
  7840. */
  7841. getClassName(): string;
  7842. /**
  7843. * Update the url (and optional buffer) of this texture if url was null during construction.
  7844. * @param url the url of the texture
  7845. * @param forcedExtension defines the extension to use
  7846. * @param onLoad callback called when the texture is loaded (defaults to null)
  7847. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7848. */
  7849. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7850. /**
  7851. * Delays loading of the cube texture
  7852. * @param forcedExtension defines the extension to use
  7853. */
  7854. delayLoad(forcedExtension?: string): void;
  7855. /**
  7856. * Returns the reflection texture matrix
  7857. * @returns the reflection texture matrix
  7858. */
  7859. getReflectionTextureMatrix(): Matrix;
  7860. /**
  7861. * Sets the reflection texture matrix
  7862. * @param value Reflection texture matrix
  7863. */
  7864. setReflectionTextureMatrix(value: Matrix): void;
  7865. /**
  7866. * Parses text to create a cube texture
  7867. * @param parsedTexture define the serialized text to read from
  7868. * @param scene defines the hosting scene
  7869. * @param rootUrl defines the root url of the cube texture
  7870. * @returns a cube texture
  7871. */
  7872. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7873. /**
  7874. * Makes a clone, or deep copy, of the cube texture
  7875. * @returns a new cube texture
  7876. */
  7877. clone(): CubeTexture;
  7878. }
  7879. }
  7880. declare module "babylonjs/Materials/materialDefines" {
  7881. /**
  7882. * Manages the defines for the Material
  7883. */
  7884. export class MaterialDefines {
  7885. /** @hidden */
  7886. protected _keys: string[];
  7887. private _isDirty;
  7888. /** @hidden */
  7889. _renderId: number;
  7890. /** @hidden */
  7891. _areLightsDirty: boolean;
  7892. /** @hidden */
  7893. _areLightsDisposed: boolean;
  7894. /** @hidden */
  7895. _areAttributesDirty: boolean;
  7896. /** @hidden */
  7897. _areTexturesDirty: boolean;
  7898. /** @hidden */
  7899. _areFresnelDirty: boolean;
  7900. /** @hidden */
  7901. _areMiscDirty: boolean;
  7902. /** @hidden */
  7903. _areImageProcessingDirty: boolean;
  7904. /** @hidden */
  7905. _normals: boolean;
  7906. /** @hidden */
  7907. _uvs: boolean;
  7908. /** @hidden */
  7909. _needNormals: boolean;
  7910. /** @hidden */
  7911. _needUVs: boolean;
  7912. [id: string]: any;
  7913. /**
  7914. * Specifies if the material needs to be re-calculated
  7915. */
  7916. get isDirty(): boolean;
  7917. /**
  7918. * Marks the material to indicate that it has been re-calculated
  7919. */
  7920. markAsProcessed(): void;
  7921. /**
  7922. * Marks the material to indicate that it needs to be re-calculated
  7923. */
  7924. markAsUnprocessed(): void;
  7925. /**
  7926. * Marks the material to indicate all of its defines need to be re-calculated
  7927. */
  7928. markAllAsDirty(): void;
  7929. /**
  7930. * Marks the material to indicate that image processing needs to be re-calculated
  7931. */
  7932. markAsImageProcessingDirty(): void;
  7933. /**
  7934. * Marks the material to indicate the lights need to be re-calculated
  7935. * @param disposed Defines whether the light is dirty due to dispose or not
  7936. */
  7937. markAsLightDirty(disposed?: boolean): void;
  7938. /**
  7939. * Marks the attribute state as changed
  7940. */
  7941. markAsAttributesDirty(): void;
  7942. /**
  7943. * Marks the texture state as changed
  7944. */
  7945. markAsTexturesDirty(): void;
  7946. /**
  7947. * Marks the fresnel state as changed
  7948. */
  7949. markAsFresnelDirty(): void;
  7950. /**
  7951. * Marks the misc state as changed
  7952. */
  7953. markAsMiscDirty(): void;
  7954. /**
  7955. * Rebuilds the material defines
  7956. */
  7957. rebuild(): void;
  7958. /**
  7959. * Specifies if two material defines are equal
  7960. * @param other - A material define instance to compare to
  7961. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7962. */
  7963. isEqual(other: MaterialDefines): boolean;
  7964. /**
  7965. * Clones this instance's defines to another instance
  7966. * @param other - material defines to clone values to
  7967. */
  7968. cloneTo(other: MaterialDefines): void;
  7969. /**
  7970. * Resets the material define values
  7971. */
  7972. reset(): void;
  7973. /**
  7974. * Converts the material define values to a string
  7975. * @returns - String of material define information
  7976. */
  7977. toString(): string;
  7978. }
  7979. }
  7980. declare module "babylonjs/Materials/colorCurves" {
  7981. import { Effect } from "babylonjs/Materials/effect";
  7982. /**
  7983. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7984. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7985. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7986. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7987. */
  7988. export class ColorCurves {
  7989. private _dirty;
  7990. private _tempColor;
  7991. private _globalCurve;
  7992. private _highlightsCurve;
  7993. private _midtonesCurve;
  7994. private _shadowsCurve;
  7995. private _positiveCurve;
  7996. private _negativeCurve;
  7997. private _globalHue;
  7998. private _globalDensity;
  7999. private _globalSaturation;
  8000. private _globalExposure;
  8001. /**
  8002. * Gets the global Hue value.
  8003. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8004. */
  8005. get globalHue(): number;
  8006. /**
  8007. * Sets the global Hue value.
  8008. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8009. */
  8010. set globalHue(value: number);
  8011. /**
  8012. * Gets the global Density value.
  8013. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. get globalDensity(): number;
  8017. /**
  8018. * Sets the global Density value.
  8019. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8020. * Values less than zero provide a filter of opposite hue.
  8021. */
  8022. set globalDensity(value: number);
  8023. /**
  8024. * Gets the global Saturation value.
  8025. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8026. */
  8027. get globalSaturation(): number;
  8028. /**
  8029. * Sets the global Saturation value.
  8030. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8031. */
  8032. set globalSaturation(value: number);
  8033. /**
  8034. * Gets the global Exposure value.
  8035. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8036. */
  8037. get globalExposure(): number;
  8038. /**
  8039. * Sets the global Exposure value.
  8040. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8041. */
  8042. set globalExposure(value: number);
  8043. private _highlightsHue;
  8044. private _highlightsDensity;
  8045. private _highlightsSaturation;
  8046. private _highlightsExposure;
  8047. /**
  8048. * Gets the highlights Hue value.
  8049. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8050. */
  8051. get highlightsHue(): number;
  8052. /**
  8053. * Sets the highlights Hue value.
  8054. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8055. */
  8056. set highlightsHue(value: number);
  8057. /**
  8058. * Gets the highlights Density value.
  8059. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8060. * Values less than zero provide a filter of opposite hue.
  8061. */
  8062. get highlightsDensity(): number;
  8063. /**
  8064. * Sets the highlights Density value.
  8065. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8066. * Values less than zero provide a filter of opposite hue.
  8067. */
  8068. set highlightsDensity(value: number);
  8069. /**
  8070. * Gets the highlights Saturation value.
  8071. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8072. */
  8073. get highlightsSaturation(): number;
  8074. /**
  8075. * Sets the highlights Saturation value.
  8076. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8077. */
  8078. set highlightsSaturation(value: number);
  8079. /**
  8080. * Gets the highlights Exposure value.
  8081. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8082. */
  8083. get highlightsExposure(): number;
  8084. /**
  8085. * Sets the highlights Exposure value.
  8086. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8087. */
  8088. set highlightsExposure(value: number);
  8089. private _midtonesHue;
  8090. private _midtonesDensity;
  8091. private _midtonesSaturation;
  8092. private _midtonesExposure;
  8093. /**
  8094. * Gets the midtones Hue value.
  8095. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8096. */
  8097. get midtonesHue(): number;
  8098. /**
  8099. * Sets the midtones Hue value.
  8100. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8101. */
  8102. set midtonesHue(value: number);
  8103. /**
  8104. * Gets the midtones Density value.
  8105. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8106. * Values less than zero provide a filter of opposite hue.
  8107. */
  8108. get midtonesDensity(): number;
  8109. /**
  8110. * Sets the midtones Density value.
  8111. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8112. * Values less than zero provide a filter of opposite hue.
  8113. */
  8114. set midtonesDensity(value: number);
  8115. /**
  8116. * Gets the midtones Saturation value.
  8117. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8118. */
  8119. get midtonesSaturation(): number;
  8120. /**
  8121. * Sets the midtones Saturation value.
  8122. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8123. */
  8124. set midtonesSaturation(value: number);
  8125. /**
  8126. * Gets the midtones Exposure value.
  8127. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8128. */
  8129. get midtonesExposure(): number;
  8130. /**
  8131. * Sets the midtones Exposure value.
  8132. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8133. */
  8134. set midtonesExposure(value: number);
  8135. private _shadowsHue;
  8136. private _shadowsDensity;
  8137. private _shadowsSaturation;
  8138. private _shadowsExposure;
  8139. /**
  8140. * Gets the shadows Hue value.
  8141. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8142. */
  8143. get shadowsHue(): number;
  8144. /**
  8145. * Sets the shadows Hue value.
  8146. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8147. */
  8148. set shadowsHue(value: number);
  8149. /**
  8150. * Gets the shadows Density value.
  8151. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8152. * Values less than zero provide a filter of opposite hue.
  8153. */
  8154. get shadowsDensity(): number;
  8155. /**
  8156. * Sets the shadows Density value.
  8157. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8158. * Values less than zero provide a filter of opposite hue.
  8159. */
  8160. set shadowsDensity(value: number);
  8161. /**
  8162. * Gets the shadows Saturation value.
  8163. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8164. */
  8165. get shadowsSaturation(): number;
  8166. /**
  8167. * Sets the shadows Saturation value.
  8168. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8169. */
  8170. set shadowsSaturation(value: number);
  8171. /**
  8172. * Gets the shadows Exposure value.
  8173. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8174. */
  8175. get shadowsExposure(): number;
  8176. /**
  8177. * Sets the shadows Exposure value.
  8178. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8179. */
  8180. set shadowsExposure(value: number);
  8181. /**
  8182. * Returns the class name
  8183. * @returns The class name
  8184. */
  8185. getClassName(): string;
  8186. /**
  8187. * Binds the color curves to the shader.
  8188. * @param colorCurves The color curve to bind
  8189. * @param effect The effect to bind to
  8190. * @param positiveUniform The positive uniform shader parameter
  8191. * @param neutralUniform The neutral uniform shader parameter
  8192. * @param negativeUniform The negative uniform shader parameter
  8193. */
  8194. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8195. /**
  8196. * Prepare the list of uniforms associated with the ColorCurves effects.
  8197. * @param uniformsList The list of uniforms used in the effect
  8198. */
  8199. static PrepareUniforms(uniformsList: string[]): void;
  8200. /**
  8201. * Returns color grading data based on a hue, density, saturation and exposure value.
  8202. * @param filterHue The hue of the color filter.
  8203. * @param filterDensity The density of the color filter.
  8204. * @param saturation The saturation.
  8205. * @param exposure The exposure.
  8206. * @param result The result data container.
  8207. */
  8208. private getColorGradingDataToRef;
  8209. /**
  8210. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8211. * @param value The input slider value in range [-100,100].
  8212. * @returns Adjusted value.
  8213. */
  8214. private static applyColorGradingSliderNonlinear;
  8215. /**
  8216. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8217. * @param hue The hue (H) input.
  8218. * @param saturation The saturation (S) input.
  8219. * @param brightness The brightness (B) input.
  8220. * @result An RGBA color represented as Vector4.
  8221. */
  8222. private static fromHSBToRef;
  8223. /**
  8224. * Returns a value clamped between min and max
  8225. * @param value The value to clamp
  8226. * @param min The minimum of value
  8227. * @param max The maximum of value
  8228. * @returns The clamped value.
  8229. */
  8230. private static clamp;
  8231. /**
  8232. * Clones the current color curve instance.
  8233. * @return The cloned curves
  8234. */
  8235. clone(): ColorCurves;
  8236. /**
  8237. * Serializes the current color curve instance to a json representation.
  8238. * @return a JSON representation
  8239. */
  8240. serialize(): any;
  8241. /**
  8242. * Parses the color curve from a json representation.
  8243. * @param source the JSON source to parse
  8244. * @return The parsed curves
  8245. */
  8246. static Parse(source: any): ColorCurves;
  8247. }
  8248. }
  8249. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8250. import { Observable } from "babylonjs/Misc/observable";
  8251. import { Nullable } from "babylonjs/types";
  8252. import { Color4 } from "babylonjs/Maths/math.color";
  8253. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8254. import { Effect } from "babylonjs/Materials/effect";
  8255. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8256. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8257. /**
  8258. * Interface to follow in your material defines to integrate easily the
  8259. * Image proccessing functions.
  8260. * @hidden
  8261. */
  8262. export interface IImageProcessingConfigurationDefines {
  8263. IMAGEPROCESSING: boolean;
  8264. VIGNETTE: boolean;
  8265. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8266. VIGNETTEBLENDMODEOPAQUE: boolean;
  8267. TONEMAPPING: boolean;
  8268. TONEMAPPING_ACES: boolean;
  8269. CONTRAST: boolean;
  8270. EXPOSURE: boolean;
  8271. COLORCURVES: boolean;
  8272. COLORGRADING: boolean;
  8273. COLORGRADING3D: boolean;
  8274. SAMPLER3DGREENDEPTH: boolean;
  8275. SAMPLER3DBGRMAP: boolean;
  8276. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8277. }
  8278. /**
  8279. * @hidden
  8280. */
  8281. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8282. IMAGEPROCESSING: boolean;
  8283. VIGNETTE: boolean;
  8284. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8285. VIGNETTEBLENDMODEOPAQUE: boolean;
  8286. TONEMAPPING: boolean;
  8287. TONEMAPPING_ACES: boolean;
  8288. CONTRAST: boolean;
  8289. COLORCURVES: boolean;
  8290. COLORGRADING: boolean;
  8291. COLORGRADING3D: boolean;
  8292. SAMPLER3DGREENDEPTH: boolean;
  8293. SAMPLER3DBGRMAP: boolean;
  8294. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8295. EXPOSURE: boolean;
  8296. constructor();
  8297. }
  8298. /**
  8299. * This groups together the common properties used for image processing either in direct forward pass
  8300. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8301. * or not.
  8302. */
  8303. export class ImageProcessingConfiguration {
  8304. /**
  8305. * Default tone mapping applied in BabylonJS.
  8306. */
  8307. static readonly TONEMAPPING_STANDARD: number;
  8308. /**
  8309. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8310. * to other engines rendering to increase portability.
  8311. */
  8312. static readonly TONEMAPPING_ACES: number;
  8313. /**
  8314. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8315. */
  8316. colorCurves: Nullable<ColorCurves>;
  8317. private _colorCurvesEnabled;
  8318. /**
  8319. * Gets wether the color curves effect is enabled.
  8320. */
  8321. get colorCurvesEnabled(): boolean;
  8322. /**
  8323. * Sets wether the color curves effect is enabled.
  8324. */
  8325. set colorCurvesEnabled(value: boolean);
  8326. private _colorGradingTexture;
  8327. /**
  8328. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8329. */
  8330. get colorGradingTexture(): Nullable<BaseTexture>;
  8331. /**
  8332. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8333. */
  8334. set colorGradingTexture(value: Nullable<BaseTexture>);
  8335. private _colorGradingEnabled;
  8336. /**
  8337. * Gets wether the color grading effect is enabled.
  8338. */
  8339. get colorGradingEnabled(): boolean;
  8340. /**
  8341. * Sets wether the color grading effect is enabled.
  8342. */
  8343. set colorGradingEnabled(value: boolean);
  8344. private _colorGradingWithGreenDepth;
  8345. /**
  8346. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8347. */
  8348. get colorGradingWithGreenDepth(): boolean;
  8349. /**
  8350. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8351. */
  8352. set colorGradingWithGreenDepth(value: boolean);
  8353. private _colorGradingBGR;
  8354. /**
  8355. * Gets wether the color grading texture contains BGR values.
  8356. */
  8357. get colorGradingBGR(): boolean;
  8358. /**
  8359. * Sets wether the color grading texture contains BGR values.
  8360. */
  8361. set colorGradingBGR(value: boolean);
  8362. /** @hidden */
  8363. _exposure: number;
  8364. /**
  8365. * Gets the Exposure used in the effect.
  8366. */
  8367. get exposure(): number;
  8368. /**
  8369. * Sets the Exposure used in the effect.
  8370. */
  8371. set exposure(value: number);
  8372. private _toneMappingEnabled;
  8373. /**
  8374. * Gets wether the tone mapping effect is enabled.
  8375. */
  8376. get toneMappingEnabled(): boolean;
  8377. /**
  8378. * Sets wether the tone mapping effect is enabled.
  8379. */
  8380. set toneMappingEnabled(value: boolean);
  8381. private _toneMappingType;
  8382. /**
  8383. * Gets the type of tone mapping effect.
  8384. */
  8385. get toneMappingType(): number;
  8386. /**
  8387. * Sets the type of tone mapping effect used in BabylonJS.
  8388. */
  8389. set toneMappingType(value: number);
  8390. protected _contrast: number;
  8391. /**
  8392. * Gets the contrast used in the effect.
  8393. */
  8394. get contrast(): number;
  8395. /**
  8396. * Sets the contrast used in the effect.
  8397. */
  8398. set contrast(value: number);
  8399. /**
  8400. * Vignette stretch size.
  8401. */
  8402. vignetteStretch: number;
  8403. /**
  8404. * Vignette centre X Offset.
  8405. */
  8406. vignetteCentreX: number;
  8407. /**
  8408. * Vignette centre Y Offset.
  8409. */
  8410. vignetteCentreY: number;
  8411. /**
  8412. * Vignette weight or intensity of the vignette effect.
  8413. */
  8414. vignetteWeight: number;
  8415. /**
  8416. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8417. * if vignetteEnabled is set to true.
  8418. */
  8419. vignetteColor: Color4;
  8420. /**
  8421. * Camera field of view used by the Vignette effect.
  8422. */
  8423. vignetteCameraFov: number;
  8424. private _vignetteBlendMode;
  8425. /**
  8426. * Gets the vignette blend mode allowing different kind of effect.
  8427. */
  8428. get vignetteBlendMode(): number;
  8429. /**
  8430. * Sets the vignette blend mode allowing different kind of effect.
  8431. */
  8432. set vignetteBlendMode(value: number);
  8433. private _vignetteEnabled;
  8434. /**
  8435. * Gets wether the vignette effect is enabled.
  8436. */
  8437. get vignetteEnabled(): boolean;
  8438. /**
  8439. * Sets wether the vignette effect is enabled.
  8440. */
  8441. set vignetteEnabled(value: boolean);
  8442. private _applyByPostProcess;
  8443. /**
  8444. * Gets wether the image processing is applied through a post process or not.
  8445. */
  8446. get applyByPostProcess(): boolean;
  8447. /**
  8448. * Sets wether the image processing is applied through a post process or not.
  8449. */
  8450. set applyByPostProcess(value: boolean);
  8451. private _isEnabled;
  8452. /**
  8453. * Gets wether the image processing is enabled or not.
  8454. */
  8455. get isEnabled(): boolean;
  8456. /**
  8457. * Sets wether the image processing is enabled or not.
  8458. */
  8459. set isEnabled(value: boolean);
  8460. /**
  8461. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8462. */
  8463. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8464. /**
  8465. * Method called each time the image processing information changes requires to recompile the effect.
  8466. */
  8467. protected _updateParameters(): void;
  8468. /**
  8469. * Gets the current class name.
  8470. * @return "ImageProcessingConfiguration"
  8471. */
  8472. getClassName(): string;
  8473. /**
  8474. * Prepare the list of uniforms associated with the Image Processing effects.
  8475. * @param uniforms The list of uniforms used in the effect
  8476. * @param defines the list of defines currently in use
  8477. */
  8478. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8479. /**
  8480. * Prepare the list of samplers associated with the Image Processing effects.
  8481. * @param samplersList The list of uniforms used in the effect
  8482. * @param defines the list of defines currently in use
  8483. */
  8484. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8485. /**
  8486. * Prepare the list of defines associated to the shader.
  8487. * @param defines the list of defines to complete
  8488. * @param forPostProcess Define if we are currently in post process mode or not
  8489. */
  8490. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8491. /**
  8492. * Returns true if all the image processing information are ready.
  8493. * @returns True if ready, otherwise, false
  8494. */
  8495. isReady(): boolean;
  8496. /**
  8497. * Binds the image processing to the shader.
  8498. * @param effect The effect to bind to
  8499. * @param overrideAspectRatio Override the aspect ratio of the effect
  8500. */
  8501. bind(effect: Effect, overrideAspectRatio?: number): void;
  8502. /**
  8503. * Clones the current image processing instance.
  8504. * @return The cloned image processing
  8505. */
  8506. clone(): ImageProcessingConfiguration;
  8507. /**
  8508. * Serializes the current image processing instance to a json representation.
  8509. * @return a JSON representation
  8510. */
  8511. serialize(): any;
  8512. /**
  8513. * Parses the image processing from a json representation.
  8514. * @param source the JSON source to parse
  8515. * @return The parsed image processing
  8516. */
  8517. static Parse(source: any): ImageProcessingConfiguration;
  8518. private static _VIGNETTEMODE_MULTIPLY;
  8519. private static _VIGNETTEMODE_OPAQUE;
  8520. /**
  8521. * Used to apply the vignette as a mix with the pixel color.
  8522. */
  8523. static get VIGNETTEMODE_MULTIPLY(): number;
  8524. /**
  8525. * Used to apply the vignette as a replacement of the pixel color.
  8526. */
  8527. static get VIGNETTEMODE_OPAQUE(): number;
  8528. }
  8529. }
  8530. declare module "babylonjs/Shaders/postprocess.vertex" {
  8531. /** @hidden */
  8532. export var postprocessVertexShader: {
  8533. name: string;
  8534. shader: string;
  8535. };
  8536. }
  8537. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8538. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8539. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8540. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8541. module "babylonjs/Engines/thinEngine" {
  8542. interface ThinEngine {
  8543. /**
  8544. * Creates a new render target texture
  8545. * @param size defines the size of the texture
  8546. * @param options defines the options used to create the texture
  8547. * @returns a new render target texture stored in an InternalTexture
  8548. */
  8549. createRenderTargetTexture(size: number | {
  8550. width: number;
  8551. height: number;
  8552. layers?: number;
  8553. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8554. /**
  8555. * Creates a depth stencil texture.
  8556. * This is only available in WebGL 2 or with the depth texture extension available.
  8557. * @param size The size of face edge in the texture.
  8558. * @param options The options defining the texture.
  8559. * @returns The texture
  8560. */
  8561. createDepthStencilTexture(size: number | {
  8562. width: number;
  8563. height: number;
  8564. layers?: number;
  8565. }, options: DepthTextureCreationOptions): InternalTexture;
  8566. /** @hidden */
  8567. _createDepthStencilTexture(size: number | {
  8568. width: number;
  8569. height: number;
  8570. layers?: number;
  8571. }, options: DepthTextureCreationOptions): InternalTexture;
  8572. }
  8573. }
  8574. }
  8575. declare module "babylonjs/Maths/math.axis" {
  8576. import { Vector3 } from "babylonjs/Maths/math.vector";
  8577. /** Defines supported spaces */
  8578. export enum Space {
  8579. /** Local (object) space */
  8580. LOCAL = 0,
  8581. /** World space */
  8582. WORLD = 1,
  8583. /** Bone space */
  8584. BONE = 2
  8585. }
  8586. /** Defines the 3 main axes */
  8587. export class Axis {
  8588. /** X axis */
  8589. static X: Vector3;
  8590. /** Y axis */
  8591. static Y: Vector3;
  8592. /** Z axis */
  8593. static Z: Vector3;
  8594. }
  8595. }
  8596. declare module "babylonjs/Cameras/targetCamera" {
  8597. import { Nullable } from "babylonjs/types";
  8598. import { Camera } from "babylonjs/Cameras/camera";
  8599. import { Scene } from "babylonjs/scene";
  8600. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8601. /**
  8602. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8603. * This is the base of the follow, arc rotate cameras and Free camera
  8604. * @see http://doc.babylonjs.com/features/cameras
  8605. */
  8606. export class TargetCamera extends Camera {
  8607. private static _RigCamTransformMatrix;
  8608. private static _TargetTransformMatrix;
  8609. private static _TargetFocalPoint;
  8610. /**
  8611. * Define the current direction the camera is moving to
  8612. */
  8613. cameraDirection: Vector3;
  8614. /**
  8615. * Define the current rotation the camera is rotating to
  8616. */
  8617. cameraRotation: Vector2;
  8618. /**
  8619. * When set, the up vector of the camera will be updated by the rotation of the camera
  8620. */
  8621. updateUpVectorFromRotation: boolean;
  8622. private _tmpQuaternion;
  8623. /**
  8624. * Define the current rotation of the camera
  8625. */
  8626. rotation: Vector3;
  8627. /**
  8628. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8629. */
  8630. rotationQuaternion: Quaternion;
  8631. /**
  8632. * Define the current speed of the camera
  8633. */
  8634. speed: number;
  8635. /**
  8636. * Add constraint to the camera to prevent it to move freely in all directions and
  8637. * around all axis.
  8638. */
  8639. noRotationConstraint: boolean;
  8640. /**
  8641. * Define the current target of the camera as an object or a position.
  8642. */
  8643. lockedTarget: any;
  8644. /** @hidden */
  8645. _currentTarget: Vector3;
  8646. /** @hidden */
  8647. _initialFocalDistance: number;
  8648. /** @hidden */
  8649. _viewMatrix: Matrix;
  8650. /** @hidden */
  8651. _camMatrix: Matrix;
  8652. /** @hidden */
  8653. _cameraTransformMatrix: Matrix;
  8654. /** @hidden */
  8655. _cameraRotationMatrix: Matrix;
  8656. /** @hidden */
  8657. _referencePoint: Vector3;
  8658. /** @hidden */
  8659. _transformedReferencePoint: Vector3;
  8660. protected _globalCurrentTarget: Vector3;
  8661. protected _globalCurrentUpVector: Vector3;
  8662. /** @hidden */
  8663. _reset: () => void;
  8664. private _defaultUp;
  8665. /**
  8666. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8667. * This is the base of the follow, arc rotate cameras and Free camera
  8668. * @see http://doc.babylonjs.com/features/cameras
  8669. * @param name Defines the name of the camera in the scene
  8670. * @param position Defines the start position of the camera in the scene
  8671. * @param scene Defines the scene the camera belongs to
  8672. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8673. */
  8674. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8675. /**
  8676. * Gets the position in front of the camera at a given distance.
  8677. * @param distance The distance from the camera we want the position to be
  8678. * @returns the position
  8679. */
  8680. getFrontPosition(distance: number): Vector3;
  8681. /** @hidden */
  8682. _getLockedTargetPosition(): Nullable<Vector3>;
  8683. private _storedPosition;
  8684. private _storedRotation;
  8685. private _storedRotationQuaternion;
  8686. /**
  8687. * Store current camera state of the camera (fov, position, rotation, etc..)
  8688. * @returns the camera
  8689. */
  8690. storeState(): Camera;
  8691. /**
  8692. * Restored camera state. You must call storeState() first
  8693. * @returns whether it was successful or not
  8694. * @hidden
  8695. */
  8696. _restoreStateValues(): boolean;
  8697. /** @hidden */
  8698. _initCache(): void;
  8699. /** @hidden */
  8700. _updateCache(ignoreParentClass?: boolean): void;
  8701. /** @hidden */
  8702. _isSynchronizedViewMatrix(): boolean;
  8703. /** @hidden */
  8704. _computeLocalCameraSpeed(): number;
  8705. /**
  8706. * Defines the target the camera should look at.
  8707. * @param target Defines the new target as a Vector or a mesh
  8708. */
  8709. setTarget(target: Vector3): void;
  8710. /**
  8711. * Return the current target position of the camera. This value is expressed in local space.
  8712. * @returns the target position
  8713. */
  8714. getTarget(): Vector3;
  8715. /** @hidden */
  8716. _decideIfNeedsToMove(): boolean;
  8717. /** @hidden */
  8718. _updatePosition(): void;
  8719. /** @hidden */
  8720. _checkInputs(): void;
  8721. protected _updateCameraRotationMatrix(): void;
  8722. /**
  8723. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8724. * @returns the current camera
  8725. */
  8726. private _rotateUpVectorWithCameraRotationMatrix;
  8727. private _cachedRotationZ;
  8728. private _cachedQuaternionRotationZ;
  8729. /** @hidden */
  8730. _getViewMatrix(): Matrix;
  8731. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8732. /**
  8733. * @hidden
  8734. */
  8735. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8736. /**
  8737. * @hidden
  8738. */
  8739. _updateRigCameras(): void;
  8740. private _getRigCamPositionAndTarget;
  8741. /**
  8742. * Gets the current object class name.
  8743. * @return the class name
  8744. */
  8745. getClassName(): string;
  8746. }
  8747. }
  8748. declare module "babylonjs/Events/keyboardEvents" {
  8749. /**
  8750. * Gather the list of keyboard event types as constants.
  8751. */
  8752. export class KeyboardEventTypes {
  8753. /**
  8754. * The keydown event is fired when a key becomes active (pressed).
  8755. */
  8756. static readonly KEYDOWN: number;
  8757. /**
  8758. * The keyup event is fired when a key has been released.
  8759. */
  8760. static readonly KEYUP: number;
  8761. }
  8762. /**
  8763. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8764. */
  8765. export class KeyboardInfo {
  8766. /**
  8767. * Defines the type of event (KeyboardEventTypes)
  8768. */
  8769. type: number;
  8770. /**
  8771. * Defines the related dom event
  8772. */
  8773. event: KeyboardEvent;
  8774. /**
  8775. * Instantiates a new keyboard info.
  8776. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8777. * @param type Defines the type of event (KeyboardEventTypes)
  8778. * @param event Defines the related dom event
  8779. */
  8780. constructor(
  8781. /**
  8782. * Defines the type of event (KeyboardEventTypes)
  8783. */
  8784. type: number,
  8785. /**
  8786. * Defines the related dom event
  8787. */
  8788. event: KeyboardEvent);
  8789. }
  8790. /**
  8791. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8792. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8793. */
  8794. export class KeyboardInfoPre extends KeyboardInfo {
  8795. /**
  8796. * Defines the type of event (KeyboardEventTypes)
  8797. */
  8798. type: number;
  8799. /**
  8800. * Defines the related dom event
  8801. */
  8802. event: KeyboardEvent;
  8803. /**
  8804. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8805. */
  8806. skipOnPointerObservable: boolean;
  8807. /**
  8808. * Instantiates a new keyboard pre info.
  8809. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8810. * @param type Defines the type of event (KeyboardEventTypes)
  8811. * @param event Defines the related dom event
  8812. */
  8813. constructor(
  8814. /**
  8815. * Defines the type of event (KeyboardEventTypes)
  8816. */
  8817. type: number,
  8818. /**
  8819. * Defines the related dom event
  8820. */
  8821. event: KeyboardEvent);
  8822. }
  8823. }
  8824. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8825. import { Nullable } from "babylonjs/types";
  8826. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8827. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8828. /**
  8829. * Manage the keyboard inputs to control the movement of a free camera.
  8830. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8831. */
  8832. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8833. /**
  8834. * Defines the camera the input is attached to.
  8835. */
  8836. camera: FreeCamera;
  8837. /**
  8838. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8839. */
  8840. keysUp: number[];
  8841. /**
  8842. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8843. */
  8844. keysDown: number[];
  8845. /**
  8846. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8847. */
  8848. keysLeft: number[];
  8849. /**
  8850. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8851. */
  8852. keysRight: number[];
  8853. private _keys;
  8854. private _onCanvasBlurObserver;
  8855. private _onKeyboardObserver;
  8856. private _engine;
  8857. private _scene;
  8858. /**
  8859. * Attach the input controls to a specific dom element to get the input from.
  8860. * @param element Defines the element the controls should be listened from
  8861. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8862. */
  8863. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8864. /**
  8865. * Detach the current controls from the specified dom element.
  8866. * @param element Defines the element to stop listening the inputs from
  8867. */
  8868. detachControl(element: Nullable<HTMLElement>): void;
  8869. /**
  8870. * Update the current camera state depending on the inputs that have been used this frame.
  8871. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8872. */
  8873. checkInputs(): void;
  8874. /**
  8875. * Gets the class name of the current intput.
  8876. * @returns the class name
  8877. */
  8878. getClassName(): string;
  8879. /** @hidden */
  8880. _onLostFocus(): void;
  8881. /**
  8882. * Get the friendly name associated with the input class.
  8883. * @returns the input friendly name
  8884. */
  8885. getSimpleName(): string;
  8886. }
  8887. }
  8888. declare module "babylonjs/Lights/shadowLight" {
  8889. import { Camera } from "babylonjs/Cameras/camera";
  8890. import { Scene } from "babylonjs/scene";
  8891. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8893. import { Light } from "babylonjs/Lights/light";
  8894. /**
  8895. * Interface describing all the common properties and methods a shadow light needs to implement.
  8896. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8897. * as well as binding the different shadow properties to the effects.
  8898. */
  8899. export interface IShadowLight extends Light {
  8900. /**
  8901. * The light id in the scene (used in scene.findLighById for instance)
  8902. */
  8903. id: string;
  8904. /**
  8905. * The position the shdow will be casted from.
  8906. */
  8907. position: Vector3;
  8908. /**
  8909. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8910. */
  8911. direction: Vector3;
  8912. /**
  8913. * The transformed position. Position of the light in world space taking parenting in account.
  8914. */
  8915. transformedPosition: Vector3;
  8916. /**
  8917. * The transformed direction. Direction of the light in world space taking parenting in account.
  8918. */
  8919. transformedDirection: Vector3;
  8920. /**
  8921. * The friendly name of the light in the scene.
  8922. */
  8923. name: string;
  8924. /**
  8925. * Defines the shadow projection clipping minimum z value.
  8926. */
  8927. shadowMinZ: number;
  8928. /**
  8929. * Defines the shadow projection clipping maximum z value.
  8930. */
  8931. shadowMaxZ: number;
  8932. /**
  8933. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8934. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8935. */
  8936. computeTransformedInformation(): boolean;
  8937. /**
  8938. * Gets the scene the light belongs to.
  8939. * @returns The scene
  8940. */
  8941. getScene(): Scene;
  8942. /**
  8943. * Callback defining a custom Projection Matrix Builder.
  8944. * This can be used to override the default projection matrix computation.
  8945. */
  8946. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8947. /**
  8948. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8949. * @param matrix The materix to updated with the projection information
  8950. * @param viewMatrix The transform matrix of the light
  8951. * @param renderList The list of mesh to render in the map
  8952. * @returns The current light
  8953. */
  8954. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8955. /**
  8956. * Gets the current depth scale used in ESM.
  8957. * @returns The scale
  8958. */
  8959. getDepthScale(): number;
  8960. /**
  8961. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8962. * @returns true if a cube texture needs to be use
  8963. */
  8964. needCube(): boolean;
  8965. /**
  8966. * Detects if the projection matrix requires to be recomputed this frame.
  8967. * @returns true if it requires to be recomputed otherwise, false.
  8968. */
  8969. needProjectionMatrixCompute(): boolean;
  8970. /**
  8971. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8972. */
  8973. forceProjectionMatrixCompute(): void;
  8974. /**
  8975. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8976. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8977. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8978. */
  8979. getShadowDirection(faceIndex?: number): Vector3;
  8980. /**
  8981. * Gets the minZ used for shadow according to both the scene and the light.
  8982. * @param activeCamera The camera we are returning the min for
  8983. * @returns the depth min z
  8984. */
  8985. getDepthMinZ(activeCamera: Camera): number;
  8986. /**
  8987. * Gets the maxZ used for shadow according to both the scene and the light.
  8988. * @param activeCamera The camera we are returning the max for
  8989. * @returns the depth max z
  8990. */
  8991. getDepthMaxZ(activeCamera: Camera): number;
  8992. }
  8993. /**
  8994. * Base implementation IShadowLight
  8995. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8996. */
  8997. export abstract class ShadowLight extends Light implements IShadowLight {
  8998. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8999. protected _position: Vector3;
  9000. protected _setPosition(value: Vector3): void;
  9001. /**
  9002. * Sets the position the shadow will be casted from. Also use as the light position for both
  9003. * point and spot lights.
  9004. */
  9005. get position(): Vector3;
  9006. /**
  9007. * Sets the position the shadow will be casted from. Also use as the light position for both
  9008. * point and spot lights.
  9009. */
  9010. set position(value: Vector3);
  9011. protected _direction: Vector3;
  9012. protected _setDirection(value: Vector3): void;
  9013. /**
  9014. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9015. * Also use as the light direction on spot and directional lights.
  9016. */
  9017. get direction(): Vector3;
  9018. /**
  9019. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9020. * Also use as the light direction on spot and directional lights.
  9021. */
  9022. set direction(value: Vector3);
  9023. protected _shadowMinZ: number;
  9024. /**
  9025. * Gets the shadow projection clipping minimum z value.
  9026. */
  9027. get shadowMinZ(): number;
  9028. /**
  9029. * Sets the shadow projection clipping minimum z value.
  9030. */
  9031. set shadowMinZ(value: number);
  9032. protected _shadowMaxZ: number;
  9033. /**
  9034. * Sets the shadow projection clipping maximum z value.
  9035. */
  9036. get shadowMaxZ(): number;
  9037. /**
  9038. * Gets the shadow projection clipping maximum z value.
  9039. */
  9040. set shadowMaxZ(value: number);
  9041. /**
  9042. * Callback defining a custom Projection Matrix Builder.
  9043. * This can be used to override the default projection matrix computation.
  9044. */
  9045. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9046. /**
  9047. * The transformed position. Position of the light in world space taking parenting in account.
  9048. */
  9049. transformedPosition: Vector3;
  9050. /**
  9051. * The transformed direction. Direction of the light in world space taking parenting in account.
  9052. */
  9053. transformedDirection: Vector3;
  9054. private _needProjectionMatrixCompute;
  9055. /**
  9056. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9057. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9058. */
  9059. computeTransformedInformation(): boolean;
  9060. /**
  9061. * Return the depth scale used for the shadow map.
  9062. * @returns the depth scale.
  9063. */
  9064. getDepthScale(): number;
  9065. /**
  9066. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9067. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9068. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9069. */
  9070. getShadowDirection(faceIndex?: number): Vector3;
  9071. /**
  9072. * Returns the ShadowLight absolute position in the World.
  9073. * @returns the position vector in world space
  9074. */
  9075. getAbsolutePosition(): Vector3;
  9076. /**
  9077. * Sets the ShadowLight direction toward the passed target.
  9078. * @param target The point to target in local space
  9079. * @returns the updated ShadowLight direction
  9080. */
  9081. setDirectionToTarget(target: Vector3): Vector3;
  9082. /**
  9083. * Returns the light rotation in euler definition.
  9084. * @returns the x y z rotation in local space.
  9085. */
  9086. getRotation(): Vector3;
  9087. /**
  9088. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9089. * @returns true if a cube texture needs to be use
  9090. */
  9091. needCube(): boolean;
  9092. /**
  9093. * Detects if the projection matrix requires to be recomputed this frame.
  9094. * @returns true if it requires to be recomputed otherwise, false.
  9095. */
  9096. needProjectionMatrixCompute(): boolean;
  9097. /**
  9098. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9099. */
  9100. forceProjectionMatrixCompute(): void;
  9101. /** @hidden */
  9102. _initCache(): void;
  9103. /** @hidden */
  9104. _isSynchronized(): boolean;
  9105. /**
  9106. * Computes the world matrix of the node
  9107. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9108. * @returns the world matrix
  9109. */
  9110. computeWorldMatrix(force?: boolean): Matrix;
  9111. /**
  9112. * Gets the minZ used for shadow according to both the scene and the light.
  9113. * @param activeCamera The camera we are returning the min for
  9114. * @returns the depth min z
  9115. */
  9116. getDepthMinZ(activeCamera: Camera): number;
  9117. /**
  9118. * Gets the maxZ used for shadow according to both the scene and the light.
  9119. * @param activeCamera The camera we are returning the max for
  9120. * @returns the depth max z
  9121. */
  9122. getDepthMaxZ(activeCamera: Camera): number;
  9123. /**
  9124. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9125. * @param matrix The materix to updated with the projection information
  9126. * @param viewMatrix The transform matrix of the light
  9127. * @param renderList The list of mesh to render in the map
  9128. * @returns The current light
  9129. */
  9130. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9131. }
  9132. }
  9133. declare module "babylonjs/Materials/effectFallbacks" {
  9134. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9135. import { Effect } from "babylonjs/Materials/effect";
  9136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9137. /**
  9138. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9139. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9140. */
  9141. export class EffectFallbacks implements IEffectFallbacks {
  9142. private _defines;
  9143. private _currentRank;
  9144. private _maxRank;
  9145. private _mesh;
  9146. /**
  9147. * Removes the fallback from the bound mesh.
  9148. */
  9149. unBindMesh(): void;
  9150. /**
  9151. * Adds a fallback on the specified property.
  9152. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9153. * @param define The name of the define in the shader
  9154. */
  9155. addFallback(rank: number, define: string): void;
  9156. /**
  9157. * Sets the mesh to use CPU skinning when needing to fallback.
  9158. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9159. * @param mesh The mesh to use the fallbacks.
  9160. */
  9161. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9162. /**
  9163. * Checks to see if more fallbacks are still availible.
  9164. */
  9165. get hasMoreFallbacks(): boolean;
  9166. /**
  9167. * Removes the defines that should be removed when falling back.
  9168. * @param currentDefines defines the current define statements for the shader.
  9169. * @param effect defines the current effect we try to compile
  9170. * @returns The resulting defines with defines of the current rank removed.
  9171. */
  9172. reduce(currentDefines: string, effect: Effect): string;
  9173. }
  9174. }
  9175. declare module "babylonjs/Materials/materialHelper" {
  9176. import { Nullable } from "babylonjs/types";
  9177. import { Scene } from "babylonjs/scene";
  9178. import { Engine } from "babylonjs/Engines/engine";
  9179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9180. import { Light } from "babylonjs/Lights/light";
  9181. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9182. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9183. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9184. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9185. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9186. /**
  9187. * "Static Class" containing the most commonly used helper while dealing with material for
  9188. * rendering purpose.
  9189. *
  9190. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9191. *
  9192. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9193. */
  9194. export class MaterialHelper {
  9195. /**
  9196. * Bind the current view position to an effect.
  9197. * @param effect The effect to be bound
  9198. * @param scene The scene the eyes position is used from
  9199. */
  9200. static BindEyePosition(effect: Effect, scene: Scene): void;
  9201. /**
  9202. * Helps preparing the defines values about the UVs in used in the effect.
  9203. * UVs are shared as much as we can accross channels in the shaders.
  9204. * @param texture The texture we are preparing the UVs for
  9205. * @param defines The defines to update
  9206. * @param key The channel key "diffuse", "specular"... used in the shader
  9207. */
  9208. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9209. /**
  9210. * Binds a texture matrix value to its corrsponding uniform
  9211. * @param texture The texture to bind the matrix for
  9212. * @param uniformBuffer The uniform buffer receivin the data
  9213. * @param key The channel key "diffuse", "specular"... used in the shader
  9214. */
  9215. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9216. /**
  9217. * Gets the current status of the fog (should it be enabled?)
  9218. * @param mesh defines the mesh to evaluate for fog support
  9219. * @param scene defines the hosting scene
  9220. * @returns true if fog must be enabled
  9221. */
  9222. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9223. /**
  9224. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9225. * @param mesh defines the current mesh
  9226. * @param scene defines the current scene
  9227. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9228. * @param pointsCloud defines if point cloud rendering has to be turned on
  9229. * @param fogEnabled defines if fog has to be turned on
  9230. * @param alphaTest defines if alpha testing has to be turned on
  9231. * @param defines defines the current list of defines
  9232. */
  9233. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9234. /**
  9235. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9236. * @param scene defines the current scene
  9237. * @param engine defines the current engine
  9238. * @param defines specifies the list of active defines
  9239. * @param useInstances defines if instances have to be turned on
  9240. * @param useClipPlane defines if clip plane have to be turned on
  9241. */
  9242. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9243. /**
  9244. * Prepares the defines for bones
  9245. * @param mesh The mesh containing the geometry data we will draw
  9246. * @param defines The defines to update
  9247. */
  9248. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9249. /**
  9250. * Prepares the defines for morph targets
  9251. * @param mesh The mesh containing the geometry data we will draw
  9252. * @param defines The defines to update
  9253. */
  9254. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9255. /**
  9256. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9257. * @param mesh The mesh containing the geometry data we will draw
  9258. * @param defines The defines to update
  9259. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9260. * @param useBones Precise whether bones should be used or not (override mesh info)
  9261. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9262. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9263. * @returns false if defines are considered not dirty and have not been checked
  9264. */
  9265. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9266. /**
  9267. * Prepares the defines related to multiview
  9268. * @param scene The scene we are intending to draw
  9269. * @param defines The defines to update
  9270. */
  9271. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9272. /**
  9273. * Prepares the defines related to the light information passed in parameter
  9274. * @param scene The scene we are intending to draw
  9275. * @param mesh The mesh the effect is compiling for
  9276. * @param light The light the effect is compiling for
  9277. * @param lightIndex The index of the light
  9278. * @param defines The defines to update
  9279. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9280. * @param state Defines the current state regarding what is needed (normals, etc...)
  9281. */
  9282. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9283. needNormals: boolean;
  9284. needRebuild: boolean;
  9285. shadowEnabled: boolean;
  9286. specularEnabled: boolean;
  9287. lightmapMode: boolean;
  9288. }): void;
  9289. /**
  9290. * Prepares the defines related to the light information passed in parameter
  9291. * @param scene The scene we are intending to draw
  9292. * @param mesh The mesh the effect is compiling for
  9293. * @param defines The defines to update
  9294. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9295. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9296. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9297. * @returns true if normals will be required for the rest of the effect
  9298. */
  9299. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9300. /**
  9301. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9302. * @param lightIndex defines the light index
  9303. * @param uniformsList The uniform list
  9304. * @param samplersList The sampler list
  9305. * @param projectedLightTexture defines if projected texture must be used
  9306. * @param uniformBuffersList defines an optional list of uniform buffers
  9307. */
  9308. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9309. /**
  9310. * Prepares the uniforms and samplers list to be used in the effect
  9311. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9312. * @param samplersList The sampler list
  9313. * @param defines The defines helping in the list generation
  9314. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9315. */
  9316. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9317. /**
  9318. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9319. * @param defines The defines to update while falling back
  9320. * @param fallbacks The authorized effect fallbacks
  9321. * @param maxSimultaneousLights The maximum number of lights allowed
  9322. * @param rank the current rank of the Effect
  9323. * @returns The newly affected rank
  9324. */
  9325. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9326. private static _TmpMorphInfluencers;
  9327. /**
  9328. * Prepares the list of attributes required for morph targets according to the effect defines.
  9329. * @param attribs The current list of supported attribs
  9330. * @param mesh The mesh to prepare the morph targets attributes for
  9331. * @param influencers The number of influencers
  9332. */
  9333. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9334. /**
  9335. * Prepares the list of attributes required for morph targets according to the effect defines.
  9336. * @param attribs The current list of supported attribs
  9337. * @param mesh The mesh to prepare the morph targets attributes for
  9338. * @param defines The current Defines of the effect
  9339. */
  9340. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9341. /**
  9342. * Prepares the list of attributes required for bones according to the effect defines.
  9343. * @param attribs The current list of supported attribs
  9344. * @param mesh The mesh to prepare the bones attributes for
  9345. * @param defines The current Defines of the effect
  9346. * @param fallbacks The current efffect fallback strategy
  9347. */
  9348. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9349. /**
  9350. * Check and prepare the list of attributes required for instances according to the effect defines.
  9351. * @param attribs The current list of supported attribs
  9352. * @param defines The current MaterialDefines of the effect
  9353. */
  9354. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9355. /**
  9356. * Add the list of attributes required for instances to the attribs array.
  9357. * @param attribs The current list of supported attribs
  9358. */
  9359. static PushAttributesForInstances(attribs: string[]): void;
  9360. /**
  9361. * Binds the light information to the effect.
  9362. * @param light The light containing the generator
  9363. * @param effect The effect we are binding the data to
  9364. * @param lightIndex The light index in the effect used to render
  9365. */
  9366. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9367. /**
  9368. * Binds the lights information from the scene to the effect for the given mesh.
  9369. * @param light Light to bind
  9370. * @param lightIndex Light index
  9371. * @param scene The scene where the light belongs to
  9372. * @param effect The effect we are binding the data to
  9373. * @param useSpecular Defines if specular is supported
  9374. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9375. */
  9376. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9377. /**
  9378. * Binds the lights information from the scene to the effect for the given mesh.
  9379. * @param scene The scene the lights belongs to
  9380. * @param mesh The mesh we are binding the information to render
  9381. * @param effect The effect we are binding the data to
  9382. * @param defines The generated defines for the effect
  9383. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9384. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9385. */
  9386. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9387. private static _tempFogColor;
  9388. /**
  9389. * Binds the fog information from the scene to the effect for the given mesh.
  9390. * @param scene The scene the lights belongs to
  9391. * @param mesh The mesh we are binding the information to render
  9392. * @param effect The effect we are binding the data to
  9393. * @param linearSpace Defines if the fog effect is applied in linear space
  9394. */
  9395. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9396. /**
  9397. * Binds the bones information from the mesh to the effect.
  9398. * @param mesh The mesh we are binding the information to render
  9399. * @param effect The effect we are binding the data to
  9400. */
  9401. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9402. /**
  9403. * Binds the morph targets information from the mesh to the effect.
  9404. * @param abstractMesh The mesh we are binding the information to render
  9405. * @param effect The effect we are binding the data to
  9406. */
  9407. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9408. /**
  9409. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9410. * @param defines The generated defines used in the effect
  9411. * @param effect The effect we are binding the data to
  9412. * @param scene The scene we are willing to render with logarithmic scale for
  9413. */
  9414. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9415. /**
  9416. * Binds the clip plane information from the scene to the effect.
  9417. * @param scene The scene the clip plane information are extracted from
  9418. * @param effect The effect we are binding the data to
  9419. */
  9420. static BindClipPlane(effect: Effect, scene: Scene): void;
  9421. }
  9422. }
  9423. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9424. /** @hidden */
  9425. export var packingFunctions: {
  9426. name: string;
  9427. shader: string;
  9428. };
  9429. }
  9430. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9431. /** @hidden */
  9432. export var clipPlaneFragmentDeclaration: {
  9433. name: string;
  9434. shader: string;
  9435. };
  9436. }
  9437. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9438. /** @hidden */
  9439. export var clipPlaneFragment: {
  9440. name: string;
  9441. shader: string;
  9442. };
  9443. }
  9444. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9445. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9446. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9447. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9448. /** @hidden */
  9449. export var shadowMapPixelShader: {
  9450. name: string;
  9451. shader: string;
  9452. };
  9453. }
  9454. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9455. /** @hidden */
  9456. export var bonesDeclaration: {
  9457. name: string;
  9458. shader: string;
  9459. };
  9460. }
  9461. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9462. /** @hidden */
  9463. export var morphTargetsVertexGlobalDeclaration: {
  9464. name: string;
  9465. shader: string;
  9466. };
  9467. }
  9468. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9469. /** @hidden */
  9470. export var morphTargetsVertexDeclaration: {
  9471. name: string;
  9472. shader: string;
  9473. };
  9474. }
  9475. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9476. /** @hidden */
  9477. export var instancesDeclaration: {
  9478. name: string;
  9479. shader: string;
  9480. };
  9481. }
  9482. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9483. /** @hidden */
  9484. export var helperFunctions: {
  9485. name: string;
  9486. shader: string;
  9487. };
  9488. }
  9489. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9490. /** @hidden */
  9491. export var clipPlaneVertexDeclaration: {
  9492. name: string;
  9493. shader: string;
  9494. };
  9495. }
  9496. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9497. /** @hidden */
  9498. export var morphTargetsVertex: {
  9499. name: string;
  9500. shader: string;
  9501. };
  9502. }
  9503. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9504. /** @hidden */
  9505. export var instancesVertex: {
  9506. name: string;
  9507. shader: string;
  9508. };
  9509. }
  9510. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9511. /** @hidden */
  9512. export var bonesVertex: {
  9513. name: string;
  9514. shader: string;
  9515. };
  9516. }
  9517. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9518. /** @hidden */
  9519. export var clipPlaneVertex: {
  9520. name: string;
  9521. shader: string;
  9522. };
  9523. }
  9524. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9525. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9526. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9527. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9528. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9529. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9530. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9531. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9532. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9533. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9534. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9535. /** @hidden */
  9536. export var shadowMapVertexShader: {
  9537. name: string;
  9538. shader: string;
  9539. };
  9540. }
  9541. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9542. /** @hidden */
  9543. export var depthBoxBlurPixelShader: {
  9544. name: string;
  9545. shader: string;
  9546. };
  9547. }
  9548. declare module "babylonjs/Culling/ray" {
  9549. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9550. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9552. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9553. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9554. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9555. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9556. import { Plane } from "babylonjs/Maths/math.plane";
  9557. /**
  9558. * Class representing a ray with position and direction
  9559. */
  9560. export class Ray {
  9561. /** origin point */
  9562. origin: Vector3;
  9563. /** direction */
  9564. direction: Vector3;
  9565. /** length of the ray */
  9566. length: number;
  9567. private static readonly TmpVector3;
  9568. private _tmpRay;
  9569. /**
  9570. * Creates a new ray
  9571. * @param origin origin point
  9572. * @param direction direction
  9573. * @param length length of the ray
  9574. */
  9575. constructor(
  9576. /** origin point */
  9577. origin: Vector3,
  9578. /** direction */
  9579. direction: Vector3,
  9580. /** length of the ray */
  9581. length?: number);
  9582. /**
  9583. * Checks if the ray intersects a box
  9584. * @param minimum bound of the box
  9585. * @param maximum bound of the box
  9586. * @param intersectionTreshold extra extend to be added to the box in all direction
  9587. * @returns if the box was hit
  9588. */
  9589. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9590. /**
  9591. * Checks if the ray intersects a box
  9592. * @param box the bounding box to check
  9593. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9594. * @returns if the box was hit
  9595. */
  9596. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9597. /**
  9598. * If the ray hits a sphere
  9599. * @param sphere the bounding sphere to check
  9600. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9601. * @returns true if it hits the sphere
  9602. */
  9603. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9604. /**
  9605. * If the ray hits a triange
  9606. * @param vertex0 triangle vertex
  9607. * @param vertex1 triangle vertex
  9608. * @param vertex2 triangle vertex
  9609. * @returns intersection information if hit
  9610. */
  9611. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9612. /**
  9613. * Checks if ray intersects a plane
  9614. * @param plane the plane to check
  9615. * @returns the distance away it was hit
  9616. */
  9617. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9618. /**
  9619. * Calculate the intercept of a ray on a given axis
  9620. * @param axis to check 'x' | 'y' | 'z'
  9621. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9622. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9623. */
  9624. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9625. /**
  9626. * Checks if ray intersects a mesh
  9627. * @param mesh the mesh to check
  9628. * @param fastCheck if only the bounding box should checked
  9629. * @returns picking info of the intersecton
  9630. */
  9631. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9632. /**
  9633. * Checks if ray intersects a mesh
  9634. * @param meshes the meshes to check
  9635. * @param fastCheck if only the bounding box should checked
  9636. * @param results array to store result in
  9637. * @returns Array of picking infos
  9638. */
  9639. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9640. private _comparePickingInfo;
  9641. private static smallnum;
  9642. private static rayl;
  9643. /**
  9644. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9645. * @param sega the first point of the segment to test the intersection against
  9646. * @param segb the second point of the segment to test the intersection against
  9647. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9648. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9649. */
  9650. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9651. /**
  9652. * Update the ray from viewport position
  9653. * @param x position
  9654. * @param y y position
  9655. * @param viewportWidth viewport width
  9656. * @param viewportHeight viewport height
  9657. * @param world world matrix
  9658. * @param view view matrix
  9659. * @param projection projection matrix
  9660. * @returns this ray updated
  9661. */
  9662. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9663. /**
  9664. * Creates a ray with origin and direction of 0,0,0
  9665. * @returns the new ray
  9666. */
  9667. static Zero(): Ray;
  9668. /**
  9669. * Creates a new ray from screen space and viewport
  9670. * @param x position
  9671. * @param y y position
  9672. * @param viewportWidth viewport width
  9673. * @param viewportHeight viewport height
  9674. * @param world world matrix
  9675. * @param view view matrix
  9676. * @param projection projection matrix
  9677. * @returns new ray
  9678. */
  9679. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9680. /**
  9681. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  9682. * transformed to the given world matrix.
  9683. * @param origin The origin point
  9684. * @param end The end point
  9685. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9686. * @returns the new ray
  9687. */
  9688. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9689. /**
  9690. * Transforms a ray by a matrix
  9691. * @param ray ray to transform
  9692. * @param matrix matrix to apply
  9693. * @returns the resulting new ray
  9694. */
  9695. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9696. /**
  9697. * Transforms a ray by a matrix
  9698. * @param ray ray to transform
  9699. * @param matrix matrix to apply
  9700. * @param result ray to store result in
  9701. */
  9702. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9703. /**
  9704. * Unproject a ray from screen space to object space
  9705. * @param sourceX defines the screen space x coordinate to use
  9706. * @param sourceY defines the screen space y coordinate to use
  9707. * @param viewportWidth defines the current width of the viewport
  9708. * @param viewportHeight defines the current height of the viewport
  9709. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9710. * @param view defines the view matrix to use
  9711. * @param projection defines the projection matrix to use
  9712. */
  9713. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9714. }
  9715. /**
  9716. * Type used to define predicate used to select faces when a mesh intersection is detected
  9717. */
  9718. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9719. module "babylonjs/scene" {
  9720. interface Scene {
  9721. /** @hidden */
  9722. _tempPickingRay: Nullable<Ray>;
  9723. /** @hidden */
  9724. _cachedRayForTransform: Ray;
  9725. /** @hidden */
  9726. _pickWithRayInverseMatrix: Matrix;
  9727. /** @hidden */
  9728. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9729. /** @hidden */
  9730. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9731. }
  9732. }
  9733. }
  9734. declare module "babylonjs/sceneComponent" {
  9735. import { Scene } from "babylonjs/scene";
  9736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9737. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9738. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9739. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9740. import { Nullable } from "babylonjs/types";
  9741. import { Camera } from "babylonjs/Cameras/camera";
  9742. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9743. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9744. import { AbstractScene } from "babylonjs/abstractScene";
  9745. import { Mesh } from "babylonjs/Meshes/mesh";
  9746. /**
  9747. * Groups all the scene component constants in one place to ease maintenance.
  9748. * @hidden
  9749. */
  9750. export class SceneComponentConstants {
  9751. static readonly NAME_EFFECTLAYER: string;
  9752. static readonly NAME_LAYER: string;
  9753. static readonly NAME_LENSFLARESYSTEM: string;
  9754. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9755. static readonly NAME_PARTICLESYSTEM: string;
  9756. static readonly NAME_GAMEPAD: string;
  9757. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9758. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9759. static readonly NAME_DEPTHRENDERER: string;
  9760. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9761. static readonly NAME_SPRITE: string;
  9762. static readonly NAME_OUTLINERENDERER: string;
  9763. static readonly NAME_PROCEDURALTEXTURE: string;
  9764. static readonly NAME_SHADOWGENERATOR: string;
  9765. static readonly NAME_OCTREE: string;
  9766. static readonly NAME_PHYSICSENGINE: string;
  9767. static readonly NAME_AUDIO: string;
  9768. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9769. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9770. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9771. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9772. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9773. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9774. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9775. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9776. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9777. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9778. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9779. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9780. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9781. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9782. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9783. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9784. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9785. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9786. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9787. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9788. static readonly STEP_AFTERRENDER_AUDIO: number;
  9789. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9790. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9791. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9792. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9793. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9794. static readonly STEP_POINTERMOVE_SPRITE: number;
  9795. static readonly STEP_POINTERDOWN_SPRITE: number;
  9796. static readonly STEP_POINTERUP_SPRITE: number;
  9797. }
  9798. /**
  9799. * This represents a scene component.
  9800. *
  9801. * This is used to decouple the dependency the scene is having on the different workloads like
  9802. * layers, post processes...
  9803. */
  9804. export interface ISceneComponent {
  9805. /**
  9806. * The name of the component. Each component must have a unique name.
  9807. */
  9808. name: string;
  9809. /**
  9810. * The scene the component belongs to.
  9811. */
  9812. scene: Scene;
  9813. /**
  9814. * Register the component to one instance of a scene.
  9815. */
  9816. register(): void;
  9817. /**
  9818. * Rebuilds the elements related to this component in case of
  9819. * context lost for instance.
  9820. */
  9821. rebuild(): void;
  9822. /**
  9823. * Disposes the component and the associated ressources.
  9824. */
  9825. dispose(): void;
  9826. }
  9827. /**
  9828. * This represents a SERIALIZABLE scene component.
  9829. *
  9830. * This extends Scene Component to add Serialization methods on top.
  9831. */
  9832. export interface ISceneSerializableComponent extends ISceneComponent {
  9833. /**
  9834. * Adds all the elements from the container to the scene
  9835. * @param container the container holding the elements
  9836. */
  9837. addFromContainer(container: AbstractScene): void;
  9838. /**
  9839. * Removes all the elements in the container from the scene
  9840. * @param container contains the elements to remove
  9841. * @param dispose if the removed element should be disposed (default: false)
  9842. */
  9843. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9844. /**
  9845. * Serializes the component data to the specified json object
  9846. * @param serializationObject The object to serialize to
  9847. */
  9848. serialize(serializationObject: any): void;
  9849. }
  9850. /**
  9851. * Strong typing of a Mesh related stage step action
  9852. */
  9853. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9854. /**
  9855. * Strong typing of a Evaluate Sub Mesh related stage step action
  9856. */
  9857. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9858. /**
  9859. * Strong typing of a Active Mesh related stage step action
  9860. */
  9861. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9862. /**
  9863. * Strong typing of a Camera related stage step action
  9864. */
  9865. export type CameraStageAction = (camera: Camera) => void;
  9866. /**
  9867. * Strong typing of a Camera Frame buffer related stage step action
  9868. */
  9869. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9870. /**
  9871. * Strong typing of a Render Target related stage step action
  9872. */
  9873. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9874. /**
  9875. * Strong typing of a RenderingGroup related stage step action
  9876. */
  9877. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9878. /**
  9879. * Strong typing of a Mesh Render related stage step action
  9880. */
  9881. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9882. /**
  9883. * Strong typing of a simple stage step action
  9884. */
  9885. export type SimpleStageAction = () => void;
  9886. /**
  9887. * Strong typing of a render target action.
  9888. */
  9889. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9890. /**
  9891. * Strong typing of a pointer move action.
  9892. */
  9893. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9894. /**
  9895. * Strong typing of a pointer up/down action.
  9896. */
  9897. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9898. /**
  9899. * Representation of a stage in the scene (Basically a list of ordered steps)
  9900. * @hidden
  9901. */
  9902. export class Stage<T extends Function> extends Array<{
  9903. index: number;
  9904. component: ISceneComponent;
  9905. action: T;
  9906. }> {
  9907. /**
  9908. * Hide ctor from the rest of the world.
  9909. * @param items The items to add.
  9910. */
  9911. private constructor();
  9912. /**
  9913. * Creates a new Stage.
  9914. * @returns A new instance of a Stage
  9915. */
  9916. static Create<T extends Function>(): Stage<T>;
  9917. /**
  9918. * Registers a step in an ordered way in the targeted stage.
  9919. * @param index Defines the position to register the step in
  9920. * @param component Defines the component attached to the step
  9921. * @param action Defines the action to launch during the step
  9922. */
  9923. registerStep(index: number, component: ISceneComponent, action: T): void;
  9924. /**
  9925. * Clears all the steps from the stage.
  9926. */
  9927. clear(): void;
  9928. }
  9929. }
  9930. declare module "babylonjs/Sprites/spriteSceneComponent" {
  9931. import { Nullable } from "babylonjs/types";
  9932. import { Observable } from "babylonjs/Misc/observable";
  9933. import { Scene } from "babylonjs/scene";
  9934. import { Sprite } from "babylonjs/Sprites/sprite";
  9935. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  9936. import { Ray } from "babylonjs/Culling/ray";
  9937. import { Camera } from "babylonjs/Cameras/camera";
  9938. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9939. import { ISceneComponent } from "babylonjs/sceneComponent";
  9940. module "babylonjs/scene" {
  9941. interface Scene {
  9942. /** @hidden */
  9943. _pointerOverSprite: Nullable<Sprite>;
  9944. /** @hidden */
  9945. _pickedDownSprite: Nullable<Sprite>;
  9946. /** @hidden */
  9947. _tempSpritePickingRay: Nullable<Ray>;
  9948. /**
  9949. * All of the sprite managers added to this scene
  9950. * @see http://doc.babylonjs.com/babylon101/sprites
  9951. */
  9952. spriteManagers: Array<ISpriteManager>;
  9953. /**
  9954. * An event triggered when sprites rendering is about to start
  9955. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9956. */
  9957. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9958. /**
  9959. * An event triggered when sprites rendering is done
  9960. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9961. */
  9962. onAfterSpritesRenderingObservable: Observable<Scene>;
  9963. /** @hidden */
  9964. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9965. /** Launch a ray to try to pick a sprite in the scene
  9966. * @param x position on screen
  9967. * @param y position on screen
  9968. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9969. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9970. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9971. * @returns a PickingInfo
  9972. */
  9973. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9974. /** Use the given ray to pick a sprite in the scene
  9975. * @param ray The ray (in world space) to use to pick meshes
  9976. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9977. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9978. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9979. * @returns a PickingInfo
  9980. */
  9981. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9982. /** @hidden */
  9983. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9984. /** Launch a ray to try to pick sprites in the scene
  9985. * @param x position on screen
  9986. * @param y position on screen
  9987. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9988. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9989. * @returns a PickingInfo array
  9990. */
  9991. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9992. /** Use the given ray to pick sprites in the scene
  9993. * @param ray The ray (in world space) to use to pick meshes
  9994. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9995. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9996. * @returns a PickingInfo array
  9997. */
  9998. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9999. /**
  10000. * Force the sprite under the pointer
  10001. * @param sprite defines the sprite to use
  10002. */
  10003. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10004. /**
  10005. * Gets the sprite under the pointer
  10006. * @returns a Sprite or null if no sprite is under the pointer
  10007. */
  10008. getPointerOverSprite(): Nullable<Sprite>;
  10009. }
  10010. }
  10011. /**
  10012. * Defines the sprite scene component responsible to manage sprites
  10013. * in a given scene.
  10014. */
  10015. export class SpriteSceneComponent implements ISceneComponent {
  10016. /**
  10017. * The component name helpfull to identify the component in the list of scene components.
  10018. */
  10019. readonly name: string;
  10020. /**
  10021. * The scene the component belongs to.
  10022. */
  10023. scene: Scene;
  10024. /** @hidden */
  10025. private _spritePredicate;
  10026. /**
  10027. * Creates a new instance of the component for the given scene
  10028. * @param scene Defines the scene to register the component in
  10029. */
  10030. constructor(scene: Scene);
  10031. /**
  10032. * Registers the component in a given scene
  10033. */
  10034. register(): void;
  10035. /**
  10036. * Rebuilds the elements related to this component in case of
  10037. * context lost for instance.
  10038. */
  10039. rebuild(): void;
  10040. /**
  10041. * Disposes the component and the associated ressources.
  10042. */
  10043. dispose(): void;
  10044. private _pickSpriteButKeepRay;
  10045. private _pointerMove;
  10046. private _pointerDown;
  10047. private _pointerUp;
  10048. }
  10049. }
  10050. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10051. /** @hidden */
  10052. export var fogFragmentDeclaration: {
  10053. name: string;
  10054. shader: string;
  10055. };
  10056. }
  10057. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10058. /** @hidden */
  10059. export var fogFragment: {
  10060. name: string;
  10061. shader: string;
  10062. };
  10063. }
  10064. declare module "babylonjs/Shaders/sprites.fragment" {
  10065. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10066. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10067. /** @hidden */
  10068. export var spritesPixelShader: {
  10069. name: string;
  10070. shader: string;
  10071. };
  10072. }
  10073. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10074. /** @hidden */
  10075. export var fogVertexDeclaration: {
  10076. name: string;
  10077. shader: string;
  10078. };
  10079. }
  10080. declare module "babylonjs/Shaders/sprites.vertex" {
  10081. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10082. /** @hidden */
  10083. export var spritesVertexShader: {
  10084. name: string;
  10085. shader: string;
  10086. };
  10087. }
  10088. declare module "babylonjs/Sprites/spriteManager" {
  10089. import { IDisposable, Scene } from "babylonjs/scene";
  10090. import { Nullable } from "babylonjs/types";
  10091. import { Observable } from "babylonjs/Misc/observable";
  10092. import { Sprite } from "babylonjs/Sprites/sprite";
  10093. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10094. import { Camera } from "babylonjs/Cameras/camera";
  10095. import { Texture } from "babylonjs/Materials/Textures/texture";
  10096. import "babylonjs/Shaders/sprites.fragment";
  10097. import "babylonjs/Shaders/sprites.vertex";
  10098. import { Ray } from "babylonjs/Culling/ray";
  10099. /**
  10100. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10101. */
  10102. export interface ISpriteManager extends IDisposable {
  10103. /**
  10104. * Restricts the camera to viewing objects with the same layerMask.
  10105. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10106. */
  10107. layerMask: number;
  10108. /**
  10109. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10110. */
  10111. isPickable: boolean;
  10112. /**
  10113. * Specifies the rendering group id for this mesh (0 by default)
  10114. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10115. */
  10116. renderingGroupId: number;
  10117. /**
  10118. * Defines the list of sprites managed by the manager.
  10119. */
  10120. sprites: Array<Sprite>;
  10121. /**
  10122. * Tests the intersection of a sprite with a specific ray.
  10123. * @param ray The ray we are sending to test the collision
  10124. * @param camera The camera space we are sending rays in
  10125. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10126. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10127. * @returns picking info or null.
  10128. */
  10129. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10130. /**
  10131. * Intersects the sprites with a ray
  10132. * @param ray defines the ray to intersect with
  10133. * @param camera defines the current active camera
  10134. * @param predicate defines a predicate used to select candidate sprites
  10135. * @returns null if no hit or a PickingInfo array
  10136. */
  10137. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10138. /**
  10139. * Renders the list of sprites on screen.
  10140. */
  10141. render(): void;
  10142. }
  10143. /**
  10144. * Class used to manage multiple sprites on the same spritesheet
  10145. * @see http://doc.babylonjs.com/babylon101/sprites
  10146. */
  10147. export class SpriteManager implements ISpriteManager {
  10148. /** defines the manager's name */
  10149. name: string;
  10150. /** Gets the list of sprites */
  10151. sprites: Sprite[];
  10152. /** Gets or sets the rendering group id (0 by default) */
  10153. renderingGroupId: number;
  10154. /** Gets or sets camera layer mask */
  10155. layerMask: number;
  10156. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10157. fogEnabled: boolean;
  10158. /** Gets or sets a boolean indicating if the sprites are pickable */
  10159. isPickable: boolean;
  10160. /** Defines the default width of a cell in the spritesheet */
  10161. cellWidth: number;
  10162. /** Defines the default height of a cell in the spritesheet */
  10163. cellHeight: number;
  10164. /** Associative array from JSON sprite data file */
  10165. private _cellData;
  10166. /** Array of sprite names from JSON sprite data file */
  10167. private _spriteMap;
  10168. /** True when packed cell data from JSON file is ready*/
  10169. private _packedAndReady;
  10170. /**
  10171. * An event triggered when the manager is disposed.
  10172. */
  10173. onDisposeObservable: Observable<SpriteManager>;
  10174. private _onDisposeObserver;
  10175. /**
  10176. * Callback called when the manager is disposed
  10177. */
  10178. set onDispose(callback: () => void);
  10179. private _capacity;
  10180. private _fromPacked;
  10181. private _spriteTexture;
  10182. private _epsilon;
  10183. private _scene;
  10184. private _vertexData;
  10185. private _buffer;
  10186. private _vertexBuffers;
  10187. private _indexBuffer;
  10188. private _effectBase;
  10189. private _effectFog;
  10190. /**
  10191. * Gets or sets the spritesheet texture
  10192. */
  10193. get texture(): Texture;
  10194. set texture(value: Texture);
  10195. private _blendMode;
  10196. /**
  10197. * Blend mode use to render the particle, it can be any of
  10198. * the static Constants.ALPHA_x properties provided in this class.
  10199. * Default value is Constants.ALPHA_COMBINE
  10200. */
  10201. get blendMode(): number;
  10202. set blendMode(blendMode: number);
  10203. /** Disables writing to the depth buffer when rendering the sprites.
  10204. * It can be handy to disable depth writing when using textures without alpha channel
  10205. * and setting some specific blend modes.
  10206. */
  10207. disableDepthWrite: boolean;
  10208. /**
  10209. * Creates a new sprite manager
  10210. * @param name defines the manager's name
  10211. * @param imgUrl defines the sprite sheet url
  10212. * @param capacity defines the maximum allowed number of sprites
  10213. * @param cellSize defines the size of a sprite cell
  10214. * @param scene defines the hosting scene
  10215. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10216. * @param samplingMode defines the smapling mode to use with spritesheet
  10217. * @param fromPacked set to false; do not alter
  10218. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10219. */
  10220. constructor(
  10221. /** defines the manager's name */
  10222. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10223. private _makePacked;
  10224. private _appendSpriteVertex;
  10225. /**
  10226. * Intersects the sprites with a ray
  10227. * @param ray defines the ray to intersect with
  10228. * @param camera defines the current active camera
  10229. * @param predicate defines a predicate used to select candidate sprites
  10230. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10231. * @returns null if no hit or a PickingInfo
  10232. */
  10233. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10234. /**
  10235. * Intersects the sprites with a ray
  10236. * @param ray defines the ray to intersect with
  10237. * @param camera defines the current active camera
  10238. * @param predicate defines a predicate used to select candidate sprites
  10239. * @returns null if no hit or a PickingInfo array
  10240. */
  10241. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10242. /**
  10243. * Render all child sprites
  10244. */
  10245. render(): void;
  10246. /**
  10247. * Release associated resources
  10248. */
  10249. dispose(): void;
  10250. }
  10251. }
  10252. declare module "babylonjs/Misc/gradients" {
  10253. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10254. /** Interface used by value gradients (color, factor, ...) */
  10255. export interface IValueGradient {
  10256. /**
  10257. * Gets or sets the gradient value (between 0 and 1)
  10258. */
  10259. gradient: number;
  10260. }
  10261. /** Class used to store color4 gradient */
  10262. export class ColorGradient implements IValueGradient {
  10263. /**
  10264. * Gets or sets the gradient value (between 0 and 1)
  10265. */
  10266. gradient: number;
  10267. /**
  10268. * Gets or sets first associated color
  10269. */
  10270. color1: Color4;
  10271. /**
  10272. * Gets or sets second associated color
  10273. */
  10274. color2?: Color4;
  10275. /**
  10276. * Will get a color picked randomly between color1 and color2.
  10277. * If color2 is undefined then color1 will be used
  10278. * @param result defines the target Color4 to store the result in
  10279. */
  10280. getColorToRef(result: Color4): void;
  10281. }
  10282. /** Class used to store color 3 gradient */
  10283. export class Color3Gradient implements IValueGradient {
  10284. /**
  10285. * Gets or sets the gradient value (between 0 and 1)
  10286. */
  10287. gradient: number;
  10288. /**
  10289. * Gets or sets the associated color
  10290. */
  10291. color: Color3;
  10292. }
  10293. /** Class used to store factor gradient */
  10294. export class FactorGradient implements IValueGradient {
  10295. /**
  10296. * Gets or sets the gradient value (between 0 and 1)
  10297. */
  10298. gradient: number;
  10299. /**
  10300. * Gets or sets first associated factor
  10301. */
  10302. factor1: number;
  10303. /**
  10304. * Gets or sets second associated factor
  10305. */
  10306. factor2?: number;
  10307. /**
  10308. * Will get a number picked randomly between factor1 and factor2.
  10309. * If factor2 is undefined then factor1 will be used
  10310. * @returns the picked number
  10311. */
  10312. getFactor(): number;
  10313. }
  10314. /**
  10315. * Helper used to simplify some generic gradient tasks
  10316. */
  10317. export class GradientHelper {
  10318. /**
  10319. * Gets the current gradient from an array of IValueGradient
  10320. * @param ratio defines the current ratio to get
  10321. * @param gradients defines the array of IValueGradient
  10322. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10323. */
  10324. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10325. }
  10326. }
  10327. declare module "babylonjs/Maths/math.size" {
  10328. /**
  10329. * Interface for the size containing width and height
  10330. */
  10331. export interface ISize {
  10332. /**
  10333. * Width
  10334. */
  10335. width: number;
  10336. /**
  10337. * Heighht
  10338. */
  10339. height: number;
  10340. }
  10341. /**
  10342. * Size containing widht and height
  10343. */
  10344. export class Size implements ISize {
  10345. /**
  10346. * Width
  10347. */
  10348. width: number;
  10349. /**
  10350. * Height
  10351. */
  10352. height: number;
  10353. /**
  10354. * Creates a Size object from the given width and height (floats).
  10355. * @param width width of the new size
  10356. * @param height height of the new size
  10357. */
  10358. constructor(width: number, height: number);
  10359. /**
  10360. * Returns a string with the Size width and height
  10361. * @returns a string with the Size width and height
  10362. */
  10363. toString(): string;
  10364. /**
  10365. * "Size"
  10366. * @returns the string "Size"
  10367. */
  10368. getClassName(): string;
  10369. /**
  10370. * Returns the Size hash code.
  10371. * @returns a hash code for a unique width and height
  10372. */
  10373. getHashCode(): number;
  10374. /**
  10375. * Updates the current size from the given one.
  10376. * @param src the given size
  10377. */
  10378. copyFrom(src: Size): void;
  10379. /**
  10380. * Updates in place the current Size from the given floats.
  10381. * @param width width of the new size
  10382. * @param height height of the new size
  10383. * @returns the updated Size.
  10384. */
  10385. copyFromFloats(width: number, height: number): Size;
  10386. /**
  10387. * Updates in place the current Size from the given floats.
  10388. * @param width width to set
  10389. * @param height height to set
  10390. * @returns the updated Size.
  10391. */
  10392. set(width: number, height: number): Size;
  10393. /**
  10394. * Multiplies the width and height by numbers
  10395. * @param w factor to multiple the width by
  10396. * @param h factor to multiple the height by
  10397. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10398. */
  10399. multiplyByFloats(w: number, h: number): Size;
  10400. /**
  10401. * Clones the size
  10402. * @returns a new Size copied from the given one.
  10403. */
  10404. clone(): Size;
  10405. /**
  10406. * True if the current Size and the given one width and height are strictly equal.
  10407. * @param other the other size to compare against
  10408. * @returns True if the current Size and the given one width and height are strictly equal.
  10409. */
  10410. equals(other: Size): boolean;
  10411. /**
  10412. * The surface of the Size : width * height (float).
  10413. */
  10414. get surface(): number;
  10415. /**
  10416. * Create a new size of zero
  10417. * @returns a new Size set to (0.0, 0.0)
  10418. */
  10419. static Zero(): Size;
  10420. /**
  10421. * Sums the width and height of two sizes
  10422. * @param otherSize size to add to this size
  10423. * @returns a new Size set as the addition result of the current Size and the given one.
  10424. */
  10425. add(otherSize: Size): Size;
  10426. /**
  10427. * Subtracts the width and height of two
  10428. * @param otherSize size to subtract to this size
  10429. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10430. */
  10431. subtract(otherSize: Size): Size;
  10432. /**
  10433. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10434. * @param start starting size to lerp between
  10435. * @param end end size to lerp between
  10436. * @param amount amount to lerp between the start and end values
  10437. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10438. */
  10439. static Lerp(start: Size, end: Size, amount: number): Size;
  10440. }
  10441. }
  10442. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10443. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10444. import { Nullable } from "babylonjs/types";
  10445. module "babylonjs/Engines/thinEngine" {
  10446. interface ThinEngine {
  10447. /**
  10448. * Creates a dynamic texture
  10449. * @param width defines the width of the texture
  10450. * @param height defines the height of the texture
  10451. * @param generateMipMaps defines if the engine should generate the mip levels
  10452. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10453. * @returns the dynamic texture inside an InternalTexture
  10454. */
  10455. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10456. /**
  10457. * Update the content of a dynamic texture
  10458. * @param texture defines the texture to update
  10459. * @param canvas defines the canvas containing the source
  10460. * @param invertY defines if data must be stored with Y axis inverted
  10461. * @param premulAlpha defines if alpha is stored as premultiplied
  10462. * @param format defines the format of the data
  10463. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10464. */
  10465. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10466. }
  10467. }
  10468. }
  10469. declare module "babylonjs/Misc/canvasGenerator" {
  10470. /**
  10471. * Helper class used to generate a canvas to manipulate images
  10472. */
  10473. export class CanvasGenerator {
  10474. /**
  10475. * Create a new canvas (or offscreen canvas depending on the context)
  10476. * @param width defines the expected width
  10477. * @param height defines the expected height
  10478. * @return a new canvas or offscreen canvas
  10479. */
  10480. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10481. }
  10482. }
  10483. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10484. import { Scene } from "babylonjs/scene";
  10485. import { Texture } from "babylonjs/Materials/Textures/texture";
  10486. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10487. /**
  10488. * A class extending Texture allowing drawing on a texture
  10489. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10490. */
  10491. export class DynamicTexture extends Texture {
  10492. private _generateMipMaps;
  10493. private _canvas;
  10494. private _context;
  10495. private _engine;
  10496. /**
  10497. * Creates a DynamicTexture
  10498. * @param name defines the name of the texture
  10499. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  10500. * @param scene defines the scene where you want the texture
  10501. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10502. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10503. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10504. */
  10505. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10506. /**
  10507. * Get the current class name of the texture useful for serialization or dynamic coding.
  10508. * @returns "DynamicTexture"
  10509. */
  10510. getClassName(): string;
  10511. /**
  10512. * Gets the current state of canRescale
  10513. */
  10514. get canRescale(): boolean;
  10515. private _recreate;
  10516. /**
  10517. * Scales the texture
  10518. * @param ratio the scale factor to apply to both width and height
  10519. */
  10520. scale(ratio: number): void;
  10521. /**
  10522. * Resizes the texture
  10523. * @param width the new width
  10524. * @param height the new height
  10525. */
  10526. scaleTo(width: number, height: number): void;
  10527. /**
  10528. * Gets the context of the canvas used by the texture
  10529. * @returns the canvas context of the dynamic texture
  10530. */
  10531. getContext(): CanvasRenderingContext2D;
  10532. /**
  10533. * Clears the texture
  10534. */
  10535. clear(): void;
  10536. /**
  10537. * Updates the texture
  10538. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10539. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10540. */
  10541. update(invertY?: boolean, premulAlpha?: boolean): void;
  10542. /**
  10543. * Draws text onto the texture
  10544. * @param text defines the text to be drawn
  10545. * @param x defines the placement of the text from the left
  10546. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10547. * @param font defines the font to be used with font-style, font-size, font-name
  10548. * @param color defines the color used for the text
  10549. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10550. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10551. * @param update defines whether texture is immediately update (default is true)
  10552. */
  10553. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10554. /**
  10555. * Clones the texture
  10556. * @returns the clone of the texture.
  10557. */
  10558. clone(): DynamicTexture;
  10559. /**
  10560. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10561. * @returns a serialized dynamic texture object
  10562. */
  10563. serialize(): any;
  10564. /** @hidden */
  10565. _rebuild(): void;
  10566. }
  10567. }
  10568. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10569. import { Nullable } from "babylonjs/types";
  10570. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10571. import { Scene } from "babylonjs/scene";
  10572. module "babylonjs/Engines/engine" {
  10573. interface Engine {
  10574. /**
  10575. * Creates a raw texture
  10576. * @param data defines the data to store in the texture
  10577. * @param width defines the width of the texture
  10578. * @param height defines the height of the texture
  10579. * @param format defines the format of the data
  10580. * @param generateMipMaps defines if the engine should generate the mip levels
  10581. * @param invertY defines if data must be stored with Y axis inverted
  10582. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10583. * @param compression defines the compression used (null by default)
  10584. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10585. * @returns the raw texture inside an InternalTexture
  10586. */
  10587. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10588. /**
  10589. * Update a raw texture
  10590. * @param texture defines the texture to update
  10591. * @param data defines the data to store in the texture
  10592. * @param format defines the format of the data
  10593. * @param invertY defines if data must be stored with Y axis inverted
  10594. */
  10595. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10596. /**
  10597. * Update a raw texture
  10598. * @param texture defines the texture to update
  10599. * @param data defines the data to store in the texture
  10600. * @param format defines the format of the data
  10601. * @param invertY defines if data must be stored with Y axis inverted
  10602. * @param compression defines the compression used (null by default)
  10603. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10604. */
  10605. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10606. /**
  10607. * Creates a new raw cube texture
  10608. * @param data defines the array of data to use to create each face
  10609. * @param size defines the size of the textures
  10610. * @param format defines the format of the data
  10611. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10612. * @param generateMipMaps defines if the engine should generate the mip levels
  10613. * @param invertY defines if data must be stored with Y axis inverted
  10614. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10615. * @param compression defines the compression used (null by default)
  10616. * @returns the cube texture as an InternalTexture
  10617. */
  10618. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10619. /**
  10620. * Update a raw cube texture
  10621. * @param texture defines the texture to udpdate
  10622. * @param data defines the data to store
  10623. * @param format defines the data format
  10624. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10625. * @param invertY defines if data must be stored with Y axis inverted
  10626. */
  10627. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10628. /**
  10629. * Update a raw cube texture
  10630. * @param texture defines the texture to udpdate
  10631. * @param data defines the data to store
  10632. * @param format defines the data format
  10633. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10634. * @param invertY defines if data must be stored with Y axis inverted
  10635. * @param compression defines the compression used (null by default)
  10636. */
  10637. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10638. /**
  10639. * Update a raw cube texture
  10640. * @param texture defines the texture to udpdate
  10641. * @param data defines the data to store
  10642. * @param format defines the data format
  10643. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10644. * @param invertY defines if data must be stored with Y axis inverted
  10645. * @param compression defines the compression used (null by default)
  10646. * @param level defines which level of the texture to update
  10647. */
  10648. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10649. /**
  10650. * Creates a new raw cube texture from a specified url
  10651. * @param url defines the url where the data is located
  10652. * @param scene defines the current scene
  10653. * @param size defines the size of the textures
  10654. * @param format defines the format of the data
  10655. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10656. * @param noMipmap defines if the engine should avoid generating the mip levels
  10657. * @param callback defines a callback used to extract texture data from loaded data
  10658. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10659. * @param onLoad defines a callback called when texture is loaded
  10660. * @param onError defines a callback called if there is an error
  10661. * @returns the cube texture as an InternalTexture
  10662. */
  10663. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  10664. /**
  10665. * Creates a new raw cube texture from a specified url
  10666. * @param url defines the url where the data is located
  10667. * @param scene defines the current scene
  10668. * @param size defines the size of the textures
  10669. * @param format defines the format of the data
  10670. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10671. * @param noMipmap defines if the engine should avoid generating the mip levels
  10672. * @param callback defines a callback used to extract texture data from loaded data
  10673. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10674. * @param onLoad defines a callback called when texture is loaded
  10675. * @param onError defines a callback called if there is an error
  10676. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10677. * @param invertY defines if data must be stored with Y axis inverted
  10678. * @returns the cube texture as an InternalTexture
  10679. */
  10680. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  10681. /**
  10682. * Creates a new raw 3D texture
  10683. * @param data defines the data used to create the texture
  10684. * @param width defines the width of the texture
  10685. * @param height defines the height of the texture
  10686. * @param depth defines the depth of the texture
  10687. * @param format defines the format of the texture
  10688. * @param generateMipMaps defines if the engine must generate mip levels
  10689. * @param invertY defines if data must be stored with Y axis inverted
  10690. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10691. * @param compression defines the compressed used (can be null)
  10692. * @param textureType defines the compressed used (can be null)
  10693. * @returns a new raw 3D texture (stored in an InternalTexture)
  10694. */
  10695. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10696. /**
  10697. * Update a raw 3D texture
  10698. * @param texture defines the texture to update
  10699. * @param data defines the data to store
  10700. * @param format defines the data format
  10701. * @param invertY defines if data must be stored with Y axis inverted
  10702. */
  10703. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10704. /**
  10705. * Update a raw 3D texture
  10706. * @param texture defines the texture to update
  10707. * @param data defines the data to store
  10708. * @param format defines the data format
  10709. * @param invertY defines if data must be stored with Y axis inverted
  10710. * @param compression defines the used compression (can be null)
  10711. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10712. */
  10713. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10714. /**
  10715. * Creates a new raw 2D array texture
  10716. * @param data defines the data used to create the texture
  10717. * @param width defines the width of the texture
  10718. * @param height defines the height of the texture
  10719. * @param depth defines the number of layers of the texture
  10720. * @param format defines the format of the texture
  10721. * @param generateMipMaps defines if the engine must generate mip levels
  10722. * @param invertY defines if data must be stored with Y axis inverted
  10723. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10724. * @param compression defines the compressed used (can be null)
  10725. * @param textureType defines the compressed used (can be null)
  10726. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10727. */
  10728. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10729. /**
  10730. * Update a raw 2D array texture
  10731. * @param texture defines the texture to update
  10732. * @param data defines the data to store
  10733. * @param format defines the data format
  10734. * @param invertY defines if data must be stored with Y axis inverted
  10735. */
  10736. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10737. /**
  10738. * Update a raw 2D array texture
  10739. * @param texture defines the texture to update
  10740. * @param data defines the data to store
  10741. * @param format defines the data format
  10742. * @param invertY defines if data must be stored with Y axis inverted
  10743. * @param compression defines the used compression (can be null)
  10744. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10745. */
  10746. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10747. }
  10748. }
  10749. }
  10750. declare module "babylonjs/Materials/Textures/rawTexture" {
  10751. import { Scene } from "babylonjs/scene";
  10752. import { Texture } from "babylonjs/Materials/Textures/texture";
  10753. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10754. /**
  10755. * Raw texture can help creating a texture directly from an array of data.
  10756. * This can be super useful if you either get the data from an uncompressed source or
  10757. * if you wish to create your texture pixel by pixel.
  10758. */
  10759. export class RawTexture extends Texture {
  10760. /**
  10761. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10762. */
  10763. format: number;
  10764. private _engine;
  10765. /**
  10766. * Instantiates a new RawTexture.
  10767. * Raw texture can help creating a texture directly from an array of data.
  10768. * This can be super useful if you either get the data from an uncompressed source or
  10769. * if you wish to create your texture pixel by pixel.
  10770. * @param data define the array of data to use to create the texture
  10771. * @param width define the width of the texture
  10772. * @param height define the height of the texture
  10773. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10774. * @param scene define the scene the texture belongs to
  10775. * @param generateMipMaps define whether mip maps should be generated or not
  10776. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10777. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10778. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10779. */
  10780. constructor(data: ArrayBufferView, width: number, height: number,
  10781. /**
  10782. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10783. */
  10784. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10785. /**
  10786. * Updates the texture underlying data.
  10787. * @param data Define the new data of the texture
  10788. */
  10789. update(data: ArrayBufferView): void;
  10790. /**
  10791. * Creates a luminance texture from some data.
  10792. * @param data Define the texture data
  10793. * @param width Define the width of the texture
  10794. * @param height Define the height of the texture
  10795. * @param scene Define the scene the texture belongs to
  10796. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10797. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10798. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10799. * @returns the luminance texture
  10800. */
  10801. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10802. /**
  10803. * Creates a luminance alpha texture from some data.
  10804. * @param data Define the texture data
  10805. * @param width Define the width of the texture
  10806. * @param height Define the height of the texture
  10807. * @param scene Define the scene the texture belongs to
  10808. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10809. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10810. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10811. * @returns the luminance alpha texture
  10812. */
  10813. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10814. /**
  10815. * Creates an alpha texture from some data.
  10816. * @param data Define the texture data
  10817. * @param width Define the width of the texture
  10818. * @param height Define the height of the texture
  10819. * @param scene Define the scene the texture belongs to
  10820. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10821. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10822. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10823. * @returns the alpha texture
  10824. */
  10825. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10826. /**
  10827. * Creates a RGB texture from some data.
  10828. * @param data Define the texture data
  10829. * @param width Define the width of the texture
  10830. * @param height Define the height of the texture
  10831. * @param scene Define the scene the texture belongs to
  10832. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10833. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10834. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10835. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10836. * @returns the RGB alpha texture
  10837. */
  10838. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10839. /**
  10840. * Creates a RGBA texture from some data.
  10841. * @param data Define the texture data
  10842. * @param width Define the width of the texture
  10843. * @param height Define the height of the texture
  10844. * @param scene Define the scene the texture belongs to
  10845. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10846. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10847. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10848. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10849. * @returns the RGBA texture
  10850. */
  10851. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10852. /**
  10853. * Creates a R texture from some data.
  10854. * @param data Define the texture data
  10855. * @param width Define the width of the texture
  10856. * @param height Define the height of the texture
  10857. * @param scene Define the scene the texture belongs to
  10858. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10859. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10860. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10861. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10862. * @returns the R texture
  10863. */
  10864. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10865. }
  10866. }
  10867. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10868. import { Scene } from "babylonjs/scene";
  10869. import { ISceneComponent } from "babylonjs/sceneComponent";
  10870. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10871. module "babylonjs/abstractScene" {
  10872. interface AbstractScene {
  10873. /**
  10874. * The list of procedural textures added to the scene
  10875. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10876. */
  10877. proceduralTextures: Array<ProceduralTexture>;
  10878. }
  10879. }
  10880. /**
  10881. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10882. * in a given scene.
  10883. */
  10884. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10885. /**
  10886. * The component name helpfull to identify the component in the list of scene components.
  10887. */
  10888. readonly name: string;
  10889. /**
  10890. * The scene the component belongs to.
  10891. */
  10892. scene: Scene;
  10893. /**
  10894. * Creates a new instance of the component for the given scene
  10895. * @param scene Defines the scene to register the component in
  10896. */
  10897. constructor(scene: Scene);
  10898. /**
  10899. * Registers the component in a given scene
  10900. */
  10901. register(): void;
  10902. /**
  10903. * Rebuilds the elements related to this component in case of
  10904. * context lost for instance.
  10905. */
  10906. rebuild(): void;
  10907. /**
  10908. * Disposes the component and the associated ressources.
  10909. */
  10910. dispose(): void;
  10911. private _beforeClear;
  10912. }
  10913. }
  10914. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  10915. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10916. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  10917. module "babylonjs/Engines/thinEngine" {
  10918. interface ThinEngine {
  10919. /**
  10920. * Creates a new render target cube texture
  10921. * @param size defines the size of the texture
  10922. * @param options defines the options used to create the texture
  10923. * @returns a new render target cube texture stored in an InternalTexture
  10924. */
  10925. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10926. }
  10927. }
  10928. }
  10929. declare module "babylonjs/Shaders/procedural.vertex" {
  10930. /** @hidden */
  10931. export var proceduralVertexShader: {
  10932. name: string;
  10933. shader: string;
  10934. };
  10935. }
  10936. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  10937. import { Observable } from "babylonjs/Misc/observable";
  10938. import { Nullable } from "babylonjs/types";
  10939. import { Scene } from "babylonjs/scene";
  10940. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10941. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  10942. import { Effect } from "babylonjs/Materials/effect";
  10943. import { Texture } from "babylonjs/Materials/Textures/texture";
  10944. import "babylonjs/Engines/Extensions/engine.renderTarget";
  10945. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  10946. import "babylonjs/Shaders/procedural.vertex";
  10947. /**
  10948. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  10949. * This is the base class of any Procedural texture and contains most of the shareable code.
  10950. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10951. */
  10952. export class ProceduralTexture extends Texture {
  10953. isCube: boolean;
  10954. /**
  10955. * Define if the texture is enabled or not (disabled texture will not render)
  10956. */
  10957. isEnabled: boolean;
  10958. /**
  10959. * Define if the texture must be cleared before rendering (default is true)
  10960. */
  10961. autoClear: boolean;
  10962. /**
  10963. * Callback called when the texture is generated
  10964. */
  10965. onGenerated: () => void;
  10966. /**
  10967. * Event raised when the texture is generated
  10968. */
  10969. onGeneratedObservable: Observable<ProceduralTexture>;
  10970. /** @hidden */
  10971. _generateMipMaps: boolean;
  10972. /** @hidden **/
  10973. _effect: Effect;
  10974. /** @hidden */
  10975. _textures: {
  10976. [key: string]: Texture;
  10977. };
  10978. private _size;
  10979. private _currentRefreshId;
  10980. private _frameId;
  10981. private _refreshRate;
  10982. private _vertexBuffers;
  10983. private _indexBuffer;
  10984. private _uniforms;
  10985. private _samplers;
  10986. private _fragment;
  10987. private _floats;
  10988. private _ints;
  10989. private _floatsArrays;
  10990. private _colors3;
  10991. private _colors4;
  10992. private _vectors2;
  10993. private _vectors3;
  10994. private _matrices;
  10995. private _fallbackTexture;
  10996. private _fallbackTextureUsed;
  10997. private _engine;
  10998. private _cachedDefines;
  10999. private _contentUpdateId;
  11000. private _contentData;
  11001. /**
  11002. * Instantiates a new procedural texture.
  11003. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11004. * This is the base class of any Procedural texture and contains most of the shareable code.
  11005. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11006. * @param name Define the name of the texture
  11007. * @param size Define the size of the texture to create
  11008. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11009. * @param scene Define the scene the texture belongs to
  11010. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11011. * @param generateMipMaps Define if the texture should creates mip maps or not
  11012. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11013. */
  11014. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11015. /**
  11016. * The effect that is created when initializing the post process.
  11017. * @returns The created effect corresponding the the postprocess.
  11018. */
  11019. getEffect(): Effect;
  11020. /**
  11021. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11022. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11023. */
  11024. getContent(): Nullable<ArrayBufferView>;
  11025. private _createIndexBuffer;
  11026. /** @hidden */
  11027. _rebuild(): void;
  11028. /**
  11029. * Resets the texture in order to recreate its associated resources.
  11030. * This can be called in case of context loss
  11031. */
  11032. reset(): void;
  11033. protected _getDefines(): string;
  11034. /**
  11035. * Is the texture ready to be used ? (rendered at least once)
  11036. * @returns true if ready, otherwise, false.
  11037. */
  11038. isReady(): boolean;
  11039. /**
  11040. * Resets the refresh counter of the texture and start bak from scratch.
  11041. * Could be useful to regenerate the texture if it is setup to render only once.
  11042. */
  11043. resetRefreshCounter(): void;
  11044. /**
  11045. * Set the fragment shader to use in order to render the texture.
  11046. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11047. */
  11048. setFragment(fragment: any): void;
  11049. /**
  11050. * Define the refresh rate of the texture or the rendering frequency.
  11051. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11052. */
  11053. get refreshRate(): number;
  11054. set refreshRate(value: number);
  11055. /** @hidden */
  11056. _shouldRender(): boolean;
  11057. /**
  11058. * Get the size the texture is rendering at.
  11059. * @returns the size (texture is always squared)
  11060. */
  11061. getRenderSize(): number;
  11062. /**
  11063. * Resize the texture to new value.
  11064. * @param size Define the new size the texture should have
  11065. * @param generateMipMaps Define whether the new texture should create mip maps
  11066. */
  11067. resize(size: number, generateMipMaps: boolean): void;
  11068. private _checkUniform;
  11069. /**
  11070. * Set a texture in the shader program used to render.
  11071. * @param name Define the name of the uniform samplers as defined in the shader
  11072. * @param texture Define the texture to bind to this sampler
  11073. * @return the texture itself allowing "fluent" like uniform updates
  11074. */
  11075. setTexture(name: string, texture: Texture): ProceduralTexture;
  11076. /**
  11077. * Set a float in the shader.
  11078. * @param name Define the name of the uniform as defined in the shader
  11079. * @param value Define the value to give to the uniform
  11080. * @return the texture itself allowing "fluent" like uniform updates
  11081. */
  11082. setFloat(name: string, value: number): ProceduralTexture;
  11083. /**
  11084. * Set a int in the shader.
  11085. * @param name Define the name of the uniform as defined in the shader
  11086. * @param value Define the value to give to the uniform
  11087. * @return the texture itself allowing "fluent" like uniform updates
  11088. */
  11089. setInt(name: string, value: number): ProceduralTexture;
  11090. /**
  11091. * Set an array of floats in the shader.
  11092. * @param name Define the name of the uniform as defined in the shader
  11093. * @param value Define the value to give to the uniform
  11094. * @return the texture itself allowing "fluent" like uniform updates
  11095. */
  11096. setFloats(name: string, value: number[]): ProceduralTexture;
  11097. /**
  11098. * Set a vec3 in the shader from a Color3.
  11099. * @param name Define the name of the uniform as defined in the shader
  11100. * @param value Define the value to give to the uniform
  11101. * @return the texture itself allowing "fluent" like uniform updates
  11102. */
  11103. setColor3(name: string, value: Color3): ProceduralTexture;
  11104. /**
  11105. * Set a vec4 in the shader from a Color4.
  11106. * @param name Define the name of the uniform as defined in the shader
  11107. * @param value Define the value to give to the uniform
  11108. * @return the texture itself allowing "fluent" like uniform updates
  11109. */
  11110. setColor4(name: string, value: Color4): ProceduralTexture;
  11111. /**
  11112. * Set a vec2 in the shader from a Vector2.
  11113. * @param name Define the name of the uniform as defined in the shader
  11114. * @param value Define the value to give to the uniform
  11115. * @return the texture itself allowing "fluent" like uniform updates
  11116. */
  11117. setVector2(name: string, value: Vector2): ProceduralTexture;
  11118. /**
  11119. * Set a vec3 in the shader from a Vector3.
  11120. * @param name Define the name of the uniform as defined in the shader
  11121. * @param value Define the value to give to the uniform
  11122. * @return the texture itself allowing "fluent" like uniform updates
  11123. */
  11124. setVector3(name: string, value: Vector3): ProceduralTexture;
  11125. /**
  11126. * Set a mat4 in the shader from a MAtrix.
  11127. * @param name Define the name of the uniform as defined in the shader
  11128. * @param value Define the value to give to the uniform
  11129. * @return the texture itself allowing "fluent" like uniform updates
  11130. */
  11131. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11132. /**
  11133. * Render the texture to its associated render target.
  11134. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11135. */
  11136. render(useCameraPostProcess?: boolean): void;
  11137. /**
  11138. * Clone the texture.
  11139. * @returns the cloned texture
  11140. */
  11141. clone(): ProceduralTexture;
  11142. /**
  11143. * Dispose the texture and release its asoociated resources.
  11144. */
  11145. dispose(): void;
  11146. }
  11147. }
  11148. declare module "babylonjs/Particles/baseParticleSystem" {
  11149. import { Nullable } from "babylonjs/types";
  11150. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11152. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11153. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11154. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11155. import { Scene } from "babylonjs/scene";
  11156. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11157. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11158. import { Texture } from "babylonjs/Materials/Textures/texture";
  11159. import { Color4 } from "babylonjs/Maths/math.color";
  11160. import { Animation } from "babylonjs/Animations/animation";
  11161. /**
  11162. * This represents the base class for particle system in Babylon.
  11163. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11164. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11165. * @example https://doc.babylonjs.com/babylon101/particles
  11166. */
  11167. export class BaseParticleSystem {
  11168. /**
  11169. * Source color is added to the destination color without alpha affecting the result
  11170. */
  11171. static BLENDMODE_ONEONE: number;
  11172. /**
  11173. * Blend current color and particle color using particle’s alpha
  11174. */
  11175. static BLENDMODE_STANDARD: number;
  11176. /**
  11177. * Add current color and particle color multiplied by particle’s alpha
  11178. */
  11179. static BLENDMODE_ADD: number;
  11180. /**
  11181. * Multiply current color with particle color
  11182. */
  11183. static BLENDMODE_MULTIPLY: number;
  11184. /**
  11185. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11186. */
  11187. static BLENDMODE_MULTIPLYADD: number;
  11188. /**
  11189. * List of animations used by the particle system.
  11190. */
  11191. animations: Animation[];
  11192. /**
  11193. * The id of the Particle system.
  11194. */
  11195. id: string;
  11196. /**
  11197. * The friendly name of the Particle system.
  11198. */
  11199. name: string;
  11200. /**
  11201. * The rendering group used by the Particle system to chose when to render.
  11202. */
  11203. renderingGroupId: number;
  11204. /**
  11205. * The emitter represents the Mesh or position we are attaching the particle system to.
  11206. */
  11207. emitter: Nullable<AbstractMesh | Vector3>;
  11208. /**
  11209. * The maximum number of particles to emit per frame
  11210. */
  11211. emitRate: number;
  11212. /**
  11213. * If you want to launch only a few particles at once, that can be done, as well.
  11214. */
  11215. manualEmitCount: number;
  11216. /**
  11217. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11218. */
  11219. updateSpeed: number;
  11220. /**
  11221. * The amount of time the particle system is running (depends of the overall update speed).
  11222. */
  11223. targetStopDuration: number;
  11224. /**
  11225. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11226. */
  11227. disposeOnStop: boolean;
  11228. /**
  11229. * Minimum power of emitting particles.
  11230. */
  11231. minEmitPower: number;
  11232. /**
  11233. * Maximum power of emitting particles.
  11234. */
  11235. maxEmitPower: number;
  11236. /**
  11237. * Minimum life time of emitting particles.
  11238. */
  11239. minLifeTime: number;
  11240. /**
  11241. * Maximum life time of emitting particles.
  11242. */
  11243. maxLifeTime: number;
  11244. /**
  11245. * Minimum Size of emitting particles.
  11246. */
  11247. minSize: number;
  11248. /**
  11249. * Maximum Size of emitting particles.
  11250. */
  11251. maxSize: number;
  11252. /**
  11253. * Minimum scale of emitting particles on X axis.
  11254. */
  11255. minScaleX: number;
  11256. /**
  11257. * Maximum scale of emitting particles on X axis.
  11258. */
  11259. maxScaleX: number;
  11260. /**
  11261. * Minimum scale of emitting particles on Y axis.
  11262. */
  11263. minScaleY: number;
  11264. /**
  11265. * Maximum scale of emitting particles on Y axis.
  11266. */
  11267. maxScaleY: number;
  11268. /**
  11269. * Gets or sets the minimal initial rotation in radians.
  11270. */
  11271. minInitialRotation: number;
  11272. /**
  11273. * Gets or sets the maximal initial rotation in radians.
  11274. */
  11275. maxInitialRotation: number;
  11276. /**
  11277. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11278. */
  11279. minAngularSpeed: number;
  11280. /**
  11281. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11282. */
  11283. maxAngularSpeed: number;
  11284. /**
  11285. * The texture used to render each particle. (this can be a spritesheet)
  11286. */
  11287. particleTexture: Nullable<Texture>;
  11288. /**
  11289. * The layer mask we are rendering the particles through.
  11290. */
  11291. layerMask: number;
  11292. /**
  11293. * This can help using your own shader to render the particle system.
  11294. * The according effect will be created
  11295. */
  11296. customShader: any;
  11297. /**
  11298. * By default particle system starts as soon as they are created. This prevents the
  11299. * automatic start to happen and let you decide when to start emitting particles.
  11300. */
  11301. preventAutoStart: boolean;
  11302. private _noiseTexture;
  11303. /**
  11304. * Gets or sets a texture used to add random noise to particle positions
  11305. */
  11306. get noiseTexture(): Nullable<ProceduralTexture>;
  11307. set noiseTexture(value: Nullable<ProceduralTexture>);
  11308. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11309. noiseStrength: Vector3;
  11310. /**
  11311. * Callback triggered when the particle animation is ending.
  11312. */
  11313. onAnimationEnd: Nullable<() => void>;
  11314. /**
  11315. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11316. */
  11317. blendMode: number;
  11318. /**
  11319. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11320. * to override the particles.
  11321. */
  11322. forceDepthWrite: boolean;
  11323. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  11324. preWarmCycles: number;
  11325. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11326. preWarmStepOffset: number;
  11327. /**
  11328. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  11329. */
  11330. spriteCellChangeSpeed: number;
  11331. /**
  11332. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11333. */
  11334. startSpriteCellID: number;
  11335. /**
  11336. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11337. */
  11338. endSpriteCellID: number;
  11339. /**
  11340. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11341. */
  11342. spriteCellWidth: number;
  11343. /**
  11344. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11345. */
  11346. spriteCellHeight: number;
  11347. /**
  11348. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11349. */
  11350. spriteRandomStartCell: boolean;
  11351. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11352. translationPivot: Vector2;
  11353. /** @hidden */
  11354. protected _isAnimationSheetEnabled: boolean;
  11355. /**
  11356. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11357. */
  11358. beginAnimationOnStart: boolean;
  11359. /**
  11360. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11361. */
  11362. beginAnimationFrom: number;
  11363. /**
  11364. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11365. */
  11366. beginAnimationTo: number;
  11367. /**
  11368. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11369. */
  11370. beginAnimationLoop: boolean;
  11371. /**
  11372. * Gets or sets a world offset applied to all particles
  11373. */
  11374. worldOffset: Vector3;
  11375. /**
  11376. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11377. */
  11378. get isAnimationSheetEnabled(): boolean;
  11379. set isAnimationSheetEnabled(value: boolean);
  11380. /**
  11381. * Get hosting scene
  11382. * @returns the scene
  11383. */
  11384. getScene(): Scene;
  11385. /**
  11386. * You can use gravity if you want to give an orientation to your particles.
  11387. */
  11388. gravity: Vector3;
  11389. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11390. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11391. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11392. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11393. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11394. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11395. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11396. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11397. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11398. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11399. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11400. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11401. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11402. /**
  11403. * Defines the delay in milliseconds before starting the system (0 by default)
  11404. */
  11405. startDelay: number;
  11406. /**
  11407. * Gets the current list of drag gradients.
  11408. * You must use addDragGradient and removeDragGradient to udpate this list
  11409. * @returns the list of drag gradients
  11410. */
  11411. getDragGradients(): Nullable<Array<FactorGradient>>;
  11412. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11413. limitVelocityDamping: number;
  11414. /**
  11415. * Gets the current list of limit velocity gradients.
  11416. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11417. * @returns the list of limit velocity gradients
  11418. */
  11419. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11420. /**
  11421. * Gets the current list of color gradients.
  11422. * You must use addColorGradient and removeColorGradient to udpate this list
  11423. * @returns the list of color gradients
  11424. */
  11425. getColorGradients(): Nullable<Array<ColorGradient>>;
  11426. /**
  11427. * Gets the current list of size gradients.
  11428. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11429. * @returns the list of size gradients
  11430. */
  11431. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11432. /**
  11433. * Gets the current list of color remap gradients.
  11434. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11435. * @returns the list of color remap gradients
  11436. */
  11437. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11438. /**
  11439. * Gets the current list of alpha remap gradients.
  11440. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11441. * @returns the list of alpha remap gradients
  11442. */
  11443. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11444. /**
  11445. * Gets the current list of life time gradients.
  11446. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11447. * @returns the list of life time gradients
  11448. */
  11449. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11450. /**
  11451. * Gets the current list of angular speed gradients.
  11452. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11453. * @returns the list of angular speed gradients
  11454. */
  11455. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11456. /**
  11457. * Gets the current list of velocity gradients.
  11458. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11459. * @returns the list of velocity gradients
  11460. */
  11461. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11462. /**
  11463. * Gets the current list of start size gradients.
  11464. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11465. * @returns the list of start size gradients
  11466. */
  11467. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11468. /**
  11469. * Gets the current list of emit rate gradients.
  11470. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11471. * @returns the list of emit rate gradients
  11472. */
  11473. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11474. /**
  11475. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11476. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11477. */
  11478. get direction1(): Vector3;
  11479. set direction1(value: Vector3);
  11480. /**
  11481. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11482. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11483. */
  11484. get direction2(): Vector3;
  11485. set direction2(value: Vector3);
  11486. /**
  11487. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11488. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11489. */
  11490. get minEmitBox(): Vector3;
  11491. set minEmitBox(value: Vector3);
  11492. /**
  11493. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11494. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11495. */
  11496. get maxEmitBox(): Vector3;
  11497. set maxEmitBox(value: Vector3);
  11498. /**
  11499. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11500. */
  11501. color1: Color4;
  11502. /**
  11503. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11504. */
  11505. color2: Color4;
  11506. /**
  11507. * Color the particle will have at the end of its lifetime
  11508. */
  11509. colorDead: Color4;
  11510. /**
  11511. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11512. */
  11513. textureMask: Color4;
  11514. /**
  11515. * The particle emitter type defines the emitter used by the particle system.
  11516. * It can be for example box, sphere, or cone...
  11517. */
  11518. particleEmitterType: IParticleEmitterType;
  11519. /** @hidden */
  11520. _isSubEmitter: boolean;
  11521. /**
  11522. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11523. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11524. */
  11525. billboardMode: number;
  11526. protected _isBillboardBased: boolean;
  11527. /**
  11528. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11529. */
  11530. get isBillboardBased(): boolean;
  11531. set isBillboardBased(value: boolean);
  11532. /**
  11533. * The scene the particle system belongs to.
  11534. */
  11535. protected _scene: Scene;
  11536. /**
  11537. * Local cache of defines for image processing.
  11538. */
  11539. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11540. /**
  11541. * Default configuration related to image processing available in the standard Material.
  11542. */
  11543. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11544. /**
  11545. * Gets the image processing configuration used either in this material.
  11546. */
  11547. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11548. /**
  11549. * Sets the Default image processing configuration used either in the this material.
  11550. *
  11551. * If sets to null, the scene one is in use.
  11552. */
  11553. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11554. /**
  11555. * Attaches a new image processing configuration to the Standard Material.
  11556. * @param configuration
  11557. */
  11558. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11559. /** @hidden */
  11560. protected _reset(): void;
  11561. /** @hidden */
  11562. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11563. /**
  11564. * Instantiates a particle system.
  11565. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11566. * @param name The name of the particle system
  11567. */
  11568. constructor(name: string);
  11569. /**
  11570. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11571. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11572. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11573. * @returns the emitter
  11574. */
  11575. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11576. /**
  11577. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11578. * @param radius The radius of the hemisphere to emit from
  11579. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11580. * @returns the emitter
  11581. */
  11582. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11583. /**
  11584. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11585. * @param radius The radius of the sphere to emit from
  11586. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11587. * @returns the emitter
  11588. */
  11589. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11590. /**
  11591. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11592. * @param radius The radius of the sphere to emit from
  11593. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11594. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11595. * @returns the emitter
  11596. */
  11597. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11598. /**
  11599. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11600. * @param radius The radius of the emission cylinder
  11601. * @param height The height of the emission cylinder
  11602. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11603. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11604. * @returns the emitter
  11605. */
  11606. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11607. /**
  11608. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11609. * @param radius The radius of the cylinder to emit from
  11610. * @param height The height of the emission cylinder
  11611. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11612. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11613. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11614. * @returns the emitter
  11615. */
  11616. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11617. /**
  11618. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11619. * @param radius The radius of the cone to emit from
  11620. * @param angle The base angle of the cone
  11621. * @returns the emitter
  11622. */
  11623. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11624. /**
  11625. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11626. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11627. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11628. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11629. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11630. * @returns the emitter
  11631. */
  11632. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11633. }
  11634. }
  11635. declare module "babylonjs/Particles/subEmitter" {
  11636. import { Scene } from "babylonjs/scene";
  11637. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11638. /**
  11639. * Type of sub emitter
  11640. */
  11641. export enum SubEmitterType {
  11642. /**
  11643. * Attached to the particle over it's lifetime
  11644. */
  11645. ATTACHED = 0,
  11646. /**
  11647. * Created when the particle dies
  11648. */
  11649. END = 1
  11650. }
  11651. /**
  11652. * Sub emitter class used to emit particles from an existing particle
  11653. */
  11654. export class SubEmitter {
  11655. /**
  11656. * the particle system to be used by the sub emitter
  11657. */
  11658. particleSystem: ParticleSystem;
  11659. /**
  11660. * Type of the submitter (Default: END)
  11661. */
  11662. type: SubEmitterType;
  11663. /**
  11664. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  11665. * Note: This only is supported when using an emitter of type Mesh
  11666. */
  11667. inheritDirection: boolean;
  11668. /**
  11669. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11670. */
  11671. inheritedVelocityAmount: number;
  11672. /**
  11673. * Creates a sub emitter
  11674. * @param particleSystem the particle system to be used by the sub emitter
  11675. */
  11676. constructor(
  11677. /**
  11678. * the particle system to be used by the sub emitter
  11679. */
  11680. particleSystem: ParticleSystem);
  11681. /**
  11682. * Clones the sub emitter
  11683. * @returns the cloned sub emitter
  11684. */
  11685. clone(): SubEmitter;
  11686. /**
  11687. * Serialize current object to a JSON object
  11688. * @returns the serialized object
  11689. */
  11690. serialize(): any;
  11691. /** @hidden */
  11692. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11693. /**
  11694. * Creates a new SubEmitter from a serialized JSON version
  11695. * @param serializationObject defines the JSON object to read from
  11696. * @param scene defines the hosting scene
  11697. * @param rootUrl defines the rootUrl for data loading
  11698. * @returns a new SubEmitter
  11699. */
  11700. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11701. /** Release associated resources */
  11702. dispose(): void;
  11703. }
  11704. }
  11705. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11706. /** @hidden */
  11707. export var imageProcessingDeclaration: {
  11708. name: string;
  11709. shader: string;
  11710. };
  11711. }
  11712. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11713. /** @hidden */
  11714. export var imageProcessingFunctions: {
  11715. name: string;
  11716. shader: string;
  11717. };
  11718. }
  11719. declare module "babylonjs/Shaders/particles.fragment" {
  11720. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11721. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11722. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11723. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11724. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11725. /** @hidden */
  11726. export var particlesPixelShader: {
  11727. name: string;
  11728. shader: string;
  11729. };
  11730. }
  11731. declare module "babylonjs/Shaders/particles.vertex" {
  11732. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11733. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11734. /** @hidden */
  11735. export var particlesVertexShader: {
  11736. name: string;
  11737. shader: string;
  11738. };
  11739. }
  11740. declare module "babylonjs/Particles/particleSystem" {
  11741. import { Nullable } from "babylonjs/types";
  11742. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11743. import { Observable } from "babylonjs/Misc/observable";
  11744. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11745. import { Effect } from "babylonjs/Materials/effect";
  11746. import { Scene, IDisposable } from "babylonjs/scene";
  11747. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11748. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11749. import { Particle } from "babylonjs/Particles/particle";
  11750. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11751. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11752. import "babylonjs/Shaders/particles.fragment";
  11753. import "babylonjs/Shaders/particles.vertex";
  11754. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11755. /**
  11756. * This represents a particle system in Babylon.
  11757. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11758. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11759. * @example https://doc.babylonjs.com/babylon101/particles
  11760. */
  11761. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11762. /**
  11763. * Billboard mode will only apply to Y axis
  11764. */
  11765. static readonly BILLBOARDMODE_Y: number;
  11766. /**
  11767. * Billboard mode will apply to all axes
  11768. */
  11769. static readonly BILLBOARDMODE_ALL: number;
  11770. /**
  11771. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11772. */
  11773. static readonly BILLBOARDMODE_STRETCHED: number;
  11774. /**
  11775. * This function can be defined to provide custom update for active particles.
  11776. * This function will be called instead of regular update (age, position, color, etc.).
  11777. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11778. */
  11779. updateFunction: (particles: Particle[]) => void;
  11780. private _emitterWorldMatrix;
  11781. /**
  11782. * This function can be defined to specify initial direction for every new particle.
  11783. * It by default use the emitterType defined function
  11784. */
  11785. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11786. /**
  11787. * This function can be defined to specify initial position for every new particle.
  11788. * It by default use the emitterType defined function
  11789. */
  11790. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11791. /**
  11792. * @hidden
  11793. */
  11794. _inheritedVelocityOffset: Vector3;
  11795. /**
  11796. * An event triggered when the system is disposed
  11797. */
  11798. onDisposeObservable: Observable<ParticleSystem>;
  11799. private _onDisposeObserver;
  11800. /**
  11801. * Sets a callback that will be triggered when the system is disposed
  11802. */
  11803. set onDispose(callback: () => void);
  11804. private _particles;
  11805. private _epsilon;
  11806. private _capacity;
  11807. private _stockParticles;
  11808. private _newPartsExcess;
  11809. private _vertexData;
  11810. private _vertexBuffer;
  11811. private _vertexBuffers;
  11812. private _spriteBuffer;
  11813. private _indexBuffer;
  11814. private _effect;
  11815. private _customEffect;
  11816. private _cachedDefines;
  11817. private _scaledColorStep;
  11818. private _colorDiff;
  11819. private _scaledDirection;
  11820. private _scaledGravity;
  11821. private _currentRenderId;
  11822. private _alive;
  11823. private _useInstancing;
  11824. private _started;
  11825. private _stopped;
  11826. private _actualFrame;
  11827. private _scaledUpdateSpeed;
  11828. private _vertexBufferSize;
  11829. /** @hidden */
  11830. _currentEmitRateGradient: Nullable<FactorGradient>;
  11831. /** @hidden */
  11832. _currentEmitRate1: number;
  11833. /** @hidden */
  11834. _currentEmitRate2: number;
  11835. /** @hidden */
  11836. _currentStartSizeGradient: Nullable<FactorGradient>;
  11837. /** @hidden */
  11838. _currentStartSize1: number;
  11839. /** @hidden */
  11840. _currentStartSize2: number;
  11841. private readonly _rawTextureWidth;
  11842. private _rampGradientsTexture;
  11843. private _useRampGradients;
  11844. /** Gets or sets a boolean indicating that ramp gradients must be used
  11845. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11846. */
  11847. get useRampGradients(): boolean;
  11848. set useRampGradients(value: boolean);
  11849. /**
  11850. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  11851. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  11852. */
  11853. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11854. private _subEmitters;
  11855. /**
  11856. * @hidden
  11857. * If the particle systems emitter should be disposed when the particle system is disposed
  11858. */
  11859. _disposeEmitterOnDispose: boolean;
  11860. /**
  11861. * The current active Sub-systems, this property is used by the root particle system only.
  11862. */
  11863. activeSubSystems: Array<ParticleSystem>;
  11864. /**
  11865. * Specifies if the particles are updated in emitter local space or world space
  11866. */
  11867. isLocal: boolean;
  11868. private _rootParticleSystem;
  11869. /**
  11870. * Gets the current list of active particles
  11871. */
  11872. get particles(): Particle[];
  11873. /**
  11874. * Returns the string "ParticleSystem"
  11875. * @returns a string containing the class name
  11876. */
  11877. getClassName(): string;
  11878. /**
  11879. * Instantiates a particle system.
  11880. * 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.
  11881. * @param name The name of the particle system
  11882. * @param capacity The max number of particles alive at the same time
  11883. * @param scene The scene the particle system belongs to
  11884. * @param customEffect a custom effect used to change the way particles are rendered by default
  11885. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11886. * @param epsilon Offset used to render the particles
  11887. */
  11888. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11889. private _addFactorGradient;
  11890. private _removeFactorGradient;
  11891. /**
  11892. * Adds a new life time gradient
  11893. * @param gradient defines the gradient to use (between 0 and 1)
  11894. * @param factor defines the life time factor to affect to the specified gradient
  11895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11896. * @returns the current particle system
  11897. */
  11898. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11899. /**
  11900. * Remove a specific life time gradient
  11901. * @param gradient defines the gradient to remove
  11902. * @returns the current particle system
  11903. */
  11904. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11905. /**
  11906. * Adds a new size gradient
  11907. * @param gradient defines the gradient to use (between 0 and 1)
  11908. * @param factor defines the size factor to affect to the specified gradient
  11909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11910. * @returns the current particle system
  11911. */
  11912. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11913. /**
  11914. * Remove a specific size gradient
  11915. * @param gradient defines the gradient to remove
  11916. * @returns the current particle system
  11917. */
  11918. removeSizeGradient(gradient: number): IParticleSystem;
  11919. /**
  11920. * Adds a new color remap gradient
  11921. * @param gradient defines the gradient to use (between 0 and 1)
  11922. * @param min defines the color remap minimal range
  11923. * @param max defines the color remap maximal range
  11924. * @returns the current particle system
  11925. */
  11926. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11927. /**
  11928. * Remove a specific color remap gradient
  11929. * @param gradient defines the gradient to remove
  11930. * @returns the current particle system
  11931. */
  11932. removeColorRemapGradient(gradient: number): IParticleSystem;
  11933. /**
  11934. * Adds a new alpha remap gradient
  11935. * @param gradient defines the gradient to use (between 0 and 1)
  11936. * @param min defines the alpha remap minimal range
  11937. * @param max defines the alpha remap maximal range
  11938. * @returns the current particle system
  11939. */
  11940. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11941. /**
  11942. * Remove a specific alpha remap gradient
  11943. * @param gradient defines the gradient to remove
  11944. * @returns the current particle system
  11945. */
  11946. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11947. /**
  11948. * Adds a new angular speed gradient
  11949. * @param gradient defines the gradient to use (between 0 and 1)
  11950. * @param factor defines the angular speed to affect to the specified gradient
  11951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11952. * @returns the current particle system
  11953. */
  11954. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11955. /**
  11956. * Remove a specific angular speed gradient
  11957. * @param gradient defines the gradient to remove
  11958. * @returns the current particle system
  11959. */
  11960. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11961. /**
  11962. * Adds a new velocity gradient
  11963. * @param gradient defines the gradient to use (between 0 and 1)
  11964. * @param factor defines the velocity to affect to the specified gradient
  11965. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11966. * @returns the current particle system
  11967. */
  11968. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11969. /**
  11970. * Remove a specific velocity gradient
  11971. * @param gradient defines the gradient to remove
  11972. * @returns the current particle system
  11973. */
  11974. removeVelocityGradient(gradient: number): IParticleSystem;
  11975. /**
  11976. * Adds a new limit velocity gradient
  11977. * @param gradient defines the gradient to use (between 0 and 1)
  11978. * @param factor defines the limit velocity value to affect to the specified gradient
  11979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11980. * @returns the current particle system
  11981. */
  11982. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11983. /**
  11984. * Remove a specific limit velocity gradient
  11985. * @param gradient defines the gradient to remove
  11986. * @returns the current particle system
  11987. */
  11988. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11989. /**
  11990. * Adds a new drag gradient
  11991. * @param gradient defines the gradient to use (between 0 and 1)
  11992. * @param factor defines the drag value to affect to the specified gradient
  11993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11994. * @returns the current particle system
  11995. */
  11996. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11997. /**
  11998. * Remove a specific drag gradient
  11999. * @param gradient defines the gradient to remove
  12000. * @returns the current particle system
  12001. */
  12002. removeDragGradient(gradient: number): IParticleSystem;
  12003. /**
  12004. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12005. * @param gradient defines the gradient to use (between 0 and 1)
  12006. * @param factor defines the emit rate value to affect to the specified gradient
  12007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12008. * @returns the current particle system
  12009. */
  12010. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12011. /**
  12012. * Remove a specific emit rate gradient
  12013. * @param gradient defines the gradient to remove
  12014. * @returns the current particle system
  12015. */
  12016. removeEmitRateGradient(gradient: number): IParticleSystem;
  12017. /**
  12018. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12019. * @param gradient defines the gradient to use (between 0 and 1)
  12020. * @param factor defines the start size value to affect to the specified gradient
  12021. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12022. * @returns the current particle system
  12023. */
  12024. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12025. /**
  12026. * Remove a specific start size gradient
  12027. * @param gradient defines the gradient to remove
  12028. * @returns the current particle system
  12029. */
  12030. removeStartSizeGradient(gradient: number): IParticleSystem;
  12031. private _createRampGradientTexture;
  12032. /**
  12033. * Gets the current list of ramp gradients.
  12034. * You must use addRampGradient and removeRampGradient to udpate this list
  12035. * @returns the list of ramp gradients
  12036. */
  12037. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12038. /**
  12039. * Adds a new ramp gradient used to remap particle colors
  12040. * @param gradient defines the gradient to use (between 0 and 1)
  12041. * @param color defines the color to affect to the specified gradient
  12042. * @returns the current particle system
  12043. */
  12044. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12045. /**
  12046. * Remove a specific ramp gradient
  12047. * @param gradient defines the gradient to remove
  12048. * @returns the current particle system
  12049. */
  12050. removeRampGradient(gradient: number): ParticleSystem;
  12051. /**
  12052. * Adds a new color gradient
  12053. * @param gradient defines the gradient to use (between 0 and 1)
  12054. * @param color1 defines the color to affect to the specified gradient
  12055. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12056. * @returns this particle system
  12057. */
  12058. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12059. /**
  12060. * Remove a specific color gradient
  12061. * @param gradient defines the gradient to remove
  12062. * @returns this particle system
  12063. */
  12064. removeColorGradient(gradient: number): IParticleSystem;
  12065. private _fetchR;
  12066. protected _reset(): void;
  12067. private _resetEffect;
  12068. private _createVertexBuffers;
  12069. private _createIndexBuffer;
  12070. /**
  12071. * Gets the maximum number of particles active at the same time.
  12072. * @returns The max number of active particles.
  12073. */
  12074. getCapacity(): number;
  12075. /**
  12076. * Gets whether there are still active particles in the system.
  12077. * @returns True if it is alive, otherwise false.
  12078. */
  12079. isAlive(): boolean;
  12080. /**
  12081. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12082. * @returns True if it has been started, otherwise false.
  12083. */
  12084. isStarted(): boolean;
  12085. private _prepareSubEmitterInternalArray;
  12086. /**
  12087. * Starts the particle system and begins to emit
  12088. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12089. */
  12090. start(delay?: number): void;
  12091. /**
  12092. * Stops the particle system.
  12093. * @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.
  12094. */
  12095. stop(stopSubEmitters?: boolean): void;
  12096. /**
  12097. * Remove all active particles
  12098. */
  12099. reset(): void;
  12100. /**
  12101. * @hidden (for internal use only)
  12102. */
  12103. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12104. /**
  12105. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12106. * Its lifetime will start back at 0.
  12107. */
  12108. recycleParticle: (particle: Particle) => void;
  12109. private _stopSubEmitters;
  12110. private _createParticle;
  12111. private _removeFromRoot;
  12112. private _emitFromParticle;
  12113. private _update;
  12114. /** @hidden */
  12115. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12116. /** @hidden */
  12117. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12118. /** @hidden */
  12119. private _getEffect;
  12120. /**
  12121. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12122. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12123. */
  12124. animate(preWarmOnly?: boolean): void;
  12125. private _appendParticleVertices;
  12126. /**
  12127. * Rebuilds the particle system.
  12128. */
  12129. rebuild(): void;
  12130. /**
  12131. * Is this system ready to be used/rendered
  12132. * @return true if the system is ready
  12133. */
  12134. isReady(): boolean;
  12135. private _render;
  12136. /**
  12137. * Renders the particle system in its current state.
  12138. * @returns the current number of particles
  12139. */
  12140. render(): number;
  12141. /**
  12142. * Disposes the particle system and free the associated resources
  12143. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12144. */
  12145. dispose(disposeTexture?: boolean): void;
  12146. /**
  12147. * Clones the particle system.
  12148. * @param name The name of the cloned object
  12149. * @param newEmitter The new emitter to use
  12150. * @returns the cloned particle system
  12151. */
  12152. clone(name: string, newEmitter: any): ParticleSystem;
  12153. /**
  12154. * Serializes the particle system to a JSON object.
  12155. * @returns the JSON object
  12156. */
  12157. serialize(): any;
  12158. /** @hidden */
  12159. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12160. /** @hidden */
  12161. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12162. /**
  12163. * Parses a JSON object to create a particle system.
  12164. * @param parsedParticleSystem The JSON object to parse
  12165. * @param scene The scene to create the particle system in
  12166. * @param rootUrl The root url to use to load external dependencies like texture
  12167. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12168. * @returns the Parsed particle system
  12169. */
  12170. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12171. }
  12172. }
  12173. declare module "babylonjs/Particles/particle" {
  12174. import { Nullable } from "babylonjs/types";
  12175. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12176. import { Color4 } from "babylonjs/Maths/math.color";
  12177. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12178. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12179. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12180. /**
  12181. * A particle represents one of the element emitted by a particle system.
  12182. * This is mainly define by its coordinates, direction, velocity and age.
  12183. */
  12184. export class Particle {
  12185. /**
  12186. * The particle system the particle belongs to.
  12187. */
  12188. particleSystem: ParticleSystem;
  12189. private static _Count;
  12190. /**
  12191. * Unique ID of the particle
  12192. */
  12193. id: number;
  12194. /**
  12195. * The world position of the particle in the scene.
  12196. */
  12197. position: Vector3;
  12198. /**
  12199. * The world direction of the particle in the scene.
  12200. */
  12201. direction: Vector3;
  12202. /**
  12203. * The color of the particle.
  12204. */
  12205. color: Color4;
  12206. /**
  12207. * The color change of the particle per step.
  12208. */
  12209. colorStep: Color4;
  12210. /**
  12211. * Defines how long will the life of the particle be.
  12212. */
  12213. lifeTime: number;
  12214. /**
  12215. * The current age of the particle.
  12216. */
  12217. age: number;
  12218. /**
  12219. * The current size of the particle.
  12220. */
  12221. size: number;
  12222. /**
  12223. * The current scale of the particle.
  12224. */
  12225. scale: Vector2;
  12226. /**
  12227. * The current angle of the particle.
  12228. */
  12229. angle: number;
  12230. /**
  12231. * Defines how fast is the angle changing.
  12232. */
  12233. angularSpeed: number;
  12234. /**
  12235. * Defines the cell index used by the particle to be rendered from a sprite.
  12236. */
  12237. cellIndex: number;
  12238. /**
  12239. * The information required to support color remapping
  12240. */
  12241. remapData: Vector4;
  12242. /** @hidden */
  12243. _randomCellOffset?: number;
  12244. /** @hidden */
  12245. _initialDirection: Nullable<Vector3>;
  12246. /** @hidden */
  12247. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12248. /** @hidden */
  12249. _initialStartSpriteCellID: number;
  12250. /** @hidden */
  12251. _initialEndSpriteCellID: number;
  12252. /** @hidden */
  12253. _currentColorGradient: Nullable<ColorGradient>;
  12254. /** @hidden */
  12255. _currentColor1: Color4;
  12256. /** @hidden */
  12257. _currentColor2: Color4;
  12258. /** @hidden */
  12259. _currentSizeGradient: Nullable<FactorGradient>;
  12260. /** @hidden */
  12261. _currentSize1: number;
  12262. /** @hidden */
  12263. _currentSize2: number;
  12264. /** @hidden */
  12265. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12266. /** @hidden */
  12267. _currentAngularSpeed1: number;
  12268. /** @hidden */
  12269. _currentAngularSpeed2: number;
  12270. /** @hidden */
  12271. _currentVelocityGradient: Nullable<FactorGradient>;
  12272. /** @hidden */
  12273. _currentVelocity1: number;
  12274. /** @hidden */
  12275. _currentVelocity2: number;
  12276. /** @hidden */
  12277. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12278. /** @hidden */
  12279. _currentLimitVelocity1: number;
  12280. /** @hidden */
  12281. _currentLimitVelocity2: number;
  12282. /** @hidden */
  12283. _currentDragGradient: Nullable<FactorGradient>;
  12284. /** @hidden */
  12285. _currentDrag1: number;
  12286. /** @hidden */
  12287. _currentDrag2: number;
  12288. /** @hidden */
  12289. _randomNoiseCoordinates1: Vector3;
  12290. /** @hidden */
  12291. _randomNoiseCoordinates2: Vector3;
  12292. /** @hidden */
  12293. _localPosition?: Vector3;
  12294. /**
  12295. * Creates a new instance Particle
  12296. * @param particleSystem the particle system the particle belongs to
  12297. */
  12298. constructor(
  12299. /**
  12300. * The particle system the particle belongs to.
  12301. */
  12302. particleSystem: ParticleSystem);
  12303. private updateCellInfoFromSystem;
  12304. /**
  12305. * Defines how the sprite cell index is updated for the particle
  12306. */
  12307. updateCellIndex(): void;
  12308. /** @hidden */
  12309. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12310. /** @hidden */
  12311. _inheritParticleInfoToSubEmitters(): void;
  12312. /** @hidden */
  12313. _reset(): void;
  12314. /**
  12315. * Copy the properties of particle to another one.
  12316. * @param other the particle to copy the information to.
  12317. */
  12318. copyTo(other: Particle): void;
  12319. }
  12320. }
  12321. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12322. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12323. import { Effect } from "babylonjs/Materials/effect";
  12324. import { Particle } from "babylonjs/Particles/particle";
  12325. import { Scene } from "babylonjs/scene";
  12326. /**
  12327. * Particle emitter represents a volume emitting particles.
  12328. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12329. */
  12330. export interface IParticleEmitterType {
  12331. /**
  12332. * Called by the particle System when the direction is computed for the created particle.
  12333. * @param worldMatrix is the world matrix of the particle system
  12334. * @param directionToUpdate is the direction vector to update with the result
  12335. * @param particle is the particle we are computed the direction for
  12336. * @param isLocal defines if the direction should be set in local space
  12337. */
  12338. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12339. /**
  12340. * Called by the particle System when the position is computed for the created particle.
  12341. * @param worldMatrix is the world matrix of the particle system
  12342. * @param positionToUpdate is the position vector to update with the result
  12343. * @param particle is the particle we are computed the position for
  12344. * @param isLocal defines if the position should be set in local space
  12345. */
  12346. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12347. /**
  12348. * Clones the current emitter and returns a copy of it
  12349. * @returns the new emitter
  12350. */
  12351. clone(): IParticleEmitterType;
  12352. /**
  12353. * Called by the GPUParticleSystem to setup the update shader
  12354. * @param effect defines the update shader
  12355. */
  12356. applyToShader(effect: Effect): void;
  12357. /**
  12358. * Returns a string to use to update the GPU particles update shader
  12359. * @returns the effect defines string
  12360. */
  12361. getEffectDefines(): string;
  12362. /**
  12363. * Returns a string representing the class name
  12364. * @returns a string containing the class name
  12365. */
  12366. getClassName(): string;
  12367. /**
  12368. * Serializes the particle system to a JSON object.
  12369. * @returns the JSON object
  12370. */
  12371. serialize(): any;
  12372. /**
  12373. * Parse properties from a JSON object
  12374. * @param serializationObject defines the JSON object
  12375. * @param scene defines the hosting scene
  12376. */
  12377. parse(serializationObject: any, scene: Scene): void;
  12378. }
  12379. }
  12380. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12381. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12382. import { Effect } from "babylonjs/Materials/effect";
  12383. import { Particle } from "babylonjs/Particles/particle";
  12384. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12385. /**
  12386. * Particle emitter emitting particles from the inside of a box.
  12387. * It emits the particles randomly between 2 given directions.
  12388. */
  12389. export class BoxParticleEmitter implements IParticleEmitterType {
  12390. /**
  12391. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12392. */
  12393. direction1: Vector3;
  12394. /**
  12395. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12396. */
  12397. direction2: Vector3;
  12398. /**
  12399. * 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.
  12400. */
  12401. minEmitBox: Vector3;
  12402. /**
  12403. * 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.
  12404. */
  12405. maxEmitBox: Vector3;
  12406. /**
  12407. * Creates a new instance BoxParticleEmitter
  12408. */
  12409. constructor();
  12410. /**
  12411. * Called by the particle System when the direction is computed for the created particle.
  12412. * @param worldMatrix is the world matrix of the particle system
  12413. * @param directionToUpdate is the direction vector to update with the result
  12414. * @param particle is the particle we are computed the direction for
  12415. * @param isLocal defines if the direction should be set in local space
  12416. */
  12417. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12418. /**
  12419. * Called by the particle System when the position is computed for the created particle.
  12420. * @param worldMatrix is the world matrix of the particle system
  12421. * @param positionToUpdate is the position vector to update with the result
  12422. * @param particle is the particle we are computed the position for
  12423. * @param isLocal defines if the position should be set in local space
  12424. */
  12425. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12426. /**
  12427. * Clones the current emitter and returns a copy of it
  12428. * @returns the new emitter
  12429. */
  12430. clone(): BoxParticleEmitter;
  12431. /**
  12432. * Called by the GPUParticleSystem to setup the update shader
  12433. * @param effect defines the update shader
  12434. */
  12435. applyToShader(effect: Effect): void;
  12436. /**
  12437. * Returns a string to use to update the GPU particles update shader
  12438. * @returns a string containng the defines string
  12439. */
  12440. getEffectDefines(): string;
  12441. /**
  12442. * Returns the string "BoxParticleEmitter"
  12443. * @returns a string containing the class name
  12444. */
  12445. getClassName(): string;
  12446. /**
  12447. * Serializes the particle system to a JSON object.
  12448. * @returns the JSON object
  12449. */
  12450. serialize(): any;
  12451. /**
  12452. * Parse properties from a JSON object
  12453. * @param serializationObject defines the JSON object
  12454. */
  12455. parse(serializationObject: any): void;
  12456. }
  12457. }
  12458. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12459. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12460. import { Effect } from "babylonjs/Materials/effect";
  12461. import { Particle } from "babylonjs/Particles/particle";
  12462. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12463. /**
  12464. * Particle emitter emitting particles from the inside of a cone.
  12465. * It emits the particles alongside the cone volume from the base to the particle.
  12466. * The emission direction might be randomized.
  12467. */
  12468. export class ConeParticleEmitter implements IParticleEmitterType {
  12469. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12470. directionRandomizer: number;
  12471. private _radius;
  12472. private _angle;
  12473. private _height;
  12474. /**
  12475. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12476. */
  12477. radiusRange: number;
  12478. /**
  12479. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12480. */
  12481. heightRange: number;
  12482. /**
  12483. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12484. */
  12485. emitFromSpawnPointOnly: boolean;
  12486. /**
  12487. * Gets or sets the radius of the emission cone
  12488. */
  12489. get radius(): number;
  12490. set radius(value: number);
  12491. /**
  12492. * Gets or sets the angle of the emission cone
  12493. */
  12494. get angle(): number;
  12495. set angle(value: number);
  12496. private _buildHeight;
  12497. /**
  12498. * Creates a new instance ConeParticleEmitter
  12499. * @param radius the radius of the emission cone (1 by default)
  12500. * @param angle the cone base angle (PI by default)
  12501. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12502. */
  12503. constructor(radius?: number, angle?: number,
  12504. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12505. directionRandomizer?: number);
  12506. /**
  12507. * Called by the particle System when the direction is computed for the created particle.
  12508. * @param worldMatrix is the world matrix of the particle system
  12509. * @param directionToUpdate is the direction vector to update with the result
  12510. * @param particle is the particle we are computed the direction for
  12511. * @param isLocal defines if the direction should be set in local space
  12512. */
  12513. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12514. /**
  12515. * Called by the particle System when the position is computed for the created particle.
  12516. * @param worldMatrix is the world matrix of the particle system
  12517. * @param positionToUpdate is the position vector to update with the result
  12518. * @param particle is the particle we are computed the position for
  12519. * @param isLocal defines if the position should be set in local space
  12520. */
  12521. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12522. /**
  12523. * Clones the current emitter and returns a copy of it
  12524. * @returns the new emitter
  12525. */
  12526. clone(): ConeParticleEmitter;
  12527. /**
  12528. * Called by the GPUParticleSystem to setup the update shader
  12529. * @param effect defines the update shader
  12530. */
  12531. applyToShader(effect: Effect): void;
  12532. /**
  12533. * Returns a string to use to update the GPU particles update shader
  12534. * @returns a string containng the defines string
  12535. */
  12536. getEffectDefines(): string;
  12537. /**
  12538. * Returns the string "ConeParticleEmitter"
  12539. * @returns a string containing the class name
  12540. */
  12541. getClassName(): string;
  12542. /**
  12543. * Serializes the particle system to a JSON object.
  12544. * @returns the JSON object
  12545. */
  12546. serialize(): any;
  12547. /**
  12548. * Parse properties from a JSON object
  12549. * @param serializationObject defines the JSON object
  12550. */
  12551. parse(serializationObject: any): void;
  12552. }
  12553. }
  12554. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12555. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12556. import { Effect } from "babylonjs/Materials/effect";
  12557. import { Particle } from "babylonjs/Particles/particle";
  12558. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12559. /**
  12560. * Particle emitter emitting particles from the inside of a cylinder.
  12561. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12562. */
  12563. export class CylinderParticleEmitter implements IParticleEmitterType {
  12564. /**
  12565. * The radius of the emission cylinder.
  12566. */
  12567. radius: number;
  12568. /**
  12569. * The height of the emission cylinder.
  12570. */
  12571. height: number;
  12572. /**
  12573. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12574. */
  12575. radiusRange: number;
  12576. /**
  12577. * How much to randomize the particle direction [0-1].
  12578. */
  12579. directionRandomizer: number;
  12580. /**
  12581. * Creates a new instance CylinderParticleEmitter
  12582. * @param radius the radius of the emission cylinder (1 by default)
  12583. * @param height the height of the emission cylinder (1 by default)
  12584. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12585. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12586. */
  12587. constructor(
  12588. /**
  12589. * The radius of the emission cylinder.
  12590. */
  12591. radius?: number,
  12592. /**
  12593. * The height of the emission cylinder.
  12594. */
  12595. height?: number,
  12596. /**
  12597. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12598. */
  12599. radiusRange?: number,
  12600. /**
  12601. * How much to randomize the particle direction [0-1].
  12602. */
  12603. directionRandomizer?: number);
  12604. /**
  12605. * Called by the particle System when the direction is computed for the created particle.
  12606. * @param worldMatrix is the world matrix of the particle system
  12607. * @param directionToUpdate is the direction vector to update with the result
  12608. * @param particle is the particle we are computed the direction for
  12609. * @param isLocal defines if the direction should be set in local space
  12610. */
  12611. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12612. /**
  12613. * Called by the particle System when the position is computed for the created particle.
  12614. * @param worldMatrix is the world matrix of the particle system
  12615. * @param positionToUpdate is the position vector to update with the result
  12616. * @param particle is the particle we are computed the position for
  12617. * @param isLocal defines if the position should be set in local space
  12618. */
  12619. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12620. /**
  12621. * Clones the current emitter and returns a copy of it
  12622. * @returns the new emitter
  12623. */
  12624. clone(): CylinderParticleEmitter;
  12625. /**
  12626. * Called by the GPUParticleSystem to setup the update shader
  12627. * @param effect defines the update shader
  12628. */
  12629. applyToShader(effect: Effect): void;
  12630. /**
  12631. * Returns a string to use to update the GPU particles update shader
  12632. * @returns a string containng the defines string
  12633. */
  12634. getEffectDefines(): string;
  12635. /**
  12636. * Returns the string "CylinderParticleEmitter"
  12637. * @returns a string containing the class name
  12638. */
  12639. getClassName(): string;
  12640. /**
  12641. * Serializes the particle system to a JSON object.
  12642. * @returns the JSON object
  12643. */
  12644. serialize(): any;
  12645. /**
  12646. * Parse properties from a JSON object
  12647. * @param serializationObject defines the JSON object
  12648. */
  12649. parse(serializationObject: any): void;
  12650. }
  12651. /**
  12652. * Particle emitter emitting particles from the inside of a cylinder.
  12653. * It emits the particles randomly between two vectors.
  12654. */
  12655. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12656. /**
  12657. * The min limit of the emission direction.
  12658. */
  12659. direction1: Vector3;
  12660. /**
  12661. * The max limit of the emission direction.
  12662. */
  12663. direction2: Vector3;
  12664. /**
  12665. * Creates a new instance CylinderDirectedParticleEmitter
  12666. * @param radius the radius of the emission cylinder (1 by default)
  12667. * @param height the height of the emission cylinder (1 by default)
  12668. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12669. * @param direction1 the min limit of the emission direction (up vector by default)
  12670. * @param direction2 the max limit of the emission direction (up vector by default)
  12671. */
  12672. constructor(radius?: number, height?: number, radiusRange?: number,
  12673. /**
  12674. * The min limit of the emission direction.
  12675. */
  12676. direction1?: Vector3,
  12677. /**
  12678. * The max limit of the emission direction.
  12679. */
  12680. direction2?: Vector3);
  12681. /**
  12682. * Called by the particle System when the direction is computed for the created particle.
  12683. * @param worldMatrix is the world matrix of the particle system
  12684. * @param directionToUpdate is the direction vector to update with the result
  12685. * @param particle is the particle we are computed the direction for
  12686. */
  12687. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12688. /**
  12689. * Clones the current emitter and returns a copy of it
  12690. * @returns the new emitter
  12691. */
  12692. clone(): CylinderDirectedParticleEmitter;
  12693. /**
  12694. * Called by the GPUParticleSystem to setup the update shader
  12695. * @param effect defines the update shader
  12696. */
  12697. applyToShader(effect: Effect): void;
  12698. /**
  12699. * Returns a string to use to update the GPU particles update shader
  12700. * @returns a string containng the defines string
  12701. */
  12702. getEffectDefines(): string;
  12703. /**
  12704. * Returns the string "CylinderDirectedParticleEmitter"
  12705. * @returns a string containing the class name
  12706. */
  12707. getClassName(): string;
  12708. /**
  12709. * Serializes the particle system to a JSON object.
  12710. * @returns the JSON object
  12711. */
  12712. serialize(): any;
  12713. /**
  12714. * Parse properties from a JSON object
  12715. * @param serializationObject defines the JSON object
  12716. */
  12717. parse(serializationObject: any): void;
  12718. }
  12719. }
  12720. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12721. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12722. import { Effect } from "babylonjs/Materials/effect";
  12723. import { Particle } from "babylonjs/Particles/particle";
  12724. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12725. /**
  12726. * Particle emitter emitting particles from the inside of a hemisphere.
  12727. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12728. */
  12729. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12730. /**
  12731. * The radius of the emission hemisphere.
  12732. */
  12733. radius: number;
  12734. /**
  12735. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12736. */
  12737. radiusRange: number;
  12738. /**
  12739. * How much to randomize the particle direction [0-1].
  12740. */
  12741. directionRandomizer: number;
  12742. /**
  12743. * Creates a new instance HemisphericParticleEmitter
  12744. * @param radius the radius of the emission hemisphere (1 by default)
  12745. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12746. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12747. */
  12748. constructor(
  12749. /**
  12750. * The radius of the emission hemisphere.
  12751. */
  12752. radius?: number,
  12753. /**
  12754. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12755. */
  12756. radiusRange?: number,
  12757. /**
  12758. * How much to randomize the particle direction [0-1].
  12759. */
  12760. directionRandomizer?: number);
  12761. /**
  12762. * Called by the particle System when the direction is computed for the created particle.
  12763. * @param worldMatrix is the world matrix of the particle system
  12764. * @param directionToUpdate is the direction vector to update with the result
  12765. * @param particle is the particle we are computed the direction for
  12766. * @param isLocal defines if the direction should be set in local space
  12767. */
  12768. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12769. /**
  12770. * Called by the particle System when the position is computed for the created particle.
  12771. * @param worldMatrix is the world matrix of the particle system
  12772. * @param positionToUpdate is the position vector to update with the result
  12773. * @param particle is the particle we are computed the position for
  12774. * @param isLocal defines if the position should be set in local space
  12775. */
  12776. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12777. /**
  12778. * Clones the current emitter and returns a copy of it
  12779. * @returns the new emitter
  12780. */
  12781. clone(): HemisphericParticleEmitter;
  12782. /**
  12783. * Called by the GPUParticleSystem to setup the update shader
  12784. * @param effect defines the update shader
  12785. */
  12786. applyToShader(effect: Effect): void;
  12787. /**
  12788. * Returns a string to use to update the GPU particles update shader
  12789. * @returns a string containng the defines string
  12790. */
  12791. getEffectDefines(): string;
  12792. /**
  12793. * Returns the string "HemisphericParticleEmitter"
  12794. * @returns a string containing the class name
  12795. */
  12796. getClassName(): string;
  12797. /**
  12798. * Serializes the particle system to a JSON object.
  12799. * @returns the JSON object
  12800. */
  12801. serialize(): any;
  12802. /**
  12803. * Parse properties from a JSON object
  12804. * @param serializationObject defines the JSON object
  12805. */
  12806. parse(serializationObject: any): void;
  12807. }
  12808. }
  12809. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12810. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12811. import { Effect } from "babylonjs/Materials/effect";
  12812. import { Particle } from "babylonjs/Particles/particle";
  12813. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12814. /**
  12815. * Particle emitter emitting particles from a point.
  12816. * It emits the particles randomly between 2 given directions.
  12817. */
  12818. export class PointParticleEmitter implements IParticleEmitterType {
  12819. /**
  12820. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12821. */
  12822. direction1: Vector3;
  12823. /**
  12824. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12825. */
  12826. direction2: Vector3;
  12827. /**
  12828. * Creates a new instance PointParticleEmitter
  12829. */
  12830. constructor();
  12831. /**
  12832. * Called by the particle System when the direction is computed for the created particle.
  12833. * @param worldMatrix is the world matrix of the particle system
  12834. * @param directionToUpdate is the direction vector to update with the result
  12835. * @param particle is the particle we are computed the direction for
  12836. * @param isLocal defines if the direction should be set in local space
  12837. */
  12838. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12839. /**
  12840. * Called by the particle System when the position is computed for the created particle.
  12841. * @param worldMatrix is the world matrix of the particle system
  12842. * @param positionToUpdate is the position vector to update with the result
  12843. * @param particle is the particle we are computed the position for
  12844. * @param isLocal defines if the position should be set in local space
  12845. */
  12846. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12847. /**
  12848. * Clones the current emitter and returns a copy of it
  12849. * @returns the new emitter
  12850. */
  12851. clone(): PointParticleEmitter;
  12852. /**
  12853. * Called by the GPUParticleSystem to setup the update shader
  12854. * @param effect defines the update shader
  12855. */
  12856. applyToShader(effect: Effect): void;
  12857. /**
  12858. * Returns a string to use to update the GPU particles update shader
  12859. * @returns a string containng the defines string
  12860. */
  12861. getEffectDefines(): string;
  12862. /**
  12863. * Returns the string "PointParticleEmitter"
  12864. * @returns a string containing the class name
  12865. */
  12866. getClassName(): string;
  12867. /**
  12868. * Serializes the particle system to a JSON object.
  12869. * @returns the JSON object
  12870. */
  12871. serialize(): any;
  12872. /**
  12873. * Parse properties from a JSON object
  12874. * @param serializationObject defines the JSON object
  12875. */
  12876. parse(serializationObject: any): void;
  12877. }
  12878. }
  12879. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  12880. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12881. import { Effect } from "babylonjs/Materials/effect";
  12882. import { Particle } from "babylonjs/Particles/particle";
  12883. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12884. /**
  12885. * Particle emitter emitting particles from the inside of a sphere.
  12886. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12887. */
  12888. export class SphereParticleEmitter implements IParticleEmitterType {
  12889. /**
  12890. * The radius of the emission sphere.
  12891. */
  12892. radius: number;
  12893. /**
  12894. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12895. */
  12896. radiusRange: number;
  12897. /**
  12898. * How much to randomize the particle direction [0-1].
  12899. */
  12900. directionRandomizer: number;
  12901. /**
  12902. * Creates a new instance SphereParticleEmitter
  12903. * @param radius the radius of the emission sphere (1 by default)
  12904. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12905. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12906. */
  12907. constructor(
  12908. /**
  12909. * The radius of the emission sphere.
  12910. */
  12911. radius?: number,
  12912. /**
  12913. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12914. */
  12915. radiusRange?: number,
  12916. /**
  12917. * How much to randomize the particle direction [0-1].
  12918. */
  12919. directionRandomizer?: number);
  12920. /**
  12921. * Called by the particle System when the direction is computed for the created particle.
  12922. * @param worldMatrix is the world matrix of the particle system
  12923. * @param directionToUpdate is the direction vector to update with the result
  12924. * @param particle is the particle we are computed the direction for
  12925. * @param isLocal defines if the direction should be set in local space
  12926. */
  12927. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12928. /**
  12929. * Called by the particle System when the position is computed for the created particle.
  12930. * @param worldMatrix is the world matrix of the particle system
  12931. * @param positionToUpdate is the position vector to update with the result
  12932. * @param particle is the particle we are computed the position for
  12933. * @param isLocal defines if the position should be set in local space
  12934. */
  12935. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12936. /**
  12937. * Clones the current emitter and returns a copy of it
  12938. * @returns the new emitter
  12939. */
  12940. clone(): SphereParticleEmitter;
  12941. /**
  12942. * Called by the GPUParticleSystem to setup the update shader
  12943. * @param effect defines the update shader
  12944. */
  12945. applyToShader(effect: Effect): void;
  12946. /**
  12947. * Returns a string to use to update the GPU particles update shader
  12948. * @returns a string containng the defines string
  12949. */
  12950. getEffectDefines(): string;
  12951. /**
  12952. * Returns the string "SphereParticleEmitter"
  12953. * @returns a string containing the class name
  12954. */
  12955. getClassName(): string;
  12956. /**
  12957. * Serializes the particle system to a JSON object.
  12958. * @returns the JSON object
  12959. */
  12960. serialize(): any;
  12961. /**
  12962. * Parse properties from a JSON object
  12963. * @param serializationObject defines the JSON object
  12964. */
  12965. parse(serializationObject: any): void;
  12966. }
  12967. /**
  12968. * Particle emitter emitting particles from the inside of a sphere.
  12969. * It emits the particles randomly between two vectors.
  12970. */
  12971. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12972. /**
  12973. * The min limit of the emission direction.
  12974. */
  12975. direction1: Vector3;
  12976. /**
  12977. * The max limit of the emission direction.
  12978. */
  12979. direction2: Vector3;
  12980. /**
  12981. * Creates a new instance SphereDirectedParticleEmitter
  12982. * @param radius the radius of the emission sphere (1 by default)
  12983. * @param direction1 the min limit of the emission direction (up vector by default)
  12984. * @param direction2 the max limit of the emission direction (up vector by default)
  12985. */
  12986. constructor(radius?: number,
  12987. /**
  12988. * The min limit of the emission direction.
  12989. */
  12990. direction1?: Vector3,
  12991. /**
  12992. * The max limit of the emission direction.
  12993. */
  12994. direction2?: Vector3);
  12995. /**
  12996. * Called by the particle System when the direction is computed for the created particle.
  12997. * @param worldMatrix is the world matrix of the particle system
  12998. * @param directionToUpdate is the direction vector to update with the result
  12999. * @param particle is the particle we are computed the direction for
  13000. */
  13001. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13002. /**
  13003. * Clones the current emitter and returns a copy of it
  13004. * @returns the new emitter
  13005. */
  13006. clone(): SphereDirectedParticleEmitter;
  13007. /**
  13008. * Called by the GPUParticleSystem to setup the update shader
  13009. * @param effect defines the update shader
  13010. */
  13011. applyToShader(effect: Effect): void;
  13012. /**
  13013. * Returns a string to use to update the GPU particles update shader
  13014. * @returns a string containng the defines string
  13015. */
  13016. getEffectDefines(): string;
  13017. /**
  13018. * Returns the string "SphereDirectedParticleEmitter"
  13019. * @returns a string containing the class name
  13020. */
  13021. getClassName(): string;
  13022. /**
  13023. * Serializes the particle system to a JSON object.
  13024. * @returns the JSON object
  13025. */
  13026. serialize(): any;
  13027. /**
  13028. * Parse properties from a JSON object
  13029. * @param serializationObject defines the JSON object
  13030. */
  13031. parse(serializationObject: any): void;
  13032. }
  13033. }
  13034. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13035. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13036. import { Effect } from "babylonjs/Materials/effect";
  13037. import { Particle } from "babylonjs/Particles/particle";
  13038. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13039. import { Nullable } from "babylonjs/types";
  13040. /**
  13041. * Particle emitter emitting particles from a custom list of positions.
  13042. */
  13043. export class CustomParticleEmitter implements IParticleEmitterType {
  13044. /**
  13045. * Gets or sets the position generator that will create the inital position of each particle.
  13046. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13047. */
  13048. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13049. /**
  13050. * Gets or sets the destination generator that will create the final destination of each particle.
  13051. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13052. */
  13053. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13054. /**
  13055. * Creates a new instance CustomParticleEmitter
  13056. */
  13057. constructor();
  13058. /**
  13059. * Called by the particle System when the direction is computed for the created particle.
  13060. * @param worldMatrix is the world matrix of the particle system
  13061. * @param directionToUpdate is the direction vector to update with the result
  13062. * @param particle is the particle we are computed the direction for
  13063. * @param isLocal defines if the direction should be set in local space
  13064. */
  13065. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13066. /**
  13067. * Called by the particle System when the position is computed for the created particle.
  13068. * @param worldMatrix is the world matrix of the particle system
  13069. * @param positionToUpdate is the position vector to update with the result
  13070. * @param particle is the particle we are computed the position for
  13071. * @param isLocal defines if the position should be set in local space
  13072. */
  13073. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13074. /**
  13075. * Clones the current emitter and returns a copy of it
  13076. * @returns the new emitter
  13077. */
  13078. clone(): CustomParticleEmitter;
  13079. /**
  13080. * Called by the GPUParticleSystem to setup the update shader
  13081. * @param effect defines the update shader
  13082. */
  13083. applyToShader(effect: Effect): void;
  13084. /**
  13085. * Returns a string to use to update the GPU particles update shader
  13086. * @returns a string containng the defines string
  13087. */
  13088. getEffectDefines(): string;
  13089. /**
  13090. * Returns the string "PointParticleEmitter"
  13091. * @returns a string containing the class name
  13092. */
  13093. getClassName(): string;
  13094. /**
  13095. * Serializes the particle system to a JSON object.
  13096. * @returns the JSON object
  13097. */
  13098. serialize(): any;
  13099. /**
  13100. * Parse properties from a JSON object
  13101. * @param serializationObject defines the JSON object
  13102. */
  13103. parse(serializationObject: any): void;
  13104. }
  13105. }
  13106. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13107. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13108. import { Effect } from "babylonjs/Materials/effect";
  13109. import { Particle } from "babylonjs/Particles/particle";
  13110. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13111. import { Scene } from "babylonjs/scene";
  13112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13113. /**
  13114. * Particle emitter emitting particles from the inside of a box.
  13115. * It emits the particles randomly between 2 given directions.
  13116. */
  13117. export class MeshParticleEmitter implements IParticleEmitterType {
  13118. /** Defines the mesh to use as source */
  13119. mesh?: AbstractMesh | undefined;
  13120. private _indices;
  13121. private _positions;
  13122. private _normals;
  13123. private _storedNormal;
  13124. /**
  13125. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13126. */
  13127. direction1: Vector3;
  13128. /**
  13129. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13130. */
  13131. direction2: Vector3;
  13132. /**
  13133. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13134. */
  13135. useMeshNormalsForDirection: boolean;
  13136. /**
  13137. * Creates a new instance MeshParticleEmitter
  13138. * @param mesh defines the mesh to use as source
  13139. */
  13140. constructor(
  13141. /** Defines the mesh to use as source */
  13142. mesh?: AbstractMesh | undefined);
  13143. /**
  13144. * Called by the particle System when the direction is computed for the created particle.
  13145. * @param worldMatrix is the world matrix of the particle system
  13146. * @param directionToUpdate is the direction vector to update with the result
  13147. * @param particle is the particle we are computed the direction for
  13148. * @param isLocal defines if the direction should be set in local space
  13149. */
  13150. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13151. /**
  13152. * Called by the particle System when the position is computed for the created particle.
  13153. * @param worldMatrix is the world matrix of the particle system
  13154. * @param positionToUpdate is the position vector to update with the result
  13155. * @param particle is the particle we are computed the position for
  13156. * @param isLocal defines if the position should be set in local space
  13157. */
  13158. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13159. /**
  13160. * Clones the current emitter and returns a copy of it
  13161. * @returns the new emitter
  13162. */
  13163. clone(): MeshParticleEmitter;
  13164. /**
  13165. * Called by the GPUParticleSystem to setup the update shader
  13166. * @param effect defines the update shader
  13167. */
  13168. applyToShader(effect: Effect): void;
  13169. /**
  13170. * Returns a string to use to update the GPU particles update shader
  13171. * @returns a string containng the defines string
  13172. */
  13173. getEffectDefines(): string;
  13174. /**
  13175. * Returns the string "BoxParticleEmitter"
  13176. * @returns a string containing the class name
  13177. */
  13178. getClassName(): string;
  13179. /**
  13180. * Serializes the particle system to a JSON object.
  13181. * @returns the JSON object
  13182. */
  13183. serialize(): any;
  13184. /**
  13185. * Parse properties from a JSON object
  13186. * @param serializationObject defines the JSON object
  13187. * @param scene defines the hosting scene
  13188. */
  13189. parse(serializationObject: any, scene: Scene): void;
  13190. }
  13191. }
  13192. declare module "babylonjs/Particles/EmitterTypes/index" {
  13193. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13194. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13195. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13196. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13197. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13198. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13199. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13200. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13201. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13202. }
  13203. declare module "babylonjs/Particles/IParticleSystem" {
  13204. import { Nullable } from "babylonjs/types";
  13205. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13206. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13207. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13208. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13209. import { Texture } from "babylonjs/Materials/Textures/texture";
  13210. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13211. import { Scene } from "babylonjs/scene";
  13212. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13213. import { Animation } from "babylonjs/Animations/animation";
  13214. /**
  13215. * Interface representing a particle system in Babylon.js.
  13216. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13217. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13218. */
  13219. export interface IParticleSystem {
  13220. /**
  13221. * List of animations used by the particle system.
  13222. */
  13223. animations: Animation[];
  13224. /**
  13225. * The id of the Particle system.
  13226. */
  13227. id: string;
  13228. /**
  13229. * The name of the Particle system.
  13230. */
  13231. name: string;
  13232. /**
  13233. * The emitter represents the Mesh or position we are attaching the particle system to.
  13234. */
  13235. emitter: Nullable<AbstractMesh | Vector3>;
  13236. /**
  13237. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13238. */
  13239. isBillboardBased: boolean;
  13240. /**
  13241. * The rendering group used by the Particle system to chose when to render.
  13242. */
  13243. renderingGroupId: number;
  13244. /**
  13245. * The layer mask we are rendering the particles through.
  13246. */
  13247. layerMask: number;
  13248. /**
  13249. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13250. */
  13251. updateSpeed: number;
  13252. /**
  13253. * The amount of time the particle system is running (depends of the overall update speed).
  13254. */
  13255. targetStopDuration: number;
  13256. /**
  13257. * The texture used to render each particle. (this can be a spritesheet)
  13258. */
  13259. particleTexture: Nullable<Texture>;
  13260. /**
  13261. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13262. */
  13263. blendMode: number;
  13264. /**
  13265. * Minimum life time of emitting particles.
  13266. */
  13267. minLifeTime: number;
  13268. /**
  13269. * Maximum life time of emitting particles.
  13270. */
  13271. maxLifeTime: number;
  13272. /**
  13273. * Minimum Size of emitting particles.
  13274. */
  13275. minSize: number;
  13276. /**
  13277. * Maximum Size of emitting particles.
  13278. */
  13279. maxSize: number;
  13280. /**
  13281. * Minimum scale of emitting particles on X axis.
  13282. */
  13283. minScaleX: number;
  13284. /**
  13285. * Maximum scale of emitting particles on X axis.
  13286. */
  13287. maxScaleX: number;
  13288. /**
  13289. * Minimum scale of emitting particles on Y axis.
  13290. */
  13291. minScaleY: number;
  13292. /**
  13293. * Maximum scale of emitting particles on Y axis.
  13294. */
  13295. maxScaleY: number;
  13296. /**
  13297. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13298. */
  13299. color1: Color4;
  13300. /**
  13301. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13302. */
  13303. color2: Color4;
  13304. /**
  13305. * Color the particle will have at the end of its lifetime.
  13306. */
  13307. colorDead: Color4;
  13308. /**
  13309. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13310. */
  13311. emitRate: number;
  13312. /**
  13313. * You can use gravity if you want to give an orientation to your particles.
  13314. */
  13315. gravity: Vector3;
  13316. /**
  13317. * Minimum power of emitting particles.
  13318. */
  13319. minEmitPower: number;
  13320. /**
  13321. * Maximum power of emitting particles.
  13322. */
  13323. maxEmitPower: number;
  13324. /**
  13325. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13326. */
  13327. minAngularSpeed: number;
  13328. /**
  13329. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13330. */
  13331. maxAngularSpeed: number;
  13332. /**
  13333. * Gets or sets the minimal initial rotation in radians.
  13334. */
  13335. minInitialRotation: number;
  13336. /**
  13337. * Gets or sets the maximal initial rotation in radians.
  13338. */
  13339. maxInitialRotation: number;
  13340. /**
  13341. * The particle emitter type defines the emitter used by the particle system.
  13342. * It can be for example box, sphere, or cone...
  13343. */
  13344. particleEmitterType: Nullable<IParticleEmitterType>;
  13345. /**
  13346. * Defines the delay in milliseconds before starting the system (0 by default)
  13347. */
  13348. startDelay: number;
  13349. /**
  13350. * 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
  13351. */
  13352. preWarmCycles: number;
  13353. /**
  13354. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13355. */
  13356. preWarmStepOffset: number;
  13357. /**
  13358. * 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)
  13359. */
  13360. spriteCellChangeSpeed: number;
  13361. /**
  13362. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13363. */
  13364. startSpriteCellID: number;
  13365. /**
  13366. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13367. */
  13368. endSpriteCellID: number;
  13369. /**
  13370. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13371. */
  13372. spriteCellWidth: number;
  13373. /**
  13374. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13375. */
  13376. spriteCellHeight: number;
  13377. /**
  13378. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13379. */
  13380. spriteRandomStartCell: boolean;
  13381. /**
  13382. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13383. */
  13384. isAnimationSheetEnabled: boolean;
  13385. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13386. translationPivot: Vector2;
  13387. /**
  13388. * Gets or sets a texture used to add random noise to particle positions
  13389. */
  13390. noiseTexture: Nullable<BaseTexture>;
  13391. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13392. noiseStrength: Vector3;
  13393. /**
  13394. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13395. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13396. */
  13397. billboardMode: number;
  13398. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13399. limitVelocityDamping: number;
  13400. /**
  13401. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13402. */
  13403. beginAnimationOnStart: boolean;
  13404. /**
  13405. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13406. */
  13407. beginAnimationFrom: number;
  13408. /**
  13409. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13410. */
  13411. beginAnimationTo: number;
  13412. /**
  13413. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13414. */
  13415. beginAnimationLoop: boolean;
  13416. /**
  13417. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13418. */
  13419. disposeOnStop: boolean;
  13420. /**
  13421. * Specifies if the particles are updated in emitter local space or world space
  13422. */
  13423. isLocal: boolean;
  13424. /**
  13425. * Gets the maximum number of particles active at the same time.
  13426. * @returns The max number of active particles.
  13427. */
  13428. getCapacity(): number;
  13429. /**
  13430. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13431. * @returns True if it has been started, otherwise false.
  13432. */
  13433. isStarted(): boolean;
  13434. /**
  13435. * Animates the particle system for this frame.
  13436. */
  13437. animate(): void;
  13438. /**
  13439. * Renders the particle system in its current state.
  13440. * @returns the current number of particles
  13441. */
  13442. render(): number;
  13443. /**
  13444. * Dispose the particle system and frees its associated resources.
  13445. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13446. */
  13447. dispose(disposeTexture?: boolean): void;
  13448. /**
  13449. * Clones the particle system.
  13450. * @param name The name of the cloned object
  13451. * @param newEmitter The new emitter to use
  13452. * @returns the cloned particle system
  13453. */
  13454. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13455. /**
  13456. * Serializes the particle system to a JSON object.
  13457. * @returns the JSON object
  13458. */
  13459. serialize(): any;
  13460. /**
  13461. * Rebuild the particle system
  13462. */
  13463. rebuild(): void;
  13464. /**
  13465. * Starts the particle system and begins to emit
  13466. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13467. */
  13468. start(delay?: number): void;
  13469. /**
  13470. * Stops the particle system.
  13471. */
  13472. stop(): void;
  13473. /**
  13474. * Remove all active particles
  13475. */
  13476. reset(): void;
  13477. /**
  13478. * Is this system ready to be used/rendered
  13479. * @return true if the system is ready
  13480. */
  13481. isReady(): boolean;
  13482. /**
  13483. * Adds a new color gradient
  13484. * @param gradient defines the gradient to use (between 0 and 1)
  13485. * @param color1 defines the color to affect to the specified gradient
  13486. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13487. * @returns the current particle system
  13488. */
  13489. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13490. /**
  13491. * Remove a specific color gradient
  13492. * @param gradient defines the gradient to remove
  13493. * @returns the current particle system
  13494. */
  13495. removeColorGradient(gradient: number): IParticleSystem;
  13496. /**
  13497. * Adds a new size gradient
  13498. * @param gradient defines the gradient to use (between 0 and 1)
  13499. * @param factor defines the size factor to affect to the specified gradient
  13500. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13501. * @returns the current particle system
  13502. */
  13503. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13504. /**
  13505. * Remove a specific size gradient
  13506. * @param gradient defines the gradient to remove
  13507. * @returns the current particle system
  13508. */
  13509. removeSizeGradient(gradient: number): IParticleSystem;
  13510. /**
  13511. * Gets the current list of color gradients.
  13512. * You must use addColorGradient and removeColorGradient to udpate this list
  13513. * @returns the list of color gradients
  13514. */
  13515. getColorGradients(): Nullable<Array<ColorGradient>>;
  13516. /**
  13517. * Gets the current list of size gradients.
  13518. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13519. * @returns the list of size gradients
  13520. */
  13521. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13522. /**
  13523. * Gets the current list of angular speed gradients.
  13524. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13525. * @returns the list of angular speed gradients
  13526. */
  13527. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13528. /**
  13529. * Adds a new angular speed gradient
  13530. * @param gradient defines the gradient to use (between 0 and 1)
  13531. * @param factor defines the angular speed to affect to the specified gradient
  13532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13533. * @returns the current particle system
  13534. */
  13535. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13536. /**
  13537. * Remove a specific angular speed gradient
  13538. * @param gradient defines the gradient to remove
  13539. * @returns the current particle system
  13540. */
  13541. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13542. /**
  13543. * Gets the current list of velocity gradients.
  13544. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13545. * @returns the list of velocity gradients
  13546. */
  13547. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13548. /**
  13549. * Adds a new velocity gradient
  13550. * @param gradient defines the gradient to use (between 0 and 1)
  13551. * @param factor defines the velocity to affect to the specified gradient
  13552. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13553. * @returns the current particle system
  13554. */
  13555. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13556. /**
  13557. * Remove a specific velocity gradient
  13558. * @param gradient defines the gradient to remove
  13559. * @returns the current particle system
  13560. */
  13561. removeVelocityGradient(gradient: number): IParticleSystem;
  13562. /**
  13563. * Gets the current list of limit velocity gradients.
  13564. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13565. * @returns the list of limit velocity gradients
  13566. */
  13567. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13568. /**
  13569. * Adds a new limit velocity gradient
  13570. * @param gradient defines the gradient to use (between 0 and 1)
  13571. * @param factor defines the limit velocity to affect to the specified gradient
  13572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13573. * @returns the current particle system
  13574. */
  13575. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13576. /**
  13577. * Remove a specific limit velocity gradient
  13578. * @param gradient defines the gradient to remove
  13579. * @returns the current particle system
  13580. */
  13581. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13582. /**
  13583. * Adds a new drag gradient
  13584. * @param gradient defines the gradient to use (between 0 and 1)
  13585. * @param factor defines the drag to affect to the specified gradient
  13586. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13587. * @returns the current particle system
  13588. */
  13589. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13590. /**
  13591. * Remove a specific drag gradient
  13592. * @param gradient defines the gradient to remove
  13593. * @returns the current particle system
  13594. */
  13595. removeDragGradient(gradient: number): IParticleSystem;
  13596. /**
  13597. * Gets the current list of drag gradients.
  13598. * You must use addDragGradient and removeDragGradient to udpate this list
  13599. * @returns the list of drag gradients
  13600. */
  13601. getDragGradients(): Nullable<Array<FactorGradient>>;
  13602. /**
  13603. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13604. * @param gradient defines the gradient to use (between 0 and 1)
  13605. * @param factor defines the emit rate to affect to the specified gradient
  13606. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13607. * @returns the current particle system
  13608. */
  13609. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13610. /**
  13611. * Remove a specific emit rate gradient
  13612. * @param gradient defines the gradient to remove
  13613. * @returns the current particle system
  13614. */
  13615. removeEmitRateGradient(gradient: number): IParticleSystem;
  13616. /**
  13617. * Gets the current list of emit rate gradients.
  13618. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13619. * @returns the list of emit rate gradients
  13620. */
  13621. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13622. /**
  13623. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13624. * @param gradient defines the gradient to use (between 0 and 1)
  13625. * @param factor defines the start size to affect to the specified gradient
  13626. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13627. * @returns the current particle system
  13628. */
  13629. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13630. /**
  13631. * Remove a specific start size gradient
  13632. * @param gradient defines the gradient to remove
  13633. * @returns the current particle system
  13634. */
  13635. removeStartSizeGradient(gradient: number): IParticleSystem;
  13636. /**
  13637. * Gets the current list of start size gradients.
  13638. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13639. * @returns the list of start size gradients
  13640. */
  13641. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13642. /**
  13643. * Adds a new life time gradient
  13644. * @param gradient defines the gradient to use (between 0 and 1)
  13645. * @param factor defines the life time factor to affect to the specified gradient
  13646. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13647. * @returns the current particle system
  13648. */
  13649. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13650. /**
  13651. * Remove a specific life time gradient
  13652. * @param gradient defines the gradient to remove
  13653. * @returns the current particle system
  13654. */
  13655. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13656. /**
  13657. * Gets the current list of life time gradients.
  13658. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13659. * @returns the list of life time gradients
  13660. */
  13661. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13662. /**
  13663. * Gets the current list of color gradients.
  13664. * You must use addColorGradient and removeColorGradient to udpate this list
  13665. * @returns the list of color gradients
  13666. */
  13667. getColorGradients(): Nullable<Array<ColorGradient>>;
  13668. /**
  13669. * Adds a new ramp gradient used to remap particle colors
  13670. * @param gradient defines the gradient to use (between 0 and 1)
  13671. * @param color defines the color to affect to the specified gradient
  13672. * @returns the current particle system
  13673. */
  13674. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13675. /**
  13676. * Gets the current list of ramp gradients.
  13677. * You must use addRampGradient and removeRampGradient to udpate this list
  13678. * @returns the list of ramp gradients
  13679. */
  13680. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13681. /** Gets or sets a boolean indicating that ramp gradients must be used
  13682. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13683. */
  13684. useRampGradients: boolean;
  13685. /**
  13686. * Adds a new color remap gradient
  13687. * @param gradient defines the gradient to use (between 0 and 1)
  13688. * @param min defines the color remap minimal range
  13689. * @param max defines the color remap maximal range
  13690. * @returns the current particle system
  13691. */
  13692. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13693. /**
  13694. * Gets the current list of color remap gradients.
  13695. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13696. * @returns the list of color remap gradients
  13697. */
  13698. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13699. /**
  13700. * Adds a new alpha remap gradient
  13701. * @param gradient defines the gradient to use (between 0 and 1)
  13702. * @param min defines the alpha remap minimal range
  13703. * @param max defines the alpha remap maximal range
  13704. * @returns the current particle system
  13705. */
  13706. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13707. /**
  13708. * Gets the current list of alpha remap gradients.
  13709. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13710. * @returns the list of alpha remap gradients
  13711. */
  13712. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13713. /**
  13714. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13715. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13716. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13717. * @returns the emitter
  13718. */
  13719. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13720. /**
  13721. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13722. * @param radius The radius of the hemisphere to emit from
  13723. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13724. * @returns the emitter
  13725. */
  13726. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13727. /**
  13728. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13729. * @param radius The radius of the sphere to emit from
  13730. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13731. * @returns the emitter
  13732. */
  13733. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13734. /**
  13735. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13736. * @param radius The radius of the sphere to emit from
  13737. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13738. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13739. * @returns the emitter
  13740. */
  13741. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13742. /**
  13743. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13744. * @param radius The radius of the emission cylinder
  13745. * @param height The height of the emission cylinder
  13746. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13747. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13748. * @returns the emitter
  13749. */
  13750. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13751. /**
  13752. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13753. * @param radius The radius of the cylinder to emit from
  13754. * @param height The height of the emission cylinder
  13755. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13756. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13757. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13758. * @returns the emitter
  13759. */
  13760. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13761. /**
  13762. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13763. * @param radius The radius of the cone to emit from
  13764. * @param angle The base angle of the cone
  13765. * @returns the emitter
  13766. */
  13767. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13768. /**
  13769. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13770. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13771. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13772. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13773. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13774. * @returns the emitter
  13775. */
  13776. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13777. /**
  13778. * Get hosting scene
  13779. * @returns the scene
  13780. */
  13781. getScene(): Scene;
  13782. }
  13783. }
  13784. declare module "babylonjs/Meshes/transformNode" {
  13785. import { DeepImmutable } from "babylonjs/types";
  13786. import { Observable } from "babylonjs/Misc/observable";
  13787. import { Nullable } from "babylonjs/types";
  13788. import { Camera } from "babylonjs/Cameras/camera";
  13789. import { Scene } from "babylonjs/scene";
  13790. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13791. import { Node } from "babylonjs/node";
  13792. import { Bone } from "babylonjs/Bones/bone";
  13793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13794. import { Space } from "babylonjs/Maths/math.axis";
  13795. /**
  13796. * 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.
  13797. * @see https://doc.babylonjs.com/how_to/transformnode
  13798. */
  13799. export class TransformNode extends Node {
  13800. /**
  13801. * Object will not rotate to face the camera
  13802. */
  13803. static BILLBOARDMODE_NONE: number;
  13804. /**
  13805. * Object will rotate to face the camera but only on the x axis
  13806. */
  13807. static BILLBOARDMODE_X: number;
  13808. /**
  13809. * Object will rotate to face the camera but only on the y axis
  13810. */
  13811. static BILLBOARDMODE_Y: number;
  13812. /**
  13813. * Object will rotate to face the camera but only on the z axis
  13814. */
  13815. static BILLBOARDMODE_Z: number;
  13816. /**
  13817. * Object will rotate to face the camera
  13818. */
  13819. static BILLBOARDMODE_ALL: number;
  13820. /**
  13821. * Object will rotate to face the camera's position instead of orientation
  13822. */
  13823. static BILLBOARDMODE_USE_POSITION: number;
  13824. private _forward;
  13825. private _forwardInverted;
  13826. private _up;
  13827. private _right;
  13828. private _rightInverted;
  13829. private _position;
  13830. private _rotation;
  13831. private _rotationQuaternion;
  13832. protected _scaling: Vector3;
  13833. protected _isDirty: boolean;
  13834. private _transformToBoneReferal;
  13835. private _isAbsoluteSynced;
  13836. private _billboardMode;
  13837. /**
  13838. * Gets or sets the billboard mode. Default is 0.
  13839. *
  13840. * | Value | Type | Description |
  13841. * | --- | --- | --- |
  13842. * | 0 | BILLBOARDMODE_NONE | |
  13843. * | 1 | BILLBOARDMODE_X | |
  13844. * | 2 | BILLBOARDMODE_Y | |
  13845. * | 4 | BILLBOARDMODE_Z | |
  13846. * | 7 | BILLBOARDMODE_ALL | |
  13847. *
  13848. */
  13849. get billboardMode(): number;
  13850. set billboardMode(value: number);
  13851. private _preserveParentRotationForBillboard;
  13852. /**
  13853. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13854. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13855. */
  13856. get preserveParentRotationForBillboard(): boolean;
  13857. set preserveParentRotationForBillboard(value: boolean);
  13858. /**
  13859. * 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
  13860. */
  13861. scalingDeterminant: number;
  13862. private _infiniteDistance;
  13863. /**
  13864. * Gets or sets the distance of the object to max, often used by skybox
  13865. */
  13866. get infiniteDistance(): boolean;
  13867. set infiniteDistance(value: boolean);
  13868. /**
  13869. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13870. * By default the system will update normals to compensate
  13871. */
  13872. ignoreNonUniformScaling: boolean;
  13873. /**
  13874. * 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
  13875. */
  13876. reIntegrateRotationIntoRotationQuaternion: boolean;
  13877. /** @hidden */
  13878. _poseMatrix: Nullable<Matrix>;
  13879. /** @hidden */
  13880. _localMatrix: Matrix;
  13881. private _usePivotMatrix;
  13882. private _absolutePosition;
  13883. private _absoluteScaling;
  13884. private _absoluteRotationQuaternion;
  13885. private _pivotMatrix;
  13886. private _pivotMatrixInverse;
  13887. protected _postMultiplyPivotMatrix: boolean;
  13888. protected _isWorldMatrixFrozen: boolean;
  13889. /** @hidden */
  13890. _indexInSceneTransformNodesArray: number;
  13891. /**
  13892. * An event triggered after the world matrix is updated
  13893. */
  13894. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13895. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13896. /**
  13897. * Gets a string identifying the name of the class
  13898. * @returns "TransformNode" string
  13899. */
  13900. getClassName(): string;
  13901. /**
  13902. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13903. */
  13904. get position(): Vector3;
  13905. set position(newPosition: Vector3);
  13906. /**
  13907. * 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)).
  13908. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13909. */
  13910. get rotation(): Vector3;
  13911. set rotation(newRotation: Vector3);
  13912. /**
  13913. * 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)).
  13914. */
  13915. get scaling(): Vector3;
  13916. set scaling(newScaling: Vector3);
  13917. /**
  13918. * 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).
  13919. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13920. */
  13921. get rotationQuaternion(): Nullable<Quaternion>;
  13922. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13923. /**
  13924. * The forward direction of that transform in world space.
  13925. */
  13926. get forward(): Vector3;
  13927. /**
  13928. * The up direction of that transform in world space.
  13929. */
  13930. get up(): Vector3;
  13931. /**
  13932. * The right direction of that transform in world space.
  13933. */
  13934. get right(): Vector3;
  13935. /**
  13936. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13937. * @param matrix the matrix to copy the pose from
  13938. * @returns this TransformNode.
  13939. */
  13940. updatePoseMatrix(matrix: Matrix): TransformNode;
  13941. /**
  13942. * Returns the mesh Pose matrix.
  13943. * @returns the pose matrix
  13944. */
  13945. getPoseMatrix(): Matrix;
  13946. /** @hidden */
  13947. _isSynchronized(): boolean;
  13948. /** @hidden */
  13949. _initCache(): void;
  13950. /**
  13951. * Flag the transform node as dirty (Forcing it to update everything)
  13952. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13953. * @returns this transform node
  13954. */
  13955. markAsDirty(property: string): TransformNode;
  13956. /**
  13957. * Returns the current mesh absolute position.
  13958. * Returns a Vector3.
  13959. */
  13960. get absolutePosition(): Vector3;
  13961. /**
  13962. * Returns the current mesh absolute scaling.
  13963. * Returns a Vector3.
  13964. */
  13965. get absoluteScaling(): Vector3;
  13966. /**
  13967. * Returns the current mesh absolute rotation.
  13968. * Returns a Quaternion.
  13969. */
  13970. get absoluteRotationQuaternion(): Quaternion;
  13971. /**
  13972. * Sets a new matrix to apply before all other transformation
  13973. * @param matrix defines the transform matrix
  13974. * @returns the current TransformNode
  13975. */
  13976. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13977. /**
  13978. * Sets a new pivot matrix to the current node
  13979. * @param matrix defines the new pivot matrix to use
  13980. * @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
  13981. * @returns the current TransformNode
  13982. */
  13983. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13984. /**
  13985. * Returns the mesh pivot matrix.
  13986. * Default : Identity.
  13987. * @returns the matrix
  13988. */
  13989. getPivotMatrix(): Matrix;
  13990. /**
  13991. * Instantiate (when possible) or clone that node with its hierarchy
  13992. * @param newParent defines the new parent to use for the instance (or clone)
  13993. * @param options defines options to configure how copy is done
  13994. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13995. * @returns an instance (or a clone) of the current node with its hiearchy
  13996. */
  13997. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13998. doNotInstantiate: boolean;
  13999. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14000. /**
  14001. * Prevents the World matrix to be computed any longer
  14002. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14003. * @returns the TransformNode.
  14004. */
  14005. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14006. /**
  14007. * Allows back the World matrix computation.
  14008. * @returns the TransformNode.
  14009. */
  14010. unfreezeWorldMatrix(): this;
  14011. /**
  14012. * True if the World matrix has been frozen.
  14013. */
  14014. get isWorldMatrixFrozen(): boolean;
  14015. /**
  14016. * Retuns the mesh absolute position in the World.
  14017. * @returns a Vector3.
  14018. */
  14019. getAbsolutePosition(): Vector3;
  14020. /**
  14021. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14022. * @param absolutePosition the absolute position to set
  14023. * @returns the TransformNode.
  14024. */
  14025. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14026. /**
  14027. * Sets the mesh position in its local space.
  14028. * @param vector3 the position to set in localspace
  14029. * @returns the TransformNode.
  14030. */
  14031. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14032. /**
  14033. * Returns the mesh position in the local space from the current World matrix values.
  14034. * @returns a new Vector3.
  14035. */
  14036. getPositionExpressedInLocalSpace(): Vector3;
  14037. /**
  14038. * Translates the mesh along the passed Vector3 in its local space.
  14039. * @param vector3 the distance to translate in localspace
  14040. * @returns the TransformNode.
  14041. */
  14042. locallyTranslate(vector3: Vector3): TransformNode;
  14043. private static _lookAtVectorCache;
  14044. /**
  14045. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14046. * @param targetPoint the position (must be in same space as current mesh) to look at
  14047. * @param yawCor optional yaw (y-axis) correction in radians
  14048. * @param pitchCor optional pitch (x-axis) correction in radians
  14049. * @param rollCor optional roll (z-axis) correction in radians
  14050. * @param space the choosen space of the target
  14051. * @returns the TransformNode.
  14052. */
  14053. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14054. /**
  14055. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14056. * This Vector3 is expressed in the World space.
  14057. * @param localAxis axis to rotate
  14058. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14059. */
  14060. getDirection(localAxis: Vector3): Vector3;
  14061. /**
  14062. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14063. * localAxis is expressed in the mesh local space.
  14064. * result is computed in the Wordl space from the mesh World matrix.
  14065. * @param localAxis axis to rotate
  14066. * @param result the resulting transformnode
  14067. * @returns this TransformNode.
  14068. */
  14069. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14070. /**
  14071. * Sets this transform node rotation to the given local axis.
  14072. * @param localAxis the axis in local space
  14073. * @param yawCor optional yaw (y-axis) correction in radians
  14074. * @param pitchCor optional pitch (x-axis) correction in radians
  14075. * @param rollCor optional roll (z-axis) correction in radians
  14076. * @returns this TransformNode
  14077. */
  14078. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14079. /**
  14080. * Sets a new pivot point to the current node
  14081. * @param point defines the new pivot point to use
  14082. * @param space defines if the point is in world or local space (local by default)
  14083. * @returns the current TransformNode
  14084. */
  14085. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14086. /**
  14087. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14088. * @returns the pivot point
  14089. */
  14090. getPivotPoint(): Vector3;
  14091. /**
  14092. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14093. * @param result the vector3 to store the result
  14094. * @returns this TransformNode.
  14095. */
  14096. getPivotPointToRef(result: Vector3): TransformNode;
  14097. /**
  14098. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14099. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14100. */
  14101. getAbsolutePivotPoint(): Vector3;
  14102. /**
  14103. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14104. * @param result vector3 to store the result
  14105. * @returns this TransformNode.
  14106. */
  14107. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14108. /**
  14109. * Defines the passed node as the parent of the current node.
  14110. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14111. * @see https://doc.babylonjs.com/how_to/parenting
  14112. * @param node the node ot set as the parent
  14113. * @returns this TransformNode.
  14114. */
  14115. setParent(node: Nullable<Node>): TransformNode;
  14116. private _nonUniformScaling;
  14117. /**
  14118. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14119. */
  14120. get nonUniformScaling(): boolean;
  14121. /** @hidden */
  14122. _updateNonUniformScalingState(value: boolean): boolean;
  14123. /**
  14124. * Attach the current TransformNode to another TransformNode associated with a bone
  14125. * @param bone Bone affecting the TransformNode
  14126. * @param affectedTransformNode TransformNode associated with the bone
  14127. * @returns this object
  14128. */
  14129. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14130. /**
  14131. * Detach the transform node if its associated with a bone
  14132. * @returns this object
  14133. */
  14134. detachFromBone(): TransformNode;
  14135. private static _rotationAxisCache;
  14136. /**
  14137. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14138. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14139. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14140. * The passed axis is also normalized.
  14141. * @param axis the axis to rotate around
  14142. * @param amount the amount to rotate in radians
  14143. * @param space Space to rotate in (Default: local)
  14144. * @returns the TransformNode.
  14145. */
  14146. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14147. /**
  14148. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14149. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14150. * The passed axis is also normalized. .
  14151. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14152. * @param point the point to rotate around
  14153. * @param axis the axis to rotate around
  14154. * @param amount the amount to rotate in radians
  14155. * @returns the TransformNode
  14156. */
  14157. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14158. /**
  14159. * Translates the mesh along the axis vector for the passed distance in the given space.
  14160. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14161. * @param axis the axis to translate in
  14162. * @param distance the distance to translate
  14163. * @param space Space to rotate in (Default: local)
  14164. * @returns the TransformNode.
  14165. */
  14166. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14167. /**
  14168. * Adds a rotation step to the mesh current rotation.
  14169. * x, y, z are Euler angles expressed in radians.
  14170. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14171. * This means this rotation is made in the mesh local space only.
  14172. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14173. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14174. * ```javascript
  14175. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14176. * ```
  14177. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14178. * 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.
  14179. * @param x Rotation to add
  14180. * @param y Rotation to add
  14181. * @param z Rotation to add
  14182. * @returns the TransformNode.
  14183. */
  14184. addRotation(x: number, y: number, z: number): TransformNode;
  14185. /**
  14186. * @hidden
  14187. */
  14188. protected _getEffectiveParent(): Nullable<Node>;
  14189. /**
  14190. * Computes the world matrix of the node
  14191. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14192. * @returns the world matrix
  14193. */
  14194. computeWorldMatrix(force?: boolean): Matrix;
  14195. /**
  14196. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14197. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14198. */
  14199. resetLocalMatrix(independentOfChildren?: boolean): void;
  14200. protected _afterComputeWorldMatrix(): void;
  14201. /**
  14202. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14203. * @param func callback function to add
  14204. *
  14205. * @returns the TransformNode.
  14206. */
  14207. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14208. /**
  14209. * Removes a registered callback function.
  14210. * @param func callback function to remove
  14211. * @returns the TransformNode.
  14212. */
  14213. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14214. /**
  14215. * Gets the position of the current mesh in camera space
  14216. * @param camera defines the camera to use
  14217. * @returns a position
  14218. */
  14219. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14220. /**
  14221. * Returns the distance from the mesh to the active camera
  14222. * @param camera defines the camera to use
  14223. * @returns the distance
  14224. */
  14225. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14226. /**
  14227. * Clone the current transform node
  14228. * @param name Name of the new clone
  14229. * @param newParent New parent for the clone
  14230. * @param doNotCloneChildren Do not clone children hierarchy
  14231. * @returns the new transform node
  14232. */
  14233. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14234. /**
  14235. * Serializes the objects information.
  14236. * @param currentSerializationObject defines the object to serialize in
  14237. * @returns the serialized object
  14238. */
  14239. serialize(currentSerializationObject?: any): any;
  14240. /**
  14241. * Returns a new TransformNode object parsed from the source provided.
  14242. * @param parsedTransformNode is the source.
  14243. * @param scene the scne the object belongs to
  14244. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14245. * @returns a new TransformNode object parsed from the source provided.
  14246. */
  14247. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14248. /**
  14249. * Get all child-transformNodes of this node
  14250. * @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
  14251. * @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
  14252. * @returns an array of TransformNode
  14253. */
  14254. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14255. /**
  14256. * Releases resources associated with this transform node.
  14257. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14258. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14259. */
  14260. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14261. /**
  14262. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14263. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14264. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14265. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14266. * @returns the current mesh
  14267. */
  14268. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14269. private _syncAbsoluteScalingAndRotation;
  14270. }
  14271. }
  14272. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14273. /**
  14274. * Class used to override all child animations of a given target
  14275. */
  14276. export class AnimationPropertiesOverride {
  14277. /**
  14278. * Gets or sets a value indicating if animation blending must be used
  14279. */
  14280. enableBlending: boolean;
  14281. /**
  14282. * Gets or sets the blending speed to use when enableBlending is true
  14283. */
  14284. blendingSpeed: number;
  14285. /**
  14286. * Gets or sets the default loop mode to use
  14287. */
  14288. loopMode: number;
  14289. }
  14290. }
  14291. declare module "babylonjs/Bones/bone" {
  14292. import { Skeleton } from "babylonjs/Bones/skeleton";
  14293. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14294. import { Nullable } from "babylonjs/types";
  14295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14296. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14297. import { Node } from "babylonjs/node";
  14298. import { Space } from "babylonjs/Maths/math.axis";
  14299. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14300. /**
  14301. * Class used to store bone information
  14302. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14303. */
  14304. export class Bone extends Node {
  14305. /**
  14306. * defines the bone name
  14307. */
  14308. name: string;
  14309. private static _tmpVecs;
  14310. private static _tmpQuat;
  14311. private static _tmpMats;
  14312. /**
  14313. * Gets the list of child bones
  14314. */
  14315. children: Bone[];
  14316. /** Gets the animations associated with this bone */
  14317. animations: import("babylonjs/Animations/animation").Animation[];
  14318. /**
  14319. * Gets or sets bone length
  14320. */
  14321. length: number;
  14322. /**
  14323. * @hidden Internal only
  14324. * Set this value to map this bone to a different index in the transform matrices
  14325. * Set this value to -1 to exclude the bone from the transform matrices
  14326. */
  14327. _index: Nullable<number>;
  14328. private _skeleton;
  14329. private _localMatrix;
  14330. private _restPose;
  14331. private _baseMatrix;
  14332. private _absoluteTransform;
  14333. private _invertedAbsoluteTransform;
  14334. private _parent;
  14335. private _scalingDeterminant;
  14336. private _worldTransform;
  14337. private _localScaling;
  14338. private _localRotation;
  14339. private _localPosition;
  14340. private _needToDecompose;
  14341. private _needToCompose;
  14342. /** @hidden */
  14343. _linkedTransformNode: Nullable<TransformNode>;
  14344. /** @hidden */
  14345. _waitingTransformNodeId: Nullable<string>;
  14346. /** @hidden */
  14347. get _matrix(): Matrix;
  14348. /** @hidden */
  14349. set _matrix(value: Matrix);
  14350. /**
  14351. * Create a new bone
  14352. * @param name defines the bone name
  14353. * @param skeleton defines the parent skeleton
  14354. * @param parentBone defines the parent (can be null if the bone is the root)
  14355. * @param localMatrix defines the local matrix
  14356. * @param restPose defines the rest pose matrix
  14357. * @param baseMatrix defines the base matrix
  14358. * @param index defines index of the bone in the hiearchy
  14359. */
  14360. constructor(
  14361. /**
  14362. * defines the bone name
  14363. */
  14364. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14365. /**
  14366. * Gets the current object class name.
  14367. * @return the class name
  14368. */
  14369. getClassName(): string;
  14370. /**
  14371. * Gets the parent skeleton
  14372. * @returns a skeleton
  14373. */
  14374. getSkeleton(): Skeleton;
  14375. /**
  14376. * Gets parent bone
  14377. * @returns a bone or null if the bone is the root of the bone hierarchy
  14378. */
  14379. getParent(): Nullable<Bone>;
  14380. /**
  14381. * Returns an array containing the root bones
  14382. * @returns an array containing the root bones
  14383. */
  14384. getChildren(): Array<Bone>;
  14385. /**
  14386. * Gets the node index in matrix array generated for rendering
  14387. * @returns the node index
  14388. */
  14389. getIndex(): number;
  14390. /**
  14391. * Sets the parent bone
  14392. * @param parent defines the parent (can be null if the bone is the root)
  14393. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14394. */
  14395. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14396. /**
  14397. * Gets the local matrix
  14398. * @returns a matrix
  14399. */
  14400. getLocalMatrix(): Matrix;
  14401. /**
  14402. * Gets the base matrix (initial matrix which remains unchanged)
  14403. * @returns a matrix
  14404. */
  14405. getBaseMatrix(): Matrix;
  14406. /**
  14407. * Gets the rest pose matrix
  14408. * @returns a matrix
  14409. */
  14410. getRestPose(): Matrix;
  14411. /**
  14412. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14413. */
  14414. getWorldMatrix(): Matrix;
  14415. /**
  14416. * Sets the local matrix to rest pose matrix
  14417. */
  14418. returnToRest(): void;
  14419. /**
  14420. * Gets the inverse of the absolute transform matrix.
  14421. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14422. * @returns a matrix
  14423. */
  14424. getInvertedAbsoluteTransform(): Matrix;
  14425. /**
  14426. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14427. * @returns a matrix
  14428. */
  14429. getAbsoluteTransform(): Matrix;
  14430. /**
  14431. * Links with the given transform node.
  14432. * The local matrix of this bone is copied from the transform node every frame.
  14433. * @param transformNode defines the transform node to link to
  14434. */
  14435. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14436. /**
  14437. * Gets the node used to drive the bone's transformation
  14438. * @returns a transform node or null
  14439. */
  14440. getTransformNode(): Nullable<TransformNode>;
  14441. /** Gets or sets current position (in local space) */
  14442. get position(): Vector3;
  14443. set position(newPosition: Vector3);
  14444. /** Gets or sets current rotation (in local space) */
  14445. get rotation(): Vector3;
  14446. set rotation(newRotation: Vector3);
  14447. /** Gets or sets current rotation quaternion (in local space) */
  14448. get rotationQuaternion(): Quaternion;
  14449. set rotationQuaternion(newRotation: Quaternion);
  14450. /** Gets or sets current scaling (in local space) */
  14451. get scaling(): Vector3;
  14452. set scaling(newScaling: Vector3);
  14453. /**
  14454. * Gets the animation properties override
  14455. */
  14456. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14457. private _decompose;
  14458. private _compose;
  14459. /**
  14460. * Update the base and local matrices
  14461. * @param matrix defines the new base or local matrix
  14462. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14463. * @param updateLocalMatrix defines if the local matrix should be updated
  14464. */
  14465. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14466. /** @hidden */
  14467. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14468. /**
  14469. * Flag the bone as dirty (Forcing it to update everything)
  14470. */
  14471. markAsDirty(): void;
  14472. /** @hidden */
  14473. _markAsDirtyAndCompose(): void;
  14474. private _markAsDirtyAndDecompose;
  14475. /**
  14476. * Translate the bone in local or world space
  14477. * @param vec The amount to translate the bone
  14478. * @param space The space that the translation is in
  14479. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14480. */
  14481. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14482. /**
  14483. * Set the postion of the bone in local or world space
  14484. * @param position The position to set the bone
  14485. * @param space The space that the position is in
  14486. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14487. */
  14488. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14489. /**
  14490. * Set the absolute position of the bone (world space)
  14491. * @param position The position to set the bone
  14492. * @param mesh The mesh that this bone is attached to
  14493. */
  14494. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14495. /**
  14496. * Scale the bone on the x, y and z axes (in local space)
  14497. * @param x The amount to scale the bone on the x axis
  14498. * @param y The amount to scale the bone on the y axis
  14499. * @param z The amount to scale the bone on the z axis
  14500. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14501. */
  14502. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14503. /**
  14504. * Set the bone scaling in local space
  14505. * @param scale defines the scaling vector
  14506. */
  14507. setScale(scale: Vector3): void;
  14508. /**
  14509. * Gets the current scaling in local space
  14510. * @returns the current scaling vector
  14511. */
  14512. getScale(): Vector3;
  14513. /**
  14514. * Gets the current scaling in local space and stores it in a target vector
  14515. * @param result defines the target vector
  14516. */
  14517. getScaleToRef(result: Vector3): void;
  14518. /**
  14519. * Set the yaw, pitch, and roll of the bone in local or world space
  14520. * @param yaw The rotation of the bone on the y axis
  14521. * @param pitch The rotation of the bone on the x axis
  14522. * @param roll The rotation of the bone on the z axis
  14523. * @param space The space that the axes of rotation are in
  14524. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14525. */
  14526. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14527. /**
  14528. * Add a rotation to the bone on an axis in local or world space
  14529. * @param axis The axis to rotate the bone on
  14530. * @param amount The amount to rotate the bone
  14531. * @param space The space that the axis is in
  14532. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14533. */
  14534. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14535. /**
  14536. * Set the rotation of the bone to a particular axis angle in local or world space
  14537. * @param axis The axis to rotate the bone on
  14538. * @param angle The angle that the bone should be rotated to
  14539. * @param space The space that the axis is in
  14540. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14541. */
  14542. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14543. /**
  14544. * Set the euler rotation of the bone in local of world space
  14545. * @param rotation The euler rotation that the bone should be set to
  14546. * @param space The space that the rotation is in
  14547. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14548. */
  14549. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14550. /**
  14551. * Set the quaternion rotation of the bone in local of world space
  14552. * @param quat The quaternion rotation that the bone should be set to
  14553. * @param space The space that the rotation is in
  14554. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14555. */
  14556. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14557. /**
  14558. * Set the rotation matrix of the bone in local of world space
  14559. * @param rotMat The rotation matrix that the bone should be set to
  14560. * @param space The space that the rotation is in
  14561. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14562. */
  14563. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14564. private _rotateWithMatrix;
  14565. private _getNegativeRotationToRef;
  14566. /**
  14567. * Get the position of the bone in local or world space
  14568. * @param space The space that the returned position is in
  14569. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14570. * @returns The position of the bone
  14571. */
  14572. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14573. /**
  14574. * Copy the position of the bone to a vector3 in local or world space
  14575. * @param space The space that the returned position is in
  14576. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14577. * @param result The vector3 to copy the position to
  14578. */
  14579. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14580. /**
  14581. * Get the absolute position of the bone (world space)
  14582. * @param mesh The mesh that this bone is attached to
  14583. * @returns The absolute position of the bone
  14584. */
  14585. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14586. /**
  14587. * Copy the absolute position of the bone (world space) to the result param
  14588. * @param mesh The mesh that this bone is attached to
  14589. * @param result The vector3 to copy the absolute position to
  14590. */
  14591. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14592. /**
  14593. * Compute the absolute transforms of this bone and its children
  14594. */
  14595. computeAbsoluteTransforms(): void;
  14596. /**
  14597. * Get the world direction from an axis that is in the local space of the bone
  14598. * @param localAxis The local direction that is used to compute the world direction
  14599. * @param mesh The mesh that this bone is attached to
  14600. * @returns The world direction
  14601. */
  14602. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14603. /**
  14604. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14605. * @param localAxis The local direction that is used to compute the world direction
  14606. * @param mesh The mesh that this bone is attached to
  14607. * @param result The vector3 that the world direction will be copied to
  14608. */
  14609. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14610. /**
  14611. * Get the euler rotation of the bone in local or world space
  14612. * @param space The space that the rotation should be in
  14613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14614. * @returns The euler rotation
  14615. */
  14616. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14617. /**
  14618. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14619. * @param space The space that the rotation should be in
  14620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14621. * @param result The vector3 that the rotation should be copied to
  14622. */
  14623. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14624. /**
  14625. * Get the quaternion rotation of the bone in either local or world space
  14626. * @param space The space that the rotation should be in
  14627. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14628. * @returns The quaternion rotation
  14629. */
  14630. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14631. /**
  14632. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14633. * @param space The space that the rotation should be in
  14634. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14635. * @param result The quaternion that the rotation should be copied to
  14636. */
  14637. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14638. /**
  14639. * Get the rotation matrix of the bone in local or world space
  14640. * @param space The space that the rotation should be in
  14641. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14642. * @returns The rotation matrix
  14643. */
  14644. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14645. /**
  14646. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14647. * @param space The space that the rotation should be in
  14648. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14649. * @param result The quaternion that the rotation should be copied to
  14650. */
  14651. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14652. /**
  14653. * Get the world position of a point that is in the local space of the bone
  14654. * @param position The local position
  14655. * @param mesh The mesh that this bone is attached to
  14656. * @returns The world position
  14657. */
  14658. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14659. /**
  14660. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14661. * @param position The local position
  14662. * @param mesh The mesh that this bone is attached to
  14663. * @param result The vector3 that the world position should be copied to
  14664. */
  14665. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14666. /**
  14667. * Get the local position of a point that is in world space
  14668. * @param position The world position
  14669. * @param mesh The mesh that this bone is attached to
  14670. * @returns The local position
  14671. */
  14672. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14673. /**
  14674. * Get the local position of a point that is in world space and copy it to the result param
  14675. * @param position The world position
  14676. * @param mesh The mesh that this bone is attached to
  14677. * @param result The vector3 that the local position should be copied to
  14678. */
  14679. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14680. }
  14681. }
  14682. declare module "babylonjs/Animations/runtimeAnimation" {
  14683. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14684. import { Animatable } from "babylonjs/Animations/animatable";
  14685. import { Scene } from "babylonjs/scene";
  14686. /**
  14687. * Defines a runtime animation
  14688. */
  14689. export class RuntimeAnimation {
  14690. private _events;
  14691. /**
  14692. * The current frame of the runtime animation
  14693. */
  14694. private _currentFrame;
  14695. /**
  14696. * The animation used by the runtime animation
  14697. */
  14698. private _animation;
  14699. /**
  14700. * The target of the runtime animation
  14701. */
  14702. private _target;
  14703. /**
  14704. * The initiating animatable
  14705. */
  14706. private _host;
  14707. /**
  14708. * The original value of the runtime animation
  14709. */
  14710. private _originalValue;
  14711. /**
  14712. * The original blend value of the runtime animation
  14713. */
  14714. private _originalBlendValue;
  14715. /**
  14716. * The offsets cache of the runtime animation
  14717. */
  14718. private _offsetsCache;
  14719. /**
  14720. * The high limits cache of the runtime animation
  14721. */
  14722. private _highLimitsCache;
  14723. /**
  14724. * Specifies if the runtime animation has been stopped
  14725. */
  14726. private _stopped;
  14727. /**
  14728. * The blending factor of the runtime animation
  14729. */
  14730. private _blendingFactor;
  14731. /**
  14732. * The BabylonJS scene
  14733. */
  14734. private _scene;
  14735. /**
  14736. * The current value of the runtime animation
  14737. */
  14738. private _currentValue;
  14739. /** @hidden */
  14740. _animationState: _IAnimationState;
  14741. /**
  14742. * The active target of the runtime animation
  14743. */
  14744. private _activeTargets;
  14745. private _currentActiveTarget;
  14746. private _directTarget;
  14747. /**
  14748. * The target path of the runtime animation
  14749. */
  14750. private _targetPath;
  14751. /**
  14752. * The weight of the runtime animation
  14753. */
  14754. private _weight;
  14755. /**
  14756. * The ratio offset of the runtime animation
  14757. */
  14758. private _ratioOffset;
  14759. /**
  14760. * The previous delay of the runtime animation
  14761. */
  14762. private _previousDelay;
  14763. /**
  14764. * The previous ratio of the runtime animation
  14765. */
  14766. private _previousRatio;
  14767. private _enableBlending;
  14768. private _keys;
  14769. private _minFrame;
  14770. private _maxFrame;
  14771. private _minValue;
  14772. private _maxValue;
  14773. private _targetIsArray;
  14774. /**
  14775. * Gets the current frame of the runtime animation
  14776. */
  14777. get currentFrame(): number;
  14778. /**
  14779. * Gets the weight of the runtime animation
  14780. */
  14781. get weight(): number;
  14782. /**
  14783. * Gets the current value of the runtime animation
  14784. */
  14785. get currentValue(): any;
  14786. /**
  14787. * Gets the target path of the runtime animation
  14788. */
  14789. get targetPath(): string;
  14790. /**
  14791. * Gets the actual target of the runtime animation
  14792. */
  14793. get target(): any;
  14794. /** @hidden */
  14795. _onLoop: () => void;
  14796. /**
  14797. * Create a new RuntimeAnimation object
  14798. * @param target defines the target of the animation
  14799. * @param animation defines the source animation object
  14800. * @param scene defines the hosting scene
  14801. * @param host defines the initiating Animatable
  14802. */
  14803. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14804. private _preparePath;
  14805. /**
  14806. * Gets the animation from the runtime animation
  14807. */
  14808. get animation(): Animation;
  14809. /**
  14810. * Resets the runtime animation to the beginning
  14811. * @param restoreOriginal defines whether to restore the target property to the original value
  14812. */
  14813. reset(restoreOriginal?: boolean): void;
  14814. /**
  14815. * Specifies if the runtime animation is stopped
  14816. * @returns Boolean specifying if the runtime animation is stopped
  14817. */
  14818. isStopped(): boolean;
  14819. /**
  14820. * Disposes of the runtime animation
  14821. */
  14822. dispose(): void;
  14823. /**
  14824. * Apply the interpolated value to the target
  14825. * @param currentValue defines the value computed by the animation
  14826. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14827. */
  14828. setValue(currentValue: any, weight: number): void;
  14829. private _getOriginalValues;
  14830. private _setValue;
  14831. /**
  14832. * Gets the loop pmode of the runtime animation
  14833. * @returns Loop Mode
  14834. */
  14835. private _getCorrectLoopMode;
  14836. /**
  14837. * Move the current animation to a given frame
  14838. * @param frame defines the frame to move to
  14839. */
  14840. goToFrame(frame: number): void;
  14841. /**
  14842. * @hidden Internal use only
  14843. */
  14844. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14845. /**
  14846. * Execute the current animation
  14847. * @param delay defines the delay to add to the current frame
  14848. * @param from defines the lower bound of the animation range
  14849. * @param to defines the upper bound of the animation range
  14850. * @param loop defines if the current animation must loop
  14851. * @param speedRatio defines the current speed ratio
  14852. * @param weight defines the weight of the animation (default is -1 so no weight)
  14853. * @param onLoop optional callback called when animation loops
  14854. * @returns a boolean indicating if the animation is running
  14855. */
  14856. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14857. }
  14858. }
  14859. declare module "babylonjs/Animations/animatable" {
  14860. import { Animation } from "babylonjs/Animations/animation";
  14861. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  14862. import { Nullable } from "babylonjs/types";
  14863. import { Observable } from "babylonjs/Misc/observable";
  14864. import { Scene } from "babylonjs/scene";
  14865. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  14866. import { Node } from "babylonjs/node";
  14867. /**
  14868. * Class used to store an actual running animation
  14869. */
  14870. export class Animatable {
  14871. /** defines the target object */
  14872. target: any;
  14873. /** defines the starting frame number (default is 0) */
  14874. fromFrame: number;
  14875. /** defines the ending frame number (default is 100) */
  14876. toFrame: number;
  14877. /** defines if the animation must loop (default is false) */
  14878. loopAnimation: boolean;
  14879. /** defines a callback to call when animation ends if it is not looping */
  14880. onAnimationEnd?: (() => void) | null | undefined;
  14881. /** defines a callback to call when animation loops */
  14882. onAnimationLoop?: (() => void) | null | undefined;
  14883. private _localDelayOffset;
  14884. private _pausedDelay;
  14885. private _runtimeAnimations;
  14886. private _paused;
  14887. private _scene;
  14888. private _speedRatio;
  14889. private _weight;
  14890. private _syncRoot;
  14891. /**
  14892. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14893. * This will only apply for non looping animation (default is true)
  14894. */
  14895. disposeOnEnd: boolean;
  14896. /**
  14897. * Gets a boolean indicating if the animation has started
  14898. */
  14899. animationStarted: boolean;
  14900. /**
  14901. * Observer raised when the animation ends
  14902. */
  14903. onAnimationEndObservable: Observable<Animatable>;
  14904. /**
  14905. * Observer raised when the animation loops
  14906. */
  14907. onAnimationLoopObservable: Observable<Animatable>;
  14908. /**
  14909. * Gets the root Animatable used to synchronize and normalize animations
  14910. */
  14911. get syncRoot(): Nullable<Animatable>;
  14912. /**
  14913. * Gets the current frame of the first RuntimeAnimation
  14914. * Used to synchronize Animatables
  14915. */
  14916. get masterFrame(): number;
  14917. /**
  14918. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14919. */
  14920. get weight(): number;
  14921. set weight(value: number);
  14922. /**
  14923. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14924. */
  14925. get speedRatio(): number;
  14926. set speedRatio(value: number);
  14927. /**
  14928. * Creates a new Animatable
  14929. * @param scene defines the hosting scene
  14930. * @param target defines the target object
  14931. * @param fromFrame defines the starting frame number (default is 0)
  14932. * @param toFrame defines the ending frame number (default is 100)
  14933. * @param loopAnimation defines if the animation must loop (default is false)
  14934. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14935. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14936. * @param animations defines a group of animation to add to the new Animatable
  14937. * @param onAnimationLoop defines a callback to call when animation loops
  14938. */
  14939. constructor(scene: Scene,
  14940. /** defines the target object */
  14941. target: any,
  14942. /** defines the starting frame number (default is 0) */
  14943. fromFrame?: number,
  14944. /** defines the ending frame number (default is 100) */
  14945. toFrame?: number,
  14946. /** defines if the animation must loop (default is false) */
  14947. loopAnimation?: boolean, speedRatio?: number,
  14948. /** defines a callback to call when animation ends if it is not looping */
  14949. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14950. /** defines a callback to call when animation loops */
  14951. onAnimationLoop?: (() => void) | null | undefined);
  14952. /**
  14953. * Synchronize and normalize current Animatable with a source Animatable
  14954. * This is useful when using animation weights and when animations are not of the same length
  14955. * @param root defines the root Animatable to synchronize with
  14956. * @returns the current Animatable
  14957. */
  14958. syncWith(root: Animatable): Animatable;
  14959. /**
  14960. * Gets the list of runtime animations
  14961. * @returns an array of RuntimeAnimation
  14962. */
  14963. getAnimations(): RuntimeAnimation[];
  14964. /**
  14965. * Adds more animations to the current animatable
  14966. * @param target defines the target of the animations
  14967. * @param animations defines the new animations to add
  14968. */
  14969. appendAnimations(target: any, animations: Animation[]): void;
  14970. /**
  14971. * Gets the source animation for a specific property
  14972. * @param property defines the propertyu to look for
  14973. * @returns null or the source animation for the given property
  14974. */
  14975. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14976. /**
  14977. * Gets the runtime animation for a specific property
  14978. * @param property defines the propertyu to look for
  14979. * @returns null or the runtime animation for the given property
  14980. */
  14981. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14982. /**
  14983. * Resets the animatable to its original state
  14984. */
  14985. reset(): void;
  14986. /**
  14987. * Allows the animatable to blend with current running animations
  14988. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14989. * @param blendingSpeed defines the blending speed to use
  14990. */
  14991. enableBlending(blendingSpeed: number): void;
  14992. /**
  14993. * Disable animation blending
  14994. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14995. */
  14996. disableBlending(): void;
  14997. /**
  14998. * Jump directly to a given frame
  14999. * @param frame defines the frame to jump to
  15000. */
  15001. goToFrame(frame: number): void;
  15002. /**
  15003. * Pause the animation
  15004. */
  15005. pause(): void;
  15006. /**
  15007. * Restart the animation
  15008. */
  15009. restart(): void;
  15010. private _raiseOnAnimationEnd;
  15011. /**
  15012. * Stop and delete the current animation
  15013. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15014. * @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)
  15015. */
  15016. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15017. /**
  15018. * Wait asynchronously for the animation to end
  15019. * @returns a promise which will be fullfilled when the animation ends
  15020. */
  15021. waitAsync(): Promise<Animatable>;
  15022. /** @hidden */
  15023. _animate(delay: number): boolean;
  15024. }
  15025. module "babylonjs/scene" {
  15026. interface Scene {
  15027. /** @hidden */
  15028. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15029. /** @hidden */
  15030. _processLateAnimationBindingsForMatrices(holder: {
  15031. totalWeight: number;
  15032. animations: RuntimeAnimation[];
  15033. originalValue: Matrix;
  15034. }): any;
  15035. /** @hidden */
  15036. _processLateAnimationBindingsForQuaternions(holder: {
  15037. totalWeight: number;
  15038. animations: RuntimeAnimation[];
  15039. originalValue: Quaternion;
  15040. }, refQuaternion: Quaternion): Quaternion;
  15041. /** @hidden */
  15042. _processLateAnimationBindings(): void;
  15043. /**
  15044. * Will start the animation sequence of a given target
  15045. * @param target defines the target
  15046. * @param from defines from which frame should animation start
  15047. * @param to defines until which frame should animation run.
  15048. * @param weight defines the weight to apply to the animation (1.0 by default)
  15049. * @param loop defines if the animation loops
  15050. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15051. * @param onAnimationEnd defines the function to be executed when the animation ends
  15052. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15053. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15054. * @param onAnimationLoop defines the callback to call when an animation loops
  15055. * @returns the animatable object created for this animation
  15056. */
  15057. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15058. /**
  15059. * Will start the animation sequence of a given target
  15060. * @param target defines the target
  15061. * @param from defines from which frame should animation start
  15062. * @param to defines until which frame should animation run.
  15063. * @param loop defines if the animation loops
  15064. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15065. * @param onAnimationEnd defines the function to be executed when the animation ends
  15066. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15067. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15068. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15069. * @param onAnimationLoop defines the callback to call when an animation loops
  15070. * @returns the animatable object created for this animation
  15071. */
  15072. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15073. /**
  15074. * Will start the animation sequence of a given target and its hierarchy
  15075. * @param target defines the target
  15076. * @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.
  15077. * @param from defines from which frame should animation start
  15078. * @param to defines until which frame should animation run.
  15079. * @param loop defines if the animation loops
  15080. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15081. * @param onAnimationEnd defines the function to be executed when the animation ends
  15082. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15083. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15084. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15085. * @param onAnimationLoop defines the callback to call when an animation loops
  15086. * @returns the list of created animatables
  15087. */
  15088. 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[];
  15089. /**
  15090. * Begin a new animation on a given node
  15091. * @param target defines the target where the animation will take place
  15092. * @param animations defines the list of animations to start
  15093. * @param from defines the initial value
  15094. * @param to defines the final value
  15095. * @param loop defines if you want animation to loop (off by default)
  15096. * @param speedRatio defines the speed ratio to apply to all animations
  15097. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15098. * @param onAnimationLoop defines the callback to call when an animation loops
  15099. * @returns the list of created animatables
  15100. */
  15101. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  15102. /**
  15103. * Begin a new animation on a given node and its hierarchy
  15104. * @param target defines the root node where the animation will take place
  15105. * @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.
  15106. * @param animations defines the list of animations to start
  15107. * @param from defines the initial value
  15108. * @param to defines the final value
  15109. * @param loop defines if you want animation to loop (off by default)
  15110. * @param speedRatio defines the speed ratio to apply to all animations
  15111. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15112. * @param onAnimationLoop defines the callback to call when an animation loops
  15113. * @returns the list of animatables created for all nodes
  15114. */
  15115. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  15116. /**
  15117. * Gets the animatable associated with a specific target
  15118. * @param target defines the target of the animatable
  15119. * @returns the required animatable if found
  15120. */
  15121. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15122. /**
  15123. * Gets all animatables associated with a given target
  15124. * @param target defines the target to look animatables for
  15125. * @returns an array of Animatables
  15126. */
  15127. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15128. /**
  15129. * Stops and removes all animations that have been applied to the scene
  15130. */
  15131. stopAllAnimations(): void;
  15132. /**
  15133. * Gets the current delta time used by animation engine
  15134. */
  15135. deltaTime: number;
  15136. }
  15137. }
  15138. module "babylonjs/Bones/bone" {
  15139. interface Bone {
  15140. /**
  15141. * Copy an animation range from another bone
  15142. * @param source defines the source bone
  15143. * @param rangeName defines the range name to copy
  15144. * @param frameOffset defines the frame offset
  15145. * @param rescaleAsRequired defines if rescaling must be applied if required
  15146. * @param skelDimensionsRatio defines the scaling ratio
  15147. * @returns true if operation was successful
  15148. */
  15149. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15150. }
  15151. }
  15152. }
  15153. declare module "babylonjs/Bones/skeleton" {
  15154. import { Bone } from "babylonjs/Bones/bone";
  15155. import { Observable } from "babylonjs/Misc/observable";
  15156. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15157. import { Scene } from "babylonjs/scene";
  15158. import { Nullable } from "babylonjs/types";
  15159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15160. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15161. import { Animatable } from "babylonjs/Animations/animatable";
  15162. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15163. import { Animation } from "babylonjs/Animations/animation";
  15164. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15165. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15166. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15167. /**
  15168. * Class used to handle skinning animations
  15169. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15170. */
  15171. export class Skeleton implements IAnimatable {
  15172. /** defines the skeleton name */
  15173. name: string;
  15174. /** defines the skeleton Id */
  15175. id: string;
  15176. /**
  15177. * Defines the list of child bones
  15178. */
  15179. bones: Bone[];
  15180. /**
  15181. * Defines an estimate of the dimension of the skeleton at rest
  15182. */
  15183. dimensionsAtRest: Vector3;
  15184. /**
  15185. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15186. */
  15187. needInitialSkinMatrix: boolean;
  15188. /**
  15189. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15190. */
  15191. overrideMesh: Nullable<AbstractMesh>;
  15192. /**
  15193. * Gets the list of animations attached to this skeleton
  15194. */
  15195. animations: Array<Animation>;
  15196. private _scene;
  15197. private _isDirty;
  15198. private _transformMatrices;
  15199. private _transformMatrixTexture;
  15200. private _meshesWithPoseMatrix;
  15201. private _animatables;
  15202. private _identity;
  15203. private _synchronizedWithMesh;
  15204. private _ranges;
  15205. private _lastAbsoluteTransformsUpdateId;
  15206. private _canUseTextureForBones;
  15207. private _uniqueId;
  15208. /** @hidden */
  15209. _numBonesWithLinkedTransformNode: number;
  15210. /** @hidden */
  15211. _hasWaitingData: Nullable<boolean>;
  15212. /**
  15213. * Specifies if the skeleton should be serialized
  15214. */
  15215. doNotSerialize: boolean;
  15216. private _useTextureToStoreBoneMatrices;
  15217. /**
  15218. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15219. * Please note that this option is not available if the hardware does not support it
  15220. */
  15221. get useTextureToStoreBoneMatrices(): boolean;
  15222. set useTextureToStoreBoneMatrices(value: boolean);
  15223. private _animationPropertiesOverride;
  15224. /**
  15225. * Gets or sets the animation properties override
  15226. */
  15227. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15228. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15229. /**
  15230. * List of inspectable custom properties (used by the Inspector)
  15231. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15232. */
  15233. inspectableCustomProperties: IInspectable[];
  15234. /**
  15235. * An observable triggered before computing the skeleton's matrices
  15236. */
  15237. onBeforeComputeObservable: Observable<Skeleton>;
  15238. /**
  15239. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15240. */
  15241. get isUsingTextureForMatrices(): boolean;
  15242. /**
  15243. * Gets the unique ID of this skeleton
  15244. */
  15245. get uniqueId(): number;
  15246. /**
  15247. * Creates a new skeleton
  15248. * @param name defines the skeleton name
  15249. * @param id defines the skeleton Id
  15250. * @param scene defines the hosting scene
  15251. */
  15252. constructor(
  15253. /** defines the skeleton name */
  15254. name: string,
  15255. /** defines the skeleton Id */
  15256. id: string, scene: Scene);
  15257. /**
  15258. * Gets the current object class name.
  15259. * @return the class name
  15260. */
  15261. getClassName(): string;
  15262. /**
  15263. * Returns an array containing the root bones
  15264. * @returns an array containing the root bones
  15265. */
  15266. getChildren(): Array<Bone>;
  15267. /**
  15268. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15269. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15270. * @returns a Float32Array containing matrices data
  15271. */
  15272. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15273. /**
  15274. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15275. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15276. * @returns a raw texture containing the data
  15277. */
  15278. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15279. /**
  15280. * Gets the current hosting scene
  15281. * @returns a scene object
  15282. */
  15283. getScene(): Scene;
  15284. /**
  15285. * Gets a string representing the current skeleton data
  15286. * @param fullDetails defines a boolean indicating if we want a verbose version
  15287. * @returns a string representing the current skeleton data
  15288. */
  15289. toString(fullDetails?: boolean): string;
  15290. /**
  15291. * Get bone's index searching by name
  15292. * @param name defines bone's name to search for
  15293. * @return the indice of the bone. Returns -1 if not found
  15294. */
  15295. getBoneIndexByName(name: string): number;
  15296. /**
  15297. * Creater a new animation range
  15298. * @param name defines the name of the range
  15299. * @param from defines the start key
  15300. * @param to defines the end key
  15301. */
  15302. createAnimationRange(name: string, from: number, to: number): void;
  15303. /**
  15304. * Delete a specific animation range
  15305. * @param name defines the name of the range
  15306. * @param deleteFrames defines if frames must be removed as well
  15307. */
  15308. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15309. /**
  15310. * Gets a specific animation range
  15311. * @param name defines the name of the range to look for
  15312. * @returns the requested animation range or null if not found
  15313. */
  15314. getAnimationRange(name: string): Nullable<AnimationRange>;
  15315. /**
  15316. * Gets the list of all animation ranges defined on this skeleton
  15317. * @returns an array
  15318. */
  15319. getAnimationRanges(): Nullable<AnimationRange>[];
  15320. /**
  15321. * Copy animation range from a source skeleton.
  15322. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15323. * @param source defines the source skeleton
  15324. * @param name defines the name of the range to copy
  15325. * @param rescaleAsRequired defines if rescaling must be applied if required
  15326. * @returns true if operation was successful
  15327. */
  15328. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15329. /**
  15330. * Forces the skeleton to go to rest pose
  15331. */
  15332. returnToRest(): void;
  15333. private _getHighestAnimationFrame;
  15334. /**
  15335. * Begin a specific animation range
  15336. * @param name defines the name of the range to start
  15337. * @param loop defines if looping must be turned on (false by default)
  15338. * @param speedRatio defines the speed ratio to apply (1 by default)
  15339. * @param onAnimationEnd defines a callback which will be called when animation will end
  15340. * @returns a new animatable
  15341. */
  15342. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15343. /** @hidden */
  15344. _markAsDirty(): void;
  15345. /** @hidden */
  15346. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15347. /** @hidden */
  15348. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15349. private _computeTransformMatrices;
  15350. /**
  15351. * Build all resources required to render a skeleton
  15352. */
  15353. prepare(): void;
  15354. /**
  15355. * Gets the list of animatables currently running for this skeleton
  15356. * @returns an array of animatables
  15357. */
  15358. getAnimatables(): IAnimatable[];
  15359. /**
  15360. * Clone the current skeleton
  15361. * @param name defines the name of the new skeleton
  15362. * @param id defines the id of the new skeleton
  15363. * @returns the new skeleton
  15364. */
  15365. clone(name: string, id?: string): Skeleton;
  15366. /**
  15367. * Enable animation blending for this skeleton
  15368. * @param blendingSpeed defines the blending speed to apply
  15369. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15370. */
  15371. enableBlending(blendingSpeed?: number): void;
  15372. /**
  15373. * Releases all resources associated with the current skeleton
  15374. */
  15375. dispose(): void;
  15376. /**
  15377. * Serialize the skeleton in a JSON object
  15378. * @returns a JSON object
  15379. */
  15380. serialize(): any;
  15381. /**
  15382. * Creates a new skeleton from serialized data
  15383. * @param parsedSkeleton defines the serialized data
  15384. * @param scene defines the hosting scene
  15385. * @returns a new skeleton
  15386. */
  15387. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15388. /**
  15389. * Compute all node absolute transforms
  15390. * @param forceUpdate defines if computation must be done even if cache is up to date
  15391. */
  15392. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15393. /**
  15394. * Gets the root pose matrix
  15395. * @returns a matrix
  15396. */
  15397. getPoseMatrix(): Nullable<Matrix>;
  15398. /**
  15399. * Sorts bones per internal index
  15400. */
  15401. sortBones(): void;
  15402. private _sortBones;
  15403. }
  15404. }
  15405. declare module "babylonjs/Meshes/instancedMesh" {
  15406. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15407. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15408. import { Camera } from "babylonjs/Cameras/camera";
  15409. import { Node } from "babylonjs/node";
  15410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15411. import { Mesh } from "babylonjs/Meshes/mesh";
  15412. import { Material } from "babylonjs/Materials/material";
  15413. import { Skeleton } from "babylonjs/Bones/skeleton";
  15414. import { Light } from "babylonjs/Lights/light";
  15415. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15416. /**
  15417. * Creates an instance based on a source mesh.
  15418. */
  15419. export class InstancedMesh extends AbstractMesh {
  15420. private _sourceMesh;
  15421. private _currentLOD;
  15422. /** @hidden */
  15423. _indexInSourceMeshInstanceArray: number;
  15424. constructor(name: string, source: Mesh);
  15425. /**
  15426. * Returns the string "InstancedMesh".
  15427. */
  15428. getClassName(): string;
  15429. /** Gets the list of lights affecting that mesh */
  15430. get lightSources(): Light[];
  15431. _resyncLightSources(): void;
  15432. _resyncLightSource(light: Light): void;
  15433. _removeLightSource(light: Light, dispose: boolean): void;
  15434. /**
  15435. * If the source mesh receives shadows
  15436. */
  15437. get receiveShadows(): boolean;
  15438. /**
  15439. * The material of the source mesh
  15440. */
  15441. get material(): Nullable<Material>;
  15442. /**
  15443. * Visibility of the source mesh
  15444. */
  15445. get visibility(): number;
  15446. /**
  15447. * Skeleton of the source mesh
  15448. */
  15449. get skeleton(): Nullable<Skeleton>;
  15450. /**
  15451. * Rendering ground id of the source mesh
  15452. */
  15453. get renderingGroupId(): number;
  15454. set renderingGroupId(value: number);
  15455. /**
  15456. * Returns the total number of vertices (integer).
  15457. */
  15458. getTotalVertices(): number;
  15459. /**
  15460. * Returns a positive integer : the total number of indices in this mesh geometry.
  15461. * @returns the numner of indices or zero if the mesh has no geometry.
  15462. */
  15463. getTotalIndices(): number;
  15464. /**
  15465. * The source mesh of the instance
  15466. */
  15467. get sourceMesh(): Mesh;
  15468. /**
  15469. * Is this node ready to be used/rendered
  15470. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15471. * @return {boolean} is it ready
  15472. */
  15473. isReady(completeCheck?: boolean): boolean;
  15474. /**
  15475. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15476. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15477. * @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.
  15478. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15479. */
  15480. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15481. /**
  15482. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15483. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15484. * The `data` are either a numeric array either a Float32Array.
  15485. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15486. * 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).
  15487. * Note that a new underlying VertexBuffer object is created each call.
  15488. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15489. *
  15490. * Possible `kind` values :
  15491. * - VertexBuffer.PositionKind
  15492. * - VertexBuffer.UVKind
  15493. * - VertexBuffer.UV2Kind
  15494. * - VertexBuffer.UV3Kind
  15495. * - VertexBuffer.UV4Kind
  15496. * - VertexBuffer.UV5Kind
  15497. * - VertexBuffer.UV6Kind
  15498. * - VertexBuffer.ColorKind
  15499. * - VertexBuffer.MatricesIndicesKind
  15500. * - VertexBuffer.MatricesIndicesExtraKind
  15501. * - VertexBuffer.MatricesWeightsKind
  15502. * - VertexBuffer.MatricesWeightsExtraKind
  15503. *
  15504. * Returns the Mesh.
  15505. */
  15506. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15507. /**
  15508. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15509. * If the mesh has no geometry, it is simply returned as it is.
  15510. * The `data` are either a numeric array either a Float32Array.
  15511. * No new underlying VertexBuffer object is created.
  15512. * 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.
  15513. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15514. *
  15515. * Possible `kind` values :
  15516. * - VertexBuffer.PositionKind
  15517. * - VertexBuffer.UVKind
  15518. * - VertexBuffer.UV2Kind
  15519. * - VertexBuffer.UV3Kind
  15520. * - VertexBuffer.UV4Kind
  15521. * - VertexBuffer.UV5Kind
  15522. * - VertexBuffer.UV6Kind
  15523. * - VertexBuffer.ColorKind
  15524. * - VertexBuffer.MatricesIndicesKind
  15525. * - VertexBuffer.MatricesIndicesExtraKind
  15526. * - VertexBuffer.MatricesWeightsKind
  15527. * - VertexBuffer.MatricesWeightsExtraKind
  15528. *
  15529. * Returns the Mesh.
  15530. */
  15531. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15532. /**
  15533. * Sets the mesh indices.
  15534. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15535. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15536. * This method creates a new index buffer each call.
  15537. * Returns the Mesh.
  15538. */
  15539. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15540. /**
  15541. * Boolean : True if the mesh owns the requested kind of data.
  15542. */
  15543. isVerticesDataPresent(kind: string): boolean;
  15544. /**
  15545. * Returns an array of indices (IndicesArray).
  15546. */
  15547. getIndices(): Nullable<IndicesArray>;
  15548. get _positions(): Nullable<Vector3[]>;
  15549. /**
  15550. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15551. * This means the mesh underlying bounding box and sphere are recomputed.
  15552. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15553. * @returns the current mesh
  15554. */
  15555. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15556. /** @hidden */
  15557. _preActivate(): InstancedMesh;
  15558. /** @hidden */
  15559. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15560. /** @hidden */
  15561. _postActivate(): void;
  15562. getWorldMatrix(): Matrix;
  15563. get isAnInstance(): boolean;
  15564. /**
  15565. * Returns the current associated LOD AbstractMesh.
  15566. */
  15567. getLOD(camera: Camera): AbstractMesh;
  15568. /** @hidden */
  15569. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15570. /** @hidden */
  15571. _syncSubMeshes(): InstancedMesh;
  15572. /** @hidden */
  15573. _generatePointsArray(): boolean;
  15574. /**
  15575. * Creates a new InstancedMesh from the current mesh.
  15576. * - name (string) : the cloned mesh name
  15577. * - newParent (optional Node) : the optional Node to parent the clone to.
  15578. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15579. *
  15580. * Returns the clone.
  15581. */
  15582. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15583. /**
  15584. * Disposes the InstancedMesh.
  15585. * Returns nothing.
  15586. */
  15587. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15588. }
  15589. module "babylonjs/Meshes/mesh" {
  15590. interface Mesh {
  15591. /**
  15592. * Register a custom buffer that will be instanced
  15593. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15594. * @param kind defines the buffer kind
  15595. * @param stride defines the stride in floats
  15596. */
  15597. registerInstancedBuffer(kind: string, stride: number): void;
  15598. /** @hidden */
  15599. _userInstancedBuffersStorage: {
  15600. data: {
  15601. [key: string]: Float32Array;
  15602. };
  15603. sizes: {
  15604. [key: string]: number;
  15605. };
  15606. vertexBuffers: {
  15607. [key: string]: Nullable<VertexBuffer>;
  15608. };
  15609. strides: {
  15610. [key: string]: number;
  15611. };
  15612. };
  15613. }
  15614. }
  15615. module "babylonjs/Meshes/abstractMesh" {
  15616. interface AbstractMesh {
  15617. /**
  15618. * Object used to store instanced buffers defined by user
  15619. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15620. */
  15621. instancedBuffers: {
  15622. [key: string]: any;
  15623. };
  15624. }
  15625. }
  15626. }
  15627. declare module "babylonjs/Materials/shaderMaterial" {
  15628. import { Scene } from "babylonjs/scene";
  15629. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15631. import { Mesh } from "babylonjs/Meshes/mesh";
  15632. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15633. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15634. import { Texture } from "babylonjs/Materials/Textures/texture";
  15635. import { Material } from "babylonjs/Materials/material";
  15636. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15637. /**
  15638. * Defines the options associated with the creation of a shader material.
  15639. */
  15640. export interface IShaderMaterialOptions {
  15641. /**
  15642. * Does the material work in alpha blend mode
  15643. */
  15644. needAlphaBlending: boolean;
  15645. /**
  15646. * Does the material work in alpha test mode
  15647. */
  15648. needAlphaTesting: boolean;
  15649. /**
  15650. * The list of attribute names used in the shader
  15651. */
  15652. attributes: string[];
  15653. /**
  15654. * The list of unifrom names used in the shader
  15655. */
  15656. uniforms: string[];
  15657. /**
  15658. * The list of UBO names used in the shader
  15659. */
  15660. uniformBuffers: string[];
  15661. /**
  15662. * The list of sampler names used in the shader
  15663. */
  15664. samplers: string[];
  15665. /**
  15666. * The list of defines used in the shader
  15667. */
  15668. defines: string[];
  15669. }
  15670. /**
  15671. * 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.
  15672. *
  15673. * This returned material effects how the mesh will look based on the code in the shaders.
  15674. *
  15675. * @see http://doc.babylonjs.com/how_to/shader_material
  15676. */
  15677. export class ShaderMaterial extends Material {
  15678. private _shaderPath;
  15679. private _options;
  15680. private _textures;
  15681. private _textureArrays;
  15682. private _floats;
  15683. private _ints;
  15684. private _floatsArrays;
  15685. private _colors3;
  15686. private _colors3Arrays;
  15687. private _colors4;
  15688. private _colors4Arrays;
  15689. private _vectors2;
  15690. private _vectors3;
  15691. private _vectors4;
  15692. private _matrices;
  15693. private _matrixArrays;
  15694. private _matrices3x3;
  15695. private _matrices2x2;
  15696. private _vectors2Arrays;
  15697. private _vectors3Arrays;
  15698. private _vectors4Arrays;
  15699. private _cachedWorldViewMatrix;
  15700. private _cachedWorldViewProjectionMatrix;
  15701. private _renderId;
  15702. private _multiview;
  15703. /**
  15704. * Instantiate a new shader material.
  15705. * 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.
  15706. * This returned material effects how the mesh will look based on the code in the shaders.
  15707. * @see http://doc.babylonjs.com/how_to/shader_material
  15708. * @param name Define the name of the material in the scene
  15709. * @param scene Define the scene the material belongs to
  15710. * @param shaderPath Defines the route to the shader code in one of three ways:
  15711. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15712. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15713. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15714. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15715. * @param options Define the options used to create the shader
  15716. */
  15717. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15718. /**
  15719. * Gets the shader path used to define the shader code
  15720. * It can be modified to trigger a new compilation
  15721. */
  15722. get shaderPath(): any;
  15723. /**
  15724. * Sets the shader path used to define the shader code
  15725. * It can be modified to trigger a new compilation
  15726. */
  15727. set shaderPath(shaderPath: any);
  15728. /**
  15729. * Gets the options used to compile the shader.
  15730. * They can be modified to trigger a new compilation
  15731. */
  15732. get options(): IShaderMaterialOptions;
  15733. /**
  15734. * Gets the current class name of the material e.g. "ShaderMaterial"
  15735. * Mainly use in serialization.
  15736. * @returns the class name
  15737. */
  15738. getClassName(): string;
  15739. /**
  15740. * Specifies if the material will require alpha blending
  15741. * @returns a boolean specifying if alpha blending is needed
  15742. */
  15743. needAlphaBlending(): boolean;
  15744. /**
  15745. * Specifies if this material should be rendered in alpha test mode
  15746. * @returns a boolean specifying if an alpha test is needed.
  15747. */
  15748. needAlphaTesting(): boolean;
  15749. private _checkUniform;
  15750. /**
  15751. * Set a texture in the shader.
  15752. * @param name Define the name of the uniform samplers as defined in the shader
  15753. * @param texture Define the texture to bind to this sampler
  15754. * @return the material itself allowing "fluent" like uniform updates
  15755. */
  15756. setTexture(name: string, texture: Texture): ShaderMaterial;
  15757. /**
  15758. * Set a texture array in the shader.
  15759. * @param name Define the name of the uniform sampler array as defined in the shader
  15760. * @param textures Define the list of textures to bind to this sampler
  15761. * @return the material itself allowing "fluent" like uniform updates
  15762. */
  15763. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15764. /**
  15765. * Set a float in the shader.
  15766. * @param name Define the name of the uniform as defined in the shader
  15767. * @param value Define the value to give to the uniform
  15768. * @return the material itself allowing "fluent" like uniform updates
  15769. */
  15770. setFloat(name: string, value: number): ShaderMaterial;
  15771. /**
  15772. * Set a int in the shader.
  15773. * @param name Define the name of the uniform as defined in the shader
  15774. * @param value Define the value to give to the uniform
  15775. * @return the material itself allowing "fluent" like uniform updates
  15776. */
  15777. setInt(name: string, value: number): ShaderMaterial;
  15778. /**
  15779. * Set an array of floats in the shader.
  15780. * @param name Define the name of the uniform as defined in the shader
  15781. * @param value Define the value to give to the uniform
  15782. * @return the material itself allowing "fluent" like uniform updates
  15783. */
  15784. setFloats(name: string, value: number[]): ShaderMaterial;
  15785. /**
  15786. * Set a vec3 in the shader from a Color3.
  15787. * @param name Define the name of the uniform as defined in the shader
  15788. * @param value Define the value to give to the uniform
  15789. * @return the material itself allowing "fluent" like uniform updates
  15790. */
  15791. setColor3(name: string, value: Color3): ShaderMaterial;
  15792. /**
  15793. * Set a vec3 array in the shader from a Color3 array.
  15794. * @param name Define the name of the uniform as defined in the shader
  15795. * @param value Define the value to give to the uniform
  15796. * @return the material itself allowing "fluent" like uniform updates
  15797. */
  15798. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15799. /**
  15800. * Set a vec4 in the shader from a Color4.
  15801. * @param name Define the name of the uniform as defined in the shader
  15802. * @param value Define the value to give to the uniform
  15803. * @return the material itself allowing "fluent" like uniform updates
  15804. */
  15805. setColor4(name: string, value: Color4): ShaderMaterial;
  15806. /**
  15807. * Set a vec4 array in the shader from a Color4 array.
  15808. * @param name Define the name of the uniform as defined in the shader
  15809. * @param value Define the value to give to the uniform
  15810. * @return the material itself allowing "fluent" like uniform updates
  15811. */
  15812. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15813. /**
  15814. * Set a vec2 in the shader from a Vector2.
  15815. * @param name Define the name of the uniform as defined in the shader
  15816. * @param value Define the value to give to the uniform
  15817. * @return the material itself allowing "fluent" like uniform updates
  15818. */
  15819. setVector2(name: string, value: Vector2): ShaderMaterial;
  15820. /**
  15821. * Set a vec3 in the shader from a Vector3.
  15822. * @param name Define the name of the uniform as defined in the shader
  15823. * @param value Define the value to give to the uniform
  15824. * @return the material itself allowing "fluent" like uniform updates
  15825. */
  15826. setVector3(name: string, value: Vector3): ShaderMaterial;
  15827. /**
  15828. * Set a vec4 in the shader from a Vector4.
  15829. * @param name Define the name of the uniform as defined in the shader
  15830. * @param value Define the value to give to the uniform
  15831. * @return the material itself allowing "fluent" like uniform updates
  15832. */
  15833. setVector4(name: string, value: Vector4): ShaderMaterial;
  15834. /**
  15835. * Set a mat4 in the shader from a Matrix.
  15836. * @param name Define the name of the uniform as defined in the shader
  15837. * @param value Define the value to give to the uniform
  15838. * @return the material itself allowing "fluent" like uniform updates
  15839. */
  15840. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15841. /**
  15842. * Set a float32Array in the shader from a matrix array.
  15843. * @param name Define the name of the uniform as defined in the shader
  15844. * @param value Define the value to give to the uniform
  15845. * @return the material itself allowing "fluent" like uniform updates
  15846. */
  15847. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15848. /**
  15849. * Set a mat3 in the shader from a Float32Array.
  15850. * @param name Define the name of the uniform as defined in the shader
  15851. * @param value Define the value to give to the uniform
  15852. * @return the material itself allowing "fluent" like uniform updates
  15853. */
  15854. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15855. /**
  15856. * Set a mat2 in the shader from a Float32Array.
  15857. * @param name Define the name of the uniform as defined in the shader
  15858. * @param value Define the value to give to the uniform
  15859. * @return the material itself allowing "fluent" like uniform updates
  15860. */
  15861. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15862. /**
  15863. * Set a vec2 array in the shader from a number array.
  15864. * @param name Define the name of the uniform as defined in the shader
  15865. * @param value Define the value to give to the uniform
  15866. * @return the material itself allowing "fluent" like uniform updates
  15867. */
  15868. setArray2(name: string, value: number[]): ShaderMaterial;
  15869. /**
  15870. * Set a vec3 array in the shader from a number array.
  15871. * @param name Define the name of the uniform as defined in the shader
  15872. * @param value Define the value to give to the uniform
  15873. * @return the material itself allowing "fluent" like uniform updates
  15874. */
  15875. setArray3(name: string, value: number[]): ShaderMaterial;
  15876. /**
  15877. * Set a vec4 array in the shader from a number array.
  15878. * @param name Define the name of the uniform as defined in the shader
  15879. * @param value Define the value to give to the uniform
  15880. * @return the material itself allowing "fluent" like uniform updates
  15881. */
  15882. setArray4(name: string, value: number[]): ShaderMaterial;
  15883. private _checkCache;
  15884. /**
  15885. * Specifies that the submesh is ready to be used
  15886. * @param mesh defines the mesh to check
  15887. * @param subMesh defines which submesh to check
  15888. * @param useInstances specifies that instances should be used
  15889. * @returns a boolean indicating that the submesh is ready or not
  15890. */
  15891. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15892. /**
  15893. * Checks if the material is ready to render the requested mesh
  15894. * @param mesh Define the mesh to render
  15895. * @param useInstances Define whether or not the material is used with instances
  15896. * @returns true if ready, otherwise false
  15897. */
  15898. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15899. /**
  15900. * Binds the world matrix to the material
  15901. * @param world defines the world transformation matrix
  15902. */
  15903. bindOnlyWorldMatrix(world: Matrix): void;
  15904. /**
  15905. * Binds the material to the mesh
  15906. * @param world defines the world transformation matrix
  15907. * @param mesh defines the mesh to bind the material to
  15908. */
  15909. bind(world: Matrix, mesh?: Mesh): void;
  15910. /**
  15911. * Gets the active textures from the material
  15912. * @returns an array of textures
  15913. */
  15914. getActiveTextures(): BaseTexture[];
  15915. /**
  15916. * Specifies if the material uses a texture
  15917. * @param texture defines the texture to check against the material
  15918. * @returns a boolean specifying if the material uses the texture
  15919. */
  15920. hasTexture(texture: BaseTexture): boolean;
  15921. /**
  15922. * Makes a duplicate of the material, and gives it a new name
  15923. * @param name defines the new name for the duplicated material
  15924. * @returns the cloned material
  15925. */
  15926. clone(name: string): ShaderMaterial;
  15927. /**
  15928. * Disposes the material
  15929. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15930. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15931. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15932. */
  15933. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15934. /**
  15935. * Serializes this material in a JSON representation
  15936. * @returns the serialized material object
  15937. */
  15938. serialize(): any;
  15939. /**
  15940. * Creates a shader material from parsed shader material data
  15941. * @param source defines the JSON represnetation of the material
  15942. * @param scene defines the hosting scene
  15943. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15944. * @returns a new material
  15945. */
  15946. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15947. }
  15948. }
  15949. declare module "babylonjs/Shaders/color.fragment" {
  15950. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15951. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15952. /** @hidden */
  15953. export var colorPixelShader: {
  15954. name: string;
  15955. shader: string;
  15956. };
  15957. }
  15958. declare module "babylonjs/Shaders/color.vertex" {
  15959. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  15960. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15961. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  15962. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  15963. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  15964. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15965. /** @hidden */
  15966. export var colorVertexShader: {
  15967. name: string;
  15968. shader: string;
  15969. };
  15970. }
  15971. declare module "babylonjs/Meshes/linesMesh" {
  15972. import { Nullable } from "babylonjs/types";
  15973. import { Scene } from "babylonjs/scene";
  15974. import { Color3 } from "babylonjs/Maths/math.color";
  15975. import { Node } from "babylonjs/node";
  15976. import { SubMesh } from "babylonjs/Meshes/subMesh";
  15977. import { Mesh } from "babylonjs/Meshes/mesh";
  15978. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  15979. import { Effect } from "babylonjs/Materials/effect";
  15980. import { Material } from "babylonjs/Materials/material";
  15981. import "babylonjs/Shaders/color.fragment";
  15982. import "babylonjs/Shaders/color.vertex";
  15983. /**
  15984. * Line mesh
  15985. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15986. */
  15987. export class LinesMesh extends Mesh {
  15988. /**
  15989. * If vertex color should be applied to the mesh
  15990. */
  15991. readonly useVertexColor?: boolean | undefined;
  15992. /**
  15993. * If vertex alpha should be applied to the mesh
  15994. */
  15995. readonly useVertexAlpha?: boolean | undefined;
  15996. /**
  15997. * Color of the line (Default: White)
  15998. */
  15999. color: Color3;
  16000. /**
  16001. * Alpha of the line (Default: 1)
  16002. */
  16003. alpha: number;
  16004. /**
  16005. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16006. * This margin is expressed in world space coordinates, so its value may vary.
  16007. * Default value is 0.1
  16008. */
  16009. intersectionThreshold: number;
  16010. private _colorShader;
  16011. private color4;
  16012. /**
  16013. * Creates a new LinesMesh
  16014. * @param name defines the name
  16015. * @param scene defines the hosting scene
  16016. * @param parent defines the parent mesh if any
  16017. * @param source defines the optional source LinesMesh used to clone data from
  16018. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16019. * When false, achieved by calling a clone(), also passing False.
  16020. * This will make creation of children, recursive.
  16021. * @param useVertexColor defines if this LinesMesh supports vertex color
  16022. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16023. */
  16024. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16025. /**
  16026. * If vertex color should be applied to the mesh
  16027. */
  16028. useVertexColor?: boolean | undefined,
  16029. /**
  16030. * If vertex alpha should be applied to the mesh
  16031. */
  16032. useVertexAlpha?: boolean | undefined);
  16033. private _addClipPlaneDefine;
  16034. private _removeClipPlaneDefine;
  16035. isReady(): boolean;
  16036. /**
  16037. * Returns the string "LineMesh"
  16038. */
  16039. getClassName(): string;
  16040. /**
  16041. * @hidden
  16042. */
  16043. get material(): Material;
  16044. /**
  16045. * @hidden
  16046. */
  16047. set material(value: Material);
  16048. /**
  16049. * @hidden
  16050. */
  16051. get checkCollisions(): boolean;
  16052. /** @hidden */
  16053. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16054. /** @hidden */
  16055. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16056. /**
  16057. * Disposes of the line mesh
  16058. * @param doNotRecurse If children should be disposed
  16059. */
  16060. dispose(doNotRecurse?: boolean): void;
  16061. /**
  16062. * Returns a new LineMesh object cloned from the current one.
  16063. */
  16064. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16065. /**
  16066. * Creates a new InstancedLinesMesh object from the mesh model.
  16067. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16068. * @param name defines the name of the new instance
  16069. * @returns a new InstancedLinesMesh
  16070. */
  16071. createInstance(name: string): InstancedLinesMesh;
  16072. }
  16073. /**
  16074. * Creates an instance based on a source LinesMesh
  16075. */
  16076. export class InstancedLinesMesh extends InstancedMesh {
  16077. /**
  16078. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16079. * This margin is expressed in world space coordinates, so its value may vary.
  16080. * Initilized with the intersectionThreshold value of the source LinesMesh
  16081. */
  16082. intersectionThreshold: number;
  16083. constructor(name: string, source: LinesMesh);
  16084. /**
  16085. * Returns the string "InstancedLinesMesh".
  16086. */
  16087. getClassName(): string;
  16088. }
  16089. }
  16090. declare module "babylonjs/Shaders/line.fragment" {
  16091. /** @hidden */
  16092. export var linePixelShader: {
  16093. name: string;
  16094. shader: string;
  16095. };
  16096. }
  16097. declare module "babylonjs/Shaders/line.vertex" {
  16098. /** @hidden */
  16099. export var lineVertexShader: {
  16100. name: string;
  16101. shader: string;
  16102. };
  16103. }
  16104. declare module "babylonjs/Rendering/edgesRenderer" {
  16105. import { Nullable } from "babylonjs/types";
  16106. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16108. import { Vector3 } from "babylonjs/Maths/math.vector";
  16109. import { IDisposable } from "babylonjs/scene";
  16110. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16111. import "babylonjs/Shaders/line.fragment";
  16112. import "babylonjs/Shaders/line.vertex";
  16113. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16114. module "babylonjs/Meshes/abstractMesh" {
  16115. interface AbstractMesh {
  16116. /**
  16117. * Gets the edgesRenderer associated with the mesh
  16118. */
  16119. edgesRenderer: Nullable<EdgesRenderer>;
  16120. }
  16121. }
  16122. module "babylonjs/Meshes/linesMesh" {
  16123. interface LinesMesh {
  16124. /**
  16125. * Enables the edge rendering mode on the mesh.
  16126. * This mode makes the mesh edges visible
  16127. * @param epsilon defines the maximal distance between two angles to detect a face
  16128. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16129. * @returns the currentAbstractMesh
  16130. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16131. */
  16132. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16133. }
  16134. }
  16135. module "babylonjs/Meshes/linesMesh" {
  16136. interface InstancedLinesMesh {
  16137. /**
  16138. * Enables the edge rendering mode on the mesh.
  16139. * This mode makes the mesh edges visible
  16140. * @param epsilon defines the maximal distance between two angles to detect a face
  16141. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16142. * @returns the current InstancedLinesMesh
  16143. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16144. */
  16145. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16146. }
  16147. }
  16148. /**
  16149. * Defines the minimum contract an Edges renderer should follow.
  16150. */
  16151. export interface IEdgesRenderer extends IDisposable {
  16152. /**
  16153. * Gets or sets a boolean indicating if the edgesRenderer is active
  16154. */
  16155. isEnabled: boolean;
  16156. /**
  16157. * Renders the edges of the attached mesh,
  16158. */
  16159. render(): void;
  16160. /**
  16161. * Checks wether or not the edges renderer is ready to render.
  16162. * @return true if ready, otherwise false.
  16163. */
  16164. isReady(): boolean;
  16165. }
  16166. /**
  16167. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16168. */
  16169. export class EdgesRenderer implements IEdgesRenderer {
  16170. /**
  16171. * Define the size of the edges with an orthographic camera
  16172. */
  16173. edgesWidthScalerForOrthographic: number;
  16174. /**
  16175. * Define the size of the edges with a perspective camera
  16176. */
  16177. edgesWidthScalerForPerspective: number;
  16178. protected _source: AbstractMesh;
  16179. protected _linesPositions: number[];
  16180. protected _linesNormals: number[];
  16181. protected _linesIndices: number[];
  16182. protected _epsilon: number;
  16183. protected _indicesCount: number;
  16184. protected _lineShader: ShaderMaterial;
  16185. protected _ib: DataBuffer;
  16186. protected _buffers: {
  16187. [key: string]: Nullable<VertexBuffer>;
  16188. };
  16189. protected _checkVerticesInsteadOfIndices: boolean;
  16190. private _meshRebuildObserver;
  16191. private _meshDisposeObserver;
  16192. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16193. isEnabled: boolean;
  16194. /**
  16195. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16196. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16197. * @param source Mesh used to create edges
  16198. * @param epsilon sum of angles in adjacency to check for edge
  16199. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16200. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16201. */
  16202. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16203. protected _prepareRessources(): void;
  16204. /** @hidden */
  16205. _rebuild(): void;
  16206. /**
  16207. * Releases the required resources for the edges renderer
  16208. */
  16209. dispose(): void;
  16210. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16211. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16212. /**
  16213. * Checks if the pair of p0 and p1 is en edge
  16214. * @param faceIndex
  16215. * @param edge
  16216. * @param faceNormals
  16217. * @param p0
  16218. * @param p1
  16219. * @private
  16220. */
  16221. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16222. /**
  16223. * push line into the position, normal and index buffer
  16224. * @protected
  16225. */
  16226. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16227. /**
  16228. * Generates lines edges from adjacencjes
  16229. * @private
  16230. */
  16231. _generateEdgesLines(): void;
  16232. /**
  16233. * Checks wether or not the edges renderer is ready to render.
  16234. * @return true if ready, otherwise false.
  16235. */
  16236. isReady(): boolean;
  16237. /**
  16238. * Renders the edges of the attached mesh,
  16239. */
  16240. render(): void;
  16241. }
  16242. /**
  16243. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16244. */
  16245. export class LineEdgesRenderer extends EdgesRenderer {
  16246. /**
  16247. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16248. * @param source LineMesh used to generate edges
  16249. * @param epsilon not important (specified angle for edge detection)
  16250. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16251. */
  16252. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16253. /**
  16254. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16255. */
  16256. _generateEdgesLines(): void;
  16257. }
  16258. }
  16259. declare module "babylonjs/Rendering/renderingGroup" {
  16260. import { SmartArray } from "babylonjs/Misc/smartArray";
  16261. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16263. import { Nullable } from "babylonjs/types";
  16264. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16265. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16266. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16267. import { Material } from "babylonjs/Materials/material";
  16268. import { Scene } from "babylonjs/scene";
  16269. /**
  16270. * This represents the object necessary to create a rendering group.
  16271. * This is exclusively used and created by the rendering manager.
  16272. * To modify the behavior, you use the available helpers in your scene or meshes.
  16273. * @hidden
  16274. */
  16275. export class RenderingGroup {
  16276. index: number;
  16277. private static _zeroVector;
  16278. private _scene;
  16279. private _opaqueSubMeshes;
  16280. private _transparentSubMeshes;
  16281. private _alphaTestSubMeshes;
  16282. private _depthOnlySubMeshes;
  16283. private _particleSystems;
  16284. private _spriteManagers;
  16285. private _opaqueSortCompareFn;
  16286. private _alphaTestSortCompareFn;
  16287. private _transparentSortCompareFn;
  16288. private _renderOpaque;
  16289. private _renderAlphaTest;
  16290. private _renderTransparent;
  16291. /** @hidden */
  16292. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16293. onBeforeTransparentRendering: () => void;
  16294. /**
  16295. * Set the opaque sort comparison function.
  16296. * If null the sub meshes will be render in the order they were created
  16297. */
  16298. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16299. /**
  16300. * Set the alpha test sort comparison function.
  16301. * If null the sub meshes will be render in the order they were created
  16302. */
  16303. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16304. /**
  16305. * Set the transparent sort comparison function.
  16306. * If null the sub meshes will be render in the order they were created
  16307. */
  16308. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16309. /**
  16310. * Creates a new rendering group.
  16311. * @param index The rendering group index
  16312. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16313. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16314. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16315. */
  16316. 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>);
  16317. /**
  16318. * Render all the sub meshes contained in the group.
  16319. * @param customRenderFunction Used to override the default render behaviour of the group.
  16320. * @returns true if rendered some submeshes.
  16321. */
  16322. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16323. /**
  16324. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16325. * @param subMeshes The submeshes to render
  16326. */
  16327. private renderOpaqueSorted;
  16328. /**
  16329. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16330. * @param subMeshes The submeshes to render
  16331. */
  16332. private renderAlphaTestSorted;
  16333. /**
  16334. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16335. * @param subMeshes The submeshes to render
  16336. */
  16337. private renderTransparentSorted;
  16338. /**
  16339. * Renders the submeshes in a specified order.
  16340. * @param subMeshes The submeshes to sort before render
  16341. * @param sortCompareFn The comparison function use to sort
  16342. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16343. * @param transparent Specifies to activate blending if true
  16344. */
  16345. private static renderSorted;
  16346. /**
  16347. * Renders the submeshes in the order they were dispatched (no sort applied).
  16348. * @param subMeshes The submeshes to render
  16349. */
  16350. private static renderUnsorted;
  16351. /**
  16352. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16353. * are rendered back to front if in the same alpha index.
  16354. *
  16355. * @param a The first submesh
  16356. * @param b The second submesh
  16357. * @returns The result of the comparison
  16358. */
  16359. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16360. /**
  16361. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16362. * are rendered back to front.
  16363. *
  16364. * @param a The first submesh
  16365. * @param b The second submesh
  16366. * @returns The result of the comparison
  16367. */
  16368. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16369. /**
  16370. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16371. * are rendered front to back (prevent overdraw).
  16372. *
  16373. * @param a The first submesh
  16374. * @param b The second submesh
  16375. * @returns The result of the comparison
  16376. */
  16377. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16378. /**
  16379. * Resets the different lists of submeshes to prepare a new frame.
  16380. */
  16381. prepare(): void;
  16382. dispose(): void;
  16383. /**
  16384. * Inserts the submesh in its correct queue depending on its material.
  16385. * @param subMesh The submesh to dispatch
  16386. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16387. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16388. */
  16389. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16390. dispatchSprites(spriteManager: ISpriteManager): void;
  16391. dispatchParticles(particleSystem: IParticleSystem): void;
  16392. private _renderParticles;
  16393. private _renderSprites;
  16394. }
  16395. }
  16396. declare module "babylonjs/Rendering/renderingManager" {
  16397. import { Nullable } from "babylonjs/types";
  16398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16399. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16400. import { SmartArray } from "babylonjs/Misc/smartArray";
  16401. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16402. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16403. import { Material } from "babylonjs/Materials/material";
  16404. import { Scene } from "babylonjs/scene";
  16405. import { Camera } from "babylonjs/Cameras/camera";
  16406. /**
  16407. * Interface describing the different options available in the rendering manager
  16408. * regarding Auto Clear between groups.
  16409. */
  16410. export interface IRenderingManagerAutoClearSetup {
  16411. /**
  16412. * Defines whether or not autoclear is enable.
  16413. */
  16414. autoClear: boolean;
  16415. /**
  16416. * Defines whether or not to autoclear the depth buffer.
  16417. */
  16418. depth: boolean;
  16419. /**
  16420. * Defines whether or not to autoclear the stencil buffer.
  16421. */
  16422. stencil: boolean;
  16423. }
  16424. /**
  16425. * This class is used by the onRenderingGroupObservable
  16426. */
  16427. export class RenderingGroupInfo {
  16428. /**
  16429. * The Scene that being rendered
  16430. */
  16431. scene: Scene;
  16432. /**
  16433. * The camera currently used for the rendering pass
  16434. */
  16435. camera: Nullable<Camera>;
  16436. /**
  16437. * The ID of the renderingGroup being processed
  16438. */
  16439. renderingGroupId: number;
  16440. }
  16441. /**
  16442. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16443. * It is enable to manage the different groups as well as the different necessary sort functions.
  16444. * This should not be used directly aside of the few static configurations
  16445. */
  16446. export class RenderingManager {
  16447. /**
  16448. * The max id used for rendering groups (not included)
  16449. */
  16450. static MAX_RENDERINGGROUPS: number;
  16451. /**
  16452. * The min id used for rendering groups (included)
  16453. */
  16454. static MIN_RENDERINGGROUPS: number;
  16455. /**
  16456. * Used to globally prevent autoclearing scenes.
  16457. */
  16458. static AUTOCLEAR: boolean;
  16459. /**
  16460. * @hidden
  16461. */
  16462. _useSceneAutoClearSetup: boolean;
  16463. private _scene;
  16464. private _renderingGroups;
  16465. private _depthStencilBufferAlreadyCleaned;
  16466. private _autoClearDepthStencil;
  16467. private _customOpaqueSortCompareFn;
  16468. private _customAlphaTestSortCompareFn;
  16469. private _customTransparentSortCompareFn;
  16470. private _renderingGroupInfo;
  16471. /**
  16472. * Instantiates a new rendering group for a particular scene
  16473. * @param scene Defines the scene the groups belongs to
  16474. */
  16475. constructor(scene: Scene);
  16476. private _clearDepthStencilBuffer;
  16477. /**
  16478. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16479. * @hidden
  16480. */
  16481. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16482. /**
  16483. * Resets the different information of the group to prepare a new frame
  16484. * @hidden
  16485. */
  16486. reset(): void;
  16487. /**
  16488. * Dispose and release the group and its associated resources.
  16489. * @hidden
  16490. */
  16491. dispose(): void;
  16492. /**
  16493. * Clear the info related to rendering groups preventing retention points during dispose.
  16494. */
  16495. freeRenderingGroups(): void;
  16496. private _prepareRenderingGroup;
  16497. /**
  16498. * Add a sprite manager to the rendering manager in order to render it this frame.
  16499. * @param spriteManager Define the sprite manager to render
  16500. */
  16501. dispatchSprites(spriteManager: ISpriteManager): void;
  16502. /**
  16503. * Add a particle system to the rendering manager in order to render it this frame.
  16504. * @param particleSystem Define the particle system to render
  16505. */
  16506. dispatchParticles(particleSystem: IParticleSystem): void;
  16507. /**
  16508. * Add a submesh to the manager in order to render it this frame
  16509. * @param subMesh The submesh to dispatch
  16510. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16511. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16512. */
  16513. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16514. /**
  16515. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16516. * This allowed control for front to back rendering or reversly depending of the special needs.
  16517. *
  16518. * @param renderingGroupId The rendering group id corresponding to its index
  16519. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16520. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16521. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16522. */
  16523. 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;
  16524. /**
  16525. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16526. *
  16527. * @param renderingGroupId The rendering group id corresponding to its index
  16528. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16529. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16530. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16531. */
  16532. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16533. /**
  16534. * Gets the current auto clear configuration for one rendering group of the rendering
  16535. * manager.
  16536. * @param index the rendering group index to get the information for
  16537. * @returns The auto clear setup for the requested rendering group
  16538. */
  16539. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16540. }
  16541. }
  16542. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16543. import { SmartArray } from "babylonjs/Misc/smartArray";
  16544. import { Nullable } from "babylonjs/types";
  16545. import { Scene } from "babylonjs/scene";
  16546. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16547. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16549. import { Mesh } from "babylonjs/Meshes/mesh";
  16550. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16551. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16552. import { Effect } from "babylonjs/Materials/effect";
  16553. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16554. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16555. import "babylonjs/Shaders/shadowMap.fragment";
  16556. import "babylonjs/Shaders/shadowMap.vertex";
  16557. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16558. import { Observable } from "babylonjs/Misc/observable";
  16559. /**
  16560. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16561. */
  16562. export interface ICustomShaderOptions {
  16563. /**
  16564. * Gets or sets the custom shader name to use
  16565. */
  16566. shaderName: string;
  16567. /**
  16568. * The list of attribute names used in the shader
  16569. */
  16570. attributes?: string[];
  16571. /**
  16572. * The list of unifrom names used in the shader
  16573. */
  16574. uniforms?: string[];
  16575. /**
  16576. * The list of sampler names used in the shader
  16577. */
  16578. samplers?: string[];
  16579. /**
  16580. * The list of defines used in the shader
  16581. */
  16582. defines?: string[];
  16583. }
  16584. /**
  16585. * Interface to implement to create a shadow generator compatible with BJS.
  16586. */
  16587. export interface IShadowGenerator {
  16588. /**
  16589. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16590. * @returns The render target texture if present otherwise, null
  16591. */
  16592. getShadowMap(): Nullable<RenderTargetTexture>;
  16593. /**
  16594. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16595. * @param subMesh The submesh we want to render in the shadow map
  16596. * @param useInstances Defines wether will draw in the map using instances
  16597. * @returns true if ready otherwise, false
  16598. */
  16599. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16600. /**
  16601. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16602. * @param defines Defines of the material we want to update
  16603. * @param lightIndex Index of the light in the enabled light list of the material
  16604. */
  16605. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16606. /**
  16607. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16608. * defined in the generator but impacting the effect).
  16609. * It implies the unifroms available on the materials are the standard BJS ones.
  16610. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16611. * @param effect The effect we are binfing the information for
  16612. */
  16613. bindShadowLight(lightIndex: string, effect: Effect): void;
  16614. /**
  16615. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16616. * (eq to shadow prjection matrix * light transform matrix)
  16617. * @returns The transform matrix used to create the shadow map
  16618. */
  16619. getTransformMatrix(): Matrix;
  16620. /**
  16621. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16622. * Cube and 2D textures for instance.
  16623. */
  16624. recreateShadowMap(): void;
  16625. /**
  16626. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16627. * @param onCompiled Callback triggered at the and of the effects compilation
  16628. * @param options Sets of optional options forcing the compilation with different modes
  16629. */
  16630. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16631. useInstances: boolean;
  16632. }>): void;
  16633. /**
  16634. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16635. * @param options Sets of optional options forcing the compilation with different modes
  16636. * @returns A promise that resolves when the compilation completes
  16637. */
  16638. forceCompilationAsync(options?: Partial<{
  16639. useInstances: boolean;
  16640. }>): Promise<void>;
  16641. /**
  16642. * Serializes the shadow generator setup to a json object.
  16643. * @returns The serialized JSON object
  16644. */
  16645. serialize(): any;
  16646. /**
  16647. * Disposes the Shadow map and related Textures and effects.
  16648. */
  16649. dispose(): void;
  16650. }
  16651. /**
  16652. * Default implementation IShadowGenerator.
  16653. * This is the main object responsible of generating shadows in the framework.
  16654. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16655. */
  16656. export class ShadowGenerator implements IShadowGenerator {
  16657. /**
  16658. * Name of the shadow generator class
  16659. */
  16660. static CLASSNAME: string;
  16661. /**
  16662. * Shadow generator mode None: no filtering applied.
  16663. */
  16664. static readonly FILTER_NONE: number;
  16665. /**
  16666. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16667. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16668. */
  16669. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16670. /**
  16671. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16672. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16673. */
  16674. static readonly FILTER_POISSONSAMPLING: number;
  16675. /**
  16676. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16677. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16678. */
  16679. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16680. /**
  16681. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16682. * edge artifacts on steep falloff.
  16683. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16684. */
  16685. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16686. /**
  16687. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16688. * edge artifacts on steep falloff.
  16689. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16690. */
  16691. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16692. /**
  16693. * Shadow generator mode PCF: Percentage Closer Filtering
  16694. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16695. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16696. */
  16697. static readonly FILTER_PCF: number;
  16698. /**
  16699. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16700. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16701. * Contact Hardening
  16702. */
  16703. static readonly FILTER_PCSS: number;
  16704. /**
  16705. * Reserved for PCF and PCSS
  16706. * Highest Quality.
  16707. *
  16708. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16709. *
  16710. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16711. */
  16712. static readonly QUALITY_HIGH: number;
  16713. /**
  16714. * Reserved for PCF and PCSS
  16715. * Good tradeoff for quality/perf cross devices
  16716. *
  16717. * Execute PCF on a 3*3 kernel.
  16718. *
  16719. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16720. */
  16721. static readonly QUALITY_MEDIUM: number;
  16722. /**
  16723. * Reserved for PCF and PCSS
  16724. * The lowest quality but the fastest.
  16725. *
  16726. * Execute PCF on a 1*1 kernel.
  16727. *
  16728. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16729. */
  16730. static readonly QUALITY_LOW: number;
  16731. /** Gets or sets the custom shader name to use */
  16732. customShaderOptions: ICustomShaderOptions;
  16733. /**
  16734. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16735. */
  16736. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16737. /**
  16738. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16739. */
  16740. onAfterShadowMapRenderObservable: Observable<Effect>;
  16741. /**
  16742. * Observable triggered before a mesh is rendered in the shadow map.
  16743. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16744. */
  16745. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16746. /**
  16747. * Observable triggered after a mesh is rendered in the shadow map.
  16748. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16749. */
  16750. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16751. protected _bias: number;
  16752. /**
  16753. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16754. */
  16755. get bias(): number;
  16756. /**
  16757. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16758. */
  16759. set bias(bias: number);
  16760. protected _normalBias: number;
  16761. /**
  16762. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16763. */
  16764. get normalBias(): number;
  16765. /**
  16766. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16767. */
  16768. set normalBias(normalBias: number);
  16769. protected _blurBoxOffset: number;
  16770. /**
  16771. * Gets the blur box offset: offset applied during the blur pass.
  16772. * Only useful if useKernelBlur = false
  16773. */
  16774. get blurBoxOffset(): number;
  16775. /**
  16776. * Sets the blur box offset: offset applied during the blur pass.
  16777. * Only useful if useKernelBlur = false
  16778. */
  16779. set blurBoxOffset(value: number);
  16780. protected _blurScale: number;
  16781. /**
  16782. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16783. * 2 means half of the size.
  16784. */
  16785. get blurScale(): number;
  16786. /**
  16787. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16788. * 2 means half of the size.
  16789. */
  16790. set blurScale(value: number);
  16791. protected _blurKernel: number;
  16792. /**
  16793. * Gets the blur kernel: kernel size of the blur pass.
  16794. * Only useful if useKernelBlur = true
  16795. */
  16796. get blurKernel(): number;
  16797. /**
  16798. * Sets the blur kernel: kernel size of the blur pass.
  16799. * Only useful if useKernelBlur = true
  16800. */
  16801. set blurKernel(value: number);
  16802. protected _useKernelBlur: boolean;
  16803. /**
  16804. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16805. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16806. */
  16807. get useKernelBlur(): boolean;
  16808. /**
  16809. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16810. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16811. */
  16812. set useKernelBlur(value: boolean);
  16813. protected _depthScale: number;
  16814. /**
  16815. * Gets the depth scale used in ESM mode.
  16816. */
  16817. get depthScale(): number;
  16818. /**
  16819. * Sets the depth scale used in ESM mode.
  16820. * This can override the scale stored on the light.
  16821. */
  16822. set depthScale(value: number);
  16823. protected _validateFilter(filter: number): number;
  16824. protected _filter: number;
  16825. /**
  16826. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16827. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16828. */
  16829. get filter(): number;
  16830. /**
  16831. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16832. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16833. */
  16834. set filter(value: number);
  16835. /**
  16836. * Gets if the current filter is set to Poisson Sampling.
  16837. */
  16838. get usePoissonSampling(): boolean;
  16839. /**
  16840. * Sets the current filter to Poisson Sampling.
  16841. */
  16842. set usePoissonSampling(value: boolean);
  16843. /**
  16844. * Gets if the current filter is set to ESM.
  16845. */
  16846. get useExponentialShadowMap(): boolean;
  16847. /**
  16848. * Sets the current filter is to ESM.
  16849. */
  16850. set useExponentialShadowMap(value: boolean);
  16851. /**
  16852. * Gets if the current filter is set to filtered ESM.
  16853. */
  16854. get useBlurExponentialShadowMap(): boolean;
  16855. /**
  16856. * Gets if the current filter is set to filtered ESM.
  16857. */
  16858. set useBlurExponentialShadowMap(value: boolean);
  16859. /**
  16860. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16861. * exponential to prevent steep falloff artifacts).
  16862. */
  16863. get useCloseExponentialShadowMap(): boolean;
  16864. /**
  16865. * Sets the current filter to "close ESM" (using the inverse of the
  16866. * exponential to prevent steep falloff artifacts).
  16867. */
  16868. set useCloseExponentialShadowMap(value: boolean);
  16869. /**
  16870. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16871. * exponential to prevent steep falloff artifacts).
  16872. */
  16873. get useBlurCloseExponentialShadowMap(): boolean;
  16874. /**
  16875. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16876. * exponential to prevent steep falloff artifacts).
  16877. */
  16878. set useBlurCloseExponentialShadowMap(value: boolean);
  16879. /**
  16880. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16881. */
  16882. get usePercentageCloserFiltering(): boolean;
  16883. /**
  16884. * Sets the current filter to "PCF" (percentage closer filtering).
  16885. */
  16886. set usePercentageCloserFiltering(value: boolean);
  16887. protected _filteringQuality: number;
  16888. /**
  16889. * Gets the PCF or PCSS Quality.
  16890. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16891. */
  16892. get filteringQuality(): number;
  16893. /**
  16894. * Sets the PCF or PCSS Quality.
  16895. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16896. */
  16897. set filteringQuality(filteringQuality: number);
  16898. /**
  16899. * Gets if the current filter is set to "PCSS" (contact hardening).
  16900. */
  16901. get useContactHardeningShadow(): boolean;
  16902. /**
  16903. * Sets the current filter to "PCSS" (contact hardening).
  16904. */
  16905. set useContactHardeningShadow(value: boolean);
  16906. protected _contactHardeningLightSizeUVRatio: number;
  16907. /**
  16908. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16909. * Using a ratio helps keeping shape stability independently of the map size.
  16910. *
  16911. * It does not account for the light projection as it was having too much
  16912. * instability during the light setup or during light position changes.
  16913. *
  16914. * Only valid if useContactHardeningShadow is true.
  16915. */
  16916. get contactHardeningLightSizeUVRatio(): number;
  16917. /**
  16918. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16919. * Using a ratio helps keeping shape stability independently of the map size.
  16920. *
  16921. * It does not account for the light projection as it was having too much
  16922. * instability during the light setup or during light position changes.
  16923. *
  16924. * Only valid if useContactHardeningShadow is true.
  16925. */
  16926. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16927. protected _darkness: number;
  16928. /** Gets or sets the actual darkness of a shadow */
  16929. get darkness(): number;
  16930. set darkness(value: number);
  16931. /**
  16932. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16933. * 0 means strongest and 1 would means no shadow.
  16934. * @returns the darkness.
  16935. */
  16936. getDarkness(): number;
  16937. /**
  16938. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16939. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16940. * @returns the shadow generator allowing fluent coding.
  16941. */
  16942. setDarkness(darkness: number): ShadowGenerator;
  16943. protected _transparencyShadow: boolean;
  16944. /** Gets or sets the ability to have transparent shadow */
  16945. get transparencyShadow(): boolean;
  16946. set transparencyShadow(value: boolean);
  16947. /**
  16948. * Sets the ability to have transparent shadow (boolean).
  16949. * @param transparent True if transparent else False
  16950. * @returns the shadow generator allowing fluent coding
  16951. */
  16952. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16953. protected _shadowMap: Nullable<RenderTargetTexture>;
  16954. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16955. /**
  16956. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16957. * @returns The render target texture if present otherwise, null
  16958. */
  16959. getShadowMap(): Nullable<RenderTargetTexture>;
  16960. /**
  16961. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16962. * @returns The render target texture if the shadow map is present otherwise, null
  16963. */
  16964. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16965. /**
  16966. * Gets the class name of that object
  16967. * @returns "ShadowGenerator"
  16968. */
  16969. getClassName(): string;
  16970. /**
  16971. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16972. * @param mesh Mesh to add
  16973. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16974. * @returns the Shadow Generator itself
  16975. */
  16976. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16977. /**
  16978. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16979. * @param mesh Mesh to remove
  16980. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16981. * @returns the Shadow Generator itself
  16982. */
  16983. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16984. /**
  16985. * Controls the extent to which the shadows fade out at the edge of the frustum
  16986. */
  16987. frustumEdgeFalloff: number;
  16988. protected _light: IShadowLight;
  16989. /**
  16990. * Returns the associated light object.
  16991. * @returns the light generating the shadow
  16992. */
  16993. getLight(): IShadowLight;
  16994. /**
  16995. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16996. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16997. * It might on the other hand introduce peter panning.
  16998. */
  16999. forceBackFacesOnly: boolean;
  17000. protected _scene: Scene;
  17001. protected _lightDirection: Vector3;
  17002. protected _effect: Effect;
  17003. protected _viewMatrix: Matrix;
  17004. protected _projectionMatrix: Matrix;
  17005. protected _transformMatrix: Matrix;
  17006. protected _cachedPosition: Vector3;
  17007. protected _cachedDirection: Vector3;
  17008. protected _cachedDefines: string;
  17009. protected _currentRenderID: number;
  17010. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17011. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17012. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17013. protected _blurPostProcesses: PostProcess[];
  17014. protected _mapSize: number;
  17015. protected _currentFaceIndex: number;
  17016. protected _currentFaceIndexCache: number;
  17017. protected _textureType: number;
  17018. protected _defaultTextureMatrix: Matrix;
  17019. protected _storedUniqueId: Nullable<number>;
  17020. /** @hidden */
  17021. static _SceneComponentInitialization: (scene: Scene) => void;
  17022. /**
  17023. * Creates a ShadowGenerator object.
  17024. * A ShadowGenerator is the required tool to use the shadows.
  17025. * Each light casting shadows needs to use its own ShadowGenerator.
  17026. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17027. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17028. * @param light The light object generating the shadows.
  17029. * @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.
  17030. */
  17031. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17032. protected _initializeGenerator(): void;
  17033. protected _createTargetRenderTexture(): void;
  17034. protected _initializeShadowMap(): void;
  17035. protected _initializeBlurRTTAndPostProcesses(): void;
  17036. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17037. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17038. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17039. protected _applyFilterValues(): void;
  17040. /**
  17041. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17042. * @param onCompiled Callback triggered at the and of the effects compilation
  17043. * @param options Sets of optional options forcing the compilation with different modes
  17044. */
  17045. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17046. useInstances: boolean;
  17047. }>): void;
  17048. /**
  17049. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17050. * @param options Sets of optional options forcing the compilation with different modes
  17051. * @returns A promise that resolves when the compilation completes
  17052. */
  17053. forceCompilationAsync(options?: Partial<{
  17054. useInstances: boolean;
  17055. }>): Promise<void>;
  17056. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17057. /**
  17058. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17059. * @param subMesh The submesh we want to render in the shadow map
  17060. * @param useInstances Defines wether will draw in the map using instances
  17061. * @returns true if ready otherwise, false
  17062. */
  17063. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17064. /**
  17065. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17066. * @param defines Defines of the material we want to update
  17067. * @param lightIndex Index of the light in the enabled light list of the material
  17068. */
  17069. prepareDefines(defines: any, lightIndex: number): void;
  17070. /**
  17071. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17072. * defined in the generator but impacting the effect).
  17073. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17074. * @param effect The effect we are binfing the information for
  17075. */
  17076. bindShadowLight(lightIndex: string, effect: Effect): void;
  17077. /**
  17078. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17079. * (eq to shadow prjection matrix * light transform matrix)
  17080. * @returns The transform matrix used to create the shadow map
  17081. */
  17082. getTransformMatrix(): Matrix;
  17083. /**
  17084. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17085. * Cube and 2D textures for instance.
  17086. */
  17087. recreateShadowMap(): void;
  17088. protected _disposeBlurPostProcesses(): void;
  17089. protected _disposeRTTandPostProcesses(): void;
  17090. /**
  17091. * Disposes the ShadowGenerator.
  17092. * Returns nothing.
  17093. */
  17094. dispose(): void;
  17095. /**
  17096. * Serializes the shadow generator setup to a json object.
  17097. * @returns The serialized JSON object
  17098. */
  17099. serialize(): any;
  17100. /**
  17101. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17102. * @param parsedShadowGenerator The JSON object to parse
  17103. * @param scene The scene to create the shadow map for
  17104. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17105. * @returns The parsed shadow generator
  17106. */
  17107. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17108. }
  17109. }
  17110. declare module "babylonjs/Lights/light" {
  17111. import { Nullable } from "babylonjs/types";
  17112. import { Scene } from "babylonjs/scene";
  17113. import { Vector3 } from "babylonjs/Maths/math.vector";
  17114. import { Color3 } from "babylonjs/Maths/math.color";
  17115. import { Node } from "babylonjs/node";
  17116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17117. import { Effect } from "babylonjs/Materials/effect";
  17118. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17119. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17120. /**
  17121. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17122. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17123. * 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.
  17124. */
  17125. export abstract class Light extends Node {
  17126. /**
  17127. * Falloff Default: light is falling off following the material specification:
  17128. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17129. */
  17130. static readonly FALLOFF_DEFAULT: number;
  17131. /**
  17132. * Falloff Physical: light is falling off following the inverse squared distance law.
  17133. */
  17134. static readonly FALLOFF_PHYSICAL: number;
  17135. /**
  17136. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17137. * to enhance interoperability with other engines.
  17138. */
  17139. static readonly FALLOFF_GLTF: number;
  17140. /**
  17141. * Falloff Standard: light is falling off like in the standard material
  17142. * to enhance interoperability with other materials.
  17143. */
  17144. static readonly FALLOFF_STANDARD: number;
  17145. /**
  17146. * If every light affecting the material is in this lightmapMode,
  17147. * material.lightmapTexture adds or multiplies
  17148. * (depends on material.useLightmapAsShadowmap)
  17149. * after every other light calculations.
  17150. */
  17151. static readonly LIGHTMAP_DEFAULT: number;
  17152. /**
  17153. * material.lightmapTexture as only diffuse lighting from this light
  17154. * adds only specular lighting from this light
  17155. * adds dynamic shadows
  17156. */
  17157. static readonly LIGHTMAP_SPECULAR: number;
  17158. /**
  17159. * material.lightmapTexture as only lighting
  17160. * no light calculation from this light
  17161. * only adds dynamic shadows from this light
  17162. */
  17163. static readonly LIGHTMAP_SHADOWSONLY: number;
  17164. /**
  17165. * Each light type uses the default quantity according to its type:
  17166. * point/spot lights use luminous intensity
  17167. * directional lights use illuminance
  17168. */
  17169. static readonly INTENSITYMODE_AUTOMATIC: number;
  17170. /**
  17171. * lumen (lm)
  17172. */
  17173. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17174. /**
  17175. * candela (lm/sr)
  17176. */
  17177. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17178. /**
  17179. * lux (lm/m^2)
  17180. */
  17181. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17182. /**
  17183. * nit (cd/m^2)
  17184. */
  17185. static readonly INTENSITYMODE_LUMINANCE: number;
  17186. /**
  17187. * Light type const id of the point light.
  17188. */
  17189. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17190. /**
  17191. * Light type const id of the directional light.
  17192. */
  17193. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17194. /**
  17195. * Light type const id of the spot light.
  17196. */
  17197. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17198. /**
  17199. * Light type const id of the hemispheric light.
  17200. */
  17201. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17202. /**
  17203. * Diffuse gives the basic color to an object.
  17204. */
  17205. diffuse: Color3;
  17206. /**
  17207. * Specular produces a highlight color on an object.
  17208. * Note: This is note affecting PBR materials.
  17209. */
  17210. specular: Color3;
  17211. /**
  17212. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17213. * falling off base on range or angle.
  17214. * This can be set to any values in Light.FALLOFF_x.
  17215. *
  17216. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17217. * other types of materials.
  17218. */
  17219. falloffType: number;
  17220. /**
  17221. * Strength of the light.
  17222. * Note: By default it is define in the framework own unit.
  17223. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17224. */
  17225. intensity: number;
  17226. private _range;
  17227. protected _inverseSquaredRange: number;
  17228. /**
  17229. * Defines how far from the source the light is impacting in scene units.
  17230. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17231. */
  17232. get range(): number;
  17233. /**
  17234. * Defines how far from the source the light is impacting in scene units.
  17235. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17236. */
  17237. set range(value: number);
  17238. /**
  17239. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17240. * of light.
  17241. */
  17242. private _photometricScale;
  17243. private _intensityMode;
  17244. /**
  17245. * Gets the photometric scale used to interpret the intensity.
  17246. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17247. */
  17248. get intensityMode(): number;
  17249. /**
  17250. * Sets the photometric scale used to interpret the intensity.
  17251. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17252. */
  17253. set intensityMode(value: number);
  17254. private _radius;
  17255. /**
  17256. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17257. */
  17258. get radius(): number;
  17259. /**
  17260. * sets the light radius used by PBR Materials to simulate soft area lights.
  17261. */
  17262. set radius(value: number);
  17263. private _renderPriority;
  17264. /**
  17265. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17266. * exceeding the number allowed of the materials.
  17267. */
  17268. renderPriority: number;
  17269. private _shadowEnabled;
  17270. /**
  17271. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17272. * the current shadow generator.
  17273. */
  17274. get shadowEnabled(): boolean;
  17275. /**
  17276. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17277. * the current shadow generator.
  17278. */
  17279. set shadowEnabled(value: boolean);
  17280. private _includedOnlyMeshes;
  17281. /**
  17282. * Gets the only meshes impacted by this light.
  17283. */
  17284. get includedOnlyMeshes(): AbstractMesh[];
  17285. /**
  17286. * Sets the only meshes impacted by this light.
  17287. */
  17288. set includedOnlyMeshes(value: AbstractMesh[]);
  17289. private _excludedMeshes;
  17290. /**
  17291. * Gets the meshes not impacted by this light.
  17292. */
  17293. get excludedMeshes(): AbstractMesh[];
  17294. /**
  17295. * Sets the meshes not impacted by this light.
  17296. */
  17297. set excludedMeshes(value: AbstractMesh[]);
  17298. private _excludeWithLayerMask;
  17299. /**
  17300. * Gets the layer id use to find what meshes are not impacted by the light.
  17301. * Inactive if 0
  17302. */
  17303. get excludeWithLayerMask(): number;
  17304. /**
  17305. * Sets the layer id use to find what meshes are not impacted by the light.
  17306. * Inactive if 0
  17307. */
  17308. set excludeWithLayerMask(value: number);
  17309. private _includeOnlyWithLayerMask;
  17310. /**
  17311. * Gets the layer id use to find what meshes are impacted by the light.
  17312. * Inactive if 0
  17313. */
  17314. get includeOnlyWithLayerMask(): number;
  17315. /**
  17316. * Sets the layer id use to find what meshes are impacted by the light.
  17317. * Inactive if 0
  17318. */
  17319. set includeOnlyWithLayerMask(value: number);
  17320. private _lightmapMode;
  17321. /**
  17322. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17323. */
  17324. get lightmapMode(): number;
  17325. /**
  17326. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17327. */
  17328. set lightmapMode(value: number);
  17329. /**
  17330. * Shadow generator associted to the light.
  17331. * @hidden Internal use only.
  17332. */
  17333. _shadowGenerator: Nullable<IShadowGenerator>;
  17334. /**
  17335. * @hidden Internal use only.
  17336. */
  17337. _excludedMeshesIds: string[];
  17338. /**
  17339. * @hidden Internal use only.
  17340. */
  17341. _includedOnlyMeshesIds: string[];
  17342. /**
  17343. * The current light unifom buffer.
  17344. * @hidden Internal use only.
  17345. */
  17346. _uniformBuffer: UniformBuffer;
  17347. /** @hidden */
  17348. _renderId: number;
  17349. /**
  17350. * Creates a Light object in the scene.
  17351. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17352. * @param name The firendly name of the light
  17353. * @param scene The scene the light belongs too
  17354. */
  17355. constructor(name: string, scene: Scene);
  17356. protected abstract _buildUniformLayout(): void;
  17357. /**
  17358. * Sets the passed Effect "effect" with the Light information.
  17359. * @param effect The effect to update
  17360. * @param lightIndex The index of the light in the effect to update
  17361. * @returns The light
  17362. */
  17363. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17364. /**
  17365. * Sets the passed Effect "effect" with the Light textures.
  17366. * @param effect The effect to update
  17367. * @param lightIndex The index of the light in the effect to update
  17368. * @returns The light
  17369. */
  17370. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17371. /**
  17372. * Binds the lights information from the scene to the effect for the given mesh.
  17373. * @param lightIndex Light index
  17374. * @param scene The scene where the light belongs to
  17375. * @param effect The effect we are binding the data to
  17376. * @param useSpecular Defines if specular is supported
  17377. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17378. */
  17379. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17380. /**
  17381. * Sets the passed Effect "effect" with the Light information.
  17382. * @param effect The effect to update
  17383. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17384. * @returns The light
  17385. */
  17386. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17387. /**
  17388. * Returns the string "Light".
  17389. * @returns the class name
  17390. */
  17391. getClassName(): string;
  17392. /** @hidden */
  17393. readonly _isLight: boolean;
  17394. /**
  17395. * Converts the light information to a readable string for debug purpose.
  17396. * @param fullDetails Supports for multiple levels of logging within scene loading
  17397. * @returns the human readable light info
  17398. */
  17399. toString(fullDetails?: boolean): string;
  17400. /** @hidden */
  17401. protected _syncParentEnabledState(): void;
  17402. /**
  17403. * Set the enabled state of this node.
  17404. * @param value - the new enabled state
  17405. */
  17406. setEnabled(value: boolean): void;
  17407. /**
  17408. * Returns the Light associated shadow generator if any.
  17409. * @return the associated shadow generator.
  17410. */
  17411. getShadowGenerator(): Nullable<IShadowGenerator>;
  17412. /**
  17413. * Returns a Vector3, the absolute light position in the World.
  17414. * @returns the world space position of the light
  17415. */
  17416. getAbsolutePosition(): Vector3;
  17417. /**
  17418. * Specifies if the light will affect the passed mesh.
  17419. * @param mesh The mesh to test against the light
  17420. * @return true the mesh is affected otherwise, false.
  17421. */
  17422. canAffectMesh(mesh: AbstractMesh): boolean;
  17423. /**
  17424. * Sort function to order lights for rendering.
  17425. * @param a First Light object to compare to second.
  17426. * @param b Second Light object to compare first.
  17427. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17428. */
  17429. static CompareLightsPriority(a: Light, b: Light): number;
  17430. /**
  17431. * Releases resources associated with this node.
  17432. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17433. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17434. */
  17435. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17436. /**
  17437. * Returns the light type ID (integer).
  17438. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17439. */
  17440. getTypeID(): number;
  17441. /**
  17442. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17443. * @returns the scaled intensity in intensity mode unit
  17444. */
  17445. getScaledIntensity(): number;
  17446. /**
  17447. * Returns a new Light object, named "name", from the current one.
  17448. * @param name The name of the cloned light
  17449. * @returns the new created light
  17450. */
  17451. clone(name: string): Nullable<Light>;
  17452. /**
  17453. * Serializes the current light into a Serialization object.
  17454. * @returns the serialized object.
  17455. */
  17456. serialize(): any;
  17457. /**
  17458. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17459. * This new light is named "name" and added to the passed scene.
  17460. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17461. * @param name The friendly name of the light
  17462. * @param scene The scene the new light will belong to
  17463. * @returns the constructor function
  17464. */
  17465. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17466. /**
  17467. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17468. * @param parsedLight The JSON representation of the light
  17469. * @param scene The scene to create the parsed light in
  17470. * @returns the created light after parsing
  17471. */
  17472. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17473. private _hookArrayForExcluded;
  17474. private _hookArrayForIncludedOnly;
  17475. private _resyncMeshes;
  17476. /**
  17477. * Forces the meshes to update their light related information in their rendering used effects
  17478. * @hidden Internal Use Only
  17479. */
  17480. _markMeshesAsLightDirty(): void;
  17481. /**
  17482. * Recomputes the cached photometric scale if needed.
  17483. */
  17484. private _computePhotometricScale;
  17485. /**
  17486. * Returns the Photometric Scale according to the light type and intensity mode.
  17487. */
  17488. private _getPhotometricScale;
  17489. /**
  17490. * Reorder the light in the scene according to their defined priority.
  17491. * @hidden Internal Use Only
  17492. */
  17493. _reorderLightsInScene(): void;
  17494. /**
  17495. * Prepares the list of defines specific to the light type.
  17496. * @param defines the list of defines
  17497. * @param lightIndex defines the index of the light for the effect
  17498. */
  17499. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17500. }
  17501. }
  17502. declare module "babylonjs/Actions/action" {
  17503. import { Observable } from "babylonjs/Misc/observable";
  17504. import { Condition } from "babylonjs/Actions/condition";
  17505. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17506. import { ActionManager } from "babylonjs/Actions/actionManager";
  17507. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17508. /**
  17509. * Interface used to define Action
  17510. */
  17511. export interface IAction {
  17512. /**
  17513. * Trigger for the action
  17514. */
  17515. trigger: number;
  17516. /** Options of the trigger */
  17517. triggerOptions: any;
  17518. /**
  17519. * Gets the trigger parameters
  17520. * @returns the trigger parameters
  17521. */
  17522. getTriggerParameter(): any;
  17523. /**
  17524. * Internal only - executes current action event
  17525. * @hidden
  17526. */
  17527. _executeCurrent(evt?: ActionEvent): void;
  17528. /**
  17529. * Serialize placeholder for child classes
  17530. * @param parent of child
  17531. * @returns the serialized object
  17532. */
  17533. serialize(parent: any): any;
  17534. /**
  17535. * Internal only
  17536. * @hidden
  17537. */
  17538. _prepare(): void;
  17539. /**
  17540. * Internal only - manager for action
  17541. * @hidden
  17542. */
  17543. _actionManager: AbstractActionManager;
  17544. /**
  17545. * Adds action to chain of actions, may be a DoNothingAction
  17546. * @param action defines the next action to execute
  17547. * @returns The action passed in
  17548. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17549. */
  17550. then(action: IAction): IAction;
  17551. }
  17552. /**
  17553. * The action to be carried out following a trigger
  17554. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17555. */
  17556. export class Action implements IAction {
  17557. /** the trigger, with or without parameters, for the action */
  17558. triggerOptions: any;
  17559. /**
  17560. * Trigger for the action
  17561. */
  17562. trigger: number;
  17563. /**
  17564. * Internal only - manager for action
  17565. * @hidden
  17566. */
  17567. _actionManager: ActionManager;
  17568. private _nextActiveAction;
  17569. private _child;
  17570. private _condition?;
  17571. private _triggerParameter;
  17572. /**
  17573. * An event triggered prior to action being executed.
  17574. */
  17575. onBeforeExecuteObservable: Observable<Action>;
  17576. /**
  17577. * Creates a new Action
  17578. * @param triggerOptions the trigger, with or without parameters, for the action
  17579. * @param condition an optional determinant of action
  17580. */
  17581. constructor(
  17582. /** the trigger, with or without parameters, for the action */
  17583. triggerOptions: any, condition?: Condition);
  17584. /**
  17585. * Internal only
  17586. * @hidden
  17587. */
  17588. _prepare(): void;
  17589. /**
  17590. * Gets the trigger parameters
  17591. * @returns the trigger parameters
  17592. */
  17593. getTriggerParameter(): any;
  17594. /**
  17595. * Internal only - executes current action event
  17596. * @hidden
  17597. */
  17598. _executeCurrent(evt?: ActionEvent): void;
  17599. /**
  17600. * Execute placeholder for child classes
  17601. * @param evt optional action event
  17602. */
  17603. execute(evt?: ActionEvent): void;
  17604. /**
  17605. * Skips to next active action
  17606. */
  17607. skipToNextActiveAction(): void;
  17608. /**
  17609. * Adds action to chain of actions, may be a DoNothingAction
  17610. * @param action defines the next action to execute
  17611. * @returns The action passed in
  17612. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17613. */
  17614. then(action: Action): Action;
  17615. /**
  17616. * Internal only
  17617. * @hidden
  17618. */
  17619. _getProperty(propertyPath: string): string;
  17620. /**
  17621. * Internal only
  17622. * @hidden
  17623. */
  17624. _getEffectiveTarget(target: any, propertyPath: string): any;
  17625. /**
  17626. * Serialize placeholder for child classes
  17627. * @param parent of child
  17628. * @returns the serialized object
  17629. */
  17630. serialize(parent: any): any;
  17631. /**
  17632. * Internal only called by serialize
  17633. * @hidden
  17634. */
  17635. protected _serialize(serializedAction: any, parent?: any): any;
  17636. /**
  17637. * Internal only
  17638. * @hidden
  17639. */
  17640. static _SerializeValueAsString: (value: any) => string;
  17641. /**
  17642. * Internal only
  17643. * @hidden
  17644. */
  17645. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17646. name: string;
  17647. targetType: string;
  17648. value: string;
  17649. };
  17650. }
  17651. }
  17652. declare module "babylonjs/Actions/condition" {
  17653. import { ActionManager } from "babylonjs/Actions/actionManager";
  17654. /**
  17655. * A Condition applied to an Action
  17656. */
  17657. export class Condition {
  17658. /**
  17659. * Internal only - manager for action
  17660. * @hidden
  17661. */
  17662. _actionManager: ActionManager;
  17663. /**
  17664. * Internal only
  17665. * @hidden
  17666. */
  17667. _evaluationId: number;
  17668. /**
  17669. * Internal only
  17670. * @hidden
  17671. */
  17672. _currentResult: boolean;
  17673. /**
  17674. * Creates a new Condition
  17675. * @param actionManager the manager of the action the condition is applied to
  17676. */
  17677. constructor(actionManager: ActionManager);
  17678. /**
  17679. * Check if the current condition is valid
  17680. * @returns a boolean
  17681. */
  17682. isValid(): boolean;
  17683. /**
  17684. * Internal only
  17685. * @hidden
  17686. */
  17687. _getProperty(propertyPath: string): string;
  17688. /**
  17689. * Internal only
  17690. * @hidden
  17691. */
  17692. _getEffectiveTarget(target: any, propertyPath: string): any;
  17693. /**
  17694. * Serialize placeholder for child classes
  17695. * @returns the serialized object
  17696. */
  17697. serialize(): any;
  17698. /**
  17699. * Internal only
  17700. * @hidden
  17701. */
  17702. protected _serialize(serializedCondition: any): any;
  17703. }
  17704. /**
  17705. * Defines specific conditional operators as extensions of Condition
  17706. */
  17707. export class ValueCondition extends Condition {
  17708. /** path to specify the property of the target the conditional operator uses */
  17709. propertyPath: string;
  17710. /** the value compared by the conditional operator against the current value of the property */
  17711. value: any;
  17712. /** the conditional operator, default ValueCondition.IsEqual */
  17713. operator: number;
  17714. /**
  17715. * Internal only
  17716. * @hidden
  17717. */
  17718. private static _IsEqual;
  17719. /**
  17720. * Internal only
  17721. * @hidden
  17722. */
  17723. private static _IsDifferent;
  17724. /**
  17725. * Internal only
  17726. * @hidden
  17727. */
  17728. private static _IsGreater;
  17729. /**
  17730. * Internal only
  17731. * @hidden
  17732. */
  17733. private static _IsLesser;
  17734. /**
  17735. * returns the number for IsEqual
  17736. */
  17737. static get IsEqual(): number;
  17738. /**
  17739. * Returns the number for IsDifferent
  17740. */
  17741. static get IsDifferent(): number;
  17742. /**
  17743. * Returns the number for IsGreater
  17744. */
  17745. static get IsGreater(): number;
  17746. /**
  17747. * Returns the number for IsLesser
  17748. */
  17749. static get IsLesser(): number;
  17750. /**
  17751. * Internal only The action manager for the condition
  17752. * @hidden
  17753. */
  17754. _actionManager: ActionManager;
  17755. /**
  17756. * Internal only
  17757. * @hidden
  17758. */
  17759. private _target;
  17760. /**
  17761. * Internal only
  17762. * @hidden
  17763. */
  17764. private _effectiveTarget;
  17765. /**
  17766. * Internal only
  17767. * @hidden
  17768. */
  17769. private _property;
  17770. /**
  17771. * Creates a new ValueCondition
  17772. * @param actionManager manager for the action the condition applies to
  17773. * @param target for the action
  17774. * @param propertyPath path to specify the property of the target the conditional operator uses
  17775. * @param value the value compared by the conditional operator against the current value of the property
  17776. * @param operator the conditional operator, default ValueCondition.IsEqual
  17777. */
  17778. constructor(actionManager: ActionManager, target: any,
  17779. /** path to specify the property of the target the conditional operator uses */
  17780. propertyPath: string,
  17781. /** the value compared by the conditional operator against the current value of the property */
  17782. value: any,
  17783. /** the conditional operator, default ValueCondition.IsEqual */
  17784. operator?: number);
  17785. /**
  17786. * Compares the given value with the property value for the specified conditional operator
  17787. * @returns the result of the comparison
  17788. */
  17789. isValid(): boolean;
  17790. /**
  17791. * Serialize the ValueCondition into a JSON compatible object
  17792. * @returns serialization object
  17793. */
  17794. serialize(): any;
  17795. /**
  17796. * Gets the name of the conditional operator for the ValueCondition
  17797. * @param operator the conditional operator
  17798. * @returns the name
  17799. */
  17800. static GetOperatorName(operator: number): string;
  17801. }
  17802. /**
  17803. * Defines a predicate condition as an extension of Condition
  17804. */
  17805. export class PredicateCondition extends Condition {
  17806. /** defines the predicate function used to validate the condition */
  17807. predicate: () => boolean;
  17808. /**
  17809. * Internal only - manager for action
  17810. * @hidden
  17811. */
  17812. _actionManager: ActionManager;
  17813. /**
  17814. * Creates a new PredicateCondition
  17815. * @param actionManager manager for the action the condition applies to
  17816. * @param predicate defines the predicate function used to validate the condition
  17817. */
  17818. constructor(actionManager: ActionManager,
  17819. /** defines the predicate function used to validate the condition */
  17820. predicate: () => boolean);
  17821. /**
  17822. * @returns the validity of the predicate condition
  17823. */
  17824. isValid(): boolean;
  17825. }
  17826. /**
  17827. * Defines a state condition as an extension of Condition
  17828. */
  17829. export class StateCondition extends Condition {
  17830. /** Value to compare with target state */
  17831. value: string;
  17832. /**
  17833. * Internal only - manager for action
  17834. * @hidden
  17835. */
  17836. _actionManager: ActionManager;
  17837. /**
  17838. * Internal only
  17839. * @hidden
  17840. */
  17841. private _target;
  17842. /**
  17843. * Creates a new StateCondition
  17844. * @param actionManager manager for the action the condition applies to
  17845. * @param target of the condition
  17846. * @param value to compare with target state
  17847. */
  17848. constructor(actionManager: ActionManager, target: any,
  17849. /** Value to compare with target state */
  17850. value: string);
  17851. /**
  17852. * Gets a boolean indicating if the current condition is met
  17853. * @returns the validity of the state
  17854. */
  17855. isValid(): boolean;
  17856. /**
  17857. * Serialize the StateCondition into a JSON compatible object
  17858. * @returns serialization object
  17859. */
  17860. serialize(): any;
  17861. }
  17862. }
  17863. declare module "babylonjs/Actions/directActions" {
  17864. import { Action } from "babylonjs/Actions/action";
  17865. import { Condition } from "babylonjs/Actions/condition";
  17866. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17867. /**
  17868. * This defines an action responsible to toggle a boolean once triggered.
  17869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17870. */
  17871. export class SwitchBooleanAction extends Action {
  17872. /**
  17873. * The path to the boolean property in the target object
  17874. */
  17875. propertyPath: string;
  17876. private _target;
  17877. private _effectiveTarget;
  17878. private _property;
  17879. /**
  17880. * Instantiate the action
  17881. * @param triggerOptions defines the trigger options
  17882. * @param target defines the object containing the boolean
  17883. * @param propertyPath defines the path to the boolean property in the target object
  17884. * @param condition defines the trigger related conditions
  17885. */
  17886. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17887. /** @hidden */
  17888. _prepare(): void;
  17889. /**
  17890. * Execute the action toggle the boolean value.
  17891. */
  17892. execute(): void;
  17893. /**
  17894. * Serializes the actions and its related information.
  17895. * @param parent defines the object to serialize in
  17896. * @returns the serialized object
  17897. */
  17898. serialize(parent: any): any;
  17899. }
  17900. /**
  17901. * This defines an action responsible to set a the state field of the target
  17902. * to a desired value once triggered.
  17903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17904. */
  17905. export class SetStateAction extends Action {
  17906. /**
  17907. * The value to store in the state field.
  17908. */
  17909. value: string;
  17910. private _target;
  17911. /**
  17912. * Instantiate the action
  17913. * @param triggerOptions defines the trigger options
  17914. * @param target defines the object containing the state property
  17915. * @param value defines the value to store in the state field
  17916. * @param condition defines the trigger related conditions
  17917. */
  17918. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17919. /**
  17920. * Execute the action and store the value on the target state property.
  17921. */
  17922. execute(): void;
  17923. /**
  17924. * Serializes the actions and its related information.
  17925. * @param parent defines the object to serialize in
  17926. * @returns the serialized object
  17927. */
  17928. serialize(parent: any): any;
  17929. }
  17930. /**
  17931. * This defines an action responsible to set a property of the target
  17932. * to a desired value once triggered.
  17933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17934. */
  17935. export class SetValueAction extends Action {
  17936. /**
  17937. * The path of the property to set in the target.
  17938. */
  17939. propertyPath: string;
  17940. /**
  17941. * The value to set in the property
  17942. */
  17943. value: any;
  17944. private _target;
  17945. private _effectiveTarget;
  17946. private _property;
  17947. /**
  17948. * Instantiate the action
  17949. * @param triggerOptions defines the trigger options
  17950. * @param target defines the object containing the property
  17951. * @param propertyPath defines the path of the property to set in the target
  17952. * @param value defines the value to set in the property
  17953. * @param condition defines the trigger related conditions
  17954. */
  17955. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17956. /** @hidden */
  17957. _prepare(): void;
  17958. /**
  17959. * Execute the action and set the targetted property to the desired value.
  17960. */
  17961. execute(): void;
  17962. /**
  17963. * Serializes the actions and its related information.
  17964. * @param parent defines the object to serialize in
  17965. * @returns the serialized object
  17966. */
  17967. serialize(parent: any): any;
  17968. }
  17969. /**
  17970. * This defines an action responsible to increment the target value
  17971. * to a desired value once triggered.
  17972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17973. */
  17974. export class IncrementValueAction extends Action {
  17975. /**
  17976. * The path of the property to increment in the target.
  17977. */
  17978. propertyPath: string;
  17979. /**
  17980. * The value we should increment the property by.
  17981. */
  17982. value: any;
  17983. private _target;
  17984. private _effectiveTarget;
  17985. private _property;
  17986. /**
  17987. * Instantiate the action
  17988. * @param triggerOptions defines the trigger options
  17989. * @param target defines the object containing the property
  17990. * @param propertyPath defines the path of the property to increment in the target
  17991. * @param value defines the value value we should increment the property by
  17992. * @param condition defines the trigger related conditions
  17993. */
  17994. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17995. /** @hidden */
  17996. _prepare(): void;
  17997. /**
  17998. * Execute the action and increment the target of the value amount.
  17999. */
  18000. execute(): void;
  18001. /**
  18002. * Serializes the actions and its related information.
  18003. * @param parent defines the object to serialize in
  18004. * @returns the serialized object
  18005. */
  18006. serialize(parent: any): any;
  18007. }
  18008. /**
  18009. * This defines an action responsible to start an animation once triggered.
  18010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18011. */
  18012. export class PlayAnimationAction extends Action {
  18013. /**
  18014. * Where the animation should start (animation frame)
  18015. */
  18016. from: number;
  18017. /**
  18018. * Where the animation should stop (animation frame)
  18019. */
  18020. to: number;
  18021. /**
  18022. * Define if the animation should loop or stop after the first play.
  18023. */
  18024. loop?: boolean;
  18025. private _target;
  18026. /**
  18027. * Instantiate the action
  18028. * @param triggerOptions defines the trigger options
  18029. * @param target defines the target animation or animation name
  18030. * @param from defines from where the animation should start (animation frame)
  18031. * @param end defines where the animation should stop (animation frame)
  18032. * @param loop defines if the animation should loop or stop after the first play
  18033. * @param condition defines the trigger related conditions
  18034. */
  18035. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18036. /** @hidden */
  18037. _prepare(): void;
  18038. /**
  18039. * Execute the action and play the animation.
  18040. */
  18041. execute(): void;
  18042. /**
  18043. * Serializes the actions and its related information.
  18044. * @param parent defines the object to serialize in
  18045. * @returns the serialized object
  18046. */
  18047. serialize(parent: any): any;
  18048. }
  18049. /**
  18050. * This defines an action responsible to stop an animation once triggered.
  18051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18052. */
  18053. export class StopAnimationAction extends Action {
  18054. private _target;
  18055. /**
  18056. * Instantiate the action
  18057. * @param triggerOptions defines the trigger options
  18058. * @param target defines the target animation or animation name
  18059. * @param condition defines the trigger related conditions
  18060. */
  18061. constructor(triggerOptions: any, target: any, condition?: Condition);
  18062. /** @hidden */
  18063. _prepare(): void;
  18064. /**
  18065. * Execute the action and stop the animation.
  18066. */
  18067. execute(): void;
  18068. /**
  18069. * Serializes the actions and its related information.
  18070. * @param parent defines the object to serialize in
  18071. * @returns the serialized object
  18072. */
  18073. serialize(parent: any): any;
  18074. }
  18075. /**
  18076. * This defines an action responsible that does nothing once triggered.
  18077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18078. */
  18079. export class DoNothingAction extends Action {
  18080. /**
  18081. * Instantiate the action
  18082. * @param triggerOptions defines the trigger options
  18083. * @param condition defines the trigger related conditions
  18084. */
  18085. constructor(triggerOptions?: any, condition?: Condition);
  18086. /**
  18087. * Execute the action and do nothing.
  18088. */
  18089. execute(): void;
  18090. /**
  18091. * Serializes the actions and its related information.
  18092. * @param parent defines the object to serialize in
  18093. * @returns the serialized object
  18094. */
  18095. serialize(parent: any): any;
  18096. }
  18097. /**
  18098. * This defines an action responsible to trigger several actions once triggered.
  18099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18100. */
  18101. export class CombineAction extends Action {
  18102. /**
  18103. * The list of aggregated animations to run.
  18104. */
  18105. children: Action[];
  18106. /**
  18107. * Instantiate the action
  18108. * @param triggerOptions defines the trigger options
  18109. * @param children defines the list of aggregated animations to run
  18110. * @param condition defines the trigger related conditions
  18111. */
  18112. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18113. /** @hidden */
  18114. _prepare(): void;
  18115. /**
  18116. * Execute the action and executes all the aggregated actions.
  18117. */
  18118. execute(evt: ActionEvent): void;
  18119. /**
  18120. * Serializes the actions and its related information.
  18121. * @param parent defines the object to serialize in
  18122. * @returns the serialized object
  18123. */
  18124. serialize(parent: any): any;
  18125. }
  18126. /**
  18127. * This defines an action responsible to run code (external event) once triggered.
  18128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18129. */
  18130. export class ExecuteCodeAction extends Action {
  18131. /**
  18132. * The callback function to run.
  18133. */
  18134. func: (evt: ActionEvent) => void;
  18135. /**
  18136. * Instantiate the action
  18137. * @param triggerOptions defines the trigger options
  18138. * @param func defines the callback function to run
  18139. * @param condition defines the trigger related conditions
  18140. */
  18141. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18142. /**
  18143. * Execute the action and run the attached code.
  18144. */
  18145. execute(evt: ActionEvent): void;
  18146. }
  18147. /**
  18148. * This defines an action responsible to set the parent property of the target once triggered.
  18149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18150. */
  18151. export class SetParentAction extends Action {
  18152. private _parent;
  18153. private _target;
  18154. /**
  18155. * Instantiate the action
  18156. * @param triggerOptions defines the trigger options
  18157. * @param target defines the target containing the parent property
  18158. * @param parent defines from where the animation should start (animation frame)
  18159. * @param condition defines the trigger related conditions
  18160. */
  18161. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18162. /** @hidden */
  18163. _prepare(): void;
  18164. /**
  18165. * Execute the action and set the parent property.
  18166. */
  18167. execute(): void;
  18168. /**
  18169. * Serializes the actions and its related information.
  18170. * @param parent defines the object to serialize in
  18171. * @returns the serialized object
  18172. */
  18173. serialize(parent: any): any;
  18174. }
  18175. }
  18176. declare module "babylonjs/Actions/actionManager" {
  18177. import { Nullable } from "babylonjs/types";
  18178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18179. import { Scene } from "babylonjs/scene";
  18180. import { IAction } from "babylonjs/Actions/action";
  18181. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18182. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18183. /**
  18184. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18185. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18187. */
  18188. export class ActionManager extends AbstractActionManager {
  18189. /**
  18190. * Nothing
  18191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18192. */
  18193. static readonly NothingTrigger: number;
  18194. /**
  18195. * On pick
  18196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18197. */
  18198. static readonly OnPickTrigger: number;
  18199. /**
  18200. * On left pick
  18201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18202. */
  18203. static readonly OnLeftPickTrigger: number;
  18204. /**
  18205. * On right pick
  18206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18207. */
  18208. static readonly OnRightPickTrigger: number;
  18209. /**
  18210. * On center pick
  18211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18212. */
  18213. static readonly OnCenterPickTrigger: number;
  18214. /**
  18215. * On pick down
  18216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18217. */
  18218. static readonly OnPickDownTrigger: number;
  18219. /**
  18220. * On double pick
  18221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18222. */
  18223. static readonly OnDoublePickTrigger: number;
  18224. /**
  18225. * On pick up
  18226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18227. */
  18228. static readonly OnPickUpTrigger: number;
  18229. /**
  18230. * On pick out.
  18231. * This trigger will only be raised if you also declared a OnPickDown
  18232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18233. */
  18234. static readonly OnPickOutTrigger: number;
  18235. /**
  18236. * On long press
  18237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18238. */
  18239. static readonly OnLongPressTrigger: number;
  18240. /**
  18241. * On pointer over
  18242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18243. */
  18244. static readonly OnPointerOverTrigger: number;
  18245. /**
  18246. * On pointer out
  18247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18248. */
  18249. static readonly OnPointerOutTrigger: number;
  18250. /**
  18251. * On every frame
  18252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18253. */
  18254. static readonly OnEveryFrameTrigger: number;
  18255. /**
  18256. * On intersection enter
  18257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18258. */
  18259. static readonly OnIntersectionEnterTrigger: number;
  18260. /**
  18261. * On intersection exit
  18262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18263. */
  18264. static readonly OnIntersectionExitTrigger: number;
  18265. /**
  18266. * On key down
  18267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18268. */
  18269. static readonly OnKeyDownTrigger: number;
  18270. /**
  18271. * On key up
  18272. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18273. */
  18274. static readonly OnKeyUpTrigger: number;
  18275. private _scene;
  18276. /**
  18277. * Creates a new action manager
  18278. * @param scene defines the hosting scene
  18279. */
  18280. constructor(scene: Scene);
  18281. /**
  18282. * Releases all associated resources
  18283. */
  18284. dispose(): void;
  18285. /**
  18286. * Gets hosting scene
  18287. * @returns the hosting scene
  18288. */
  18289. getScene(): Scene;
  18290. /**
  18291. * Does this action manager handles actions of any of the given triggers
  18292. * @param triggers defines the triggers to be tested
  18293. * @return a boolean indicating whether one (or more) of the triggers is handled
  18294. */
  18295. hasSpecificTriggers(triggers: number[]): boolean;
  18296. /**
  18297. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18298. * speed.
  18299. * @param triggerA defines the trigger to be tested
  18300. * @param triggerB defines the trigger to be tested
  18301. * @return a boolean indicating whether one (or more) of the triggers is handled
  18302. */
  18303. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18304. /**
  18305. * Does this action manager handles actions of a given trigger
  18306. * @param trigger defines the trigger to be tested
  18307. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18308. * @return whether the trigger is handled
  18309. */
  18310. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18311. /**
  18312. * Does this action manager has pointer triggers
  18313. */
  18314. get hasPointerTriggers(): boolean;
  18315. /**
  18316. * Does this action manager has pick triggers
  18317. */
  18318. get hasPickTriggers(): boolean;
  18319. /**
  18320. * Registers an action to this action manager
  18321. * @param action defines the action to be registered
  18322. * @return the action amended (prepared) after registration
  18323. */
  18324. registerAction(action: IAction): Nullable<IAction>;
  18325. /**
  18326. * Unregisters an action to this action manager
  18327. * @param action defines the action to be unregistered
  18328. * @return a boolean indicating whether the action has been unregistered
  18329. */
  18330. unregisterAction(action: IAction): Boolean;
  18331. /**
  18332. * Process a specific trigger
  18333. * @param trigger defines the trigger to process
  18334. * @param evt defines the event details to be processed
  18335. */
  18336. processTrigger(trigger: number, evt?: IActionEvent): void;
  18337. /** @hidden */
  18338. _getEffectiveTarget(target: any, propertyPath: string): any;
  18339. /** @hidden */
  18340. _getProperty(propertyPath: string): string;
  18341. /**
  18342. * Serialize this manager to a JSON object
  18343. * @param name defines the property name to store this manager
  18344. * @returns a JSON representation of this manager
  18345. */
  18346. serialize(name: string): any;
  18347. /**
  18348. * Creates a new ActionManager from a JSON data
  18349. * @param parsedActions defines the JSON data to read from
  18350. * @param object defines the hosting mesh
  18351. * @param scene defines the hosting scene
  18352. */
  18353. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18354. /**
  18355. * Get a trigger name by index
  18356. * @param trigger defines the trigger index
  18357. * @returns a trigger name
  18358. */
  18359. static GetTriggerName(trigger: number): string;
  18360. }
  18361. }
  18362. declare module "babylonjs/Sprites/sprite" {
  18363. import { Vector3 } from "babylonjs/Maths/math.vector";
  18364. import { Nullable } from "babylonjs/types";
  18365. import { ActionManager } from "babylonjs/Actions/actionManager";
  18366. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18367. import { Color4 } from "babylonjs/Maths/math.color";
  18368. /**
  18369. * Class used to represent a sprite
  18370. * @see http://doc.babylonjs.com/babylon101/sprites
  18371. */
  18372. export class Sprite {
  18373. /** defines the name */
  18374. name: string;
  18375. /** Gets or sets the current world position */
  18376. position: Vector3;
  18377. /** Gets or sets the main color */
  18378. color: Color4;
  18379. /** Gets or sets the width */
  18380. width: number;
  18381. /** Gets or sets the height */
  18382. height: number;
  18383. /** Gets or sets rotation angle */
  18384. angle: number;
  18385. /** Gets or sets the cell index in the sprite sheet */
  18386. cellIndex: number;
  18387. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18388. cellRef: string;
  18389. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18390. invertU: number;
  18391. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18392. invertV: number;
  18393. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18394. disposeWhenFinishedAnimating: boolean;
  18395. /** Gets the list of attached animations */
  18396. animations: Animation[];
  18397. /** Gets or sets a boolean indicating if the sprite can be picked */
  18398. isPickable: boolean;
  18399. /**
  18400. * Gets or sets the associated action manager
  18401. */
  18402. actionManager: Nullable<ActionManager>;
  18403. private _animationStarted;
  18404. private _loopAnimation;
  18405. private _fromIndex;
  18406. private _toIndex;
  18407. private _delay;
  18408. private _direction;
  18409. private _manager;
  18410. private _time;
  18411. private _onAnimationEnd;
  18412. /**
  18413. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18414. */
  18415. isVisible: boolean;
  18416. /**
  18417. * Gets or sets the sprite size
  18418. */
  18419. get size(): number;
  18420. set size(value: number);
  18421. /**
  18422. * Creates a new Sprite
  18423. * @param name defines the name
  18424. * @param manager defines the manager
  18425. */
  18426. constructor(
  18427. /** defines the name */
  18428. name: string, manager: ISpriteManager);
  18429. /**
  18430. * Starts an animation
  18431. * @param from defines the initial key
  18432. * @param to defines the end key
  18433. * @param loop defines if the animation must loop
  18434. * @param delay defines the start delay (in ms)
  18435. * @param onAnimationEnd defines a callback to call when animation ends
  18436. */
  18437. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18438. /** Stops current animation (if any) */
  18439. stopAnimation(): void;
  18440. /** @hidden */
  18441. _animate(deltaTime: number): void;
  18442. /** Release associated resources */
  18443. dispose(): void;
  18444. }
  18445. }
  18446. declare module "babylonjs/Collisions/pickingInfo" {
  18447. import { Nullable } from "babylonjs/types";
  18448. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18450. import { Sprite } from "babylonjs/Sprites/sprite";
  18451. import { Ray } from "babylonjs/Culling/ray";
  18452. /**
  18453. * Information about the result of picking within a scene
  18454. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18455. */
  18456. export class PickingInfo {
  18457. /** @hidden */
  18458. _pickingUnavailable: boolean;
  18459. /**
  18460. * If the pick collided with an object
  18461. */
  18462. hit: boolean;
  18463. /**
  18464. * Distance away where the pick collided
  18465. */
  18466. distance: number;
  18467. /**
  18468. * The location of pick collision
  18469. */
  18470. pickedPoint: Nullable<Vector3>;
  18471. /**
  18472. * The mesh corresponding the the pick collision
  18473. */
  18474. pickedMesh: Nullable<AbstractMesh>;
  18475. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18476. bu: number;
  18477. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18478. bv: number;
  18479. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18480. faceId: number;
  18481. /** Id of the the submesh that was picked */
  18482. subMeshId: number;
  18483. /** If a sprite was picked, this will be the sprite the pick collided with */
  18484. pickedSprite: Nullable<Sprite>;
  18485. /**
  18486. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18487. */
  18488. originMesh: Nullable<AbstractMesh>;
  18489. /**
  18490. * The ray that was used to perform the picking.
  18491. */
  18492. ray: Nullable<Ray>;
  18493. /**
  18494. * Gets the normal correspodning to the face the pick collided with
  18495. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18496. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18497. * @returns The normal correspodning to the face the pick collided with
  18498. */
  18499. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18500. /**
  18501. * Gets the texture coordinates of where the pick occured
  18502. * @returns the vector containing the coordnates of the texture
  18503. */
  18504. getTextureCoordinates(): Nullable<Vector2>;
  18505. }
  18506. }
  18507. declare module "babylonjs/Events/pointerEvents" {
  18508. import { Nullable } from "babylonjs/types";
  18509. import { Vector2 } from "babylonjs/Maths/math.vector";
  18510. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18511. import { Ray } from "babylonjs/Culling/ray";
  18512. /**
  18513. * Gather the list of pointer event types as constants.
  18514. */
  18515. export class PointerEventTypes {
  18516. /**
  18517. * 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.
  18518. */
  18519. static readonly POINTERDOWN: number;
  18520. /**
  18521. * The pointerup event is fired when a pointer is no longer active.
  18522. */
  18523. static readonly POINTERUP: number;
  18524. /**
  18525. * The pointermove event is fired when a pointer changes coordinates.
  18526. */
  18527. static readonly POINTERMOVE: number;
  18528. /**
  18529. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18530. */
  18531. static readonly POINTERWHEEL: number;
  18532. /**
  18533. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18534. */
  18535. static readonly POINTERPICK: number;
  18536. /**
  18537. * The pointertap event is fired when a the object has been touched and released without drag.
  18538. */
  18539. static readonly POINTERTAP: number;
  18540. /**
  18541. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18542. */
  18543. static readonly POINTERDOUBLETAP: number;
  18544. }
  18545. /**
  18546. * Base class of pointer info types.
  18547. */
  18548. export class PointerInfoBase {
  18549. /**
  18550. * Defines the type of event (PointerEventTypes)
  18551. */
  18552. type: number;
  18553. /**
  18554. * Defines the related dom event
  18555. */
  18556. event: PointerEvent | MouseWheelEvent;
  18557. /**
  18558. * Instantiates the base class of pointers info.
  18559. * @param type Defines the type of event (PointerEventTypes)
  18560. * @param event Defines the related dom event
  18561. */
  18562. constructor(
  18563. /**
  18564. * Defines the type of event (PointerEventTypes)
  18565. */
  18566. type: number,
  18567. /**
  18568. * Defines the related dom event
  18569. */
  18570. event: PointerEvent | MouseWheelEvent);
  18571. }
  18572. /**
  18573. * This class is used to store pointer related info for the onPrePointerObservable event.
  18574. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18575. */
  18576. export class PointerInfoPre extends PointerInfoBase {
  18577. /**
  18578. * Ray from a pointer if availible (eg. 6dof controller)
  18579. */
  18580. ray: Nullable<Ray>;
  18581. /**
  18582. * Defines the local position of the pointer on the canvas.
  18583. */
  18584. localPosition: Vector2;
  18585. /**
  18586. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18587. */
  18588. skipOnPointerObservable: boolean;
  18589. /**
  18590. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18591. * @param type Defines the type of event (PointerEventTypes)
  18592. * @param event Defines the related dom event
  18593. * @param localX Defines the local x coordinates of the pointer when the event occured
  18594. * @param localY Defines the local y coordinates of the pointer when the event occured
  18595. */
  18596. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18597. }
  18598. /**
  18599. * This type contains all the data related to a pointer event in Babylon.js.
  18600. * 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.
  18601. */
  18602. export class PointerInfo extends PointerInfoBase {
  18603. /**
  18604. * Defines the picking info associated to the info (if any)\
  18605. */
  18606. pickInfo: Nullable<PickingInfo>;
  18607. /**
  18608. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18609. * @param type Defines the type of event (PointerEventTypes)
  18610. * @param event Defines the related dom event
  18611. * @param pickInfo Defines the picking info associated to the info (if any)\
  18612. */
  18613. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18614. /**
  18615. * Defines the picking info associated to the info (if any)\
  18616. */
  18617. pickInfo: Nullable<PickingInfo>);
  18618. }
  18619. /**
  18620. * Data relating to a touch event on the screen.
  18621. */
  18622. export interface PointerTouch {
  18623. /**
  18624. * X coordinate of touch.
  18625. */
  18626. x: number;
  18627. /**
  18628. * Y coordinate of touch.
  18629. */
  18630. y: number;
  18631. /**
  18632. * Id of touch. Unique for each finger.
  18633. */
  18634. pointerId: number;
  18635. /**
  18636. * Event type passed from DOM.
  18637. */
  18638. type: any;
  18639. }
  18640. }
  18641. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18642. import { Observable } from "babylonjs/Misc/observable";
  18643. import { Nullable } from "babylonjs/types";
  18644. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18645. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18646. /**
  18647. * Manage the mouse inputs to control the movement of a free camera.
  18648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18649. */
  18650. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18651. /**
  18652. * Define if touch is enabled in the mouse input
  18653. */
  18654. touchEnabled: boolean;
  18655. /**
  18656. * Defines the camera the input is attached to.
  18657. */
  18658. camera: FreeCamera;
  18659. /**
  18660. * Defines the buttons associated with the input to handle camera move.
  18661. */
  18662. buttons: number[];
  18663. /**
  18664. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18665. */
  18666. angularSensibility: number;
  18667. private _pointerInput;
  18668. private _onMouseMove;
  18669. private _observer;
  18670. private previousPosition;
  18671. /**
  18672. * Observable for when a pointer move event occurs containing the move offset
  18673. */
  18674. onPointerMovedObservable: Observable<{
  18675. offsetX: number;
  18676. offsetY: number;
  18677. }>;
  18678. /**
  18679. * @hidden
  18680. * If the camera should be rotated automatically based on pointer movement
  18681. */
  18682. _allowCameraRotation: boolean;
  18683. /**
  18684. * Manage the mouse inputs to control the movement of a free camera.
  18685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18686. * @param touchEnabled Defines if touch is enabled or not
  18687. */
  18688. constructor(
  18689. /**
  18690. * Define if touch is enabled in the mouse input
  18691. */
  18692. touchEnabled?: boolean);
  18693. /**
  18694. * Attach the input controls to a specific dom element to get the input from.
  18695. * @param element Defines the element the controls should be listened from
  18696. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18697. */
  18698. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18699. /**
  18700. * Called on JS contextmenu event.
  18701. * Override this method to provide functionality.
  18702. */
  18703. protected onContextMenu(evt: PointerEvent): void;
  18704. /**
  18705. * Detach the current controls from the specified dom element.
  18706. * @param element Defines the element to stop listening the inputs from
  18707. */
  18708. detachControl(element: Nullable<HTMLElement>): void;
  18709. /**
  18710. * Gets the class name of the current intput.
  18711. * @returns the class name
  18712. */
  18713. getClassName(): string;
  18714. /**
  18715. * Get the friendly name associated with the input class.
  18716. * @returns the input friendly name
  18717. */
  18718. getSimpleName(): string;
  18719. }
  18720. }
  18721. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18722. import { Nullable } from "babylonjs/types";
  18723. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18724. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18725. /**
  18726. * Manage the touch inputs to control the movement of a free camera.
  18727. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18728. */
  18729. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18730. /**
  18731. * Defines the camera the input is attached to.
  18732. */
  18733. camera: FreeCamera;
  18734. /**
  18735. * Defines the touch sensibility for rotation.
  18736. * The higher the faster.
  18737. */
  18738. touchAngularSensibility: number;
  18739. /**
  18740. * Defines the touch sensibility for move.
  18741. * The higher the faster.
  18742. */
  18743. touchMoveSensibility: number;
  18744. private _offsetX;
  18745. private _offsetY;
  18746. private _pointerPressed;
  18747. private _pointerInput;
  18748. private _observer;
  18749. private _onLostFocus;
  18750. /**
  18751. * Attach the input controls to a specific dom element to get the input from.
  18752. * @param element Defines the element the controls should be listened from
  18753. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18754. */
  18755. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18756. /**
  18757. * Detach the current controls from the specified dom element.
  18758. * @param element Defines the element to stop listening the inputs from
  18759. */
  18760. detachControl(element: Nullable<HTMLElement>): void;
  18761. /**
  18762. * Update the current camera state depending on the inputs that have been used this frame.
  18763. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18764. */
  18765. checkInputs(): void;
  18766. /**
  18767. * Gets the class name of the current intput.
  18768. * @returns the class name
  18769. */
  18770. getClassName(): string;
  18771. /**
  18772. * Get the friendly name associated with the input class.
  18773. * @returns the input friendly name
  18774. */
  18775. getSimpleName(): string;
  18776. }
  18777. }
  18778. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18779. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18780. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18781. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18782. import { Nullable } from "babylonjs/types";
  18783. /**
  18784. * Default Inputs manager for the FreeCamera.
  18785. * It groups all the default supported inputs for ease of use.
  18786. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18787. */
  18788. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18789. /**
  18790. * @hidden
  18791. */
  18792. _mouseInput: Nullable<FreeCameraMouseInput>;
  18793. /**
  18794. * Instantiates a new FreeCameraInputsManager.
  18795. * @param camera Defines the camera the inputs belong to
  18796. */
  18797. constructor(camera: FreeCamera);
  18798. /**
  18799. * Add keyboard input support to the input manager.
  18800. * @returns the current input manager
  18801. */
  18802. addKeyboard(): FreeCameraInputsManager;
  18803. /**
  18804. * Add mouse input support to the input manager.
  18805. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18806. * @returns the current input manager
  18807. */
  18808. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18809. /**
  18810. * Removes the mouse input support from the manager
  18811. * @returns the current input manager
  18812. */
  18813. removeMouse(): FreeCameraInputsManager;
  18814. /**
  18815. * Add touch input support to the input manager.
  18816. * @returns the current input manager
  18817. */
  18818. addTouch(): FreeCameraInputsManager;
  18819. /**
  18820. * Remove all attached input methods from a camera
  18821. */
  18822. clear(): void;
  18823. }
  18824. }
  18825. declare module "babylonjs/Cameras/freeCamera" {
  18826. import { Vector3 } from "babylonjs/Maths/math.vector";
  18827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18828. import { Scene } from "babylonjs/scene";
  18829. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18830. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18831. /**
  18832. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18833. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18834. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18835. */
  18836. export class FreeCamera extends TargetCamera {
  18837. /**
  18838. * Define the collision ellipsoid of the camera.
  18839. * This is helpful to simulate a camera body like the player body around the camera
  18840. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18841. */
  18842. ellipsoid: Vector3;
  18843. /**
  18844. * Define an offset for the position of the ellipsoid around the camera.
  18845. * This can be helpful to determine the center of the body near the gravity center of the body
  18846. * instead of its head.
  18847. */
  18848. ellipsoidOffset: Vector3;
  18849. /**
  18850. * Enable or disable collisions of the camera with the rest of the scene objects.
  18851. */
  18852. checkCollisions: boolean;
  18853. /**
  18854. * Enable or disable gravity on the camera.
  18855. */
  18856. applyGravity: boolean;
  18857. /**
  18858. * Define the input manager associated to the camera.
  18859. */
  18860. inputs: FreeCameraInputsManager;
  18861. /**
  18862. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18863. * Higher values reduce sensitivity.
  18864. */
  18865. get angularSensibility(): number;
  18866. /**
  18867. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18868. * Higher values reduce sensitivity.
  18869. */
  18870. set angularSensibility(value: number);
  18871. /**
  18872. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18873. */
  18874. get keysUp(): number[];
  18875. set keysUp(value: number[]);
  18876. /**
  18877. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18878. */
  18879. get keysDown(): number[];
  18880. set keysDown(value: number[]);
  18881. /**
  18882. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18883. */
  18884. get keysLeft(): number[];
  18885. set keysLeft(value: number[]);
  18886. /**
  18887. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18888. */
  18889. get keysRight(): number[];
  18890. set keysRight(value: number[]);
  18891. /**
  18892. * Event raised when the camera collide with a mesh in the scene.
  18893. */
  18894. onCollide: (collidedMesh: AbstractMesh) => void;
  18895. private _collider;
  18896. private _needMoveForGravity;
  18897. private _oldPosition;
  18898. private _diffPosition;
  18899. private _newPosition;
  18900. /** @hidden */
  18901. _localDirection: Vector3;
  18902. /** @hidden */
  18903. _transformedDirection: Vector3;
  18904. /**
  18905. * Instantiates a Free Camera.
  18906. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18907. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18908. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18909. * @param name Define the name of the camera in the scene
  18910. * @param position Define the start position of the camera in the scene
  18911. * @param scene Define the scene the camera belongs to
  18912. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18913. */
  18914. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18915. /**
  18916. * Attached controls to the current camera.
  18917. * @param element Defines the element the controls should be listened from
  18918. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18919. */
  18920. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18921. /**
  18922. * Detach the current controls from the camera.
  18923. * The camera will stop reacting to inputs.
  18924. * @param element Defines the element to stop listening the inputs from
  18925. */
  18926. detachControl(element: HTMLElement): void;
  18927. private _collisionMask;
  18928. /**
  18929. * Define a collision mask to limit the list of object the camera can collide with
  18930. */
  18931. get collisionMask(): number;
  18932. set collisionMask(mask: number);
  18933. /** @hidden */
  18934. _collideWithWorld(displacement: Vector3): void;
  18935. private _onCollisionPositionChange;
  18936. /** @hidden */
  18937. _checkInputs(): void;
  18938. /** @hidden */
  18939. _decideIfNeedsToMove(): boolean;
  18940. /** @hidden */
  18941. _updatePosition(): void;
  18942. /**
  18943. * Destroy the camera and release the current resources hold by it.
  18944. */
  18945. dispose(): void;
  18946. /**
  18947. * Gets the current object class name.
  18948. * @return the class name
  18949. */
  18950. getClassName(): string;
  18951. }
  18952. }
  18953. declare module "babylonjs/Gamepads/gamepad" {
  18954. import { Observable } from "babylonjs/Misc/observable";
  18955. /**
  18956. * Represents a gamepad control stick position
  18957. */
  18958. export class StickValues {
  18959. /**
  18960. * The x component of the control stick
  18961. */
  18962. x: number;
  18963. /**
  18964. * The y component of the control stick
  18965. */
  18966. y: number;
  18967. /**
  18968. * Initializes the gamepad x and y control stick values
  18969. * @param x The x component of the gamepad control stick value
  18970. * @param y The y component of the gamepad control stick value
  18971. */
  18972. constructor(
  18973. /**
  18974. * The x component of the control stick
  18975. */
  18976. x: number,
  18977. /**
  18978. * The y component of the control stick
  18979. */
  18980. y: number);
  18981. }
  18982. /**
  18983. * An interface which manages callbacks for gamepad button changes
  18984. */
  18985. export interface GamepadButtonChanges {
  18986. /**
  18987. * Called when a gamepad has been changed
  18988. */
  18989. changed: boolean;
  18990. /**
  18991. * Called when a gamepad press event has been triggered
  18992. */
  18993. pressChanged: boolean;
  18994. /**
  18995. * Called when a touch event has been triggered
  18996. */
  18997. touchChanged: boolean;
  18998. /**
  18999. * Called when a value has changed
  19000. */
  19001. valueChanged: boolean;
  19002. }
  19003. /**
  19004. * Represents a gamepad
  19005. */
  19006. export class Gamepad {
  19007. /**
  19008. * The id of the gamepad
  19009. */
  19010. id: string;
  19011. /**
  19012. * The index of the gamepad
  19013. */
  19014. index: number;
  19015. /**
  19016. * The browser gamepad
  19017. */
  19018. browserGamepad: any;
  19019. /**
  19020. * Specifies what type of gamepad this represents
  19021. */
  19022. type: number;
  19023. private _leftStick;
  19024. private _rightStick;
  19025. /** @hidden */
  19026. _isConnected: boolean;
  19027. private _leftStickAxisX;
  19028. private _leftStickAxisY;
  19029. private _rightStickAxisX;
  19030. private _rightStickAxisY;
  19031. /**
  19032. * Triggered when the left control stick has been changed
  19033. */
  19034. private _onleftstickchanged;
  19035. /**
  19036. * Triggered when the right control stick has been changed
  19037. */
  19038. private _onrightstickchanged;
  19039. /**
  19040. * Represents a gamepad controller
  19041. */
  19042. static GAMEPAD: number;
  19043. /**
  19044. * Represents a generic controller
  19045. */
  19046. static GENERIC: number;
  19047. /**
  19048. * Represents an XBox controller
  19049. */
  19050. static XBOX: number;
  19051. /**
  19052. * Represents a pose-enabled controller
  19053. */
  19054. static POSE_ENABLED: number;
  19055. /**
  19056. * Represents an Dual Shock controller
  19057. */
  19058. static DUALSHOCK: number;
  19059. /**
  19060. * Specifies whether the left control stick should be Y-inverted
  19061. */
  19062. protected _invertLeftStickY: boolean;
  19063. /**
  19064. * Specifies if the gamepad has been connected
  19065. */
  19066. get isConnected(): boolean;
  19067. /**
  19068. * Initializes the gamepad
  19069. * @param id The id of the gamepad
  19070. * @param index The index of the gamepad
  19071. * @param browserGamepad The browser gamepad
  19072. * @param leftStickX The x component of the left joystick
  19073. * @param leftStickY The y component of the left joystick
  19074. * @param rightStickX The x component of the right joystick
  19075. * @param rightStickY The y component of the right joystick
  19076. */
  19077. constructor(
  19078. /**
  19079. * The id of the gamepad
  19080. */
  19081. id: string,
  19082. /**
  19083. * The index of the gamepad
  19084. */
  19085. index: number,
  19086. /**
  19087. * The browser gamepad
  19088. */
  19089. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19090. /**
  19091. * Callback triggered when the left joystick has changed
  19092. * @param callback
  19093. */
  19094. onleftstickchanged(callback: (values: StickValues) => void): void;
  19095. /**
  19096. * Callback triggered when the right joystick has changed
  19097. * @param callback
  19098. */
  19099. onrightstickchanged(callback: (values: StickValues) => void): void;
  19100. /**
  19101. * Gets the left joystick
  19102. */
  19103. get leftStick(): StickValues;
  19104. /**
  19105. * Sets the left joystick values
  19106. */
  19107. set leftStick(newValues: StickValues);
  19108. /**
  19109. * Gets the right joystick
  19110. */
  19111. get rightStick(): StickValues;
  19112. /**
  19113. * Sets the right joystick value
  19114. */
  19115. set rightStick(newValues: StickValues);
  19116. /**
  19117. * Updates the gamepad joystick positions
  19118. */
  19119. update(): void;
  19120. /**
  19121. * Disposes the gamepad
  19122. */
  19123. dispose(): void;
  19124. }
  19125. /**
  19126. * Represents a generic gamepad
  19127. */
  19128. export class GenericPad extends Gamepad {
  19129. private _buttons;
  19130. private _onbuttondown;
  19131. private _onbuttonup;
  19132. /**
  19133. * Observable triggered when a button has been pressed
  19134. */
  19135. onButtonDownObservable: Observable<number>;
  19136. /**
  19137. * Observable triggered when a button has been released
  19138. */
  19139. onButtonUpObservable: Observable<number>;
  19140. /**
  19141. * Callback triggered when a button has been pressed
  19142. * @param callback Called when a button has been pressed
  19143. */
  19144. onbuttondown(callback: (buttonPressed: number) => void): void;
  19145. /**
  19146. * Callback triggered when a button has been released
  19147. * @param callback Called when a button has been released
  19148. */
  19149. onbuttonup(callback: (buttonReleased: number) => void): void;
  19150. /**
  19151. * Initializes the generic gamepad
  19152. * @param id The id of the generic gamepad
  19153. * @param index The index of the generic gamepad
  19154. * @param browserGamepad The browser gamepad
  19155. */
  19156. constructor(id: string, index: number, browserGamepad: any);
  19157. private _setButtonValue;
  19158. /**
  19159. * Updates the generic gamepad
  19160. */
  19161. update(): void;
  19162. /**
  19163. * Disposes the generic gamepad
  19164. */
  19165. dispose(): void;
  19166. }
  19167. }
  19168. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19169. import { Observable } from "babylonjs/Misc/observable";
  19170. import { Nullable } from "babylonjs/types";
  19171. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19172. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19174. import { Ray } from "babylonjs/Culling/ray";
  19175. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19176. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19177. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19178. /**
  19179. * Defines the types of pose enabled controllers that are supported
  19180. */
  19181. export enum PoseEnabledControllerType {
  19182. /**
  19183. * HTC Vive
  19184. */
  19185. VIVE = 0,
  19186. /**
  19187. * Oculus Rift
  19188. */
  19189. OCULUS = 1,
  19190. /**
  19191. * Windows mixed reality
  19192. */
  19193. WINDOWS = 2,
  19194. /**
  19195. * Samsung gear VR
  19196. */
  19197. GEAR_VR = 3,
  19198. /**
  19199. * Google Daydream
  19200. */
  19201. DAYDREAM = 4,
  19202. /**
  19203. * Generic
  19204. */
  19205. GENERIC = 5
  19206. }
  19207. /**
  19208. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19209. */
  19210. export interface MutableGamepadButton {
  19211. /**
  19212. * Value of the button/trigger
  19213. */
  19214. value: number;
  19215. /**
  19216. * If the button/trigger is currently touched
  19217. */
  19218. touched: boolean;
  19219. /**
  19220. * If the button/trigger is currently pressed
  19221. */
  19222. pressed: boolean;
  19223. }
  19224. /**
  19225. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19226. * @hidden
  19227. */
  19228. export interface ExtendedGamepadButton extends GamepadButton {
  19229. /**
  19230. * If the button/trigger is currently pressed
  19231. */
  19232. readonly pressed: boolean;
  19233. /**
  19234. * If the button/trigger is currently touched
  19235. */
  19236. readonly touched: boolean;
  19237. /**
  19238. * Value of the button/trigger
  19239. */
  19240. readonly value: number;
  19241. }
  19242. /** @hidden */
  19243. export interface _GamePadFactory {
  19244. /**
  19245. * Returns whether or not the current gamepad can be created for this type of controller.
  19246. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19247. * @returns true if it can be created, otherwise false
  19248. */
  19249. canCreate(gamepadInfo: any): boolean;
  19250. /**
  19251. * Creates a new instance of the Gamepad.
  19252. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19253. * @returns the new gamepad instance
  19254. */
  19255. create(gamepadInfo: any): Gamepad;
  19256. }
  19257. /**
  19258. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19259. */
  19260. export class PoseEnabledControllerHelper {
  19261. /** @hidden */
  19262. static _ControllerFactories: _GamePadFactory[];
  19263. /** @hidden */
  19264. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19265. /**
  19266. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19267. * @param vrGamepad the gamepad to initialized
  19268. * @returns a vr controller of the type the gamepad identified as
  19269. */
  19270. static InitiateController(vrGamepad: any): Gamepad;
  19271. }
  19272. /**
  19273. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19274. */
  19275. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19276. /**
  19277. * If the controller is used in a webXR session
  19278. */
  19279. isXR: boolean;
  19280. private _deviceRoomPosition;
  19281. private _deviceRoomRotationQuaternion;
  19282. /**
  19283. * The device position in babylon space
  19284. */
  19285. devicePosition: Vector3;
  19286. /**
  19287. * The device rotation in babylon space
  19288. */
  19289. deviceRotationQuaternion: Quaternion;
  19290. /**
  19291. * The scale factor of the device in babylon space
  19292. */
  19293. deviceScaleFactor: number;
  19294. /**
  19295. * (Likely devicePosition should be used instead) The device position in its room space
  19296. */
  19297. position: Vector3;
  19298. /**
  19299. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19300. */
  19301. rotationQuaternion: Quaternion;
  19302. /**
  19303. * The type of controller (Eg. Windows mixed reality)
  19304. */
  19305. controllerType: PoseEnabledControllerType;
  19306. protected _calculatedPosition: Vector3;
  19307. private _calculatedRotation;
  19308. /**
  19309. * The raw pose from the device
  19310. */
  19311. rawPose: DevicePose;
  19312. private _trackPosition;
  19313. private _maxRotationDistFromHeadset;
  19314. private _draggedRoomRotation;
  19315. /**
  19316. * @hidden
  19317. */
  19318. _disableTrackPosition(fixedPosition: Vector3): void;
  19319. /**
  19320. * Internal, the mesh attached to the controller
  19321. * @hidden
  19322. */
  19323. _mesh: Nullable<AbstractMesh>;
  19324. private _poseControlledCamera;
  19325. private _leftHandSystemQuaternion;
  19326. /**
  19327. * Internal, matrix used to convert room space to babylon space
  19328. * @hidden
  19329. */
  19330. _deviceToWorld: Matrix;
  19331. /**
  19332. * Node to be used when casting a ray from the controller
  19333. * @hidden
  19334. */
  19335. _pointingPoseNode: Nullable<TransformNode>;
  19336. /**
  19337. * Name of the child mesh that can be used to cast a ray from the controller
  19338. */
  19339. static readonly POINTING_POSE: string;
  19340. /**
  19341. * Creates a new PoseEnabledController from a gamepad
  19342. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19343. */
  19344. constructor(browserGamepad: any);
  19345. private _workingMatrix;
  19346. /**
  19347. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19348. */
  19349. update(): void;
  19350. /**
  19351. * Updates only the pose device and mesh without doing any button event checking
  19352. */
  19353. protected _updatePoseAndMesh(): void;
  19354. /**
  19355. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19356. * @param poseData raw pose fromthe device
  19357. */
  19358. updateFromDevice(poseData: DevicePose): void;
  19359. /**
  19360. * @hidden
  19361. */
  19362. _meshAttachedObservable: Observable<AbstractMesh>;
  19363. /**
  19364. * Attaches a mesh to the controller
  19365. * @param mesh the mesh to be attached
  19366. */
  19367. attachToMesh(mesh: AbstractMesh): void;
  19368. /**
  19369. * Attaches the controllers mesh to a camera
  19370. * @param camera the camera the mesh should be attached to
  19371. */
  19372. attachToPoseControlledCamera(camera: TargetCamera): void;
  19373. /**
  19374. * Disposes of the controller
  19375. */
  19376. dispose(): void;
  19377. /**
  19378. * The mesh that is attached to the controller
  19379. */
  19380. get mesh(): Nullable<AbstractMesh>;
  19381. /**
  19382. * Gets the ray of the controller in the direction the controller is pointing
  19383. * @param length the length the resulting ray should be
  19384. * @returns a ray in the direction the controller is pointing
  19385. */
  19386. getForwardRay(length?: number): Ray;
  19387. }
  19388. }
  19389. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19390. import { Observable } from "babylonjs/Misc/observable";
  19391. import { Scene } from "babylonjs/scene";
  19392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19393. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19394. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19395. import { Nullable } from "babylonjs/types";
  19396. /**
  19397. * Defines the WebVRController object that represents controllers tracked in 3D space
  19398. */
  19399. export abstract class WebVRController extends PoseEnabledController {
  19400. /**
  19401. * Internal, the default controller model for the controller
  19402. */
  19403. protected _defaultModel: Nullable<AbstractMesh>;
  19404. /**
  19405. * Fired when the trigger state has changed
  19406. */
  19407. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19408. /**
  19409. * Fired when the main button state has changed
  19410. */
  19411. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19412. /**
  19413. * Fired when the secondary button state has changed
  19414. */
  19415. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19416. /**
  19417. * Fired when the pad state has changed
  19418. */
  19419. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19420. /**
  19421. * Fired when controllers stick values have changed
  19422. */
  19423. onPadValuesChangedObservable: Observable<StickValues>;
  19424. /**
  19425. * Array of button availible on the controller
  19426. */
  19427. protected _buttons: Array<MutableGamepadButton>;
  19428. private _onButtonStateChange;
  19429. /**
  19430. * Fired when a controller button's state has changed
  19431. * @param callback the callback containing the button that was modified
  19432. */
  19433. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19434. /**
  19435. * X and Y axis corresponding to the controllers joystick
  19436. */
  19437. pad: StickValues;
  19438. /**
  19439. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19440. */
  19441. hand: string;
  19442. /**
  19443. * The default controller model for the controller
  19444. */
  19445. get defaultModel(): Nullable<AbstractMesh>;
  19446. /**
  19447. * Creates a new WebVRController from a gamepad
  19448. * @param vrGamepad the gamepad that the WebVRController should be created from
  19449. */
  19450. constructor(vrGamepad: any);
  19451. /**
  19452. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19453. */
  19454. update(): void;
  19455. /**
  19456. * Function to be called when a button is modified
  19457. */
  19458. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19459. /**
  19460. * Loads a mesh and attaches it to the controller
  19461. * @param scene the scene the mesh should be added to
  19462. * @param meshLoaded callback for when the mesh has been loaded
  19463. */
  19464. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19465. private _setButtonValue;
  19466. private _changes;
  19467. private _checkChanges;
  19468. /**
  19469. * Disposes of th webVRCOntroller
  19470. */
  19471. dispose(): void;
  19472. }
  19473. }
  19474. declare module "babylonjs/Lights/hemisphericLight" {
  19475. import { Nullable } from "babylonjs/types";
  19476. import { Scene } from "babylonjs/scene";
  19477. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19478. import { Color3 } from "babylonjs/Maths/math.color";
  19479. import { Effect } from "babylonjs/Materials/effect";
  19480. import { Light } from "babylonjs/Lights/light";
  19481. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19482. /**
  19483. * The HemisphericLight simulates the ambient environment light,
  19484. * so the passed direction is the light reflection direction, not the incoming direction.
  19485. */
  19486. export class HemisphericLight extends Light {
  19487. /**
  19488. * The groundColor is the light in the opposite direction to the one specified during creation.
  19489. * 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.
  19490. */
  19491. groundColor: Color3;
  19492. /**
  19493. * The light reflection direction, not the incoming direction.
  19494. */
  19495. direction: Vector3;
  19496. /**
  19497. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19498. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19499. * The HemisphericLight can't cast shadows.
  19500. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19501. * @param name The friendly name of the light
  19502. * @param direction The direction of the light reflection
  19503. * @param scene The scene the light belongs to
  19504. */
  19505. constructor(name: string, direction: Vector3, scene: Scene);
  19506. protected _buildUniformLayout(): void;
  19507. /**
  19508. * Returns the string "HemisphericLight".
  19509. * @return The class name
  19510. */
  19511. getClassName(): string;
  19512. /**
  19513. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19514. * Returns the updated direction.
  19515. * @param target The target the direction should point to
  19516. * @return The computed direction
  19517. */
  19518. setDirectionToTarget(target: Vector3): Vector3;
  19519. /**
  19520. * Returns the shadow generator associated to the light.
  19521. * @returns Always null for hemispheric lights because it does not support shadows.
  19522. */
  19523. getShadowGenerator(): Nullable<IShadowGenerator>;
  19524. /**
  19525. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19526. * @param effect The effect to update
  19527. * @param lightIndex The index of the light in the effect to update
  19528. * @returns The hemispheric light
  19529. */
  19530. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19531. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19532. /**
  19533. * Computes the world matrix of the node
  19534. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19535. * @param useWasUpdatedFlag defines a reserved property
  19536. * @returns the world matrix
  19537. */
  19538. computeWorldMatrix(): Matrix;
  19539. /**
  19540. * Returns the integer 3.
  19541. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19542. */
  19543. getTypeID(): number;
  19544. /**
  19545. * Prepares the list of defines specific to the light type.
  19546. * @param defines the list of defines
  19547. * @param lightIndex defines the index of the light for the effect
  19548. */
  19549. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19550. }
  19551. }
  19552. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19553. /** @hidden */
  19554. export var vrMultiviewToSingleviewPixelShader: {
  19555. name: string;
  19556. shader: string;
  19557. };
  19558. }
  19559. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19560. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19561. import { Scene } from "babylonjs/scene";
  19562. /**
  19563. * Renders to multiple views with a single draw call
  19564. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19565. */
  19566. export class MultiviewRenderTarget extends RenderTargetTexture {
  19567. /**
  19568. * Creates a multiview render target
  19569. * @param scene scene used with the render target
  19570. * @param size the size of the render target (used for each view)
  19571. */
  19572. constructor(scene: Scene, size?: number | {
  19573. width: number;
  19574. height: number;
  19575. } | {
  19576. ratio: number;
  19577. });
  19578. /**
  19579. * @hidden
  19580. * @param faceIndex the face index, if its a cube texture
  19581. */
  19582. _bindFrameBuffer(faceIndex?: number): void;
  19583. /**
  19584. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19585. * @returns the view count
  19586. */
  19587. getViewCount(): number;
  19588. }
  19589. }
  19590. declare module "babylonjs/Maths/math.frustum" {
  19591. import { Matrix } from "babylonjs/Maths/math.vector";
  19592. import { DeepImmutable } from "babylonjs/types";
  19593. import { Plane } from "babylonjs/Maths/math.plane";
  19594. /**
  19595. * Represents a camera frustum
  19596. */
  19597. export class Frustum {
  19598. /**
  19599. * Gets the planes representing the frustum
  19600. * @param transform matrix to be applied to the returned planes
  19601. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19602. */
  19603. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19604. /**
  19605. * Gets the near frustum plane transformed by the transform matrix
  19606. * @param transform transformation matrix to be applied to the resulting frustum plane
  19607. * @param frustumPlane the resuling frustum plane
  19608. */
  19609. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19610. /**
  19611. * Gets the far frustum plane transformed by the transform matrix
  19612. * @param transform transformation matrix to be applied to the resulting frustum plane
  19613. * @param frustumPlane the resuling frustum plane
  19614. */
  19615. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19616. /**
  19617. * Gets the left frustum plane transformed by the transform matrix
  19618. * @param transform transformation matrix to be applied to the resulting frustum plane
  19619. * @param frustumPlane the resuling frustum plane
  19620. */
  19621. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19622. /**
  19623. * Gets the right frustum plane transformed by the transform matrix
  19624. * @param transform transformation matrix to be applied to the resulting frustum plane
  19625. * @param frustumPlane the resuling frustum plane
  19626. */
  19627. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19628. /**
  19629. * Gets the top frustum plane transformed by the transform matrix
  19630. * @param transform transformation matrix to be applied to the resulting frustum plane
  19631. * @param frustumPlane the resuling frustum plane
  19632. */
  19633. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19634. /**
  19635. * Gets the bottom frustum plane transformed by the transform matrix
  19636. * @param transform transformation matrix to be applied to the resulting frustum plane
  19637. * @param frustumPlane the resuling frustum plane
  19638. */
  19639. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19640. /**
  19641. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19642. * @param transform transformation matrix to be applied to the resulting frustum planes
  19643. * @param frustumPlanes the resuling frustum planes
  19644. */
  19645. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19646. }
  19647. }
  19648. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19649. import { Camera } from "babylonjs/Cameras/camera";
  19650. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19651. import { Nullable } from "babylonjs/types";
  19652. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19653. import { Matrix } from "babylonjs/Maths/math.vector";
  19654. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19655. module "babylonjs/Engines/engine" {
  19656. interface Engine {
  19657. /**
  19658. * Creates a new multiview render target
  19659. * @param width defines the width of the texture
  19660. * @param height defines the height of the texture
  19661. * @returns the created multiview texture
  19662. */
  19663. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19664. /**
  19665. * Binds a multiview framebuffer to be drawn to
  19666. * @param multiviewTexture texture to bind
  19667. */
  19668. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19669. }
  19670. }
  19671. module "babylonjs/Cameras/camera" {
  19672. interface Camera {
  19673. /**
  19674. * @hidden
  19675. * 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)
  19676. */
  19677. _useMultiviewToSingleView: boolean;
  19678. /**
  19679. * @hidden
  19680. * 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)
  19681. */
  19682. _multiviewTexture: Nullable<RenderTargetTexture>;
  19683. /**
  19684. * @hidden
  19685. * ensures the multiview texture of the camera exists and has the specified width/height
  19686. * @param width height to set on the multiview texture
  19687. * @param height width to set on the multiview texture
  19688. */
  19689. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19690. }
  19691. }
  19692. module "babylonjs/scene" {
  19693. interface Scene {
  19694. /** @hidden */
  19695. _transformMatrixR: Matrix;
  19696. /** @hidden */
  19697. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19698. /** @hidden */
  19699. _createMultiviewUbo(): void;
  19700. /** @hidden */
  19701. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19702. /** @hidden */
  19703. _renderMultiviewToSingleView(camera: Camera): void;
  19704. }
  19705. }
  19706. }
  19707. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19708. import { Camera } from "babylonjs/Cameras/camera";
  19709. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19710. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19711. import "babylonjs/Engines/Extensions/engine.multiview";
  19712. /**
  19713. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19714. * This will not be used for webXR as it supports displaying texture arrays directly
  19715. */
  19716. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19717. /**
  19718. * Initializes a VRMultiviewToSingleview
  19719. * @param name name of the post process
  19720. * @param camera camera to be applied to
  19721. * @param scaleFactor scaling factor to the size of the output texture
  19722. */
  19723. constructor(name: string, camera: Camera, scaleFactor: number);
  19724. }
  19725. }
  19726. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19727. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19728. import { Nullable } from "babylonjs/types";
  19729. import { Size } from "babylonjs/Maths/math.size";
  19730. import { Observable } from "babylonjs/Misc/observable";
  19731. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19732. /**
  19733. * Interface used to define additional presentation attributes
  19734. */
  19735. export interface IVRPresentationAttributes {
  19736. /**
  19737. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19738. */
  19739. highRefreshRate: boolean;
  19740. /**
  19741. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19742. */
  19743. foveationLevel: number;
  19744. }
  19745. module "babylonjs/Engines/engine" {
  19746. interface Engine {
  19747. /** @hidden */
  19748. _vrDisplay: any;
  19749. /** @hidden */
  19750. _vrSupported: boolean;
  19751. /** @hidden */
  19752. _oldSize: Size;
  19753. /** @hidden */
  19754. _oldHardwareScaleFactor: number;
  19755. /** @hidden */
  19756. _vrExclusivePointerMode: boolean;
  19757. /** @hidden */
  19758. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19759. /** @hidden */
  19760. _onVRDisplayPointerRestricted: () => void;
  19761. /** @hidden */
  19762. _onVRDisplayPointerUnrestricted: () => void;
  19763. /** @hidden */
  19764. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19765. /** @hidden */
  19766. _onVrDisplayDisconnect: Nullable<() => void>;
  19767. /** @hidden */
  19768. _onVrDisplayPresentChange: Nullable<() => void>;
  19769. /**
  19770. * Observable signaled when VR display mode changes
  19771. */
  19772. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19773. /**
  19774. * Observable signaled when VR request present is complete
  19775. */
  19776. onVRRequestPresentComplete: Observable<boolean>;
  19777. /**
  19778. * Observable signaled when VR request present starts
  19779. */
  19780. onVRRequestPresentStart: Observable<Engine>;
  19781. /**
  19782. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19783. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19784. */
  19785. isInVRExclusivePointerMode: boolean;
  19786. /**
  19787. * Gets a boolean indicating if a webVR device was detected
  19788. * @returns true if a webVR device was detected
  19789. */
  19790. isVRDevicePresent(): boolean;
  19791. /**
  19792. * Gets the current webVR device
  19793. * @returns the current webVR device (or null)
  19794. */
  19795. getVRDevice(): any;
  19796. /**
  19797. * Initializes a webVR display and starts listening to display change events
  19798. * The onVRDisplayChangedObservable will be notified upon these changes
  19799. * @returns A promise containing a VRDisplay and if vr is supported
  19800. */
  19801. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19802. /** @hidden */
  19803. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19804. /**
  19805. * Gets or sets the presentation attributes used to configure VR rendering
  19806. */
  19807. vrPresentationAttributes?: IVRPresentationAttributes;
  19808. /**
  19809. * Call this function to switch to webVR mode
  19810. * Will do nothing if webVR is not supported or if there is no webVR device
  19811. * @param options the webvr options provided to the camera. mainly used for multiview
  19812. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19813. */
  19814. enableVR(options: WebVROptions): void;
  19815. /** @hidden */
  19816. _onVRFullScreenTriggered(): void;
  19817. }
  19818. }
  19819. }
  19820. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19821. import { Nullable } from "babylonjs/types";
  19822. import { Observable } from "babylonjs/Misc/observable";
  19823. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19824. import { Scene } from "babylonjs/scene";
  19825. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19826. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  19827. import { Node } from "babylonjs/node";
  19828. import { Ray } from "babylonjs/Culling/ray";
  19829. import "babylonjs/Cameras/RigModes/webVRRigMode";
  19830. import "babylonjs/Engines/Extensions/engine.webVR";
  19831. /**
  19832. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19833. * IMPORTANT!! The data is right-hand data.
  19834. * @export
  19835. * @interface DevicePose
  19836. */
  19837. export interface DevicePose {
  19838. /**
  19839. * The position of the device, values in array are [x,y,z].
  19840. */
  19841. readonly position: Nullable<Float32Array>;
  19842. /**
  19843. * The linearVelocity of the device, values in array are [x,y,z].
  19844. */
  19845. readonly linearVelocity: Nullable<Float32Array>;
  19846. /**
  19847. * The linearAcceleration of the device, values in array are [x,y,z].
  19848. */
  19849. readonly linearAcceleration: Nullable<Float32Array>;
  19850. /**
  19851. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19852. */
  19853. readonly orientation: Nullable<Float32Array>;
  19854. /**
  19855. * The angularVelocity of the device, values in array are [x,y,z].
  19856. */
  19857. readonly angularVelocity: Nullable<Float32Array>;
  19858. /**
  19859. * The angularAcceleration of the device, values in array are [x,y,z].
  19860. */
  19861. readonly angularAcceleration: Nullable<Float32Array>;
  19862. }
  19863. /**
  19864. * Interface representing a pose controlled object in Babylon.
  19865. * A pose controlled object has both regular pose values as well as pose values
  19866. * from an external device such as a VR head mounted display
  19867. */
  19868. export interface PoseControlled {
  19869. /**
  19870. * The position of the object in babylon space.
  19871. */
  19872. position: Vector3;
  19873. /**
  19874. * The rotation quaternion of the object in babylon space.
  19875. */
  19876. rotationQuaternion: Quaternion;
  19877. /**
  19878. * The position of the device in babylon space.
  19879. */
  19880. devicePosition?: Vector3;
  19881. /**
  19882. * The rotation quaternion of the device in babylon space.
  19883. */
  19884. deviceRotationQuaternion: Quaternion;
  19885. /**
  19886. * The raw pose coming from the device.
  19887. */
  19888. rawPose: Nullable<DevicePose>;
  19889. /**
  19890. * The scale of the device to be used when translating from device space to babylon space.
  19891. */
  19892. deviceScaleFactor: number;
  19893. /**
  19894. * Updates the poseControlled values based on the input device pose.
  19895. * @param poseData the pose data to update the object with
  19896. */
  19897. updateFromDevice(poseData: DevicePose): void;
  19898. }
  19899. /**
  19900. * Set of options to customize the webVRCamera
  19901. */
  19902. export interface WebVROptions {
  19903. /**
  19904. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19905. */
  19906. trackPosition?: boolean;
  19907. /**
  19908. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19909. */
  19910. positionScale?: number;
  19911. /**
  19912. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19913. */
  19914. displayName?: string;
  19915. /**
  19916. * Should the native controller meshes be initialized. (default: true)
  19917. */
  19918. controllerMeshes?: boolean;
  19919. /**
  19920. * Creating a default HemiLight only on controllers. (default: true)
  19921. */
  19922. defaultLightingOnControllers?: boolean;
  19923. /**
  19924. * If you don't want to use the default VR button of the helper. (default: false)
  19925. */
  19926. useCustomVRButton?: boolean;
  19927. /**
  19928. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19929. */
  19930. customVRButton?: HTMLButtonElement;
  19931. /**
  19932. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19933. */
  19934. rayLength?: number;
  19935. /**
  19936. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19937. */
  19938. defaultHeight?: number;
  19939. /**
  19940. * If multiview should be used if availible (default: false)
  19941. */
  19942. useMultiview?: boolean;
  19943. }
  19944. /**
  19945. * This represents a WebVR camera.
  19946. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19947. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19948. */
  19949. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19950. private webVROptions;
  19951. /**
  19952. * @hidden
  19953. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19954. */
  19955. _vrDevice: any;
  19956. /**
  19957. * The rawPose of the vrDevice.
  19958. */
  19959. rawPose: Nullable<DevicePose>;
  19960. private _onVREnabled;
  19961. private _specsVersion;
  19962. private _attached;
  19963. private _frameData;
  19964. protected _descendants: Array<Node>;
  19965. private _deviceRoomPosition;
  19966. /** @hidden */
  19967. _deviceRoomRotationQuaternion: Quaternion;
  19968. private _standingMatrix;
  19969. /**
  19970. * Represents device position in babylon space.
  19971. */
  19972. devicePosition: Vector3;
  19973. /**
  19974. * Represents device rotation in babylon space.
  19975. */
  19976. deviceRotationQuaternion: Quaternion;
  19977. /**
  19978. * The scale of the device to be used when translating from device space to babylon space.
  19979. */
  19980. deviceScaleFactor: number;
  19981. private _deviceToWorld;
  19982. private _worldToDevice;
  19983. /**
  19984. * References to the webVR controllers for the vrDevice.
  19985. */
  19986. controllers: Array<WebVRController>;
  19987. /**
  19988. * Emits an event when a controller is attached.
  19989. */
  19990. onControllersAttachedObservable: Observable<WebVRController[]>;
  19991. /**
  19992. * Emits an event when a controller's mesh has been loaded;
  19993. */
  19994. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19995. /**
  19996. * Emits an event when the HMD's pose has been updated.
  19997. */
  19998. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19999. private _poseSet;
  20000. /**
  20001. * If the rig cameras be used as parent instead of this camera.
  20002. */
  20003. rigParenting: boolean;
  20004. private _lightOnControllers;
  20005. private _defaultHeight?;
  20006. /**
  20007. * Instantiates a WebVRFreeCamera.
  20008. * @param name The name of the WebVRFreeCamera
  20009. * @param position The starting anchor position for the camera
  20010. * @param scene The scene the camera belongs to
  20011. * @param webVROptions a set of customizable options for the webVRCamera
  20012. */
  20013. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20014. /**
  20015. * Gets the device distance from the ground in meters.
  20016. * @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.
  20017. */
  20018. deviceDistanceToRoomGround(): number;
  20019. /**
  20020. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20021. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20022. */
  20023. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20024. /**
  20025. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20026. * @returns A promise with a boolean set to if the standing matrix is supported.
  20027. */
  20028. useStandingMatrixAsync(): Promise<boolean>;
  20029. /**
  20030. * Disposes the camera
  20031. */
  20032. dispose(): void;
  20033. /**
  20034. * Gets a vrController by name.
  20035. * @param name The name of the controller to retreive
  20036. * @returns the controller matching the name specified or null if not found
  20037. */
  20038. getControllerByName(name: string): Nullable<WebVRController>;
  20039. private _leftController;
  20040. /**
  20041. * The controller corresponding to the users left hand.
  20042. */
  20043. get leftController(): Nullable<WebVRController>;
  20044. private _rightController;
  20045. /**
  20046. * The controller corresponding to the users right hand.
  20047. */
  20048. get rightController(): Nullable<WebVRController>;
  20049. /**
  20050. * Casts a ray forward from the vrCamera's gaze.
  20051. * @param length Length of the ray (default: 100)
  20052. * @returns the ray corresponding to the gaze
  20053. */
  20054. getForwardRay(length?: number): Ray;
  20055. /**
  20056. * @hidden
  20057. * Updates the camera based on device's frame data
  20058. */
  20059. _checkInputs(): void;
  20060. /**
  20061. * Updates the poseControlled values based on the input device pose.
  20062. * @param poseData Pose coming from the device
  20063. */
  20064. updateFromDevice(poseData: DevicePose): void;
  20065. private _htmlElementAttached;
  20066. private _detachIfAttached;
  20067. /**
  20068. * WebVR's attach control will start broadcasting frames to the device.
  20069. * Note that in certain browsers (chrome for example) this function must be called
  20070. * within a user-interaction callback. Example:
  20071. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20072. *
  20073. * @param element html element to attach the vrDevice to
  20074. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20075. */
  20076. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20077. /**
  20078. * Detaches the camera from the html element and disables VR
  20079. *
  20080. * @param element html element to detach from
  20081. */
  20082. detachControl(element: HTMLElement): void;
  20083. /**
  20084. * @returns the name of this class
  20085. */
  20086. getClassName(): string;
  20087. /**
  20088. * Calls resetPose on the vrDisplay
  20089. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20090. */
  20091. resetToCurrentRotation(): void;
  20092. /**
  20093. * @hidden
  20094. * Updates the rig cameras (left and right eye)
  20095. */
  20096. _updateRigCameras(): void;
  20097. private _workingVector;
  20098. private _oneVector;
  20099. private _workingMatrix;
  20100. private updateCacheCalled;
  20101. private _correctPositionIfNotTrackPosition;
  20102. /**
  20103. * @hidden
  20104. * Updates the cached values of the camera
  20105. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20106. */
  20107. _updateCache(ignoreParentClass?: boolean): void;
  20108. /**
  20109. * @hidden
  20110. * Get current device position in babylon world
  20111. */
  20112. _computeDevicePosition(): void;
  20113. /**
  20114. * Updates the current device position and rotation in the babylon world
  20115. */
  20116. update(): void;
  20117. /**
  20118. * @hidden
  20119. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20120. * @returns an identity matrix
  20121. */
  20122. _getViewMatrix(): Matrix;
  20123. private _tmpMatrix;
  20124. /**
  20125. * This function is called by the two RIG cameras.
  20126. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20127. * @hidden
  20128. */
  20129. _getWebVRViewMatrix(): Matrix;
  20130. /** @hidden */
  20131. _getWebVRProjectionMatrix(): Matrix;
  20132. private _onGamepadConnectedObserver;
  20133. private _onGamepadDisconnectedObserver;
  20134. private _updateCacheWhenTrackingDisabledObserver;
  20135. /**
  20136. * Initializes the controllers and their meshes
  20137. */
  20138. initControllers(): void;
  20139. }
  20140. }
  20141. declare module "babylonjs/PostProcesses/postProcess" {
  20142. import { Nullable } from "babylonjs/types";
  20143. import { SmartArray } from "babylonjs/Misc/smartArray";
  20144. import { Observable } from "babylonjs/Misc/observable";
  20145. import { Vector2 } from "babylonjs/Maths/math.vector";
  20146. import { Camera } from "babylonjs/Cameras/camera";
  20147. import { Effect } from "babylonjs/Materials/effect";
  20148. import "babylonjs/Shaders/postprocess.vertex";
  20149. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20150. import { Engine } from "babylonjs/Engines/engine";
  20151. import { Color4 } from "babylonjs/Maths/math.color";
  20152. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20153. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20154. /**
  20155. * Size options for a post process
  20156. */
  20157. export type PostProcessOptions = {
  20158. width: number;
  20159. height: number;
  20160. };
  20161. /**
  20162. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20163. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20164. */
  20165. export class PostProcess {
  20166. /** Name of the PostProcess. */
  20167. name: string;
  20168. /**
  20169. * Gets or sets the unique id of the post process
  20170. */
  20171. uniqueId: number;
  20172. /**
  20173. * Width of the texture to apply the post process on
  20174. */
  20175. width: number;
  20176. /**
  20177. * Height of the texture to apply the post process on
  20178. */
  20179. height: number;
  20180. /**
  20181. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20182. * @hidden
  20183. */
  20184. _outputTexture: Nullable<InternalTexture>;
  20185. /**
  20186. * Sampling mode used by the shader
  20187. * See https://doc.babylonjs.com/classes/3.1/texture
  20188. */
  20189. renderTargetSamplingMode: number;
  20190. /**
  20191. * Clear color to use when screen clearing
  20192. */
  20193. clearColor: Color4;
  20194. /**
  20195. * If the buffer needs to be cleared before applying the post process. (default: true)
  20196. * Should be set to false if shader will overwrite all previous pixels.
  20197. */
  20198. autoClear: boolean;
  20199. /**
  20200. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20201. */
  20202. alphaMode: number;
  20203. /**
  20204. * Sets the setAlphaBlendConstants of the babylon engine
  20205. */
  20206. alphaConstants: Color4;
  20207. /**
  20208. * Animations to be used for the post processing
  20209. */
  20210. animations: import("babylonjs/Animations/animation").Animation[];
  20211. /**
  20212. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20213. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20214. */
  20215. enablePixelPerfectMode: boolean;
  20216. /**
  20217. * Force the postprocess to be applied without taking in account viewport
  20218. */
  20219. forceFullscreenViewport: boolean;
  20220. /**
  20221. * List of inspectable custom properties (used by the Inspector)
  20222. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20223. */
  20224. inspectableCustomProperties: IInspectable[];
  20225. /**
  20226. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20227. *
  20228. * | Value | Type | Description |
  20229. * | ----- | ----------------------------------- | ----------- |
  20230. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20231. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20232. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20233. *
  20234. */
  20235. scaleMode: number;
  20236. /**
  20237. * Force textures to be a power of two (default: false)
  20238. */
  20239. alwaysForcePOT: boolean;
  20240. private _samples;
  20241. /**
  20242. * Number of sample textures (default: 1)
  20243. */
  20244. get samples(): number;
  20245. set samples(n: number);
  20246. /**
  20247. * Modify the scale of the post process to be the same as the viewport (default: false)
  20248. */
  20249. adaptScaleToCurrentViewport: boolean;
  20250. private _camera;
  20251. private _scene;
  20252. private _engine;
  20253. private _options;
  20254. private _reusable;
  20255. private _textureType;
  20256. private _textureFormat;
  20257. /**
  20258. * Smart array of input and output textures for the post process.
  20259. * @hidden
  20260. */
  20261. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20262. /**
  20263. * The index in _textures that corresponds to the output texture.
  20264. * @hidden
  20265. */
  20266. _currentRenderTextureInd: number;
  20267. private _effect;
  20268. private _samplers;
  20269. private _fragmentUrl;
  20270. private _vertexUrl;
  20271. private _parameters;
  20272. private _scaleRatio;
  20273. protected _indexParameters: any;
  20274. private _shareOutputWithPostProcess;
  20275. private _texelSize;
  20276. private _forcedOutputTexture;
  20277. /**
  20278. * Returns the fragment url or shader name used in the post process.
  20279. * @returns the fragment url or name in the shader store.
  20280. */
  20281. getEffectName(): string;
  20282. /**
  20283. * An event triggered when the postprocess is activated.
  20284. */
  20285. onActivateObservable: Observable<Camera>;
  20286. private _onActivateObserver;
  20287. /**
  20288. * A function that is added to the onActivateObservable
  20289. */
  20290. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20291. /**
  20292. * An event triggered when the postprocess changes its size.
  20293. */
  20294. onSizeChangedObservable: Observable<PostProcess>;
  20295. private _onSizeChangedObserver;
  20296. /**
  20297. * A function that is added to the onSizeChangedObservable
  20298. */
  20299. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20300. /**
  20301. * An event triggered when the postprocess applies its effect.
  20302. */
  20303. onApplyObservable: Observable<Effect>;
  20304. private _onApplyObserver;
  20305. /**
  20306. * A function that is added to the onApplyObservable
  20307. */
  20308. set onApply(callback: (effect: Effect) => void);
  20309. /**
  20310. * An event triggered before rendering the postprocess
  20311. */
  20312. onBeforeRenderObservable: Observable<Effect>;
  20313. private _onBeforeRenderObserver;
  20314. /**
  20315. * A function that is added to the onBeforeRenderObservable
  20316. */
  20317. set onBeforeRender(callback: (effect: Effect) => void);
  20318. /**
  20319. * An event triggered after rendering the postprocess
  20320. */
  20321. onAfterRenderObservable: Observable<Effect>;
  20322. private _onAfterRenderObserver;
  20323. /**
  20324. * A function that is added to the onAfterRenderObservable
  20325. */
  20326. set onAfterRender(callback: (efect: Effect) => void);
  20327. /**
  20328. * 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
  20329. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20330. */
  20331. get inputTexture(): InternalTexture;
  20332. set inputTexture(value: InternalTexture);
  20333. /**
  20334. * Gets the camera which post process is applied to.
  20335. * @returns The camera the post process is applied to.
  20336. */
  20337. getCamera(): Camera;
  20338. /**
  20339. * Gets the texel size of the postprocess.
  20340. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20341. */
  20342. get texelSize(): Vector2;
  20343. /**
  20344. * Creates a new instance PostProcess
  20345. * @param name The name of the PostProcess.
  20346. * @param fragmentUrl The url of the fragment shader to be used.
  20347. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20348. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20349. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20350. * @param camera The camera to apply the render pass to.
  20351. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20352. * @param engine The engine which the post process will be applied. (default: current engine)
  20353. * @param reusable If the post process can be reused on the same frame. (default: false)
  20354. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20355. * @param textureType Type of textures used when performing the post process. (default: 0)
  20356. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20357. * @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
  20358. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20359. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20360. */
  20361. constructor(
  20362. /** Name of the PostProcess. */
  20363. 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);
  20364. /**
  20365. * Gets a string idenfifying the name of the class
  20366. * @returns "PostProcess" string
  20367. */
  20368. getClassName(): string;
  20369. /**
  20370. * Gets the engine which this post process belongs to.
  20371. * @returns The engine the post process was enabled with.
  20372. */
  20373. getEngine(): Engine;
  20374. /**
  20375. * The effect that is created when initializing the post process.
  20376. * @returns The created effect corresponding the the postprocess.
  20377. */
  20378. getEffect(): Effect;
  20379. /**
  20380. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20381. * @param postProcess The post process to share the output with.
  20382. * @returns This post process.
  20383. */
  20384. shareOutputWith(postProcess: PostProcess): PostProcess;
  20385. /**
  20386. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20387. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20388. */
  20389. useOwnOutput(): void;
  20390. /**
  20391. * Updates the effect with the current post process compile time values and recompiles the shader.
  20392. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20393. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20394. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20395. * @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
  20396. * @param onCompiled Called when the shader has been compiled.
  20397. * @param onError Called if there is an error when compiling a shader.
  20398. */
  20399. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20400. /**
  20401. * The post process is reusable if it can be used multiple times within one frame.
  20402. * @returns If the post process is reusable
  20403. */
  20404. isReusable(): boolean;
  20405. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20406. markTextureDirty(): void;
  20407. /**
  20408. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20409. * 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.
  20410. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20411. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20412. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20413. * @returns The target texture that was bound to be written to.
  20414. */
  20415. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20416. /**
  20417. * If the post process is supported.
  20418. */
  20419. get isSupported(): boolean;
  20420. /**
  20421. * The aspect ratio of the output texture.
  20422. */
  20423. get aspectRatio(): number;
  20424. /**
  20425. * Get a value indicating if the post-process is ready to be used
  20426. * @returns true if the post-process is ready (shader is compiled)
  20427. */
  20428. isReady(): boolean;
  20429. /**
  20430. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20431. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20432. */
  20433. apply(): Nullable<Effect>;
  20434. private _disposeTextures;
  20435. /**
  20436. * Disposes the post process.
  20437. * @param camera The camera to dispose the post process on.
  20438. */
  20439. dispose(camera?: Camera): void;
  20440. }
  20441. }
  20442. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20443. /** @hidden */
  20444. export var kernelBlurVaryingDeclaration: {
  20445. name: string;
  20446. shader: string;
  20447. };
  20448. }
  20449. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20450. /** @hidden */
  20451. export var kernelBlurFragment: {
  20452. name: string;
  20453. shader: string;
  20454. };
  20455. }
  20456. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20457. /** @hidden */
  20458. export var kernelBlurFragment2: {
  20459. name: string;
  20460. shader: string;
  20461. };
  20462. }
  20463. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20464. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20465. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20466. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20467. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20468. /** @hidden */
  20469. export var kernelBlurPixelShader: {
  20470. name: string;
  20471. shader: string;
  20472. };
  20473. }
  20474. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20475. /** @hidden */
  20476. export var kernelBlurVertex: {
  20477. name: string;
  20478. shader: string;
  20479. };
  20480. }
  20481. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20482. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20483. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20484. /** @hidden */
  20485. export var kernelBlurVertexShader: {
  20486. name: string;
  20487. shader: string;
  20488. };
  20489. }
  20490. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20491. import { Vector2 } from "babylonjs/Maths/math.vector";
  20492. import { Nullable } from "babylonjs/types";
  20493. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20494. import { Camera } from "babylonjs/Cameras/camera";
  20495. import { Effect } from "babylonjs/Materials/effect";
  20496. import { Engine } from "babylonjs/Engines/engine";
  20497. import "babylonjs/Shaders/kernelBlur.fragment";
  20498. import "babylonjs/Shaders/kernelBlur.vertex";
  20499. /**
  20500. * The Blur Post Process which blurs an image based on a kernel and direction.
  20501. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20502. */
  20503. export class BlurPostProcess extends PostProcess {
  20504. /** The direction in which to blur the image. */
  20505. direction: Vector2;
  20506. private blockCompilation;
  20507. protected _kernel: number;
  20508. protected _idealKernel: number;
  20509. protected _packedFloat: boolean;
  20510. private _staticDefines;
  20511. /**
  20512. * Sets the length in pixels of the blur sample region
  20513. */
  20514. set kernel(v: number);
  20515. /**
  20516. * Gets the length in pixels of the blur sample region
  20517. */
  20518. get kernel(): number;
  20519. /**
  20520. * Sets wether or not the blur needs to unpack/repack floats
  20521. */
  20522. set packedFloat(v: boolean);
  20523. /**
  20524. * Gets wether or not the blur is unpacking/repacking floats
  20525. */
  20526. get packedFloat(): boolean;
  20527. /**
  20528. * Creates a new instance BlurPostProcess
  20529. * @param name The name of the effect.
  20530. * @param direction The direction in which to blur the image.
  20531. * @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.
  20532. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20533. * @param camera The camera to apply the render pass to.
  20534. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20535. * @param engine The engine which the post process will be applied. (default: current engine)
  20536. * @param reusable If the post process can be reused on the same frame. (default: false)
  20537. * @param textureType Type of textures used when performing the post process. (default: 0)
  20538. * @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)
  20539. */
  20540. constructor(name: string,
  20541. /** The direction in which to blur the image. */
  20542. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20543. /**
  20544. * Updates the effect with the current post process compile time values and recompiles the shader.
  20545. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20546. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20547. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20548. * @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
  20549. * @param onCompiled Called when the shader has been compiled.
  20550. * @param onError Called if there is an error when compiling a shader.
  20551. */
  20552. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20553. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20554. /**
  20555. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20556. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20557. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20558. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20559. * The gaps between physical kernels are compensated for in the weighting of the samples
  20560. * @param idealKernel Ideal blur kernel.
  20561. * @return Nearest best kernel.
  20562. */
  20563. protected _nearestBestKernel(idealKernel: number): number;
  20564. /**
  20565. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20566. * @param x The point on the Gaussian distribution to sample.
  20567. * @return the value of the Gaussian function at x.
  20568. */
  20569. protected _gaussianWeight(x: number): number;
  20570. /**
  20571. * Generates a string that can be used as a floating point number in GLSL.
  20572. * @param x Value to print.
  20573. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20574. * @return GLSL float string.
  20575. */
  20576. protected _glslFloat(x: number, decimalFigures?: number): string;
  20577. }
  20578. }
  20579. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20580. import { Scene } from "babylonjs/scene";
  20581. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20582. import { Plane } from "babylonjs/Maths/math.plane";
  20583. /**
  20584. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20585. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20586. * You can then easily use it as a reflectionTexture on a flat surface.
  20587. * In case the surface is not a plane, please consider relying on reflection probes.
  20588. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20589. */
  20590. export class MirrorTexture extends RenderTargetTexture {
  20591. private scene;
  20592. /**
  20593. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20594. * 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.
  20595. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20596. */
  20597. mirrorPlane: Plane;
  20598. /**
  20599. * Define the blur ratio used to blur the reflection if needed.
  20600. */
  20601. set blurRatio(value: number);
  20602. get blurRatio(): number;
  20603. /**
  20604. * Define the adaptive blur kernel used to blur the reflection if needed.
  20605. * This will autocompute the closest best match for the `blurKernel`
  20606. */
  20607. set adaptiveBlurKernel(value: number);
  20608. /**
  20609. * Define the blur kernel used to blur the reflection if needed.
  20610. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20611. */
  20612. set blurKernel(value: number);
  20613. /**
  20614. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20615. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20616. */
  20617. set blurKernelX(value: number);
  20618. get blurKernelX(): number;
  20619. /**
  20620. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20621. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20622. */
  20623. set blurKernelY(value: number);
  20624. get blurKernelY(): number;
  20625. private _autoComputeBlurKernel;
  20626. protected _onRatioRescale(): void;
  20627. private _updateGammaSpace;
  20628. private _imageProcessingConfigChangeObserver;
  20629. private _transformMatrix;
  20630. private _mirrorMatrix;
  20631. private _savedViewMatrix;
  20632. private _blurX;
  20633. private _blurY;
  20634. private _adaptiveBlurKernel;
  20635. private _blurKernelX;
  20636. private _blurKernelY;
  20637. private _blurRatio;
  20638. /**
  20639. * Instantiates a Mirror Texture.
  20640. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20641. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20642. * You can then easily use it as a reflectionTexture on a flat surface.
  20643. * In case the surface is not a plane, please consider relying on reflection probes.
  20644. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20645. * @param name
  20646. * @param size
  20647. * @param scene
  20648. * @param generateMipMaps
  20649. * @param type
  20650. * @param samplingMode
  20651. * @param generateDepthBuffer
  20652. */
  20653. constructor(name: string, size: number | {
  20654. width: number;
  20655. height: number;
  20656. } | {
  20657. ratio: number;
  20658. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20659. private _preparePostProcesses;
  20660. /**
  20661. * Clone the mirror texture.
  20662. * @returns the cloned texture
  20663. */
  20664. clone(): MirrorTexture;
  20665. /**
  20666. * Serialize the texture to a JSON representation you could use in Parse later on
  20667. * @returns the serialized JSON representation
  20668. */
  20669. serialize(): any;
  20670. /**
  20671. * Dispose the texture and release its associated resources.
  20672. */
  20673. dispose(): void;
  20674. }
  20675. }
  20676. declare module "babylonjs/Materials/Textures/texture" {
  20677. import { Observable } from "babylonjs/Misc/observable";
  20678. import { Nullable } from "babylonjs/types";
  20679. import { Matrix } from "babylonjs/Maths/math.vector";
  20680. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20681. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20682. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20683. import { Scene } from "babylonjs/scene";
  20684. /**
  20685. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20686. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20687. */
  20688. export class Texture extends BaseTexture {
  20689. /**
  20690. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20691. */
  20692. static SerializeBuffers: boolean;
  20693. /** @hidden */
  20694. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20695. /** @hidden */
  20696. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20697. /** @hidden */
  20698. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20699. /** nearest is mag = nearest and min = nearest and mip = linear */
  20700. static readonly NEAREST_SAMPLINGMODE: number;
  20701. /** nearest is mag = nearest and min = nearest and mip = linear */
  20702. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20703. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20704. static readonly BILINEAR_SAMPLINGMODE: number;
  20705. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20706. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20707. /** Trilinear is mag = linear and min = linear and mip = linear */
  20708. static readonly TRILINEAR_SAMPLINGMODE: number;
  20709. /** Trilinear is mag = linear and min = linear and mip = linear */
  20710. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20711. /** mag = nearest and min = nearest and mip = nearest */
  20712. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20713. /** mag = nearest and min = linear and mip = nearest */
  20714. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20715. /** mag = nearest and min = linear and mip = linear */
  20716. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20717. /** mag = nearest and min = linear and mip = none */
  20718. static readonly NEAREST_LINEAR: number;
  20719. /** mag = nearest and min = nearest and mip = none */
  20720. static readonly NEAREST_NEAREST: number;
  20721. /** mag = linear and min = nearest and mip = nearest */
  20722. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20723. /** mag = linear and min = nearest and mip = linear */
  20724. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20725. /** mag = linear and min = linear and mip = none */
  20726. static readonly LINEAR_LINEAR: number;
  20727. /** mag = linear and min = nearest and mip = none */
  20728. static readonly LINEAR_NEAREST: number;
  20729. /** Explicit coordinates mode */
  20730. static readonly EXPLICIT_MODE: number;
  20731. /** Spherical coordinates mode */
  20732. static readonly SPHERICAL_MODE: number;
  20733. /** Planar coordinates mode */
  20734. static readonly PLANAR_MODE: number;
  20735. /** Cubic coordinates mode */
  20736. static readonly CUBIC_MODE: number;
  20737. /** Projection coordinates mode */
  20738. static readonly PROJECTION_MODE: number;
  20739. /** Inverse Cubic coordinates mode */
  20740. static readonly SKYBOX_MODE: number;
  20741. /** Inverse Cubic coordinates mode */
  20742. static readonly INVCUBIC_MODE: number;
  20743. /** Equirectangular coordinates mode */
  20744. static readonly EQUIRECTANGULAR_MODE: number;
  20745. /** Equirectangular Fixed coordinates mode */
  20746. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20747. /** Equirectangular Fixed Mirrored coordinates mode */
  20748. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20749. /** Texture is not repeating outside of 0..1 UVs */
  20750. static readonly CLAMP_ADDRESSMODE: number;
  20751. /** Texture is repeating outside of 0..1 UVs */
  20752. static readonly WRAP_ADDRESSMODE: number;
  20753. /** Texture is repeating and mirrored */
  20754. static readonly MIRROR_ADDRESSMODE: number;
  20755. /**
  20756. * 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
  20757. */
  20758. static UseSerializedUrlIfAny: boolean;
  20759. /**
  20760. * Define the url of the texture.
  20761. */
  20762. url: Nullable<string>;
  20763. /**
  20764. * Define an offset on the texture to offset the u coordinates of the UVs
  20765. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20766. */
  20767. uOffset: number;
  20768. /**
  20769. * Define an offset on the texture to offset the v coordinates of the UVs
  20770. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20771. */
  20772. vOffset: number;
  20773. /**
  20774. * Define an offset on the texture to scale the u coordinates of the UVs
  20775. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20776. */
  20777. uScale: number;
  20778. /**
  20779. * Define an offset on the texture to scale the v coordinates of the UVs
  20780. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20781. */
  20782. vScale: number;
  20783. /**
  20784. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20785. * @see http://doc.babylonjs.com/how_to/more_materials
  20786. */
  20787. uAng: number;
  20788. /**
  20789. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20790. * @see http://doc.babylonjs.com/how_to/more_materials
  20791. */
  20792. vAng: number;
  20793. /**
  20794. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20795. * @see http://doc.babylonjs.com/how_to/more_materials
  20796. */
  20797. wAng: number;
  20798. /**
  20799. * Defines the center of rotation (U)
  20800. */
  20801. uRotationCenter: number;
  20802. /**
  20803. * Defines the center of rotation (V)
  20804. */
  20805. vRotationCenter: number;
  20806. /**
  20807. * Defines the center of rotation (W)
  20808. */
  20809. wRotationCenter: number;
  20810. /**
  20811. * Are mip maps generated for this texture or not.
  20812. */
  20813. get noMipmap(): boolean;
  20814. /**
  20815. * List of inspectable custom properties (used by the Inspector)
  20816. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20817. */
  20818. inspectableCustomProperties: Nullable<IInspectable[]>;
  20819. private _noMipmap;
  20820. /** @hidden */
  20821. _invertY: boolean;
  20822. private _rowGenerationMatrix;
  20823. private _cachedTextureMatrix;
  20824. private _projectionModeMatrix;
  20825. private _t0;
  20826. private _t1;
  20827. private _t2;
  20828. private _cachedUOffset;
  20829. private _cachedVOffset;
  20830. private _cachedUScale;
  20831. private _cachedVScale;
  20832. private _cachedUAng;
  20833. private _cachedVAng;
  20834. private _cachedWAng;
  20835. private _cachedProjectionMatrixId;
  20836. private _cachedCoordinatesMode;
  20837. /** @hidden */
  20838. protected _initialSamplingMode: number;
  20839. /** @hidden */
  20840. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20841. private _deleteBuffer;
  20842. protected _format: Nullable<number>;
  20843. private _delayedOnLoad;
  20844. private _delayedOnError;
  20845. private _mimeType?;
  20846. /**
  20847. * Observable triggered once the texture has been loaded.
  20848. */
  20849. onLoadObservable: Observable<Texture>;
  20850. protected _isBlocking: boolean;
  20851. /**
  20852. * Is the texture preventing material to render while loading.
  20853. * If false, a default texture will be used instead of the loading one during the preparation step.
  20854. */
  20855. set isBlocking(value: boolean);
  20856. get isBlocking(): boolean;
  20857. /**
  20858. * Get the current sampling mode associated with the texture.
  20859. */
  20860. get samplingMode(): number;
  20861. /**
  20862. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20863. */
  20864. get invertY(): boolean;
  20865. /**
  20866. * Instantiates a new texture.
  20867. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20868. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20869. * @param url defines the url of the picture to load as a texture
  20870. * @param scene defines the scene or engine the texture will belong to
  20871. * @param noMipmap defines if the texture will require mip maps or not
  20872. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20873. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20874. * @param onLoad defines a callback triggered when the texture has been loaded
  20875. * @param onError defines a callback triggered when an error occurred during the loading session
  20876. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20877. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20878. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20879. * @param mimeType defines an optional mime type information
  20880. */
  20881. 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);
  20882. /**
  20883. * Update the url (and optional buffer) of this texture if url was null during construction.
  20884. * @param url the url of the texture
  20885. * @param buffer the buffer of the texture (defaults to null)
  20886. * @param onLoad callback called when the texture is loaded (defaults to null)
  20887. */
  20888. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20889. /**
  20890. * Finish the loading sequence of a texture flagged as delayed load.
  20891. * @hidden
  20892. */
  20893. delayLoad(): void;
  20894. private _prepareRowForTextureGeneration;
  20895. /**
  20896. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20897. * @returns the transform matrix of the texture.
  20898. */
  20899. getTextureMatrix(uBase?: number): Matrix;
  20900. /**
  20901. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20902. * @returns The reflection texture transform
  20903. */
  20904. getReflectionTextureMatrix(): Matrix;
  20905. /**
  20906. * Clones the texture.
  20907. * @returns the cloned texture
  20908. */
  20909. clone(): Texture;
  20910. /**
  20911. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20912. * @returns The JSON representation of the texture
  20913. */
  20914. serialize(): any;
  20915. /**
  20916. * Get the current class name of the texture useful for serialization or dynamic coding.
  20917. * @returns "Texture"
  20918. */
  20919. getClassName(): string;
  20920. /**
  20921. * Dispose the texture and release its associated resources.
  20922. */
  20923. dispose(): void;
  20924. /**
  20925. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20926. * @param parsedTexture Define the JSON representation of the texture
  20927. * @param scene Define the scene the parsed texture should be instantiated in
  20928. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20929. * @returns The parsed texture if successful
  20930. */
  20931. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20932. /**
  20933. * Creates a texture from its base 64 representation.
  20934. * @param data Define the base64 payload without the data: prefix
  20935. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20936. * @param scene Define the scene the texture should belong to
  20937. * @param noMipmap Forces the texture to not create mip map information if true
  20938. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20939. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20940. * @param onLoad define a callback triggered when the texture has been loaded
  20941. * @param onError define a callback triggered when an error occurred during the loading session
  20942. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20943. * @returns the created texture
  20944. */
  20945. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20946. /**
  20947. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20948. * @param data Define the base64 payload without the data: prefix
  20949. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20950. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20951. * @param scene Define the scene the texture should belong to
  20952. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20953. * @param noMipmap Forces the texture to not create mip map information if true
  20954. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20955. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20956. * @param onLoad define a callback triggered when the texture has been loaded
  20957. * @param onError define a callback triggered when an error occurred during the loading session
  20958. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20959. * @returns the created texture
  20960. */
  20961. 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;
  20962. }
  20963. }
  20964. declare module "babylonjs/PostProcesses/postProcessManager" {
  20965. import { Nullable } from "babylonjs/types";
  20966. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20967. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20968. import { Scene } from "babylonjs/scene";
  20969. /**
  20970. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20971. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20972. */
  20973. export class PostProcessManager {
  20974. private _scene;
  20975. private _indexBuffer;
  20976. private _vertexBuffers;
  20977. /**
  20978. * Creates a new instance PostProcess
  20979. * @param scene The scene that the post process is associated with.
  20980. */
  20981. constructor(scene: Scene);
  20982. private _prepareBuffers;
  20983. private _buildIndexBuffer;
  20984. /**
  20985. * Rebuilds the vertex buffers of the manager.
  20986. * @hidden
  20987. */
  20988. _rebuild(): void;
  20989. /**
  20990. * Prepares a frame to be run through a post process.
  20991. * @param sourceTexture The input texture to the post procesess. (default: null)
  20992. * @param postProcesses An array of post processes to be run. (default: null)
  20993. * @returns True if the post processes were able to be run.
  20994. * @hidden
  20995. */
  20996. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20997. /**
  20998. * Manually render a set of post processes to a texture.
  20999. * @param postProcesses An array of post processes to be run.
  21000. * @param targetTexture The target texture to render to.
  21001. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21002. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  21003. * @param lodLevel defines which lod of the texture to render to
  21004. */
  21005. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  21006. /**
  21007. * Finalize the result of the output of the postprocesses.
  21008. * @param doNotPresent If true the result will not be displayed to the screen.
  21009. * @param targetTexture The target texture to render to.
  21010. * @param faceIndex The index of the face to bind the target texture to.
  21011. * @param postProcesses The array of post processes to render.
  21012. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21013. * @hidden
  21014. */
  21015. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21016. /**
  21017. * Disposes of the post process manager.
  21018. */
  21019. dispose(): void;
  21020. }
  21021. }
  21022. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21023. import { Observable } from "babylonjs/Misc/observable";
  21024. import { SmartArray } from "babylonjs/Misc/smartArray";
  21025. import { Nullable, Immutable } from "babylonjs/types";
  21026. import { Camera } from "babylonjs/Cameras/camera";
  21027. import { Scene } from "babylonjs/scene";
  21028. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21029. import { Color4 } from "babylonjs/Maths/math.color";
  21030. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21032. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21033. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21034. import { Texture } from "babylonjs/Materials/Textures/texture";
  21035. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21036. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21037. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21038. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21039. import { Engine } from "babylonjs/Engines/engine";
  21040. /**
  21041. * This Helps creating a texture that will be created from a camera in your scene.
  21042. * It is basically a dynamic texture that could be used to create special effects for instance.
  21043. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21044. */
  21045. export class RenderTargetTexture extends Texture {
  21046. isCube: boolean;
  21047. /**
  21048. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21049. */
  21050. static readonly REFRESHRATE_RENDER_ONCE: number;
  21051. /**
  21052. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21053. */
  21054. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21055. /**
  21056. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21057. * the central point of your effect and can save a lot of performances.
  21058. */
  21059. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21060. /**
  21061. * Use this predicate to dynamically define the list of mesh you want to render.
  21062. * If set, the renderList property will be overwritten.
  21063. */
  21064. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21065. private _renderList;
  21066. /**
  21067. * Use this list to define the list of mesh you want to render.
  21068. */
  21069. get renderList(): Nullable<Array<AbstractMesh>>;
  21070. set renderList(value: Nullable<Array<AbstractMesh>>);
  21071. /**
  21072. * Use this function to overload the renderList array at rendering time.
  21073. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21074. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21075. * the cube (if the RTT is a cube, else layerOrFace=0).
  21076. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21077. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21078. * hold dummy elements!
  21079. */
  21080. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21081. private _hookArray;
  21082. /**
  21083. * Define if particles should be rendered in your texture.
  21084. */
  21085. renderParticles: boolean;
  21086. /**
  21087. * Define if sprites should be rendered in your texture.
  21088. */
  21089. renderSprites: boolean;
  21090. /**
  21091. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21092. */
  21093. coordinatesMode: number;
  21094. /**
  21095. * Define the camera used to render the texture.
  21096. */
  21097. activeCamera: Nullable<Camera>;
  21098. /**
  21099. * Override the render function of the texture with your own one.
  21100. */
  21101. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21102. /**
  21103. * Define if camera post processes should be use while rendering the texture.
  21104. */
  21105. useCameraPostProcesses: boolean;
  21106. /**
  21107. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21108. */
  21109. ignoreCameraViewport: boolean;
  21110. private _postProcessManager;
  21111. private _postProcesses;
  21112. private _resizeObserver;
  21113. /**
  21114. * An event triggered when the texture is unbind.
  21115. */
  21116. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21117. /**
  21118. * An event triggered when the texture is unbind.
  21119. */
  21120. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21121. private _onAfterUnbindObserver;
  21122. /**
  21123. * Set a after unbind callback in the texture.
  21124. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21125. */
  21126. set onAfterUnbind(callback: () => void);
  21127. /**
  21128. * An event triggered before rendering the texture
  21129. */
  21130. onBeforeRenderObservable: Observable<number>;
  21131. private _onBeforeRenderObserver;
  21132. /**
  21133. * Set a before render callback in the texture.
  21134. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21135. */
  21136. set onBeforeRender(callback: (faceIndex: number) => void);
  21137. /**
  21138. * An event triggered after rendering the texture
  21139. */
  21140. onAfterRenderObservable: Observable<number>;
  21141. private _onAfterRenderObserver;
  21142. /**
  21143. * Set a after render callback in the texture.
  21144. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21145. */
  21146. set onAfterRender(callback: (faceIndex: number) => void);
  21147. /**
  21148. * An event triggered after the texture clear
  21149. */
  21150. onClearObservable: Observable<Engine>;
  21151. private _onClearObserver;
  21152. /**
  21153. * Set a clear callback in the texture.
  21154. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21155. */
  21156. set onClear(callback: (Engine: Engine) => void);
  21157. /**
  21158. * An event triggered when the texture is resized.
  21159. */
  21160. onResizeObservable: Observable<RenderTargetTexture>;
  21161. /**
  21162. * Define the clear color of the Render Target if it should be different from the scene.
  21163. */
  21164. clearColor: Color4;
  21165. protected _size: number | {
  21166. width: number;
  21167. height: number;
  21168. layers?: number;
  21169. };
  21170. protected _initialSizeParameter: number | {
  21171. width: number;
  21172. height: number;
  21173. } | {
  21174. ratio: number;
  21175. };
  21176. protected _sizeRatio: Nullable<number>;
  21177. /** @hidden */
  21178. _generateMipMaps: boolean;
  21179. protected _renderingManager: RenderingManager;
  21180. /** @hidden */
  21181. _waitingRenderList: string[];
  21182. protected _doNotChangeAspectRatio: boolean;
  21183. protected _currentRefreshId: number;
  21184. protected _refreshRate: number;
  21185. protected _textureMatrix: Matrix;
  21186. protected _samples: number;
  21187. protected _renderTargetOptions: RenderTargetCreationOptions;
  21188. /**
  21189. * Gets render target creation options that were used.
  21190. */
  21191. get renderTargetOptions(): RenderTargetCreationOptions;
  21192. protected _engine: Engine;
  21193. protected _onRatioRescale(): void;
  21194. /**
  21195. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21196. * It must define where the camera used to render the texture is set
  21197. */
  21198. boundingBoxPosition: Vector3;
  21199. private _boundingBoxSize;
  21200. /**
  21201. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21202. * When defined, the cubemap will switch to local mode
  21203. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21204. * @example https://www.babylonjs-playground.com/#RNASML
  21205. */
  21206. set boundingBoxSize(value: Vector3);
  21207. get boundingBoxSize(): Vector3;
  21208. /**
  21209. * In case the RTT has been created with a depth texture, get the associated
  21210. * depth texture.
  21211. * Otherwise, return null.
  21212. */
  21213. get depthStencilTexture(): Nullable<InternalTexture>;
  21214. /**
  21215. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21216. * or used a shadow, depth texture...
  21217. * @param name The friendly name of the texture
  21218. * @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)
  21219. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21220. * @param generateMipMaps True if mip maps need to be generated after render.
  21221. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21222. * @param type The type of the buffer in the RTT (int, half float, float...)
  21223. * @param isCube True if a cube texture needs to be created
  21224. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21225. * @param generateDepthBuffer True to generate a depth buffer
  21226. * @param generateStencilBuffer True to generate a stencil buffer
  21227. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21228. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21229. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21230. */
  21231. constructor(name: string, size: number | {
  21232. width: number;
  21233. height: number;
  21234. layers?: number;
  21235. } | {
  21236. ratio: number;
  21237. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21238. /**
  21239. * Creates a depth stencil texture.
  21240. * This is only available in WebGL 2 or with the depth texture extension available.
  21241. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21242. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21243. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21244. */
  21245. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21246. private _processSizeParameter;
  21247. /**
  21248. * Define the number of samples to use in case of MSAA.
  21249. * It defaults to one meaning no MSAA has been enabled.
  21250. */
  21251. get samples(): number;
  21252. set samples(value: number);
  21253. /**
  21254. * Resets the refresh counter of the texture and start bak from scratch.
  21255. * Could be useful to regenerate the texture if it is setup to render only once.
  21256. */
  21257. resetRefreshCounter(): void;
  21258. /**
  21259. * Define the refresh rate of the texture or the rendering frequency.
  21260. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21261. */
  21262. get refreshRate(): number;
  21263. set refreshRate(value: number);
  21264. /**
  21265. * Adds a post process to the render target rendering passes.
  21266. * @param postProcess define the post process to add
  21267. */
  21268. addPostProcess(postProcess: PostProcess): void;
  21269. /**
  21270. * Clear all the post processes attached to the render target
  21271. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21272. */
  21273. clearPostProcesses(dispose?: boolean): void;
  21274. /**
  21275. * Remove one of the post process from the list of attached post processes to the texture
  21276. * @param postProcess define the post process to remove from the list
  21277. */
  21278. removePostProcess(postProcess: PostProcess): void;
  21279. /** @hidden */
  21280. _shouldRender(): boolean;
  21281. /**
  21282. * Gets the actual render size of the texture.
  21283. * @returns the width of the render size
  21284. */
  21285. getRenderSize(): number;
  21286. /**
  21287. * Gets the actual render width of the texture.
  21288. * @returns the width of the render size
  21289. */
  21290. getRenderWidth(): number;
  21291. /**
  21292. * Gets the actual render height of the texture.
  21293. * @returns the height of the render size
  21294. */
  21295. getRenderHeight(): number;
  21296. /**
  21297. * Gets the actual number of layers of the texture.
  21298. * @returns the number of layers
  21299. */
  21300. getRenderLayers(): number;
  21301. /**
  21302. * Get if the texture can be rescaled or not.
  21303. */
  21304. get canRescale(): boolean;
  21305. /**
  21306. * Resize the texture using a ratio.
  21307. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21308. */
  21309. scale(ratio: number): void;
  21310. /**
  21311. * Get the texture reflection matrix used to rotate/transform the reflection.
  21312. * @returns the reflection matrix
  21313. */
  21314. getReflectionTextureMatrix(): Matrix;
  21315. /**
  21316. * Resize the texture to a new desired size.
  21317. * Be carrefull as it will recreate all the data in the new texture.
  21318. * @param size Define the new size. It can be:
  21319. * - a number for squared texture,
  21320. * - an object containing { width: number, height: number }
  21321. * - or an object containing a ratio { ratio: number }
  21322. */
  21323. resize(size: number | {
  21324. width: number;
  21325. height: number;
  21326. } | {
  21327. ratio: number;
  21328. }): void;
  21329. private _defaultRenderListPrepared;
  21330. /**
  21331. * Renders all the objects from the render list into the texture.
  21332. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21333. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21334. */
  21335. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21336. private _bestReflectionRenderTargetDimension;
  21337. private _prepareRenderingManager;
  21338. /**
  21339. * @hidden
  21340. * @param faceIndex face index to bind to if this is a cubetexture
  21341. * @param layer defines the index of the texture to bind in the array
  21342. */
  21343. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21344. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21345. private renderToTarget;
  21346. /**
  21347. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21348. * This allowed control for front to back rendering or reversly depending of the special needs.
  21349. *
  21350. * @param renderingGroupId The rendering group id corresponding to its index
  21351. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21352. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21353. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21354. */
  21355. 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;
  21356. /**
  21357. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21358. *
  21359. * @param renderingGroupId The rendering group id corresponding to its index
  21360. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21361. */
  21362. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21363. /**
  21364. * Clones the texture.
  21365. * @returns the cloned texture
  21366. */
  21367. clone(): RenderTargetTexture;
  21368. /**
  21369. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21370. * @returns The JSON representation of the texture
  21371. */
  21372. serialize(): any;
  21373. /**
  21374. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21375. */
  21376. disposeFramebufferObjects(): void;
  21377. /**
  21378. * Dispose the texture and release its associated resources.
  21379. */
  21380. dispose(): void;
  21381. /** @hidden */
  21382. _rebuild(): void;
  21383. /**
  21384. * Clear the info related to rendering groups preventing retention point in material dispose.
  21385. */
  21386. freeRenderingGroups(): void;
  21387. /**
  21388. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21389. * @returns the view count
  21390. */
  21391. getViewCount(): number;
  21392. }
  21393. }
  21394. declare module "babylonjs/Materials/material" {
  21395. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21396. import { SmartArray } from "babylonjs/Misc/smartArray";
  21397. import { Observable } from "babylonjs/Misc/observable";
  21398. import { Nullable } from "babylonjs/types";
  21399. import { Scene } from "babylonjs/scene";
  21400. import { Matrix } from "babylonjs/Maths/math.vector";
  21401. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21403. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21404. import { Effect } from "babylonjs/Materials/effect";
  21405. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21406. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21407. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21408. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21409. import { Mesh } from "babylonjs/Meshes/mesh";
  21410. import { Animation } from "babylonjs/Animations/animation";
  21411. /**
  21412. * Options for compiling materials.
  21413. */
  21414. export interface IMaterialCompilationOptions {
  21415. /**
  21416. * Defines whether clip planes are enabled.
  21417. */
  21418. clipPlane: boolean;
  21419. /**
  21420. * Defines whether instances are enabled.
  21421. */
  21422. useInstances: boolean;
  21423. }
  21424. /**
  21425. * Base class for the main features of a material in Babylon.js
  21426. */
  21427. export class Material implements IAnimatable {
  21428. /**
  21429. * Returns the triangle fill mode
  21430. */
  21431. static readonly TriangleFillMode: number;
  21432. /**
  21433. * Returns the wireframe mode
  21434. */
  21435. static readonly WireFrameFillMode: number;
  21436. /**
  21437. * Returns the point fill mode
  21438. */
  21439. static readonly PointFillMode: number;
  21440. /**
  21441. * Returns the point list draw mode
  21442. */
  21443. static readonly PointListDrawMode: number;
  21444. /**
  21445. * Returns the line list draw mode
  21446. */
  21447. static readonly LineListDrawMode: number;
  21448. /**
  21449. * Returns the line loop draw mode
  21450. */
  21451. static readonly LineLoopDrawMode: number;
  21452. /**
  21453. * Returns the line strip draw mode
  21454. */
  21455. static readonly LineStripDrawMode: number;
  21456. /**
  21457. * Returns the triangle strip draw mode
  21458. */
  21459. static readonly TriangleStripDrawMode: number;
  21460. /**
  21461. * Returns the triangle fan draw mode
  21462. */
  21463. static readonly TriangleFanDrawMode: number;
  21464. /**
  21465. * Stores the clock-wise side orientation
  21466. */
  21467. static readonly ClockWiseSideOrientation: number;
  21468. /**
  21469. * Stores the counter clock-wise side orientation
  21470. */
  21471. static readonly CounterClockWiseSideOrientation: number;
  21472. /**
  21473. * The dirty texture flag value
  21474. */
  21475. static readonly TextureDirtyFlag: number;
  21476. /**
  21477. * The dirty light flag value
  21478. */
  21479. static readonly LightDirtyFlag: number;
  21480. /**
  21481. * The dirty fresnel flag value
  21482. */
  21483. static readonly FresnelDirtyFlag: number;
  21484. /**
  21485. * The dirty attribute flag value
  21486. */
  21487. static readonly AttributesDirtyFlag: number;
  21488. /**
  21489. * The dirty misc flag value
  21490. */
  21491. static readonly MiscDirtyFlag: number;
  21492. /**
  21493. * The all dirty flag value
  21494. */
  21495. static readonly AllDirtyFlag: number;
  21496. /**
  21497. * The ID of the material
  21498. */
  21499. id: string;
  21500. /**
  21501. * Gets or sets the unique id of the material
  21502. */
  21503. uniqueId: number;
  21504. /**
  21505. * The name of the material
  21506. */
  21507. name: string;
  21508. /**
  21509. * Gets or sets user defined metadata
  21510. */
  21511. metadata: any;
  21512. /**
  21513. * For internal use only. Please do not use.
  21514. */
  21515. reservedDataStore: any;
  21516. /**
  21517. * Specifies if the ready state should be checked on each call
  21518. */
  21519. checkReadyOnEveryCall: boolean;
  21520. /**
  21521. * Specifies if the ready state should be checked once
  21522. */
  21523. checkReadyOnlyOnce: boolean;
  21524. /**
  21525. * The state of the material
  21526. */
  21527. state: string;
  21528. /**
  21529. * The alpha value of the material
  21530. */
  21531. protected _alpha: number;
  21532. /**
  21533. * List of inspectable custom properties (used by the Inspector)
  21534. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21535. */
  21536. inspectableCustomProperties: IInspectable[];
  21537. /**
  21538. * Sets the alpha value of the material
  21539. */
  21540. set alpha(value: number);
  21541. /**
  21542. * Gets the alpha value of the material
  21543. */
  21544. get alpha(): number;
  21545. /**
  21546. * Specifies if back face culling is enabled
  21547. */
  21548. protected _backFaceCulling: boolean;
  21549. /**
  21550. * Sets the back-face culling state
  21551. */
  21552. set backFaceCulling(value: boolean);
  21553. /**
  21554. * Gets the back-face culling state
  21555. */
  21556. get backFaceCulling(): boolean;
  21557. /**
  21558. * Stores the value for side orientation
  21559. */
  21560. sideOrientation: number;
  21561. /**
  21562. * Callback triggered when the material is compiled
  21563. */
  21564. onCompiled: Nullable<(effect: Effect) => void>;
  21565. /**
  21566. * Callback triggered when an error occurs
  21567. */
  21568. onError: Nullable<(effect: Effect, errors: string) => void>;
  21569. /**
  21570. * Callback triggered to get the render target textures
  21571. */
  21572. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21573. /**
  21574. * Gets a boolean indicating that current material needs to register RTT
  21575. */
  21576. get hasRenderTargetTextures(): boolean;
  21577. /**
  21578. * Specifies if the material should be serialized
  21579. */
  21580. doNotSerialize: boolean;
  21581. /**
  21582. * @hidden
  21583. */
  21584. _storeEffectOnSubMeshes: boolean;
  21585. /**
  21586. * Stores the animations for the material
  21587. */
  21588. animations: Nullable<Array<Animation>>;
  21589. /**
  21590. * An event triggered when the material is disposed
  21591. */
  21592. onDisposeObservable: Observable<Material>;
  21593. /**
  21594. * An observer which watches for dispose events
  21595. */
  21596. private _onDisposeObserver;
  21597. private _onUnBindObservable;
  21598. /**
  21599. * Called during a dispose event
  21600. */
  21601. set onDispose(callback: () => void);
  21602. private _onBindObservable;
  21603. /**
  21604. * An event triggered when the material is bound
  21605. */
  21606. get onBindObservable(): Observable<AbstractMesh>;
  21607. /**
  21608. * An observer which watches for bind events
  21609. */
  21610. private _onBindObserver;
  21611. /**
  21612. * Called during a bind event
  21613. */
  21614. set onBind(callback: (Mesh: AbstractMesh) => void);
  21615. /**
  21616. * An event triggered when the material is unbound
  21617. */
  21618. get onUnBindObservable(): Observable<Material>;
  21619. /**
  21620. * Stores the value of the alpha mode
  21621. */
  21622. private _alphaMode;
  21623. /**
  21624. * Sets the value of the alpha mode.
  21625. *
  21626. * | Value | Type | Description |
  21627. * | --- | --- | --- |
  21628. * | 0 | ALPHA_DISABLE | |
  21629. * | 1 | ALPHA_ADD | |
  21630. * | 2 | ALPHA_COMBINE | |
  21631. * | 3 | ALPHA_SUBTRACT | |
  21632. * | 4 | ALPHA_MULTIPLY | |
  21633. * | 5 | ALPHA_MAXIMIZED | |
  21634. * | 6 | ALPHA_ONEONE | |
  21635. * | 7 | ALPHA_PREMULTIPLIED | |
  21636. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21637. * | 9 | ALPHA_INTERPOLATE | |
  21638. * | 10 | ALPHA_SCREENMODE | |
  21639. *
  21640. */
  21641. set alphaMode(value: number);
  21642. /**
  21643. * Gets the value of the alpha mode
  21644. */
  21645. get alphaMode(): number;
  21646. /**
  21647. * Stores the state of the need depth pre-pass value
  21648. */
  21649. private _needDepthPrePass;
  21650. /**
  21651. * Sets the need depth pre-pass value
  21652. */
  21653. set needDepthPrePass(value: boolean);
  21654. /**
  21655. * Gets the depth pre-pass value
  21656. */
  21657. get needDepthPrePass(): boolean;
  21658. /**
  21659. * Specifies if depth writing should be disabled
  21660. */
  21661. disableDepthWrite: boolean;
  21662. /**
  21663. * Specifies if depth writing should be forced
  21664. */
  21665. forceDepthWrite: boolean;
  21666. /**
  21667. * Specifies the depth function that should be used. 0 means the default engine function
  21668. */
  21669. depthFunction: number;
  21670. /**
  21671. * Specifies if there should be a separate pass for culling
  21672. */
  21673. separateCullingPass: boolean;
  21674. /**
  21675. * Stores the state specifing if fog should be enabled
  21676. */
  21677. private _fogEnabled;
  21678. /**
  21679. * Sets the state for enabling fog
  21680. */
  21681. set fogEnabled(value: boolean);
  21682. /**
  21683. * Gets the value of the fog enabled state
  21684. */
  21685. get fogEnabled(): boolean;
  21686. /**
  21687. * Stores the size of points
  21688. */
  21689. pointSize: number;
  21690. /**
  21691. * Stores the z offset value
  21692. */
  21693. zOffset: number;
  21694. /**
  21695. * Gets a value specifying if wireframe mode is enabled
  21696. */
  21697. get wireframe(): boolean;
  21698. /**
  21699. * Sets the state of wireframe mode
  21700. */
  21701. set wireframe(value: boolean);
  21702. /**
  21703. * Gets the value specifying if point clouds are enabled
  21704. */
  21705. get pointsCloud(): boolean;
  21706. /**
  21707. * Sets the state of point cloud mode
  21708. */
  21709. set pointsCloud(value: boolean);
  21710. /**
  21711. * Gets the material fill mode
  21712. */
  21713. get fillMode(): number;
  21714. /**
  21715. * Sets the material fill mode
  21716. */
  21717. set fillMode(value: number);
  21718. /**
  21719. * @hidden
  21720. * Stores the effects for the material
  21721. */
  21722. _effect: Nullable<Effect>;
  21723. /**
  21724. * Specifies if uniform buffers should be used
  21725. */
  21726. private _useUBO;
  21727. /**
  21728. * Stores a reference to the scene
  21729. */
  21730. private _scene;
  21731. /**
  21732. * Stores the fill mode state
  21733. */
  21734. private _fillMode;
  21735. /**
  21736. * Specifies if the depth write state should be cached
  21737. */
  21738. private _cachedDepthWriteState;
  21739. /**
  21740. * Specifies if the depth function state should be cached
  21741. */
  21742. private _cachedDepthFunctionState;
  21743. /**
  21744. * Stores the uniform buffer
  21745. */
  21746. protected _uniformBuffer: UniformBuffer;
  21747. /** @hidden */
  21748. _indexInSceneMaterialArray: number;
  21749. /** @hidden */
  21750. meshMap: Nullable<{
  21751. [id: string]: AbstractMesh | undefined;
  21752. }>;
  21753. /**
  21754. * Creates a material instance
  21755. * @param name defines the name of the material
  21756. * @param scene defines the scene to reference
  21757. * @param doNotAdd specifies if the material should be added to the scene
  21758. */
  21759. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21760. /**
  21761. * Returns a string representation of the current material
  21762. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21763. * @returns a string with material information
  21764. */
  21765. toString(fullDetails?: boolean): string;
  21766. /**
  21767. * Gets the class name of the material
  21768. * @returns a string with the class name of the material
  21769. */
  21770. getClassName(): string;
  21771. /**
  21772. * Specifies if updates for the material been locked
  21773. */
  21774. get isFrozen(): boolean;
  21775. /**
  21776. * Locks updates for the material
  21777. */
  21778. freeze(): void;
  21779. /**
  21780. * Unlocks updates for the material
  21781. */
  21782. unfreeze(): void;
  21783. /**
  21784. * Specifies if the material is ready to be used
  21785. * @param mesh defines the mesh to check
  21786. * @param useInstances specifies if instances should be used
  21787. * @returns a boolean indicating if the material is ready to be used
  21788. */
  21789. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21790. /**
  21791. * Specifies that the submesh is ready to be used
  21792. * @param mesh defines the mesh to check
  21793. * @param subMesh defines which submesh to check
  21794. * @param useInstances specifies that instances should be used
  21795. * @returns a boolean indicating that the submesh is ready or not
  21796. */
  21797. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21798. /**
  21799. * Returns the material effect
  21800. * @returns the effect associated with the material
  21801. */
  21802. getEffect(): Nullable<Effect>;
  21803. /**
  21804. * Returns the current scene
  21805. * @returns a Scene
  21806. */
  21807. getScene(): Scene;
  21808. /**
  21809. * Specifies if the material will require alpha blending
  21810. * @returns a boolean specifying if alpha blending is needed
  21811. */
  21812. needAlphaBlending(): boolean;
  21813. /**
  21814. * Specifies if the mesh will require alpha blending
  21815. * @param mesh defines the mesh to check
  21816. * @returns a boolean specifying if alpha blending is needed for the mesh
  21817. */
  21818. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21819. /**
  21820. * Specifies if this material should be rendered in alpha test mode
  21821. * @returns a boolean specifying if an alpha test is needed.
  21822. */
  21823. needAlphaTesting(): boolean;
  21824. /**
  21825. * Gets the texture used for the alpha test
  21826. * @returns the texture to use for alpha testing
  21827. */
  21828. getAlphaTestTexture(): Nullable<BaseTexture>;
  21829. /**
  21830. * Marks the material to indicate that it needs to be re-calculated
  21831. */
  21832. markDirty(): void;
  21833. /** @hidden */
  21834. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21835. /**
  21836. * Binds the material to the mesh
  21837. * @param world defines the world transformation matrix
  21838. * @param mesh defines the mesh to bind the material to
  21839. */
  21840. bind(world: Matrix, mesh?: Mesh): void;
  21841. /**
  21842. * Binds the submesh to the material
  21843. * @param world defines the world transformation matrix
  21844. * @param mesh defines the mesh containing the submesh
  21845. * @param subMesh defines the submesh to bind the material to
  21846. */
  21847. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21848. /**
  21849. * Binds the world matrix to the material
  21850. * @param world defines the world transformation matrix
  21851. */
  21852. bindOnlyWorldMatrix(world: Matrix): void;
  21853. /**
  21854. * Binds the scene's uniform buffer to the effect.
  21855. * @param effect defines the effect to bind to the scene uniform buffer
  21856. * @param sceneUbo defines the uniform buffer storing scene data
  21857. */
  21858. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21859. /**
  21860. * Binds the view matrix to the effect
  21861. * @param effect defines the effect to bind the view matrix to
  21862. */
  21863. bindView(effect: Effect): void;
  21864. /**
  21865. * Binds the view projection matrix to the effect
  21866. * @param effect defines the effect to bind the view projection matrix to
  21867. */
  21868. bindViewProjection(effect: Effect): void;
  21869. /**
  21870. * Specifies if material alpha testing should be turned on for the mesh
  21871. * @param mesh defines the mesh to check
  21872. */
  21873. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21874. /**
  21875. * Processes to execute after binding the material to a mesh
  21876. * @param mesh defines the rendered mesh
  21877. */
  21878. protected _afterBind(mesh?: Mesh): void;
  21879. /**
  21880. * Unbinds the material from the mesh
  21881. */
  21882. unbind(): void;
  21883. /**
  21884. * Gets the active textures from the material
  21885. * @returns an array of textures
  21886. */
  21887. getActiveTextures(): BaseTexture[];
  21888. /**
  21889. * Specifies if the material uses a texture
  21890. * @param texture defines the texture to check against the material
  21891. * @returns a boolean specifying if the material uses the texture
  21892. */
  21893. hasTexture(texture: BaseTexture): boolean;
  21894. /**
  21895. * Makes a duplicate of the material, and gives it a new name
  21896. * @param name defines the new name for the duplicated material
  21897. * @returns the cloned material
  21898. */
  21899. clone(name: string): Nullable<Material>;
  21900. /**
  21901. * Gets the meshes bound to the material
  21902. * @returns an array of meshes bound to the material
  21903. */
  21904. getBindedMeshes(): AbstractMesh[];
  21905. /**
  21906. * Force shader compilation
  21907. * @param mesh defines the mesh associated with this material
  21908. * @param onCompiled defines a function to execute once the material is compiled
  21909. * @param options defines the options to configure the compilation
  21910. * @param onError defines a function to execute if the material fails compiling
  21911. */
  21912. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21913. /**
  21914. * Force shader compilation
  21915. * @param mesh defines the mesh that will use this material
  21916. * @param options defines additional options for compiling the shaders
  21917. * @returns a promise that resolves when the compilation completes
  21918. */
  21919. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21920. private static readonly _AllDirtyCallBack;
  21921. private static readonly _ImageProcessingDirtyCallBack;
  21922. private static readonly _TextureDirtyCallBack;
  21923. private static readonly _FresnelDirtyCallBack;
  21924. private static readonly _MiscDirtyCallBack;
  21925. private static readonly _LightsDirtyCallBack;
  21926. private static readonly _AttributeDirtyCallBack;
  21927. private static _FresnelAndMiscDirtyCallBack;
  21928. private static _TextureAndMiscDirtyCallBack;
  21929. private static readonly _DirtyCallbackArray;
  21930. private static readonly _RunDirtyCallBacks;
  21931. /**
  21932. * Marks a define in the material to indicate that it needs to be re-computed
  21933. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21934. */
  21935. markAsDirty(flag: number): void;
  21936. /**
  21937. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21938. * @param func defines a function which checks material defines against the submeshes
  21939. */
  21940. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21941. /**
  21942. * Indicates that we need to re-calculated for all submeshes
  21943. */
  21944. protected _markAllSubMeshesAsAllDirty(): void;
  21945. /**
  21946. * Indicates that image processing needs to be re-calculated for all submeshes
  21947. */
  21948. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21949. /**
  21950. * Indicates that textures need to be re-calculated for all submeshes
  21951. */
  21952. protected _markAllSubMeshesAsTexturesDirty(): void;
  21953. /**
  21954. * Indicates that fresnel needs to be re-calculated for all submeshes
  21955. */
  21956. protected _markAllSubMeshesAsFresnelDirty(): void;
  21957. /**
  21958. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21959. */
  21960. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21961. /**
  21962. * Indicates that lights need to be re-calculated for all submeshes
  21963. */
  21964. protected _markAllSubMeshesAsLightsDirty(): void;
  21965. /**
  21966. * Indicates that attributes need to be re-calculated for all submeshes
  21967. */
  21968. protected _markAllSubMeshesAsAttributesDirty(): void;
  21969. /**
  21970. * Indicates that misc needs to be re-calculated for all submeshes
  21971. */
  21972. protected _markAllSubMeshesAsMiscDirty(): void;
  21973. /**
  21974. * Indicates that textures and misc need to be re-calculated for all submeshes
  21975. */
  21976. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21977. /**
  21978. * Disposes the material
  21979. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21980. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21981. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21982. */
  21983. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21984. /** @hidden */
  21985. private releaseVertexArrayObject;
  21986. /**
  21987. * Serializes this material
  21988. * @returns the serialized material object
  21989. */
  21990. serialize(): any;
  21991. /**
  21992. * Creates a material from parsed material data
  21993. * @param parsedMaterial defines parsed material data
  21994. * @param scene defines the hosting scene
  21995. * @param rootUrl defines the root URL to use to load textures
  21996. * @returns a new material
  21997. */
  21998. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21999. }
  22000. }
  22001. declare module "babylonjs/Materials/multiMaterial" {
  22002. import { Nullable } from "babylonjs/types";
  22003. import { Scene } from "babylonjs/scene";
  22004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22005. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22006. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22007. import { Material } from "babylonjs/Materials/material";
  22008. /**
  22009. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22010. * separate meshes. This can be use to improve performances.
  22011. * @see http://doc.babylonjs.com/how_to/multi_materials
  22012. */
  22013. export class MultiMaterial extends Material {
  22014. private _subMaterials;
  22015. /**
  22016. * Gets or Sets the list of Materials used within the multi material.
  22017. * They need to be ordered according to the submeshes order in the associated mesh
  22018. */
  22019. get subMaterials(): Nullable<Material>[];
  22020. set subMaterials(value: Nullable<Material>[]);
  22021. /**
  22022. * Function used to align with Node.getChildren()
  22023. * @returns the list of Materials used within the multi material
  22024. */
  22025. getChildren(): Nullable<Material>[];
  22026. /**
  22027. * Instantiates a new Multi Material
  22028. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22029. * separate meshes. This can be use to improve performances.
  22030. * @see http://doc.babylonjs.com/how_to/multi_materials
  22031. * @param name Define the name in the scene
  22032. * @param scene Define the scene the material belongs to
  22033. */
  22034. constructor(name: string, scene: Scene);
  22035. private _hookArray;
  22036. /**
  22037. * Get one of the submaterial by its index in the submaterials array
  22038. * @param index The index to look the sub material at
  22039. * @returns The Material if the index has been defined
  22040. */
  22041. getSubMaterial(index: number): Nullable<Material>;
  22042. /**
  22043. * Get the list of active textures for the whole sub materials list.
  22044. * @returns All the textures that will be used during the rendering
  22045. */
  22046. getActiveTextures(): BaseTexture[];
  22047. /**
  22048. * Gets the current class name of the material e.g. "MultiMaterial"
  22049. * Mainly use in serialization.
  22050. * @returns the class name
  22051. */
  22052. getClassName(): string;
  22053. /**
  22054. * Checks if the material is ready to render the requested sub mesh
  22055. * @param mesh Define the mesh the submesh belongs to
  22056. * @param subMesh Define the sub mesh to look readyness for
  22057. * @param useInstances Define whether or not the material is used with instances
  22058. * @returns true if ready, otherwise false
  22059. */
  22060. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22061. /**
  22062. * Clones the current material and its related sub materials
  22063. * @param name Define the name of the newly cloned material
  22064. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22065. * @returns the cloned material
  22066. */
  22067. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22068. /**
  22069. * Serializes the materials into a JSON representation.
  22070. * @returns the JSON representation
  22071. */
  22072. serialize(): any;
  22073. /**
  22074. * Dispose the material and release its associated resources
  22075. * @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)
  22076. * @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)
  22077. * @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)
  22078. */
  22079. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22080. /**
  22081. * Creates a MultiMaterial from parsed MultiMaterial data.
  22082. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22083. * @param scene defines the hosting scene
  22084. * @returns a new MultiMaterial
  22085. */
  22086. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22087. }
  22088. }
  22089. declare module "babylonjs/Meshes/subMesh" {
  22090. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22091. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22092. import { Engine } from "babylonjs/Engines/engine";
  22093. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22094. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22095. import { Effect } from "babylonjs/Materials/effect";
  22096. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22097. import { Plane } from "babylonjs/Maths/math.plane";
  22098. import { Collider } from "babylonjs/Collisions/collider";
  22099. import { Material } from "babylonjs/Materials/material";
  22100. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22102. import { Mesh } from "babylonjs/Meshes/mesh";
  22103. import { Ray } from "babylonjs/Culling/ray";
  22104. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22105. /**
  22106. * Base class for submeshes
  22107. */
  22108. export class BaseSubMesh {
  22109. /** @hidden */
  22110. _materialDefines: Nullable<MaterialDefines>;
  22111. /** @hidden */
  22112. _materialEffect: Nullable<Effect>;
  22113. /**
  22114. * Gets material defines used by the effect associated to the sub mesh
  22115. */
  22116. get materialDefines(): Nullable<MaterialDefines>;
  22117. /**
  22118. * Sets material defines used by the effect associated to the sub mesh
  22119. */
  22120. set materialDefines(defines: Nullable<MaterialDefines>);
  22121. /**
  22122. * Gets associated effect
  22123. */
  22124. get effect(): Nullable<Effect>;
  22125. /**
  22126. * Sets associated effect (effect used to render this submesh)
  22127. * @param effect defines the effect to associate with
  22128. * @param defines defines the set of defines used to compile this effect
  22129. */
  22130. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22131. }
  22132. /**
  22133. * Defines a subdivision inside a mesh
  22134. */
  22135. export class SubMesh extends BaseSubMesh implements ICullable {
  22136. /** the material index to use */
  22137. materialIndex: number;
  22138. /** vertex index start */
  22139. verticesStart: number;
  22140. /** vertices count */
  22141. verticesCount: number;
  22142. /** index start */
  22143. indexStart: number;
  22144. /** indices count */
  22145. indexCount: number;
  22146. /** @hidden */
  22147. _linesIndexCount: number;
  22148. private _mesh;
  22149. private _renderingMesh;
  22150. private _boundingInfo;
  22151. private _linesIndexBuffer;
  22152. /** @hidden */
  22153. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22154. /** @hidden */
  22155. _trianglePlanes: Plane[];
  22156. /** @hidden */
  22157. _lastColliderTransformMatrix: Nullable<Matrix>;
  22158. /** @hidden */
  22159. _renderId: number;
  22160. /** @hidden */
  22161. _alphaIndex: number;
  22162. /** @hidden */
  22163. _distanceToCamera: number;
  22164. /** @hidden */
  22165. _id: number;
  22166. private _currentMaterial;
  22167. /**
  22168. * Add a new submesh to a mesh
  22169. * @param materialIndex defines the material index to use
  22170. * @param verticesStart defines vertex index start
  22171. * @param verticesCount defines vertices count
  22172. * @param indexStart defines index start
  22173. * @param indexCount defines indices count
  22174. * @param mesh defines the parent mesh
  22175. * @param renderingMesh defines an optional rendering mesh
  22176. * @param createBoundingBox defines if bounding box should be created for this submesh
  22177. * @returns the new submesh
  22178. */
  22179. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22180. /**
  22181. * Creates a new submesh
  22182. * @param materialIndex defines the material index to use
  22183. * @param verticesStart defines vertex index start
  22184. * @param verticesCount defines vertices count
  22185. * @param indexStart defines index start
  22186. * @param indexCount defines indices count
  22187. * @param mesh defines the parent mesh
  22188. * @param renderingMesh defines an optional rendering mesh
  22189. * @param createBoundingBox defines if bounding box should be created for this submesh
  22190. */
  22191. constructor(
  22192. /** the material index to use */
  22193. materialIndex: number,
  22194. /** vertex index start */
  22195. verticesStart: number,
  22196. /** vertices count */
  22197. verticesCount: number,
  22198. /** index start */
  22199. indexStart: number,
  22200. /** indices count */
  22201. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22202. /**
  22203. * Returns true if this submesh covers the entire parent mesh
  22204. * @ignorenaming
  22205. */
  22206. get IsGlobal(): boolean;
  22207. /**
  22208. * Returns the submesh BoudingInfo object
  22209. * @returns current bounding info (or mesh's one if the submesh is global)
  22210. */
  22211. getBoundingInfo(): BoundingInfo;
  22212. /**
  22213. * Sets the submesh BoundingInfo
  22214. * @param boundingInfo defines the new bounding info to use
  22215. * @returns the SubMesh
  22216. */
  22217. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22218. /**
  22219. * Returns the mesh of the current submesh
  22220. * @return the parent mesh
  22221. */
  22222. getMesh(): AbstractMesh;
  22223. /**
  22224. * Returns the rendering mesh of the submesh
  22225. * @returns the rendering mesh (could be different from parent mesh)
  22226. */
  22227. getRenderingMesh(): Mesh;
  22228. /**
  22229. * Returns the submesh material
  22230. * @returns null or the current material
  22231. */
  22232. getMaterial(): Nullable<Material>;
  22233. /**
  22234. * Sets a new updated BoundingInfo object to the submesh
  22235. * @param data defines an optional position array to use to determine the bounding info
  22236. * @returns the SubMesh
  22237. */
  22238. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22239. /** @hidden */
  22240. _checkCollision(collider: Collider): boolean;
  22241. /**
  22242. * Updates the submesh BoundingInfo
  22243. * @param world defines the world matrix to use to update the bounding info
  22244. * @returns the submesh
  22245. */
  22246. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22247. /**
  22248. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22249. * @param frustumPlanes defines the frustum planes
  22250. * @returns true if the submesh is intersecting with the frustum
  22251. */
  22252. isInFrustum(frustumPlanes: Plane[]): boolean;
  22253. /**
  22254. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22255. * @param frustumPlanes defines the frustum planes
  22256. * @returns true if the submesh is inside the frustum
  22257. */
  22258. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22259. /**
  22260. * Renders the submesh
  22261. * @param enableAlphaMode defines if alpha needs to be used
  22262. * @returns the submesh
  22263. */
  22264. render(enableAlphaMode: boolean): SubMesh;
  22265. /**
  22266. * @hidden
  22267. */
  22268. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22269. /**
  22270. * Checks if the submesh intersects with a ray
  22271. * @param ray defines the ray to test
  22272. * @returns true is the passed ray intersects the submesh bounding box
  22273. */
  22274. canIntersects(ray: Ray): boolean;
  22275. /**
  22276. * Intersects current submesh with a ray
  22277. * @param ray defines the ray to test
  22278. * @param positions defines mesh's positions array
  22279. * @param indices defines mesh's indices array
  22280. * @param fastCheck defines if only bounding info should be used
  22281. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22282. * @returns intersection info or null if no intersection
  22283. */
  22284. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22285. /** @hidden */
  22286. private _intersectLines;
  22287. /** @hidden */
  22288. private _intersectUnIndexedLines;
  22289. /** @hidden */
  22290. private _intersectTriangles;
  22291. /** @hidden */
  22292. private _intersectUnIndexedTriangles;
  22293. /** @hidden */
  22294. _rebuild(): void;
  22295. /**
  22296. * Creates a new submesh from the passed mesh
  22297. * @param newMesh defines the new hosting mesh
  22298. * @param newRenderingMesh defines an optional rendering mesh
  22299. * @returns the new submesh
  22300. */
  22301. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22302. /**
  22303. * Release associated resources
  22304. */
  22305. dispose(): void;
  22306. /**
  22307. * Gets the class name
  22308. * @returns the string "SubMesh".
  22309. */
  22310. getClassName(): string;
  22311. /**
  22312. * Creates a new submesh from indices data
  22313. * @param materialIndex the index of the main mesh material
  22314. * @param startIndex the index where to start the copy in the mesh indices array
  22315. * @param indexCount the number of indices to copy then from the startIndex
  22316. * @param mesh the main mesh to create the submesh from
  22317. * @param renderingMesh the optional rendering mesh
  22318. * @returns a new submesh
  22319. */
  22320. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22321. }
  22322. }
  22323. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22324. /**
  22325. * Class used to represent data loading progression
  22326. */
  22327. export class SceneLoaderFlags {
  22328. private static _ForceFullSceneLoadingForIncremental;
  22329. private static _ShowLoadingScreen;
  22330. private static _CleanBoneMatrixWeights;
  22331. private static _loggingLevel;
  22332. /**
  22333. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22334. */
  22335. static get ForceFullSceneLoadingForIncremental(): boolean;
  22336. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22337. /**
  22338. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22339. */
  22340. static get ShowLoadingScreen(): boolean;
  22341. static set ShowLoadingScreen(value: boolean);
  22342. /**
  22343. * Defines the current logging level (while loading the scene)
  22344. * @ignorenaming
  22345. */
  22346. static get loggingLevel(): number;
  22347. static set loggingLevel(value: number);
  22348. /**
  22349. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22350. */
  22351. static get CleanBoneMatrixWeights(): boolean;
  22352. static set CleanBoneMatrixWeights(value: boolean);
  22353. }
  22354. }
  22355. declare module "babylonjs/Meshes/geometry" {
  22356. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22357. import { Scene } from "babylonjs/scene";
  22358. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22359. import { Engine } from "babylonjs/Engines/engine";
  22360. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22361. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22362. import { Effect } from "babylonjs/Materials/effect";
  22363. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22364. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22365. import { Mesh } from "babylonjs/Meshes/mesh";
  22366. /**
  22367. * Class used to store geometry data (vertex buffers + index buffer)
  22368. */
  22369. export class Geometry implements IGetSetVerticesData {
  22370. /**
  22371. * Gets or sets the ID of the geometry
  22372. */
  22373. id: string;
  22374. /**
  22375. * Gets or sets the unique ID of the geometry
  22376. */
  22377. uniqueId: number;
  22378. /**
  22379. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22380. */
  22381. delayLoadState: number;
  22382. /**
  22383. * Gets the file containing the data to load when running in delay load state
  22384. */
  22385. delayLoadingFile: Nullable<string>;
  22386. /**
  22387. * Callback called when the geometry is updated
  22388. */
  22389. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22390. private _scene;
  22391. private _engine;
  22392. private _meshes;
  22393. private _totalVertices;
  22394. /** @hidden */
  22395. _indices: IndicesArray;
  22396. /** @hidden */
  22397. _vertexBuffers: {
  22398. [key: string]: VertexBuffer;
  22399. };
  22400. private _isDisposed;
  22401. private _extend;
  22402. private _boundingBias;
  22403. /** @hidden */
  22404. _delayInfo: Array<string>;
  22405. private _indexBuffer;
  22406. private _indexBufferIsUpdatable;
  22407. /** @hidden */
  22408. _boundingInfo: Nullable<BoundingInfo>;
  22409. /** @hidden */
  22410. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22411. /** @hidden */
  22412. _softwareSkinningFrameId: number;
  22413. private _vertexArrayObjects;
  22414. private _updatable;
  22415. /** @hidden */
  22416. _positions: Nullable<Vector3[]>;
  22417. /**
  22418. * 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
  22419. */
  22420. get boundingBias(): Vector2;
  22421. /**
  22422. * 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
  22423. */
  22424. set boundingBias(value: Vector2);
  22425. /**
  22426. * Static function used to attach a new empty geometry to a mesh
  22427. * @param mesh defines the mesh to attach the geometry to
  22428. * @returns the new Geometry
  22429. */
  22430. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22431. /**
  22432. * Creates a new geometry
  22433. * @param id defines the unique ID
  22434. * @param scene defines the hosting scene
  22435. * @param vertexData defines the VertexData used to get geometry data
  22436. * @param updatable defines if geometry must be updatable (false by default)
  22437. * @param mesh defines the mesh that will be associated with the geometry
  22438. */
  22439. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22440. /**
  22441. * Gets the current extend of the geometry
  22442. */
  22443. get extend(): {
  22444. minimum: Vector3;
  22445. maximum: Vector3;
  22446. };
  22447. /**
  22448. * Gets the hosting scene
  22449. * @returns the hosting Scene
  22450. */
  22451. getScene(): Scene;
  22452. /**
  22453. * Gets the hosting engine
  22454. * @returns the hosting Engine
  22455. */
  22456. getEngine(): Engine;
  22457. /**
  22458. * Defines if the geometry is ready to use
  22459. * @returns true if the geometry is ready to be used
  22460. */
  22461. isReady(): boolean;
  22462. /**
  22463. * Gets a value indicating that the geometry should not be serialized
  22464. */
  22465. get doNotSerialize(): boolean;
  22466. /** @hidden */
  22467. _rebuild(): void;
  22468. /**
  22469. * Affects all geometry data in one call
  22470. * @param vertexData defines the geometry data
  22471. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22472. */
  22473. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22474. /**
  22475. * Set specific vertex data
  22476. * @param kind defines the data kind (Position, normal, etc...)
  22477. * @param data defines the vertex data to use
  22478. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22479. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22480. */
  22481. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22482. /**
  22483. * Removes a specific vertex data
  22484. * @param kind defines the data kind (Position, normal, etc...)
  22485. */
  22486. removeVerticesData(kind: string): void;
  22487. /**
  22488. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22489. * @param buffer defines the vertex buffer to use
  22490. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22491. */
  22492. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22493. /**
  22494. * Update a specific vertex buffer
  22495. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22496. * It will do nothing if the buffer is not updatable
  22497. * @param kind defines the data kind (Position, normal, etc...)
  22498. * @param data defines the data to use
  22499. * @param offset defines the offset in the target buffer where to store the data
  22500. * @param useBytes set to true if the offset is in bytes
  22501. */
  22502. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22503. /**
  22504. * Update a specific vertex buffer
  22505. * This function will create a new buffer if the current one is not updatable
  22506. * @param kind defines the data kind (Position, normal, etc...)
  22507. * @param data defines the data to use
  22508. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22509. */
  22510. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22511. private _updateBoundingInfo;
  22512. /** @hidden */
  22513. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22514. /**
  22515. * Gets total number of vertices
  22516. * @returns the total number of vertices
  22517. */
  22518. getTotalVertices(): number;
  22519. /**
  22520. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22521. * @param kind defines the data kind (Position, normal, etc...)
  22522. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22523. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22524. * @returns a float array containing vertex data
  22525. */
  22526. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22527. /**
  22528. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22529. * @param kind defines the data kind (Position, normal, etc...)
  22530. * @returns true if the vertex buffer with the specified kind is updatable
  22531. */
  22532. isVertexBufferUpdatable(kind: string): boolean;
  22533. /**
  22534. * Gets a specific vertex buffer
  22535. * @param kind defines the data kind (Position, normal, etc...)
  22536. * @returns a VertexBuffer
  22537. */
  22538. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22539. /**
  22540. * Returns all vertex buffers
  22541. * @return an object holding all vertex buffers indexed by kind
  22542. */
  22543. getVertexBuffers(): Nullable<{
  22544. [key: string]: VertexBuffer;
  22545. }>;
  22546. /**
  22547. * Gets a boolean indicating if specific vertex buffer is present
  22548. * @param kind defines the data kind (Position, normal, etc...)
  22549. * @returns true if data is present
  22550. */
  22551. isVerticesDataPresent(kind: string): boolean;
  22552. /**
  22553. * Gets a list of all attached data kinds (Position, normal, etc...)
  22554. * @returns a list of string containing all kinds
  22555. */
  22556. getVerticesDataKinds(): string[];
  22557. /**
  22558. * Update index buffer
  22559. * @param indices defines the indices to store in the index buffer
  22560. * @param offset defines the offset in the target buffer where to store the data
  22561. * @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)
  22562. */
  22563. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22564. /**
  22565. * Creates a new index buffer
  22566. * @param indices defines the indices to store in the index buffer
  22567. * @param totalVertices defines the total number of vertices (could be null)
  22568. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22569. */
  22570. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22571. /**
  22572. * Return the total number of indices
  22573. * @returns the total number of indices
  22574. */
  22575. getTotalIndices(): number;
  22576. /**
  22577. * Gets the index buffer array
  22578. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22579. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22580. * @returns the index buffer array
  22581. */
  22582. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22583. /**
  22584. * Gets the index buffer
  22585. * @return the index buffer
  22586. */
  22587. getIndexBuffer(): Nullable<DataBuffer>;
  22588. /** @hidden */
  22589. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22590. /**
  22591. * Release the associated resources for a specific mesh
  22592. * @param mesh defines the source mesh
  22593. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22594. */
  22595. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22596. /**
  22597. * Apply current geometry to a given mesh
  22598. * @param mesh defines the mesh to apply geometry to
  22599. */
  22600. applyToMesh(mesh: Mesh): void;
  22601. private _updateExtend;
  22602. private _applyToMesh;
  22603. private notifyUpdate;
  22604. /**
  22605. * Load the geometry if it was flagged as delay loaded
  22606. * @param scene defines the hosting scene
  22607. * @param onLoaded defines a callback called when the geometry is loaded
  22608. */
  22609. load(scene: Scene, onLoaded?: () => void): void;
  22610. private _queueLoad;
  22611. /**
  22612. * Invert the geometry to move from a right handed system to a left handed one.
  22613. */
  22614. toLeftHanded(): void;
  22615. /** @hidden */
  22616. _resetPointsArrayCache(): void;
  22617. /** @hidden */
  22618. _generatePointsArray(): boolean;
  22619. /**
  22620. * Gets a value indicating if the geometry is disposed
  22621. * @returns true if the geometry was disposed
  22622. */
  22623. isDisposed(): boolean;
  22624. private _disposeVertexArrayObjects;
  22625. /**
  22626. * Free all associated resources
  22627. */
  22628. dispose(): void;
  22629. /**
  22630. * Clone the current geometry into a new geometry
  22631. * @param id defines the unique ID of the new geometry
  22632. * @returns a new geometry object
  22633. */
  22634. copy(id: string): Geometry;
  22635. /**
  22636. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22637. * @return a JSON representation of the current geometry data (without the vertices data)
  22638. */
  22639. serialize(): any;
  22640. private toNumberArray;
  22641. /**
  22642. * Serialize all vertices data into a JSON oject
  22643. * @returns a JSON representation of the current geometry data
  22644. */
  22645. serializeVerticeData(): any;
  22646. /**
  22647. * Extracts a clone of a mesh geometry
  22648. * @param mesh defines the source mesh
  22649. * @param id defines the unique ID of the new geometry object
  22650. * @returns the new geometry object
  22651. */
  22652. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22653. /**
  22654. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22655. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22656. * Be aware Math.random() could cause collisions, but:
  22657. * "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"
  22658. * @returns a string containing a new GUID
  22659. */
  22660. static RandomId(): string;
  22661. /** @hidden */
  22662. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22663. private static _CleanMatricesWeights;
  22664. /**
  22665. * Create a new geometry from persisted data (Using .babylon file format)
  22666. * @param parsedVertexData defines the persisted data
  22667. * @param scene defines the hosting scene
  22668. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22669. * @returns the new geometry object
  22670. */
  22671. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22672. }
  22673. }
  22674. declare module "babylonjs/Meshes/mesh.vertexData" {
  22675. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22676. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22677. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22678. import { Geometry } from "babylonjs/Meshes/geometry";
  22679. import { Mesh } from "babylonjs/Meshes/mesh";
  22680. /**
  22681. * Define an interface for all classes that will get and set the data on vertices
  22682. */
  22683. export interface IGetSetVerticesData {
  22684. /**
  22685. * Gets a boolean indicating if specific vertex data is present
  22686. * @param kind defines the vertex data kind to use
  22687. * @returns true is data kind is present
  22688. */
  22689. isVerticesDataPresent(kind: string): boolean;
  22690. /**
  22691. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22692. * @param kind defines the data kind (Position, normal, etc...)
  22693. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22694. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22695. * @returns a float array containing vertex data
  22696. */
  22697. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22698. /**
  22699. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22700. * @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.
  22701. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22702. * @returns the indices array or an empty array if the mesh has no geometry
  22703. */
  22704. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22705. /**
  22706. * Set specific vertex data
  22707. * @param kind defines the data kind (Position, normal, etc...)
  22708. * @param data defines the vertex data to use
  22709. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22710. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22711. */
  22712. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22713. /**
  22714. * Update a specific associated vertex buffer
  22715. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22716. * - VertexBuffer.PositionKind
  22717. * - VertexBuffer.UVKind
  22718. * - VertexBuffer.UV2Kind
  22719. * - VertexBuffer.UV3Kind
  22720. * - VertexBuffer.UV4Kind
  22721. * - VertexBuffer.UV5Kind
  22722. * - VertexBuffer.UV6Kind
  22723. * - VertexBuffer.ColorKind
  22724. * - VertexBuffer.MatricesIndicesKind
  22725. * - VertexBuffer.MatricesIndicesExtraKind
  22726. * - VertexBuffer.MatricesWeightsKind
  22727. * - VertexBuffer.MatricesWeightsExtraKind
  22728. * @param data defines the data source
  22729. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22730. * @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)
  22731. */
  22732. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22733. /**
  22734. * Creates a new index buffer
  22735. * @param indices defines the indices to store in the index buffer
  22736. * @param totalVertices defines the total number of vertices (could be null)
  22737. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22738. */
  22739. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22740. }
  22741. /**
  22742. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22743. */
  22744. export class VertexData {
  22745. /**
  22746. * Mesh side orientation : usually the external or front surface
  22747. */
  22748. static readonly FRONTSIDE: number;
  22749. /**
  22750. * Mesh side orientation : usually the internal or back surface
  22751. */
  22752. static readonly BACKSIDE: number;
  22753. /**
  22754. * Mesh side orientation : both internal and external or front and back surfaces
  22755. */
  22756. static readonly DOUBLESIDE: number;
  22757. /**
  22758. * Mesh side orientation : by default, `FRONTSIDE`
  22759. */
  22760. static readonly DEFAULTSIDE: number;
  22761. /**
  22762. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22763. */
  22764. positions: Nullable<FloatArray>;
  22765. /**
  22766. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22767. */
  22768. normals: Nullable<FloatArray>;
  22769. /**
  22770. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22771. */
  22772. tangents: Nullable<FloatArray>;
  22773. /**
  22774. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22775. */
  22776. uvs: Nullable<FloatArray>;
  22777. /**
  22778. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22779. */
  22780. uvs2: Nullable<FloatArray>;
  22781. /**
  22782. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22783. */
  22784. uvs3: Nullable<FloatArray>;
  22785. /**
  22786. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22787. */
  22788. uvs4: Nullable<FloatArray>;
  22789. /**
  22790. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22791. */
  22792. uvs5: Nullable<FloatArray>;
  22793. /**
  22794. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22795. */
  22796. uvs6: Nullable<FloatArray>;
  22797. /**
  22798. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22799. */
  22800. colors: Nullable<FloatArray>;
  22801. /**
  22802. * 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).
  22803. */
  22804. matricesIndices: Nullable<FloatArray>;
  22805. /**
  22806. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22807. */
  22808. matricesWeights: Nullable<FloatArray>;
  22809. /**
  22810. * An array extending the number of possible indices
  22811. */
  22812. matricesIndicesExtra: Nullable<FloatArray>;
  22813. /**
  22814. * An array extending the number of possible weights when the number of indices is extended
  22815. */
  22816. matricesWeightsExtra: Nullable<FloatArray>;
  22817. /**
  22818. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22819. */
  22820. indices: Nullable<IndicesArray>;
  22821. /**
  22822. * Uses the passed data array to set the set the values for the specified kind of data
  22823. * @param data a linear array of floating numbers
  22824. * @param kind the type of data that is being set, eg positions, colors etc
  22825. */
  22826. set(data: FloatArray, kind: string): void;
  22827. /**
  22828. * Associates the vertexData to the passed Mesh.
  22829. * Sets it as updatable or not (default `false`)
  22830. * @param mesh the mesh the vertexData is applied to
  22831. * @param updatable when used and having the value true allows new data to update the vertexData
  22832. * @returns the VertexData
  22833. */
  22834. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22835. /**
  22836. * Associates the vertexData to the passed Geometry.
  22837. * Sets it as updatable or not (default `false`)
  22838. * @param geometry the geometry the vertexData is applied to
  22839. * @param updatable when used and having the value true allows new data to update the vertexData
  22840. * @returns VertexData
  22841. */
  22842. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22843. /**
  22844. * Updates the associated mesh
  22845. * @param mesh the mesh to be updated
  22846. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22847. * @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
  22848. * @returns VertexData
  22849. */
  22850. updateMesh(mesh: Mesh): VertexData;
  22851. /**
  22852. * Updates the associated geometry
  22853. * @param geometry the geometry to be updated
  22854. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22855. * @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
  22856. * @returns VertexData.
  22857. */
  22858. updateGeometry(geometry: Geometry): VertexData;
  22859. private _applyTo;
  22860. private _update;
  22861. /**
  22862. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22863. * @param matrix the transforming matrix
  22864. * @returns the VertexData
  22865. */
  22866. transform(matrix: Matrix): VertexData;
  22867. /**
  22868. * Merges the passed VertexData into the current one
  22869. * @param other the VertexData to be merged into the current one
  22870. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22871. * @returns the modified VertexData
  22872. */
  22873. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22874. private _mergeElement;
  22875. private _validate;
  22876. /**
  22877. * Serializes the VertexData
  22878. * @returns a serialized object
  22879. */
  22880. serialize(): any;
  22881. /**
  22882. * Extracts the vertexData from a mesh
  22883. * @param mesh the mesh from which to extract the VertexData
  22884. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22885. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22886. * @returns the object VertexData associated to the passed mesh
  22887. */
  22888. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22889. /**
  22890. * Extracts the vertexData from the geometry
  22891. * @param geometry the geometry from which to extract the VertexData
  22892. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22893. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22894. * @returns the object VertexData associated to the passed mesh
  22895. */
  22896. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22897. private static _ExtractFrom;
  22898. /**
  22899. * Creates the VertexData for a Ribbon
  22900. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22901. * * pathArray array of paths, each of which an array of successive Vector3
  22902. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22903. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22904. * * 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
  22905. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22906. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22907. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22908. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22909. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22910. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22911. * @returns the VertexData of the ribbon
  22912. */
  22913. static CreateRibbon(options: {
  22914. pathArray: Vector3[][];
  22915. closeArray?: boolean;
  22916. closePath?: boolean;
  22917. offset?: number;
  22918. sideOrientation?: number;
  22919. frontUVs?: Vector4;
  22920. backUVs?: Vector4;
  22921. invertUV?: boolean;
  22922. uvs?: Vector2[];
  22923. colors?: Color4[];
  22924. }): VertexData;
  22925. /**
  22926. * Creates the VertexData for a box
  22927. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22928. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22929. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22930. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22931. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22932. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22933. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22934. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22935. * * 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)
  22936. * * 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)
  22937. * @returns the VertexData of the box
  22938. */
  22939. static CreateBox(options: {
  22940. size?: number;
  22941. width?: number;
  22942. height?: number;
  22943. depth?: number;
  22944. faceUV?: Vector4[];
  22945. faceColors?: Color4[];
  22946. sideOrientation?: number;
  22947. frontUVs?: Vector4;
  22948. backUVs?: Vector4;
  22949. }): VertexData;
  22950. /**
  22951. * Creates the VertexData for a tiled box
  22952. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22953. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22954. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22955. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22956. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22957. * @returns the VertexData of the box
  22958. */
  22959. static CreateTiledBox(options: {
  22960. pattern?: number;
  22961. width?: number;
  22962. height?: number;
  22963. depth?: number;
  22964. tileSize?: number;
  22965. tileWidth?: number;
  22966. tileHeight?: number;
  22967. alignHorizontal?: number;
  22968. alignVertical?: number;
  22969. faceUV?: Vector4[];
  22970. faceColors?: Color4[];
  22971. sideOrientation?: number;
  22972. }): VertexData;
  22973. /**
  22974. * Creates the VertexData for a tiled plane
  22975. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22976. * * pattern a limited pattern arrangement depending on the number
  22977. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22978. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22979. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22980. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22981. * * 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)
  22982. * * 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)
  22983. * @returns the VertexData of the tiled plane
  22984. */
  22985. static CreateTiledPlane(options: {
  22986. pattern?: number;
  22987. tileSize?: number;
  22988. tileWidth?: number;
  22989. tileHeight?: number;
  22990. size?: number;
  22991. width?: number;
  22992. height?: number;
  22993. alignHorizontal?: number;
  22994. alignVertical?: number;
  22995. sideOrientation?: number;
  22996. frontUVs?: Vector4;
  22997. backUVs?: Vector4;
  22998. }): VertexData;
  22999. /**
  23000. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23001. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23002. * * segments sets the number of horizontal strips optional, default 32
  23003. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23004. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23005. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23006. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23007. * * 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
  23008. * * 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
  23009. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23010. * * 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)
  23011. * * 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)
  23012. * @returns the VertexData of the ellipsoid
  23013. */
  23014. static CreateSphere(options: {
  23015. segments?: number;
  23016. diameter?: number;
  23017. diameterX?: number;
  23018. diameterY?: number;
  23019. diameterZ?: number;
  23020. arc?: number;
  23021. slice?: number;
  23022. sideOrientation?: number;
  23023. frontUVs?: Vector4;
  23024. backUVs?: Vector4;
  23025. }): VertexData;
  23026. /**
  23027. * Creates the VertexData for a cylinder, cone or prism
  23028. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23029. * * height sets the height (y direction) of the cylinder, optional, default 2
  23030. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23031. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23032. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23033. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23034. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23035. * * 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
  23036. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23037. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23038. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23039. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23040. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23041. * * 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)
  23042. * * 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)
  23043. * @returns the VertexData of the cylinder, cone or prism
  23044. */
  23045. static CreateCylinder(options: {
  23046. height?: number;
  23047. diameterTop?: number;
  23048. diameterBottom?: number;
  23049. diameter?: number;
  23050. tessellation?: number;
  23051. subdivisions?: number;
  23052. arc?: number;
  23053. faceColors?: Color4[];
  23054. faceUV?: Vector4[];
  23055. hasRings?: boolean;
  23056. enclose?: boolean;
  23057. sideOrientation?: number;
  23058. frontUVs?: Vector4;
  23059. backUVs?: Vector4;
  23060. }): VertexData;
  23061. /**
  23062. * Creates the VertexData for a torus
  23063. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23064. * * diameter the diameter of the torus, optional default 1
  23065. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23066. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23067. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23068. * * 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)
  23069. * * 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)
  23070. * @returns the VertexData of the torus
  23071. */
  23072. static CreateTorus(options: {
  23073. diameter?: number;
  23074. thickness?: number;
  23075. tessellation?: number;
  23076. sideOrientation?: number;
  23077. frontUVs?: Vector4;
  23078. backUVs?: Vector4;
  23079. }): VertexData;
  23080. /**
  23081. * Creates the VertexData of the LineSystem
  23082. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23083. * - lines an array of lines, each line being an array of successive Vector3
  23084. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23085. * @returns the VertexData of the LineSystem
  23086. */
  23087. static CreateLineSystem(options: {
  23088. lines: Vector3[][];
  23089. colors?: Nullable<Color4[][]>;
  23090. }): VertexData;
  23091. /**
  23092. * Create the VertexData for a DashedLines
  23093. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23094. * - points an array successive Vector3
  23095. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23096. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23097. * - dashNb the intended total number of dashes, optional, default 200
  23098. * @returns the VertexData for the DashedLines
  23099. */
  23100. static CreateDashedLines(options: {
  23101. points: Vector3[];
  23102. dashSize?: number;
  23103. gapSize?: number;
  23104. dashNb?: number;
  23105. }): VertexData;
  23106. /**
  23107. * Creates the VertexData for a Ground
  23108. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23109. * - width the width (x direction) of the ground, optional, default 1
  23110. * - height the height (z direction) of the ground, optional, default 1
  23111. * - subdivisions the number of subdivisions per side, optional, default 1
  23112. * @returns the VertexData of the Ground
  23113. */
  23114. static CreateGround(options: {
  23115. width?: number;
  23116. height?: number;
  23117. subdivisions?: number;
  23118. subdivisionsX?: number;
  23119. subdivisionsY?: number;
  23120. }): VertexData;
  23121. /**
  23122. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23123. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23124. * * xmin the ground minimum X coordinate, optional, default -1
  23125. * * zmin the ground minimum Z coordinate, optional, default -1
  23126. * * xmax the ground maximum X coordinate, optional, default 1
  23127. * * zmax the ground maximum Z coordinate, optional, default 1
  23128. * * 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}
  23129. * * 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}
  23130. * @returns the VertexData of the TiledGround
  23131. */
  23132. static CreateTiledGround(options: {
  23133. xmin: number;
  23134. zmin: number;
  23135. xmax: number;
  23136. zmax: number;
  23137. subdivisions?: {
  23138. w: number;
  23139. h: number;
  23140. };
  23141. precision?: {
  23142. w: number;
  23143. h: number;
  23144. };
  23145. }): VertexData;
  23146. /**
  23147. * Creates the VertexData of the Ground designed from a heightmap
  23148. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23149. * * width the width (x direction) of the ground
  23150. * * height the height (z direction) of the ground
  23151. * * subdivisions the number of subdivisions per side
  23152. * * minHeight the minimum altitude on the ground, optional, default 0
  23153. * * maxHeight the maximum altitude on the ground, optional default 1
  23154. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23155. * * buffer the array holding the image color data
  23156. * * bufferWidth the width of image
  23157. * * bufferHeight the height of image
  23158. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23159. * @returns the VertexData of the Ground designed from a heightmap
  23160. */
  23161. static CreateGroundFromHeightMap(options: {
  23162. width: number;
  23163. height: number;
  23164. subdivisions: number;
  23165. minHeight: number;
  23166. maxHeight: number;
  23167. colorFilter: Color3;
  23168. buffer: Uint8Array;
  23169. bufferWidth: number;
  23170. bufferHeight: number;
  23171. alphaFilter: number;
  23172. }): VertexData;
  23173. /**
  23174. * Creates the VertexData for a Plane
  23175. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23176. * * size sets the width and height of the plane to the value of size, optional default 1
  23177. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23178. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23179. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23180. * * 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)
  23181. * * 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)
  23182. * @returns the VertexData of the box
  23183. */
  23184. static CreatePlane(options: {
  23185. size?: number;
  23186. width?: number;
  23187. height?: number;
  23188. sideOrientation?: number;
  23189. frontUVs?: Vector4;
  23190. backUVs?: Vector4;
  23191. }): VertexData;
  23192. /**
  23193. * Creates the VertexData of the Disc or regular Polygon
  23194. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23195. * * radius the radius of the disc, optional default 0.5
  23196. * * tessellation the number of polygon sides, optional, default 64
  23197. * * 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
  23198. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23199. * * 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)
  23200. * * 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)
  23201. * @returns the VertexData of the box
  23202. */
  23203. static CreateDisc(options: {
  23204. radius?: number;
  23205. tessellation?: number;
  23206. arc?: number;
  23207. sideOrientation?: number;
  23208. frontUVs?: Vector4;
  23209. backUVs?: Vector4;
  23210. }): VertexData;
  23211. /**
  23212. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23213. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23214. * @param polygon a mesh built from polygonTriangulation.build()
  23215. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23216. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23217. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23218. * @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)
  23219. * @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)
  23220. * @returns the VertexData of the Polygon
  23221. */
  23222. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23223. /**
  23224. * Creates the VertexData of the IcoSphere
  23225. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23226. * * radius the radius of the IcoSphere, optional default 1
  23227. * * radiusX allows stretching in the x direction, optional, default radius
  23228. * * radiusY allows stretching in the y direction, optional, default radius
  23229. * * radiusZ allows stretching in the z direction, optional, default radius
  23230. * * flat when true creates a flat shaded mesh, optional, default true
  23231. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23232. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23233. * * 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)
  23234. * * 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)
  23235. * @returns the VertexData of the IcoSphere
  23236. */
  23237. static CreateIcoSphere(options: {
  23238. radius?: number;
  23239. radiusX?: number;
  23240. radiusY?: number;
  23241. radiusZ?: number;
  23242. flat?: boolean;
  23243. subdivisions?: number;
  23244. sideOrientation?: number;
  23245. frontUVs?: Vector4;
  23246. backUVs?: Vector4;
  23247. }): VertexData;
  23248. /**
  23249. * Creates the VertexData for a Polyhedron
  23250. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23251. * * type provided types are:
  23252. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23253. * * 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)
  23254. * * size the size of the IcoSphere, optional default 1
  23255. * * sizeX allows stretching in the x direction, optional, default size
  23256. * * sizeY allows stretching in the y direction, optional, default size
  23257. * * sizeZ allows stretching in the z direction, optional, default size
  23258. * * 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
  23259. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23260. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23261. * * flat when true creates a flat shaded mesh, optional, default true
  23262. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23263. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23264. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23265. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23266. * @returns the VertexData of the Polyhedron
  23267. */
  23268. static CreatePolyhedron(options: {
  23269. type?: number;
  23270. size?: number;
  23271. sizeX?: number;
  23272. sizeY?: number;
  23273. sizeZ?: number;
  23274. custom?: any;
  23275. faceUV?: Vector4[];
  23276. faceColors?: Color4[];
  23277. flat?: boolean;
  23278. sideOrientation?: number;
  23279. frontUVs?: Vector4;
  23280. backUVs?: Vector4;
  23281. }): VertexData;
  23282. /**
  23283. * Creates the VertexData for a TorusKnot
  23284. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23285. * * radius the radius of the torus knot, optional, default 2
  23286. * * tube the thickness of the tube, optional, default 0.5
  23287. * * radialSegments the number of sides on each tube segments, optional, default 32
  23288. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23289. * * p the number of windings around the z axis, optional, default 2
  23290. * * q the number of windings around the x axis, optional, default 3
  23291. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23292. * * 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)
  23293. * * 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)
  23294. * @returns the VertexData of the Torus Knot
  23295. */
  23296. static CreateTorusKnot(options: {
  23297. radius?: number;
  23298. tube?: number;
  23299. radialSegments?: number;
  23300. tubularSegments?: number;
  23301. p?: number;
  23302. q?: number;
  23303. sideOrientation?: number;
  23304. frontUVs?: Vector4;
  23305. backUVs?: Vector4;
  23306. }): VertexData;
  23307. /**
  23308. * Compute normals for given positions and indices
  23309. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23310. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23311. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23312. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23313. * * facetNormals : optional array of facet normals (vector3)
  23314. * * facetPositions : optional array of facet positions (vector3)
  23315. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23316. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23317. * * bInfo : optional bounding info, required for facetPartitioning computation
  23318. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23319. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23320. * * useRightHandedSystem: optional boolean to for right handed system computation
  23321. * * depthSort : optional boolean to enable the facet depth sort computation
  23322. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23323. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23324. */
  23325. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23326. facetNormals?: any;
  23327. facetPositions?: any;
  23328. facetPartitioning?: any;
  23329. ratio?: number;
  23330. bInfo?: any;
  23331. bbSize?: Vector3;
  23332. subDiv?: any;
  23333. useRightHandedSystem?: boolean;
  23334. depthSort?: boolean;
  23335. distanceTo?: Vector3;
  23336. depthSortedFacets?: any;
  23337. }): void;
  23338. /** @hidden */
  23339. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23340. /**
  23341. * Applies VertexData created from the imported parameters to the geometry
  23342. * @param parsedVertexData the parsed data from an imported file
  23343. * @param geometry the geometry to apply the VertexData to
  23344. */
  23345. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23346. }
  23347. }
  23348. declare module "babylonjs/Morph/morphTarget" {
  23349. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23350. import { Observable } from "babylonjs/Misc/observable";
  23351. import { Nullable, FloatArray } from "babylonjs/types";
  23352. import { Scene } from "babylonjs/scene";
  23353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23354. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23355. /**
  23356. * Defines a target to use with MorphTargetManager
  23357. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23358. */
  23359. export class MorphTarget implements IAnimatable {
  23360. /** defines the name of the target */
  23361. name: string;
  23362. /**
  23363. * Gets or sets the list of animations
  23364. */
  23365. animations: import("babylonjs/Animations/animation").Animation[];
  23366. private _scene;
  23367. private _positions;
  23368. private _normals;
  23369. private _tangents;
  23370. private _uvs;
  23371. private _influence;
  23372. private _uniqueId;
  23373. /**
  23374. * Observable raised when the influence changes
  23375. */
  23376. onInfluenceChanged: Observable<boolean>;
  23377. /** @hidden */
  23378. _onDataLayoutChanged: Observable<void>;
  23379. /**
  23380. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23381. */
  23382. get influence(): number;
  23383. set influence(influence: number);
  23384. /**
  23385. * Gets or sets the id of the morph Target
  23386. */
  23387. id: string;
  23388. private _animationPropertiesOverride;
  23389. /**
  23390. * Gets or sets the animation properties override
  23391. */
  23392. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23393. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23394. /**
  23395. * Creates a new MorphTarget
  23396. * @param name defines the name of the target
  23397. * @param influence defines the influence to use
  23398. * @param scene defines the scene the morphtarget belongs to
  23399. */
  23400. constructor(
  23401. /** defines the name of the target */
  23402. name: string, influence?: number, scene?: Nullable<Scene>);
  23403. /**
  23404. * Gets the unique ID of this manager
  23405. */
  23406. get uniqueId(): number;
  23407. /**
  23408. * Gets a boolean defining if the target contains position data
  23409. */
  23410. get hasPositions(): boolean;
  23411. /**
  23412. * Gets a boolean defining if the target contains normal data
  23413. */
  23414. get hasNormals(): boolean;
  23415. /**
  23416. * Gets a boolean defining if the target contains tangent data
  23417. */
  23418. get hasTangents(): boolean;
  23419. /**
  23420. * Gets a boolean defining if the target contains texture coordinates data
  23421. */
  23422. get hasUVs(): boolean;
  23423. /**
  23424. * Affects position data to this target
  23425. * @param data defines the position data to use
  23426. */
  23427. setPositions(data: Nullable<FloatArray>): void;
  23428. /**
  23429. * Gets the position data stored in this target
  23430. * @returns a FloatArray containing the position data (or null if not present)
  23431. */
  23432. getPositions(): Nullable<FloatArray>;
  23433. /**
  23434. * Affects normal data to this target
  23435. * @param data defines the normal data to use
  23436. */
  23437. setNormals(data: Nullable<FloatArray>): void;
  23438. /**
  23439. * Gets the normal data stored in this target
  23440. * @returns a FloatArray containing the normal data (or null if not present)
  23441. */
  23442. getNormals(): Nullable<FloatArray>;
  23443. /**
  23444. * Affects tangent data to this target
  23445. * @param data defines the tangent data to use
  23446. */
  23447. setTangents(data: Nullable<FloatArray>): void;
  23448. /**
  23449. * Gets the tangent data stored in this target
  23450. * @returns a FloatArray containing the tangent data (or null if not present)
  23451. */
  23452. getTangents(): Nullable<FloatArray>;
  23453. /**
  23454. * Affects texture coordinates data to this target
  23455. * @param data defines the texture coordinates data to use
  23456. */
  23457. setUVs(data: Nullable<FloatArray>): void;
  23458. /**
  23459. * Gets the texture coordinates data stored in this target
  23460. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23461. */
  23462. getUVs(): Nullable<FloatArray>;
  23463. /**
  23464. * Clone the current target
  23465. * @returns a new MorphTarget
  23466. */
  23467. clone(): MorphTarget;
  23468. /**
  23469. * Serializes the current target into a Serialization object
  23470. * @returns the serialized object
  23471. */
  23472. serialize(): any;
  23473. /**
  23474. * Returns the string "MorphTarget"
  23475. * @returns "MorphTarget"
  23476. */
  23477. getClassName(): string;
  23478. /**
  23479. * Creates a new target from serialized data
  23480. * @param serializationObject defines the serialized data to use
  23481. * @returns a new MorphTarget
  23482. */
  23483. static Parse(serializationObject: any): MorphTarget;
  23484. /**
  23485. * Creates a MorphTarget from mesh data
  23486. * @param mesh defines the source mesh
  23487. * @param name defines the name to use for the new target
  23488. * @param influence defines the influence to attach to the target
  23489. * @returns a new MorphTarget
  23490. */
  23491. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23492. }
  23493. }
  23494. declare module "babylonjs/Morph/morphTargetManager" {
  23495. import { Nullable } from "babylonjs/types";
  23496. import { Scene } from "babylonjs/scene";
  23497. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23498. /**
  23499. * This class is used to deform meshes using morphing between different targets
  23500. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23501. */
  23502. export class MorphTargetManager {
  23503. private _targets;
  23504. private _targetInfluenceChangedObservers;
  23505. private _targetDataLayoutChangedObservers;
  23506. private _activeTargets;
  23507. private _scene;
  23508. private _influences;
  23509. private _supportsNormals;
  23510. private _supportsTangents;
  23511. private _supportsUVs;
  23512. private _vertexCount;
  23513. private _uniqueId;
  23514. private _tempInfluences;
  23515. /**
  23516. * Gets or sets a boolean indicating if normals must be morphed
  23517. */
  23518. enableNormalMorphing: boolean;
  23519. /**
  23520. * Gets or sets a boolean indicating if tangents must be morphed
  23521. */
  23522. enableTangentMorphing: boolean;
  23523. /**
  23524. * Gets or sets a boolean indicating if UV must be morphed
  23525. */
  23526. enableUVMorphing: boolean;
  23527. /**
  23528. * Creates a new MorphTargetManager
  23529. * @param scene defines the current scene
  23530. */
  23531. constructor(scene?: Nullable<Scene>);
  23532. /**
  23533. * Gets the unique ID of this manager
  23534. */
  23535. get uniqueId(): number;
  23536. /**
  23537. * Gets the number of vertices handled by this manager
  23538. */
  23539. get vertexCount(): number;
  23540. /**
  23541. * Gets a boolean indicating if this manager supports morphing of normals
  23542. */
  23543. get supportsNormals(): boolean;
  23544. /**
  23545. * Gets a boolean indicating if this manager supports morphing of tangents
  23546. */
  23547. get supportsTangents(): boolean;
  23548. /**
  23549. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23550. */
  23551. get supportsUVs(): boolean;
  23552. /**
  23553. * Gets the number of targets stored in this manager
  23554. */
  23555. get numTargets(): number;
  23556. /**
  23557. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23558. */
  23559. get numInfluencers(): number;
  23560. /**
  23561. * Gets the list of influences (one per target)
  23562. */
  23563. get influences(): Float32Array;
  23564. /**
  23565. * Gets the active target at specified index. An active target is a target with an influence > 0
  23566. * @param index defines the index to check
  23567. * @returns the requested target
  23568. */
  23569. getActiveTarget(index: number): MorphTarget;
  23570. /**
  23571. * Gets the target at specified index
  23572. * @param index defines the index to check
  23573. * @returns the requested target
  23574. */
  23575. getTarget(index: number): MorphTarget;
  23576. /**
  23577. * Add a new target to this manager
  23578. * @param target defines the target to add
  23579. */
  23580. addTarget(target: MorphTarget): void;
  23581. /**
  23582. * Removes a target from the manager
  23583. * @param target defines the target to remove
  23584. */
  23585. removeTarget(target: MorphTarget): void;
  23586. /**
  23587. * Clone the current manager
  23588. * @returns a new MorphTargetManager
  23589. */
  23590. clone(): MorphTargetManager;
  23591. /**
  23592. * Serializes the current manager into a Serialization object
  23593. * @returns the serialized object
  23594. */
  23595. serialize(): any;
  23596. private _syncActiveTargets;
  23597. /**
  23598. * Syncrhonize the targets with all the meshes using this morph target manager
  23599. */
  23600. synchronize(): void;
  23601. /**
  23602. * Creates a new MorphTargetManager from serialized data
  23603. * @param serializationObject defines the serialized data
  23604. * @param scene defines the hosting scene
  23605. * @returns the new MorphTargetManager
  23606. */
  23607. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23608. }
  23609. }
  23610. declare module "babylonjs/Meshes/meshLODLevel" {
  23611. import { Mesh } from "babylonjs/Meshes/mesh";
  23612. import { Nullable } from "babylonjs/types";
  23613. /**
  23614. * Class used to represent a specific level of detail of a mesh
  23615. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23616. */
  23617. export class MeshLODLevel {
  23618. /** Defines the distance where this level should start being displayed */
  23619. distance: number;
  23620. /** Defines the mesh to use to render this level */
  23621. mesh: Nullable<Mesh>;
  23622. /**
  23623. * Creates a new LOD level
  23624. * @param distance defines the distance where this level should star being displayed
  23625. * @param mesh defines the mesh to use to render this level
  23626. */
  23627. constructor(
  23628. /** Defines the distance where this level should start being displayed */
  23629. distance: number,
  23630. /** Defines the mesh to use to render this level */
  23631. mesh: Nullable<Mesh>);
  23632. }
  23633. }
  23634. declare module "babylonjs/Meshes/groundMesh" {
  23635. import { Scene } from "babylonjs/scene";
  23636. import { Vector3 } from "babylonjs/Maths/math.vector";
  23637. import { Mesh } from "babylonjs/Meshes/mesh";
  23638. /**
  23639. * Mesh representing the gorund
  23640. */
  23641. export class GroundMesh extends Mesh {
  23642. /** If octree should be generated */
  23643. generateOctree: boolean;
  23644. private _heightQuads;
  23645. /** @hidden */
  23646. _subdivisionsX: number;
  23647. /** @hidden */
  23648. _subdivisionsY: number;
  23649. /** @hidden */
  23650. _width: number;
  23651. /** @hidden */
  23652. _height: number;
  23653. /** @hidden */
  23654. _minX: number;
  23655. /** @hidden */
  23656. _maxX: number;
  23657. /** @hidden */
  23658. _minZ: number;
  23659. /** @hidden */
  23660. _maxZ: number;
  23661. constructor(name: string, scene: Scene);
  23662. /**
  23663. * "GroundMesh"
  23664. * @returns "GroundMesh"
  23665. */
  23666. getClassName(): string;
  23667. /**
  23668. * The minimum of x and y subdivisions
  23669. */
  23670. get subdivisions(): number;
  23671. /**
  23672. * X subdivisions
  23673. */
  23674. get subdivisionsX(): number;
  23675. /**
  23676. * Y subdivisions
  23677. */
  23678. get subdivisionsY(): number;
  23679. /**
  23680. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23681. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23682. * @param chunksCount the number of subdivisions for x and y
  23683. * @param octreeBlocksSize (Default: 32)
  23684. */
  23685. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23686. /**
  23687. * Returns a height (y) value in the Worl system :
  23688. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23689. * @param x x coordinate
  23690. * @param z z coordinate
  23691. * @returns the ground y position if (x, z) are outside the ground surface.
  23692. */
  23693. getHeightAtCoordinates(x: number, z: number): number;
  23694. /**
  23695. * Returns a normalized vector (Vector3) orthogonal to the ground
  23696. * at the ground coordinates (x, z) expressed in the World system.
  23697. * @param x x coordinate
  23698. * @param z z coordinate
  23699. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23700. */
  23701. getNormalAtCoordinates(x: number, z: number): Vector3;
  23702. /**
  23703. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23704. * at the ground coordinates (x, z) expressed in the World system.
  23705. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23706. * @param x x coordinate
  23707. * @param z z coordinate
  23708. * @param ref vector to store the result
  23709. * @returns the GroundMesh.
  23710. */
  23711. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23712. /**
  23713. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23714. * if the ground has been updated.
  23715. * This can be used in the render loop.
  23716. * @returns the GroundMesh.
  23717. */
  23718. updateCoordinateHeights(): GroundMesh;
  23719. private _getFacetAt;
  23720. private _initHeightQuads;
  23721. private _computeHeightQuads;
  23722. /**
  23723. * Serializes this ground mesh
  23724. * @param serializationObject object to write serialization to
  23725. */
  23726. serialize(serializationObject: any): void;
  23727. /**
  23728. * Parses a serialized ground mesh
  23729. * @param parsedMesh the serialized mesh
  23730. * @param scene the scene to create the ground mesh in
  23731. * @returns the created ground mesh
  23732. */
  23733. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23734. }
  23735. }
  23736. declare module "babylonjs/Physics/physicsJoint" {
  23737. import { Vector3 } from "babylonjs/Maths/math.vector";
  23738. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23739. /**
  23740. * Interface for Physics-Joint data
  23741. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23742. */
  23743. export interface PhysicsJointData {
  23744. /**
  23745. * The main pivot of the joint
  23746. */
  23747. mainPivot?: Vector3;
  23748. /**
  23749. * The connected pivot of the joint
  23750. */
  23751. connectedPivot?: Vector3;
  23752. /**
  23753. * The main axis of the joint
  23754. */
  23755. mainAxis?: Vector3;
  23756. /**
  23757. * The connected axis of the joint
  23758. */
  23759. connectedAxis?: Vector3;
  23760. /**
  23761. * The collision of the joint
  23762. */
  23763. collision?: boolean;
  23764. /**
  23765. * Native Oimo/Cannon/Energy data
  23766. */
  23767. nativeParams?: any;
  23768. }
  23769. /**
  23770. * This is a holder class for the physics joint created by the physics plugin
  23771. * It holds a set of functions to control the underlying joint
  23772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23773. */
  23774. export class PhysicsJoint {
  23775. /**
  23776. * The type of the physics joint
  23777. */
  23778. type: number;
  23779. /**
  23780. * The data for the physics joint
  23781. */
  23782. jointData: PhysicsJointData;
  23783. private _physicsJoint;
  23784. protected _physicsPlugin: IPhysicsEnginePlugin;
  23785. /**
  23786. * Initializes the physics joint
  23787. * @param type The type of the physics joint
  23788. * @param jointData The data for the physics joint
  23789. */
  23790. constructor(
  23791. /**
  23792. * The type of the physics joint
  23793. */
  23794. type: number,
  23795. /**
  23796. * The data for the physics joint
  23797. */
  23798. jointData: PhysicsJointData);
  23799. /**
  23800. * Gets the physics joint
  23801. */
  23802. get physicsJoint(): any;
  23803. /**
  23804. * Sets the physics joint
  23805. */
  23806. set physicsJoint(newJoint: any);
  23807. /**
  23808. * Sets the physics plugin
  23809. */
  23810. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23811. /**
  23812. * Execute a function that is physics-plugin specific.
  23813. * @param {Function} func the function that will be executed.
  23814. * It accepts two parameters: the physics world and the physics joint
  23815. */
  23816. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23817. /**
  23818. * Distance-Joint type
  23819. */
  23820. static DistanceJoint: number;
  23821. /**
  23822. * Hinge-Joint type
  23823. */
  23824. static HingeJoint: number;
  23825. /**
  23826. * Ball-and-Socket joint type
  23827. */
  23828. static BallAndSocketJoint: number;
  23829. /**
  23830. * Wheel-Joint type
  23831. */
  23832. static WheelJoint: number;
  23833. /**
  23834. * Slider-Joint type
  23835. */
  23836. static SliderJoint: number;
  23837. /**
  23838. * Prismatic-Joint type
  23839. */
  23840. static PrismaticJoint: number;
  23841. /**
  23842. * Universal-Joint type
  23843. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23844. */
  23845. static UniversalJoint: number;
  23846. /**
  23847. * Hinge-Joint 2 type
  23848. */
  23849. static Hinge2Joint: number;
  23850. /**
  23851. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23852. */
  23853. static PointToPointJoint: number;
  23854. /**
  23855. * Spring-Joint type
  23856. */
  23857. static SpringJoint: number;
  23858. /**
  23859. * Lock-Joint type
  23860. */
  23861. static LockJoint: number;
  23862. }
  23863. /**
  23864. * A class representing a physics distance joint
  23865. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23866. */
  23867. export class DistanceJoint extends PhysicsJoint {
  23868. /**
  23869. *
  23870. * @param jointData The data for the Distance-Joint
  23871. */
  23872. constructor(jointData: DistanceJointData);
  23873. /**
  23874. * Update the predefined distance.
  23875. * @param maxDistance The maximum preferred distance
  23876. * @param minDistance The minimum preferred distance
  23877. */
  23878. updateDistance(maxDistance: number, minDistance?: number): void;
  23879. }
  23880. /**
  23881. * Represents a Motor-Enabled Joint
  23882. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23883. */
  23884. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23885. /**
  23886. * Initializes the Motor-Enabled Joint
  23887. * @param type The type of the joint
  23888. * @param jointData The physica joint data for the joint
  23889. */
  23890. constructor(type: number, jointData: PhysicsJointData);
  23891. /**
  23892. * Set the motor values.
  23893. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23894. * @param force the force to apply
  23895. * @param maxForce max force for this motor.
  23896. */
  23897. setMotor(force?: number, maxForce?: number): void;
  23898. /**
  23899. * Set the motor's limits.
  23900. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23901. * @param upperLimit The upper limit of the motor
  23902. * @param lowerLimit The lower limit of the motor
  23903. */
  23904. setLimit(upperLimit: number, lowerLimit?: number): void;
  23905. }
  23906. /**
  23907. * This class represents a single physics Hinge-Joint
  23908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23909. */
  23910. export class HingeJoint extends MotorEnabledJoint {
  23911. /**
  23912. * Initializes the Hinge-Joint
  23913. * @param jointData The joint data for the Hinge-Joint
  23914. */
  23915. constructor(jointData: PhysicsJointData);
  23916. /**
  23917. * Set the motor values.
  23918. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23919. * @param {number} force the force to apply
  23920. * @param {number} maxForce max force for this motor.
  23921. */
  23922. setMotor(force?: number, maxForce?: number): void;
  23923. /**
  23924. * Set the motor's limits.
  23925. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23926. * @param upperLimit The upper limit of the motor
  23927. * @param lowerLimit The lower limit of the motor
  23928. */
  23929. setLimit(upperLimit: number, lowerLimit?: number): void;
  23930. }
  23931. /**
  23932. * This class represents a dual hinge physics joint (same as wheel joint)
  23933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23934. */
  23935. export class Hinge2Joint extends MotorEnabledJoint {
  23936. /**
  23937. * Initializes the Hinge2-Joint
  23938. * @param jointData The joint data for the Hinge2-Joint
  23939. */
  23940. constructor(jointData: PhysicsJointData);
  23941. /**
  23942. * Set the motor values.
  23943. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23944. * @param {number} targetSpeed the speed the motor is to reach
  23945. * @param {number} maxForce max force for this motor.
  23946. * @param {motorIndex} the motor's index, 0 or 1.
  23947. */
  23948. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23949. /**
  23950. * Set the motor limits.
  23951. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23952. * @param {number} upperLimit the upper limit
  23953. * @param {number} lowerLimit lower limit
  23954. * @param {motorIndex} the motor's index, 0 or 1.
  23955. */
  23956. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23957. }
  23958. /**
  23959. * Interface for a motor enabled joint
  23960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23961. */
  23962. export interface IMotorEnabledJoint {
  23963. /**
  23964. * Physics joint
  23965. */
  23966. physicsJoint: any;
  23967. /**
  23968. * Sets the motor of the motor-enabled joint
  23969. * @param force The force of the motor
  23970. * @param maxForce The maximum force of the motor
  23971. * @param motorIndex The index of the motor
  23972. */
  23973. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23974. /**
  23975. * Sets the limit of the motor
  23976. * @param upperLimit The upper limit of the motor
  23977. * @param lowerLimit The lower limit of the motor
  23978. * @param motorIndex The index of the motor
  23979. */
  23980. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23981. }
  23982. /**
  23983. * Joint data for a Distance-Joint
  23984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23985. */
  23986. export interface DistanceJointData extends PhysicsJointData {
  23987. /**
  23988. * Max distance the 2 joint objects can be apart
  23989. */
  23990. maxDistance: number;
  23991. }
  23992. /**
  23993. * Joint data from a spring joint
  23994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23995. */
  23996. export interface SpringJointData extends PhysicsJointData {
  23997. /**
  23998. * Length of the spring
  23999. */
  24000. length: number;
  24001. /**
  24002. * Stiffness of the spring
  24003. */
  24004. stiffness: number;
  24005. /**
  24006. * Damping of the spring
  24007. */
  24008. damping: number;
  24009. /** this callback will be called when applying the force to the impostors. */
  24010. forceApplicationCallback: () => void;
  24011. }
  24012. }
  24013. declare module "babylonjs/Physics/physicsRaycastResult" {
  24014. import { Vector3 } from "babylonjs/Maths/math.vector";
  24015. /**
  24016. * Holds the data for the raycast result
  24017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24018. */
  24019. export class PhysicsRaycastResult {
  24020. private _hasHit;
  24021. private _hitDistance;
  24022. private _hitNormalWorld;
  24023. private _hitPointWorld;
  24024. private _rayFromWorld;
  24025. private _rayToWorld;
  24026. /**
  24027. * Gets if there was a hit
  24028. */
  24029. get hasHit(): boolean;
  24030. /**
  24031. * Gets the distance from the hit
  24032. */
  24033. get hitDistance(): number;
  24034. /**
  24035. * Gets the hit normal/direction in the world
  24036. */
  24037. get hitNormalWorld(): Vector3;
  24038. /**
  24039. * Gets the hit point in the world
  24040. */
  24041. get hitPointWorld(): Vector3;
  24042. /**
  24043. * Gets the ray "start point" of the ray in the world
  24044. */
  24045. get rayFromWorld(): Vector3;
  24046. /**
  24047. * Gets the ray "end point" of the ray in the world
  24048. */
  24049. get rayToWorld(): Vector3;
  24050. /**
  24051. * Sets the hit data (normal & point in world space)
  24052. * @param hitNormalWorld defines the normal in world space
  24053. * @param hitPointWorld defines the point in world space
  24054. */
  24055. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24056. /**
  24057. * Sets the distance from the start point to the hit point
  24058. * @param distance
  24059. */
  24060. setHitDistance(distance: number): void;
  24061. /**
  24062. * Calculates the distance manually
  24063. */
  24064. calculateHitDistance(): void;
  24065. /**
  24066. * Resets all the values to default
  24067. * @param from The from point on world space
  24068. * @param to The to point on world space
  24069. */
  24070. reset(from?: Vector3, to?: Vector3): void;
  24071. }
  24072. /**
  24073. * Interface for the size containing width and height
  24074. */
  24075. interface IXYZ {
  24076. /**
  24077. * X
  24078. */
  24079. x: number;
  24080. /**
  24081. * Y
  24082. */
  24083. y: number;
  24084. /**
  24085. * Z
  24086. */
  24087. z: number;
  24088. }
  24089. }
  24090. declare module "babylonjs/Physics/IPhysicsEngine" {
  24091. import { Nullable } from "babylonjs/types";
  24092. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24094. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24095. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24096. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24097. /**
  24098. * Interface used to describe a physics joint
  24099. */
  24100. export interface PhysicsImpostorJoint {
  24101. /** Defines the main impostor to which the joint is linked */
  24102. mainImpostor: PhysicsImpostor;
  24103. /** Defines the impostor that is connected to the main impostor using this joint */
  24104. connectedImpostor: PhysicsImpostor;
  24105. /** Defines the joint itself */
  24106. joint: PhysicsJoint;
  24107. }
  24108. /** @hidden */
  24109. export interface IPhysicsEnginePlugin {
  24110. world: any;
  24111. name: string;
  24112. setGravity(gravity: Vector3): void;
  24113. setTimeStep(timeStep: number): void;
  24114. getTimeStep(): number;
  24115. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24116. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24117. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24118. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24119. removePhysicsBody(impostor: PhysicsImpostor): void;
  24120. generateJoint(joint: PhysicsImpostorJoint): void;
  24121. removeJoint(joint: PhysicsImpostorJoint): void;
  24122. isSupported(): boolean;
  24123. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24124. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24125. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24126. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24127. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24128. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24129. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24130. getBodyMass(impostor: PhysicsImpostor): number;
  24131. getBodyFriction(impostor: PhysicsImpostor): number;
  24132. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24133. getBodyRestitution(impostor: PhysicsImpostor): number;
  24134. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24135. getBodyPressure?(impostor: PhysicsImpostor): number;
  24136. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24137. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24138. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24139. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24140. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24141. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24142. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24143. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24144. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24145. sleepBody(impostor: PhysicsImpostor): void;
  24146. wakeUpBody(impostor: PhysicsImpostor): void;
  24147. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24148. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24149. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24150. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24151. getRadius(impostor: PhysicsImpostor): number;
  24152. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24153. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24154. dispose(): void;
  24155. }
  24156. /**
  24157. * Interface used to define a physics engine
  24158. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24159. */
  24160. export interface IPhysicsEngine {
  24161. /**
  24162. * Gets the gravity vector used by the simulation
  24163. */
  24164. gravity: Vector3;
  24165. /**
  24166. * Sets the gravity vector used by the simulation
  24167. * @param gravity defines the gravity vector to use
  24168. */
  24169. setGravity(gravity: Vector3): void;
  24170. /**
  24171. * Set the time step of the physics engine.
  24172. * Default is 1/60.
  24173. * To slow it down, enter 1/600 for example.
  24174. * To speed it up, 1/30
  24175. * @param newTimeStep the new timestep to apply to this world.
  24176. */
  24177. setTimeStep(newTimeStep: number): void;
  24178. /**
  24179. * Get the time step of the physics engine.
  24180. * @returns the current time step
  24181. */
  24182. getTimeStep(): number;
  24183. /**
  24184. * Set the sub time step of the physics engine.
  24185. * Default is 0 meaning there is no sub steps
  24186. * To increase physics resolution precision, set a small value (like 1 ms)
  24187. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24188. */
  24189. setSubTimeStep(subTimeStep: number): void;
  24190. /**
  24191. * Get the sub time step of the physics engine.
  24192. * @returns the current sub time step
  24193. */
  24194. getSubTimeStep(): number;
  24195. /**
  24196. * Release all resources
  24197. */
  24198. dispose(): void;
  24199. /**
  24200. * Gets the name of the current physics plugin
  24201. * @returns the name of the plugin
  24202. */
  24203. getPhysicsPluginName(): string;
  24204. /**
  24205. * Adding a new impostor for the impostor tracking.
  24206. * This will be done by the impostor itself.
  24207. * @param impostor the impostor to add
  24208. */
  24209. addImpostor(impostor: PhysicsImpostor): void;
  24210. /**
  24211. * Remove an impostor from the engine.
  24212. * This impostor and its mesh will not longer be updated by the physics engine.
  24213. * @param impostor the impostor to remove
  24214. */
  24215. removeImpostor(impostor: PhysicsImpostor): void;
  24216. /**
  24217. * Add a joint to the physics engine
  24218. * @param mainImpostor defines the main impostor to which the joint is added.
  24219. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24220. * @param joint defines the joint that will connect both impostors.
  24221. */
  24222. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24223. /**
  24224. * Removes a joint from the simulation
  24225. * @param mainImpostor defines the impostor used with the joint
  24226. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24227. * @param joint defines the joint to remove
  24228. */
  24229. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24230. /**
  24231. * Gets the current plugin used to run the simulation
  24232. * @returns current plugin
  24233. */
  24234. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24235. /**
  24236. * Gets the list of physic impostors
  24237. * @returns an array of PhysicsImpostor
  24238. */
  24239. getImpostors(): Array<PhysicsImpostor>;
  24240. /**
  24241. * Gets the impostor for a physics enabled object
  24242. * @param object defines the object impersonated by the impostor
  24243. * @returns the PhysicsImpostor or null if not found
  24244. */
  24245. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24246. /**
  24247. * Gets the impostor for a physics body object
  24248. * @param body defines physics body used by the impostor
  24249. * @returns the PhysicsImpostor or null if not found
  24250. */
  24251. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24252. /**
  24253. * Does a raycast in the physics world
  24254. * @param from when should the ray start?
  24255. * @param to when should the ray end?
  24256. * @returns PhysicsRaycastResult
  24257. */
  24258. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24259. /**
  24260. * Called by the scene. No need to call it.
  24261. * @param delta defines the timespam between frames
  24262. */
  24263. _step(delta: number): void;
  24264. }
  24265. }
  24266. declare module "babylonjs/Physics/physicsImpostor" {
  24267. import { Nullable, IndicesArray } from "babylonjs/types";
  24268. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24269. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24271. import { Scene } from "babylonjs/scene";
  24272. import { Bone } from "babylonjs/Bones/bone";
  24273. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24274. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24275. import { Space } from "babylonjs/Maths/math.axis";
  24276. /**
  24277. * The interface for the physics imposter parameters
  24278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24279. */
  24280. export interface PhysicsImpostorParameters {
  24281. /**
  24282. * The mass of the physics imposter
  24283. */
  24284. mass: number;
  24285. /**
  24286. * The friction of the physics imposter
  24287. */
  24288. friction?: number;
  24289. /**
  24290. * The coefficient of restitution of the physics imposter
  24291. */
  24292. restitution?: number;
  24293. /**
  24294. * The native options of the physics imposter
  24295. */
  24296. nativeOptions?: any;
  24297. /**
  24298. * Specifies if the parent should be ignored
  24299. */
  24300. ignoreParent?: boolean;
  24301. /**
  24302. * Specifies if bi-directional transformations should be disabled
  24303. */
  24304. disableBidirectionalTransformation?: boolean;
  24305. /**
  24306. * The pressure inside the physics imposter, soft object only
  24307. */
  24308. pressure?: number;
  24309. /**
  24310. * The stiffness the physics imposter, soft object only
  24311. */
  24312. stiffness?: number;
  24313. /**
  24314. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24315. */
  24316. velocityIterations?: number;
  24317. /**
  24318. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24319. */
  24320. positionIterations?: number;
  24321. /**
  24322. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24323. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24324. * Add to fix multiple points
  24325. */
  24326. fixedPoints?: number;
  24327. /**
  24328. * The collision margin around a soft object
  24329. */
  24330. margin?: number;
  24331. /**
  24332. * The collision margin around a soft object
  24333. */
  24334. damping?: number;
  24335. /**
  24336. * The path for a rope based on an extrusion
  24337. */
  24338. path?: any;
  24339. /**
  24340. * The shape of an extrusion used for a rope based on an extrusion
  24341. */
  24342. shape?: any;
  24343. }
  24344. /**
  24345. * Interface for a physics-enabled object
  24346. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24347. */
  24348. export interface IPhysicsEnabledObject {
  24349. /**
  24350. * The position of the physics-enabled object
  24351. */
  24352. position: Vector3;
  24353. /**
  24354. * The rotation of the physics-enabled object
  24355. */
  24356. rotationQuaternion: Nullable<Quaternion>;
  24357. /**
  24358. * The scale of the physics-enabled object
  24359. */
  24360. scaling: Vector3;
  24361. /**
  24362. * The rotation of the physics-enabled object
  24363. */
  24364. rotation?: Vector3;
  24365. /**
  24366. * The parent of the physics-enabled object
  24367. */
  24368. parent?: any;
  24369. /**
  24370. * The bounding info of the physics-enabled object
  24371. * @returns The bounding info of the physics-enabled object
  24372. */
  24373. getBoundingInfo(): BoundingInfo;
  24374. /**
  24375. * Computes the world matrix
  24376. * @param force Specifies if the world matrix should be computed by force
  24377. * @returns A world matrix
  24378. */
  24379. computeWorldMatrix(force: boolean): Matrix;
  24380. /**
  24381. * Gets the world matrix
  24382. * @returns A world matrix
  24383. */
  24384. getWorldMatrix?(): Matrix;
  24385. /**
  24386. * Gets the child meshes
  24387. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24388. * @returns An array of abstract meshes
  24389. */
  24390. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24391. /**
  24392. * Gets the vertex data
  24393. * @param kind The type of vertex data
  24394. * @returns A nullable array of numbers, or a float32 array
  24395. */
  24396. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24397. /**
  24398. * Gets the indices from the mesh
  24399. * @returns A nullable array of index arrays
  24400. */
  24401. getIndices?(): Nullable<IndicesArray>;
  24402. /**
  24403. * Gets the scene from the mesh
  24404. * @returns the indices array or null
  24405. */
  24406. getScene?(): Scene;
  24407. /**
  24408. * Gets the absolute position from the mesh
  24409. * @returns the absolute position
  24410. */
  24411. getAbsolutePosition(): Vector3;
  24412. /**
  24413. * Gets the absolute pivot point from the mesh
  24414. * @returns the absolute pivot point
  24415. */
  24416. getAbsolutePivotPoint(): Vector3;
  24417. /**
  24418. * Rotates the mesh
  24419. * @param axis The axis of rotation
  24420. * @param amount The amount of rotation
  24421. * @param space The space of the rotation
  24422. * @returns The rotation transform node
  24423. */
  24424. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24425. /**
  24426. * Translates the mesh
  24427. * @param axis The axis of translation
  24428. * @param distance The distance of translation
  24429. * @param space The space of the translation
  24430. * @returns The transform node
  24431. */
  24432. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24433. /**
  24434. * Sets the absolute position of the mesh
  24435. * @param absolutePosition The absolute position of the mesh
  24436. * @returns The transform node
  24437. */
  24438. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24439. /**
  24440. * Gets the class name of the mesh
  24441. * @returns The class name
  24442. */
  24443. getClassName(): string;
  24444. }
  24445. /**
  24446. * Represents a physics imposter
  24447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24448. */
  24449. export class PhysicsImpostor {
  24450. /**
  24451. * The physics-enabled object used as the physics imposter
  24452. */
  24453. object: IPhysicsEnabledObject;
  24454. /**
  24455. * The type of the physics imposter
  24456. */
  24457. type: number;
  24458. private _options;
  24459. private _scene?;
  24460. /**
  24461. * The default object size of the imposter
  24462. */
  24463. static DEFAULT_OBJECT_SIZE: Vector3;
  24464. /**
  24465. * The identity quaternion of the imposter
  24466. */
  24467. static IDENTITY_QUATERNION: Quaternion;
  24468. /** @hidden */
  24469. _pluginData: any;
  24470. private _physicsEngine;
  24471. private _physicsBody;
  24472. private _bodyUpdateRequired;
  24473. private _onBeforePhysicsStepCallbacks;
  24474. private _onAfterPhysicsStepCallbacks;
  24475. /** @hidden */
  24476. _onPhysicsCollideCallbacks: Array<{
  24477. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24478. otherImpostors: Array<PhysicsImpostor>;
  24479. }>;
  24480. private _deltaPosition;
  24481. private _deltaRotation;
  24482. private _deltaRotationConjugated;
  24483. /** @hidden */
  24484. _isFromLine: boolean;
  24485. private _parent;
  24486. private _isDisposed;
  24487. private static _tmpVecs;
  24488. private static _tmpQuat;
  24489. /**
  24490. * Specifies if the physics imposter is disposed
  24491. */
  24492. get isDisposed(): boolean;
  24493. /**
  24494. * Gets the mass of the physics imposter
  24495. */
  24496. get mass(): number;
  24497. set mass(value: number);
  24498. /**
  24499. * Gets the coefficient of friction
  24500. */
  24501. get friction(): number;
  24502. /**
  24503. * Sets the coefficient of friction
  24504. */
  24505. set friction(value: number);
  24506. /**
  24507. * Gets the coefficient of restitution
  24508. */
  24509. get restitution(): number;
  24510. /**
  24511. * Sets the coefficient of restitution
  24512. */
  24513. set restitution(value: number);
  24514. /**
  24515. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24516. */
  24517. get pressure(): number;
  24518. /**
  24519. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24520. */
  24521. set pressure(value: number);
  24522. /**
  24523. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24524. */
  24525. get stiffness(): number;
  24526. /**
  24527. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24528. */
  24529. set stiffness(value: number);
  24530. /**
  24531. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24532. */
  24533. get velocityIterations(): number;
  24534. /**
  24535. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24536. */
  24537. set velocityIterations(value: number);
  24538. /**
  24539. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24540. */
  24541. get positionIterations(): number;
  24542. /**
  24543. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24544. */
  24545. set positionIterations(value: number);
  24546. /**
  24547. * The unique id of the physics imposter
  24548. * set by the physics engine when adding this impostor to the array
  24549. */
  24550. uniqueId: number;
  24551. /**
  24552. * @hidden
  24553. */
  24554. soft: boolean;
  24555. /**
  24556. * @hidden
  24557. */
  24558. segments: number;
  24559. private _joints;
  24560. /**
  24561. * Initializes the physics imposter
  24562. * @param object The physics-enabled object used as the physics imposter
  24563. * @param type The type of the physics imposter
  24564. * @param _options The options for the physics imposter
  24565. * @param _scene The Babylon scene
  24566. */
  24567. constructor(
  24568. /**
  24569. * The physics-enabled object used as the physics imposter
  24570. */
  24571. object: IPhysicsEnabledObject,
  24572. /**
  24573. * The type of the physics imposter
  24574. */
  24575. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24576. /**
  24577. * This function will completly initialize this impostor.
  24578. * It will create a new body - but only if this mesh has no parent.
  24579. * If it has, this impostor will not be used other than to define the impostor
  24580. * of the child mesh.
  24581. * @hidden
  24582. */
  24583. _init(): void;
  24584. private _getPhysicsParent;
  24585. /**
  24586. * Should a new body be generated.
  24587. * @returns boolean specifying if body initialization is required
  24588. */
  24589. isBodyInitRequired(): boolean;
  24590. /**
  24591. * Sets the updated scaling
  24592. * @param updated Specifies if the scaling is updated
  24593. */
  24594. setScalingUpdated(): void;
  24595. /**
  24596. * Force a regeneration of this or the parent's impostor's body.
  24597. * Use under cautious - This will remove all joints already implemented.
  24598. */
  24599. forceUpdate(): void;
  24600. /**
  24601. * Gets the body that holds this impostor. Either its own, or its parent.
  24602. */
  24603. get physicsBody(): any;
  24604. /**
  24605. * Get the parent of the physics imposter
  24606. * @returns Physics imposter or null
  24607. */
  24608. get parent(): Nullable<PhysicsImpostor>;
  24609. /**
  24610. * Sets the parent of the physics imposter
  24611. */
  24612. set parent(value: Nullable<PhysicsImpostor>);
  24613. /**
  24614. * Set the physics body. Used mainly by the physics engine/plugin
  24615. */
  24616. set physicsBody(physicsBody: any);
  24617. /**
  24618. * Resets the update flags
  24619. */
  24620. resetUpdateFlags(): void;
  24621. /**
  24622. * Gets the object extend size
  24623. * @returns the object extend size
  24624. */
  24625. getObjectExtendSize(): Vector3;
  24626. /**
  24627. * Gets the object center
  24628. * @returns The object center
  24629. */
  24630. getObjectCenter(): Vector3;
  24631. /**
  24632. * Get a specific parameter from the options parameters
  24633. * @param paramName The object parameter name
  24634. * @returns The object parameter
  24635. */
  24636. getParam(paramName: string): any;
  24637. /**
  24638. * Sets a specific parameter in the options given to the physics plugin
  24639. * @param paramName The parameter name
  24640. * @param value The value of the parameter
  24641. */
  24642. setParam(paramName: string, value: number): void;
  24643. /**
  24644. * Specifically change the body's mass option. Won't recreate the physics body object
  24645. * @param mass The mass of the physics imposter
  24646. */
  24647. setMass(mass: number): void;
  24648. /**
  24649. * Gets the linear velocity
  24650. * @returns linear velocity or null
  24651. */
  24652. getLinearVelocity(): Nullable<Vector3>;
  24653. /**
  24654. * Sets the linear velocity
  24655. * @param velocity linear velocity or null
  24656. */
  24657. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24658. /**
  24659. * Gets the angular velocity
  24660. * @returns angular velocity or null
  24661. */
  24662. getAngularVelocity(): Nullable<Vector3>;
  24663. /**
  24664. * Sets the angular velocity
  24665. * @param velocity The velocity or null
  24666. */
  24667. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24668. /**
  24669. * Execute a function with the physics plugin native code
  24670. * Provide a function the will have two variables - the world object and the physics body object
  24671. * @param func The function to execute with the physics plugin native code
  24672. */
  24673. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24674. /**
  24675. * Register a function that will be executed before the physics world is stepping forward
  24676. * @param func The function to execute before the physics world is stepped forward
  24677. */
  24678. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24679. /**
  24680. * Unregister a function that will be executed before the physics world is stepping forward
  24681. * @param func The function to execute before the physics world is stepped forward
  24682. */
  24683. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24684. /**
  24685. * Register a function that will be executed after the physics step
  24686. * @param func The function to execute after physics step
  24687. */
  24688. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24689. /**
  24690. * Unregisters a function that will be executed after the physics step
  24691. * @param func The function to execute after physics step
  24692. */
  24693. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24694. /**
  24695. * register a function that will be executed when this impostor collides against a different body
  24696. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24697. * @param func Callback that is executed on collision
  24698. */
  24699. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24700. /**
  24701. * Unregisters the physics imposter on contact
  24702. * @param collideAgainst The physics object to collide against
  24703. * @param func Callback to execute on collision
  24704. */
  24705. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24706. private _tmpQuat;
  24707. private _tmpQuat2;
  24708. /**
  24709. * Get the parent rotation
  24710. * @returns The parent rotation
  24711. */
  24712. getParentsRotation(): Quaternion;
  24713. /**
  24714. * this function is executed by the physics engine.
  24715. */
  24716. beforeStep: () => void;
  24717. /**
  24718. * this function is executed by the physics engine
  24719. */
  24720. afterStep: () => void;
  24721. /**
  24722. * Legacy collision detection event support
  24723. */
  24724. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24725. /**
  24726. * event and body object due to cannon's event-based architecture.
  24727. */
  24728. onCollide: (e: {
  24729. body: any;
  24730. }) => void;
  24731. /**
  24732. * Apply a force
  24733. * @param force The force to apply
  24734. * @param contactPoint The contact point for the force
  24735. * @returns The physics imposter
  24736. */
  24737. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24738. /**
  24739. * Apply an impulse
  24740. * @param force The impulse force
  24741. * @param contactPoint The contact point for the impulse force
  24742. * @returns The physics imposter
  24743. */
  24744. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24745. /**
  24746. * A help function to create a joint
  24747. * @param otherImpostor A physics imposter used to create a joint
  24748. * @param jointType The type of joint
  24749. * @param jointData The data for the joint
  24750. * @returns The physics imposter
  24751. */
  24752. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24753. /**
  24754. * Add a joint to this impostor with a different impostor
  24755. * @param otherImpostor A physics imposter used to add a joint
  24756. * @param joint The joint to add
  24757. * @returns The physics imposter
  24758. */
  24759. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24760. /**
  24761. * Add an anchor to a cloth impostor
  24762. * @param otherImpostor rigid impostor to anchor to
  24763. * @param width ratio across width from 0 to 1
  24764. * @param height ratio up height from 0 to 1
  24765. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24766. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24767. * @returns impostor the soft imposter
  24768. */
  24769. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24770. /**
  24771. * Add a hook to a rope impostor
  24772. * @param otherImpostor rigid impostor to anchor to
  24773. * @param length ratio across rope from 0 to 1
  24774. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24775. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24776. * @returns impostor the rope imposter
  24777. */
  24778. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24779. /**
  24780. * Will keep this body still, in a sleep mode.
  24781. * @returns the physics imposter
  24782. */
  24783. sleep(): PhysicsImpostor;
  24784. /**
  24785. * Wake the body up.
  24786. * @returns The physics imposter
  24787. */
  24788. wakeUp(): PhysicsImpostor;
  24789. /**
  24790. * Clones the physics imposter
  24791. * @param newObject The physics imposter clones to this physics-enabled object
  24792. * @returns A nullable physics imposter
  24793. */
  24794. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24795. /**
  24796. * Disposes the physics imposter
  24797. */
  24798. dispose(): void;
  24799. /**
  24800. * Sets the delta position
  24801. * @param position The delta position amount
  24802. */
  24803. setDeltaPosition(position: Vector3): void;
  24804. /**
  24805. * Sets the delta rotation
  24806. * @param rotation The delta rotation amount
  24807. */
  24808. setDeltaRotation(rotation: Quaternion): void;
  24809. /**
  24810. * Gets the box size of the physics imposter and stores the result in the input parameter
  24811. * @param result Stores the box size
  24812. * @returns The physics imposter
  24813. */
  24814. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24815. /**
  24816. * Gets the radius of the physics imposter
  24817. * @returns Radius of the physics imposter
  24818. */
  24819. getRadius(): number;
  24820. /**
  24821. * Sync a bone with this impostor
  24822. * @param bone The bone to sync to the impostor.
  24823. * @param boneMesh The mesh that the bone is influencing.
  24824. * @param jointPivot The pivot of the joint / bone in local space.
  24825. * @param distToJoint Optional distance from the impostor to the joint.
  24826. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24827. */
  24828. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24829. /**
  24830. * Sync impostor to a bone
  24831. * @param bone The bone that the impostor will be synced to.
  24832. * @param boneMesh The mesh that the bone is influencing.
  24833. * @param jointPivot The pivot of the joint / bone in local space.
  24834. * @param distToJoint Optional distance from the impostor to the joint.
  24835. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24836. * @param boneAxis Optional vector3 axis the bone is aligned with
  24837. */
  24838. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24839. /**
  24840. * No-Imposter type
  24841. */
  24842. static NoImpostor: number;
  24843. /**
  24844. * Sphere-Imposter type
  24845. */
  24846. static SphereImpostor: number;
  24847. /**
  24848. * Box-Imposter type
  24849. */
  24850. static BoxImpostor: number;
  24851. /**
  24852. * Plane-Imposter type
  24853. */
  24854. static PlaneImpostor: number;
  24855. /**
  24856. * Mesh-imposter type
  24857. */
  24858. static MeshImpostor: number;
  24859. /**
  24860. * Capsule-Impostor type (Ammo.js plugin only)
  24861. */
  24862. static CapsuleImpostor: number;
  24863. /**
  24864. * Cylinder-Imposter type
  24865. */
  24866. static CylinderImpostor: number;
  24867. /**
  24868. * Particle-Imposter type
  24869. */
  24870. static ParticleImpostor: number;
  24871. /**
  24872. * Heightmap-Imposter type
  24873. */
  24874. static HeightmapImpostor: number;
  24875. /**
  24876. * ConvexHull-Impostor type (Ammo.js plugin only)
  24877. */
  24878. static ConvexHullImpostor: number;
  24879. /**
  24880. * Custom-Imposter type (Ammo.js plugin only)
  24881. */
  24882. static CustomImpostor: number;
  24883. /**
  24884. * Rope-Imposter type
  24885. */
  24886. static RopeImpostor: number;
  24887. /**
  24888. * Cloth-Imposter type
  24889. */
  24890. static ClothImpostor: number;
  24891. /**
  24892. * Softbody-Imposter type
  24893. */
  24894. static SoftbodyImpostor: number;
  24895. }
  24896. }
  24897. declare module "babylonjs/Meshes/mesh" {
  24898. import { Observable } from "babylonjs/Misc/observable";
  24899. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24900. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24901. import { Camera } from "babylonjs/Cameras/camera";
  24902. import { Scene } from "babylonjs/scene";
  24903. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24904. import { Color4 } from "babylonjs/Maths/math.color";
  24905. import { Engine } from "babylonjs/Engines/engine";
  24906. import { Node } from "babylonjs/node";
  24907. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24908. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24909. import { Buffer } from "babylonjs/Meshes/buffer";
  24910. import { Geometry } from "babylonjs/Meshes/geometry";
  24911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24912. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24913. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24914. import { Effect } from "babylonjs/Materials/effect";
  24915. import { Material } from "babylonjs/Materials/material";
  24916. import { Skeleton } from "babylonjs/Bones/skeleton";
  24917. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24918. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24919. import { Path3D } from "babylonjs/Maths/math.path";
  24920. import { Plane } from "babylonjs/Maths/math.plane";
  24921. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24922. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24923. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24924. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24925. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24926. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24927. /**
  24928. * @hidden
  24929. **/
  24930. export class _CreationDataStorage {
  24931. closePath?: boolean;
  24932. closeArray?: boolean;
  24933. idx: number[];
  24934. dashSize: number;
  24935. gapSize: number;
  24936. path3D: Path3D;
  24937. pathArray: Vector3[][];
  24938. arc: number;
  24939. radius: number;
  24940. cap: number;
  24941. tessellation: number;
  24942. }
  24943. /**
  24944. * @hidden
  24945. **/
  24946. class _InstanceDataStorage {
  24947. visibleInstances: any;
  24948. batchCache: _InstancesBatch;
  24949. instancesBufferSize: number;
  24950. instancesBuffer: Nullable<Buffer>;
  24951. instancesData: Float32Array;
  24952. overridenInstanceCount: number;
  24953. isFrozen: boolean;
  24954. previousBatch: Nullable<_InstancesBatch>;
  24955. hardwareInstancedRendering: boolean;
  24956. sideOrientation: number;
  24957. manualUpdate: boolean;
  24958. }
  24959. /**
  24960. * @hidden
  24961. **/
  24962. export class _InstancesBatch {
  24963. mustReturn: boolean;
  24964. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24965. renderSelf: boolean[];
  24966. hardwareInstancedRendering: boolean[];
  24967. }
  24968. /**
  24969. * Class used to represent renderable models
  24970. */
  24971. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24972. /**
  24973. * Mesh side orientation : usually the external or front surface
  24974. */
  24975. static readonly FRONTSIDE: number;
  24976. /**
  24977. * Mesh side orientation : usually the internal or back surface
  24978. */
  24979. static readonly BACKSIDE: number;
  24980. /**
  24981. * Mesh side orientation : both internal and external or front and back surfaces
  24982. */
  24983. static readonly DOUBLESIDE: number;
  24984. /**
  24985. * Mesh side orientation : by default, `FRONTSIDE`
  24986. */
  24987. static readonly DEFAULTSIDE: number;
  24988. /**
  24989. * Mesh cap setting : no cap
  24990. */
  24991. static readonly NO_CAP: number;
  24992. /**
  24993. * Mesh cap setting : one cap at the beginning of the mesh
  24994. */
  24995. static readonly CAP_START: number;
  24996. /**
  24997. * Mesh cap setting : one cap at the end of the mesh
  24998. */
  24999. static readonly CAP_END: number;
  25000. /**
  25001. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25002. */
  25003. static readonly CAP_ALL: number;
  25004. /**
  25005. * Mesh pattern setting : no flip or rotate
  25006. */
  25007. static readonly NO_FLIP: number;
  25008. /**
  25009. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  25010. */
  25011. static readonly FLIP_TILE: number;
  25012. /**
  25013. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  25014. */
  25015. static readonly ROTATE_TILE: number;
  25016. /**
  25017. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25018. */
  25019. static readonly FLIP_ROW: number;
  25020. /**
  25021. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25022. */
  25023. static readonly ROTATE_ROW: number;
  25024. /**
  25025. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25026. */
  25027. static readonly FLIP_N_ROTATE_TILE: number;
  25028. /**
  25029. * Mesh pattern setting : rotate pattern and rotate
  25030. */
  25031. static readonly FLIP_N_ROTATE_ROW: number;
  25032. /**
  25033. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25034. */
  25035. static readonly CENTER: number;
  25036. /**
  25037. * Mesh tile positioning : part tiles on left
  25038. */
  25039. static readonly LEFT: number;
  25040. /**
  25041. * Mesh tile positioning : part tiles on right
  25042. */
  25043. static readonly RIGHT: number;
  25044. /**
  25045. * Mesh tile positioning : part tiles on top
  25046. */
  25047. static readonly TOP: number;
  25048. /**
  25049. * Mesh tile positioning : part tiles on bottom
  25050. */
  25051. static readonly BOTTOM: number;
  25052. /**
  25053. * Gets the default side orientation.
  25054. * @param orientation the orientation to value to attempt to get
  25055. * @returns the default orientation
  25056. * @hidden
  25057. */
  25058. static _GetDefaultSideOrientation(orientation?: number): number;
  25059. private _internalMeshDataInfo;
  25060. /**
  25061. * An event triggered before rendering the mesh
  25062. */
  25063. get onBeforeRenderObservable(): Observable<Mesh>;
  25064. /**
  25065. * An event triggered before binding the mesh
  25066. */
  25067. get onBeforeBindObservable(): Observable<Mesh>;
  25068. /**
  25069. * An event triggered after rendering the mesh
  25070. */
  25071. get onAfterRenderObservable(): Observable<Mesh>;
  25072. /**
  25073. * An event triggered before drawing the mesh
  25074. */
  25075. get onBeforeDrawObservable(): Observable<Mesh>;
  25076. private _onBeforeDrawObserver;
  25077. /**
  25078. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25079. */
  25080. set onBeforeDraw(callback: () => void);
  25081. get hasInstances(): boolean;
  25082. /**
  25083. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25084. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25085. */
  25086. delayLoadState: number;
  25087. /**
  25088. * Gets the list of instances created from this mesh
  25089. * it is not supposed to be modified manually.
  25090. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25091. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25092. */
  25093. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25094. /**
  25095. * Gets the file containing delay loading data for this mesh
  25096. */
  25097. delayLoadingFile: string;
  25098. /** @hidden */
  25099. _binaryInfo: any;
  25100. /**
  25101. * User defined function used to change how LOD level selection is done
  25102. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25103. */
  25104. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25105. /**
  25106. * Gets or sets the morph target manager
  25107. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25108. */
  25109. get morphTargetManager(): Nullable<MorphTargetManager>;
  25110. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25111. /** @hidden */
  25112. _creationDataStorage: Nullable<_CreationDataStorage>;
  25113. /** @hidden */
  25114. _geometry: Nullable<Geometry>;
  25115. /** @hidden */
  25116. _delayInfo: Array<string>;
  25117. /** @hidden */
  25118. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25119. /** @hidden */
  25120. _instanceDataStorage: _InstanceDataStorage;
  25121. private _effectiveMaterial;
  25122. /** @hidden */
  25123. _shouldGenerateFlatShading: boolean;
  25124. /** @hidden */
  25125. _originalBuilderSideOrientation: number;
  25126. /**
  25127. * Use this property to change the original side orientation defined at construction time
  25128. */
  25129. overrideMaterialSideOrientation: Nullable<number>;
  25130. /**
  25131. * Gets the source mesh (the one used to clone this one from)
  25132. */
  25133. get source(): Nullable<Mesh>;
  25134. /**
  25135. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25136. */
  25137. get isUnIndexed(): boolean;
  25138. set isUnIndexed(value: boolean);
  25139. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25140. get worldMatrixInstancedBuffer(): Float32Array;
  25141. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25142. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25143. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25144. /**
  25145. * @constructor
  25146. * @param name The value used by scene.getMeshByName() to do a lookup.
  25147. * @param scene The scene to add this mesh to.
  25148. * @param parent The parent of this mesh, if it has one
  25149. * @param source An optional Mesh from which geometry is shared, cloned.
  25150. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25151. * When false, achieved by calling a clone(), also passing False.
  25152. * This will make creation of children, recursive.
  25153. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25154. */
  25155. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25156. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25157. doNotInstantiate: boolean;
  25158. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25159. /**
  25160. * Gets the class name
  25161. * @returns the string "Mesh".
  25162. */
  25163. getClassName(): string;
  25164. /** @hidden */
  25165. get _isMesh(): boolean;
  25166. /**
  25167. * Returns a description of this mesh
  25168. * @param fullDetails define if full details about this mesh must be used
  25169. * @returns a descriptive string representing this mesh
  25170. */
  25171. toString(fullDetails?: boolean): string;
  25172. /** @hidden */
  25173. _unBindEffect(): void;
  25174. /**
  25175. * Gets a boolean indicating if this mesh has LOD
  25176. */
  25177. get hasLODLevels(): boolean;
  25178. /**
  25179. * Gets the list of MeshLODLevel associated with the current mesh
  25180. * @returns an array of MeshLODLevel
  25181. */
  25182. getLODLevels(): MeshLODLevel[];
  25183. private _sortLODLevels;
  25184. /**
  25185. * Add a mesh as LOD level triggered at the given distance.
  25186. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25187. * @param distance The distance from the center of the object to show this level
  25188. * @param mesh The mesh to be added as LOD level (can be null)
  25189. * @return This mesh (for chaining)
  25190. */
  25191. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25192. /**
  25193. * Returns the LOD level mesh at the passed distance or null if not found.
  25194. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25195. * @param distance The distance from the center of the object to show this level
  25196. * @returns a Mesh or `null`
  25197. */
  25198. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25199. /**
  25200. * Remove a mesh from the LOD array
  25201. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25202. * @param mesh defines the mesh to be removed
  25203. * @return This mesh (for chaining)
  25204. */
  25205. removeLODLevel(mesh: Mesh): Mesh;
  25206. /**
  25207. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25208. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25209. * @param camera defines the camera to use to compute distance
  25210. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25211. * @return This mesh (for chaining)
  25212. */
  25213. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25214. /**
  25215. * Gets the mesh internal Geometry object
  25216. */
  25217. get geometry(): Nullable<Geometry>;
  25218. /**
  25219. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25220. * @returns the total number of vertices
  25221. */
  25222. getTotalVertices(): number;
  25223. /**
  25224. * Returns the content of an associated vertex buffer
  25225. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25226. * - VertexBuffer.PositionKind
  25227. * - VertexBuffer.UVKind
  25228. * - VertexBuffer.UV2Kind
  25229. * - VertexBuffer.UV3Kind
  25230. * - VertexBuffer.UV4Kind
  25231. * - VertexBuffer.UV5Kind
  25232. * - VertexBuffer.UV6Kind
  25233. * - VertexBuffer.ColorKind
  25234. * - VertexBuffer.MatricesIndicesKind
  25235. * - VertexBuffer.MatricesIndicesExtraKind
  25236. * - VertexBuffer.MatricesWeightsKind
  25237. * - VertexBuffer.MatricesWeightsExtraKind
  25238. * @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
  25239. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25240. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25241. */
  25242. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25243. /**
  25244. * Returns the mesh VertexBuffer object from the requested `kind`
  25245. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25246. * - VertexBuffer.PositionKind
  25247. * - VertexBuffer.NormalKind
  25248. * - VertexBuffer.UVKind
  25249. * - VertexBuffer.UV2Kind
  25250. * - VertexBuffer.UV3Kind
  25251. * - VertexBuffer.UV4Kind
  25252. * - VertexBuffer.UV5Kind
  25253. * - VertexBuffer.UV6Kind
  25254. * - VertexBuffer.ColorKind
  25255. * - VertexBuffer.MatricesIndicesKind
  25256. * - VertexBuffer.MatricesIndicesExtraKind
  25257. * - VertexBuffer.MatricesWeightsKind
  25258. * - VertexBuffer.MatricesWeightsExtraKind
  25259. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25260. */
  25261. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25262. /**
  25263. * Tests if a specific vertex buffer is associated with this mesh
  25264. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25265. * - VertexBuffer.PositionKind
  25266. * - VertexBuffer.NormalKind
  25267. * - VertexBuffer.UVKind
  25268. * - VertexBuffer.UV2Kind
  25269. * - VertexBuffer.UV3Kind
  25270. * - VertexBuffer.UV4Kind
  25271. * - VertexBuffer.UV5Kind
  25272. * - VertexBuffer.UV6Kind
  25273. * - VertexBuffer.ColorKind
  25274. * - VertexBuffer.MatricesIndicesKind
  25275. * - VertexBuffer.MatricesIndicesExtraKind
  25276. * - VertexBuffer.MatricesWeightsKind
  25277. * - VertexBuffer.MatricesWeightsExtraKind
  25278. * @returns a boolean
  25279. */
  25280. isVerticesDataPresent(kind: string): boolean;
  25281. /**
  25282. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25283. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25284. * - VertexBuffer.PositionKind
  25285. * - VertexBuffer.UVKind
  25286. * - VertexBuffer.UV2Kind
  25287. * - VertexBuffer.UV3Kind
  25288. * - VertexBuffer.UV4Kind
  25289. * - VertexBuffer.UV5Kind
  25290. * - VertexBuffer.UV6Kind
  25291. * - VertexBuffer.ColorKind
  25292. * - VertexBuffer.MatricesIndicesKind
  25293. * - VertexBuffer.MatricesIndicesExtraKind
  25294. * - VertexBuffer.MatricesWeightsKind
  25295. * - VertexBuffer.MatricesWeightsExtraKind
  25296. * @returns a boolean
  25297. */
  25298. isVertexBufferUpdatable(kind: string): boolean;
  25299. /**
  25300. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25301. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25302. * - VertexBuffer.PositionKind
  25303. * - VertexBuffer.NormalKind
  25304. * - VertexBuffer.UVKind
  25305. * - VertexBuffer.UV2Kind
  25306. * - VertexBuffer.UV3Kind
  25307. * - VertexBuffer.UV4Kind
  25308. * - VertexBuffer.UV5Kind
  25309. * - VertexBuffer.UV6Kind
  25310. * - VertexBuffer.ColorKind
  25311. * - VertexBuffer.MatricesIndicesKind
  25312. * - VertexBuffer.MatricesIndicesExtraKind
  25313. * - VertexBuffer.MatricesWeightsKind
  25314. * - VertexBuffer.MatricesWeightsExtraKind
  25315. * @returns an array of strings
  25316. */
  25317. getVerticesDataKinds(): string[];
  25318. /**
  25319. * Returns a positive integer : the total number of indices in this mesh geometry.
  25320. * @returns the numner of indices or zero if the mesh has no geometry.
  25321. */
  25322. getTotalIndices(): number;
  25323. /**
  25324. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25325. * @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.
  25326. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25327. * @returns the indices array or an empty array if the mesh has no geometry
  25328. */
  25329. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25330. get isBlocked(): boolean;
  25331. /**
  25332. * Determine if the current mesh is ready to be rendered
  25333. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25334. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25335. * @returns true if all associated assets are ready (material, textures, shaders)
  25336. */
  25337. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25338. /**
  25339. * 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.
  25340. */
  25341. get areNormalsFrozen(): boolean;
  25342. /**
  25343. * 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.
  25344. * @returns the current mesh
  25345. */
  25346. freezeNormals(): Mesh;
  25347. /**
  25348. * 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
  25349. * @returns the current mesh
  25350. */
  25351. unfreezeNormals(): Mesh;
  25352. /**
  25353. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25354. */
  25355. set overridenInstanceCount(count: number);
  25356. /** @hidden */
  25357. _preActivate(): Mesh;
  25358. /** @hidden */
  25359. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25360. /** @hidden */
  25361. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25362. /**
  25363. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25364. * This means the mesh underlying bounding box and sphere are recomputed.
  25365. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25366. * @returns the current mesh
  25367. */
  25368. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25369. /** @hidden */
  25370. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25371. /**
  25372. * This function will subdivide the mesh into multiple submeshes
  25373. * @param count defines the expected number of submeshes
  25374. */
  25375. subdivide(count: number): void;
  25376. /**
  25377. * Copy a FloatArray into a specific associated vertex buffer
  25378. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25379. * - VertexBuffer.PositionKind
  25380. * - VertexBuffer.UVKind
  25381. * - VertexBuffer.UV2Kind
  25382. * - VertexBuffer.UV3Kind
  25383. * - VertexBuffer.UV4Kind
  25384. * - VertexBuffer.UV5Kind
  25385. * - VertexBuffer.UV6Kind
  25386. * - VertexBuffer.ColorKind
  25387. * - VertexBuffer.MatricesIndicesKind
  25388. * - VertexBuffer.MatricesIndicesExtraKind
  25389. * - VertexBuffer.MatricesWeightsKind
  25390. * - VertexBuffer.MatricesWeightsExtraKind
  25391. * @param data defines the data source
  25392. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25393. * @param stride defines the data stride size (can be null)
  25394. * @returns the current mesh
  25395. */
  25396. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25397. /**
  25398. * Delete a vertex buffer associated with this mesh
  25399. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25400. * - VertexBuffer.PositionKind
  25401. * - VertexBuffer.UVKind
  25402. * - VertexBuffer.UV2Kind
  25403. * - VertexBuffer.UV3Kind
  25404. * - VertexBuffer.UV4Kind
  25405. * - VertexBuffer.UV5Kind
  25406. * - VertexBuffer.UV6Kind
  25407. * - VertexBuffer.ColorKind
  25408. * - VertexBuffer.MatricesIndicesKind
  25409. * - VertexBuffer.MatricesIndicesExtraKind
  25410. * - VertexBuffer.MatricesWeightsKind
  25411. * - VertexBuffer.MatricesWeightsExtraKind
  25412. */
  25413. removeVerticesData(kind: string): void;
  25414. /**
  25415. * Flags an associated vertex buffer as updatable
  25416. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25417. * - VertexBuffer.PositionKind
  25418. * - VertexBuffer.UVKind
  25419. * - VertexBuffer.UV2Kind
  25420. * - VertexBuffer.UV3Kind
  25421. * - VertexBuffer.UV4Kind
  25422. * - VertexBuffer.UV5Kind
  25423. * - VertexBuffer.UV6Kind
  25424. * - VertexBuffer.ColorKind
  25425. * - VertexBuffer.MatricesIndicesKind
  25426. * - VertexBuffer.MatricesIndicesExtraKind
  25427. * - VertexBuffer.MatricesWeightsKind
  25428. * - VertexBuffer.MatricesWeightsExtraKind
  25429. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25430. */
  25431. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25432. /**
  25433. * Sets the mesh global Vertex Buffer
  25434. * @param buffer defines the buffer to use
  25435. * @returns the current mesh
  25436. */
  25437. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25438. /**
  25439. * Update a specific associated vertex buffer
  25440. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25441. * - VertexBuffer.PositionKind
  25442. * - VertexBuffer.UVKind
  25443. * - VertexBuffer.UV2Kind
  25444. * - VertexBuffer.UV3Kind
  25445. * - VertexBuffer.UV4Kind
  25446. * - VertexBuffer.UV5Kind
  25447. * - VertexBuffer.UV6Kind
  25448. * - VertexBuffer.ColorKind
  25449. * - VertexBuffer.MatricesIndicesKind
  25450. * - VertexBuffer.MatricesIndicesExtraKind
  25451. * - VertexBuffer.MatricesWeightsKind
  25452. * - VertexBuffer.MatricesWeightsExtraKind
  25453. * @param data defines the data source
  25454. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25455. * @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)
  25456. * @returns the current mesh
  25457. */
  25458. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25459. /**
  25460. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25461. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25462. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25463. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25464. * @returns the current mesh
  25465. */
  25466. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25467. /**
  25468. * Creates a un-shared specific occurence of the geometry for the mesh.
  25469. * @returns the current mesh
  25470. */
  25471. makeGeometryUnique(): Mesh;
  25472. /**
  25473. * Set the index buffer of this mesh
  25474. * @param indices defines the source data
  25475. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25476. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25477. * @returns the current mesh
  25478. */
  25479. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25480. /**
  25481. * Update the current index buffer
  25482. * @param indices defines the source data
  25483. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25484. * @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)
  25485. * @returns the current mesh
  25486. */
  25487. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25488. /**
  25489. * Invert the geometry to move from a right handed system to a left handed one.
  25490. * @returns the current mesh
  25491. */
  25492. toLeftHanded(): Mesh;
  25493. /** @hidden */
  25494. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25495. /** @hidden */
  25496. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25497. /**
  25498. * Registers for this mesh a javascript function called just before the rendering process
  25499. * @param func defines the function to call before rendering this mesh
  25500. * @returns the current mesh
  25501. */
  25502. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25503. /**
  25504. * Disposes a previously registered javascript function called before the rendering
  25505. * @param func defines the function to remove
  25506. * @returns the current mesh
  25507. */
  25508. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25509. /**
  25510. * Registers for this mesh a javascript function called just after the rendering is complete
  25511. * @param func defines the function to call after rendering this mesh
  25512. * @returns the current mesh
  25513. */
  25514. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25515. /**
  25516. * Disposes a previously registered javascript function called after the rendering.
  25517. * @param func defines the function to remove
  25518. * @returns the current mesh
  25519. */
  25520. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25521. /** @hidden */
  25522. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25523. /** @hidden */
  25524. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25525. /** @hidden */
  25526. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25527. /** @hidden */
  25528. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25529. /** @hidden */
  25530. _rebuild(): void;
  25531. /** @hidden */
  25532. _freeze(): void;
  25533. /** @hidden */
  25534. _unFreeze(): void;
  25535. /**
  25536. * 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
  25537. * @param subMesh defines the subMesh to render
  25538. * @param enableAlphaMode defines if alpha mode can be changed
  25539. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25540. * @returns the current mesh
  25541. */
  25542. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25543. private _onBeforeDraw;
  25544. /**
  25545. * Renormalize the mesh and patch it up if there are no weights
  25546. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25547. * However in the case of zero weights then we set just a single influence to 1.
  25548. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25549. */
  25550. cleanMatrixWeights(): void;
  25551. private normalizeSkinFourWeights;
  25552. private normalizeSkinWeightsAndExtra;
  25553. /**
  25554. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25555. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25556. * the user know there was an issue with importing the mesh
  25557. * @returns a validation object with skinned, valid and report string
  25558. */
  25559. validateSkinning(): {
  25560. skinned: boolean;
  25561. valid: boolean;
  25562. report: string;
  25563. };
  25564. /** @hidden */
  25565. _checkDelayState(): Mesh;
  25566. private _queueLoad;
  25567. /**
  25568. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25569. * A mesh is in the frustum if its bounding box intersects the frustum
  25570. * @param frustumPlanes defines the frustum to test
  25571. * @returns true if the mesh is in the frustum planes
  25572. */
  25573. isInFrustum(frustumPlanes: Plane[]): boolean;
  25574. /**
  25575. * Sets the mesh material by the material or multiMaterial `id` property
  25576. * @param id is a string identifying the material or the multiMaterial
  25577. * @returns the current mesh
  25578. */
  25579. setMaterialByID(id: string): Mesh;
  25580. /**
  25581. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25582. * @returns an array of IAnimatable
  25583. */
  25584. getAnimatables(): IAnimatable[];
  25585. /**
  25586. * Modifies the mesh geometry according to the passed transformation matrix.
  25587. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25588. * The mesh normals are modified using the same transformation.
  25589. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25590. * @param transform defines the transform matrix to use
  25591. * @see http://doc.babylonjs.com/resources/baking_transformations
  25592. * @returns the current mesh
  25593. */
  25594. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25595. /**
  25596. * Modifies the mesh geometry according to its own current World Matrix.
  25597. * The mesh World Matrix is then reset.
  25598. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25599. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25600. * @see http://doc.babylonjs.com/resources/baking_transformations
  25601. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25602. * @returns the current mesh
  25603. */
  25604. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25605. /** @hidden */
  25606. get _positions(): Nullable<Vector3[]>;
  25607. /** @hidden */
  25608. _resetPointsArrayCache(): Mesh;
  25609. /** @hidden */
  25610. _generatePointsArray(): boolean;
  25611. /**
  25612. * Returns a new Mesh object generated from the current mesh properties.
  25613. * This method must not get confused with createInstance()
  25614. * @param name is a string, the name given to the new mesh
  25615. * @param newParent can be any Node object (default `null`)
  25616. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25617. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25618. * @returns a new mesh
  25619. */
  25620. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25621. /**
  25622. * Releases resources associated with this mesh.
  25623. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25624. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25625. */
  25626. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25627. /** @hidden */
  25628. _disposeInstanceSpecificData(): void;
  25629. /**
  25630. * Modifies the mesh geometry according to a displacement map.
  25631. * 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.
  25632. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25633. * @param url is a string, the URL from the image file is to be downloaded.
  25634. * @param minHeight is the lower limit of the displacement.
  25635. * @param maxHeight is the upper limit of the displacement.
  25636. * @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.
  25637. * @param uvOffset is an optional vector2 used to offset UV.
  25638. * @param uvScale is an optional vector2 used to scale UV.
  25639. * @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.
  25640. * @returns the Mesh.
  25641. */
  25642. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25643. /**
  25644. * Modifies the mesh geometry according to a displacementMap buffer.
  25645. * 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.
  25646. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25647. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25648. * @param heightMapWidth is the width of the buffer image.
  25649. * @param heightMapHeight is the height of the buffer image.
  25650. * @param minHeight is the lower limit of the displacement.
  25651. * @param maxHeight is the upper limit of the displacement.
  25652. * @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.
  25653. * @param uvOffset is an optional vector2 used to offset UV.
  25654. * @param uvScale is an optional vector2 used to scale UV.
  25655. * @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.
  25656. * @returns the Mesh.
  25657. */
  25658. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25659. /**
  25660. * Modify the mesh to get a flat shading rendering.
  25661. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25662. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25663. * @returns current mesh
  25664. */
  25665. convertToFlatShadedMesh(): Mesh;
  25666. /**
  25667. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25668. * In other words, more vertices, no more indices and a single bigger VBO.
  25669. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25670. * @returns current mesh
  25671. */
  25672. convertToUnIndexedMesh(): Mesh;
  25673. /**
  25674. * Inverses facet orientations.
  25675. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25676. * @param flipNormals will also inverts the normals
  25677. * @returns current mesh
  25678. */
  25679. flipFaces(flipNormals?: boolean): Mesh;
  25680. /**
  25681. * Increase the number of facets and hence vertices in a mesh
  25682. * Vertex normals are interpolated from existing vertex normals
  25683. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25684. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25685. */
  25686. increaseVertices(numberPerEdge: number): void;
  25687. /**
  25688. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25689. * This will undo any application of covertToFlatShadedMesh
  25690. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25691. */
  25692. forceSharedVertices(): void;
  25693. /** @hidden */
  25694. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25695. /** @hidden */
  25696. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25697. /**
  25698. * Creates a new InstancedMesh object from the mesh model.
  25699. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25700. * @param name defines the name of the new instance
  25701. * @returns a new InstancedMesh
  25702. */
  25703. createInstance(name: string): InstancedMesh;
  25704. /**
  25705. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25706. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25707. * @returns the current mesh
  25708. */
  25709. synchronizeInstances(): Mesh;
  25710. /**
  25711. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25712. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25713. * This should be used together with the simplification to avoid disappearing triangles.
  25714. * @param successCallback an optional success callback to be called after the optimization finished.
  25715. * @returns the current mesh
  25716. */
  25717. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25718. /**
  25719. * Serialize current mesh
  25720. * @param serializationObject defines the object which will receive the serialization data
  25721. */
  25722. serialize(serializationObject: any): void;
  25723. /** @hidden */
  25724. _syncGeometryWithMorphTargetManager(): void;
  25725. /** @hidden */
  25726. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25727. /**
  25728. * Returns a new Mesh object parsed from the source provided.
  25729. * @param parsedMesh is the source
  25730. * @param scene defines the hosting scene
  25731. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25732. * @returns a new Mesh
  25733. */
  25734. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25735. /**
  25736. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25737. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25738. * @param name defines the name of the mesh to create
  25739. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25740. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25741. * @param closePath creates a seam between the first and the last points of each path of the path array
  25742. * @param offset is taken in account only if the `pathArray` is containing a single path
  25743. * @param scene defines the hosting scene
  25744. * @param updatable defines if the mesh must be flagged as updatable
  25745. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25746. * @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)
  25747. * @returns a new Mesh
  25748. */
  25749. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25750. /**
  25751. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25752. * @param name defines the name of the mesh to create
  25753. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25754. * @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
  25755. * @param scene defines the hosting scene
  25756. * @param updatable defines if the mesh must be flagged as updatable
  25757. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25758. * @returns a new Mesh
  25759. */
  25760. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25761. /**
  25762. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25763. * @param name defines the name of the mesh to create
  25764. * @param size sets the size (float) of each box side (default 1)
  25765. * @param scene defines the hosting scene
  25766. * @param updatable defines if the mesh must be flagged as updatable
  25767. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25768. * @returns a new Mesh
  25769. */
  25770. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25771. /**
  25772. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25773. * @param name defines the name of the mesh to create
  25774. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25775. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25776. * @param scene defines the hosting scene
  25777. * @param updatable defines if the mesh must be flagged as updatable
  25778. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25779. * @returns a new Mesh
  25780. */
  25781. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25782. /**
  25783. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25784. * @param name defines the name of the mesh to create
  25785. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25786. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25787. * @param scene defines the hosting scene
  25788. * @returns a new Mesh
  25789. */
  25790. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25791. /**
  25792. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25793. * @param name defines the name of the mesh to create
  25794. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25795. * @param diameterTop set the top cap diameter (floats, default 1)
  25796. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25797. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25798. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25799. * @param scene defines the hosting scene
  25800. * @param updatable defines if the mesh must be flagged as updatable
  25801. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25802. * @returns a new Mesh
  25803. */
  25804. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25805. /**
  25806. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25807. * @param name defines the name of the mesh to create
  25808. * @param diameter sets the diameter size (float) of the torus (default 1)
  25809. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25810. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25811. * @param scene defines the hosting scene
  25812. * @param updatable defines if the mesh must be flagged as updatable
  25813. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25814. * @returns a new Mesh
  25815. */
  25816. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25817. /**
  25818. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25819. * @param name defines the name of the mesh to create
  25820. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25821. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25822. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25823. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25824. * @param p the number of windings on X axis (positive integers, default 2)
  25825. * @param q the number of windings on Y axis (positive integers, default 3)
  25826. * @param scene defines the hosting scene
  25827. * @param updatable defines if the mesh must be flagged as updatable
  25828. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25829. * @returns a new Mesh
  25830. */
  25831. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25832. /**
  25833. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25834. * @param name defines the name of the mesh to create
  25835. * @param points is an array successive Vector3
  25836. * @param scene defines the hosting scene
  25837. * @param updatable defines if the mesh must be flagged as updatable
  25838. * @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).
  25839. * @returns a new Mesh
  25840. */
  25841. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25842. /**
  25843. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25844. * @param name defines the name of the mesh to create
  25845. * @param points is an array successive Vector3
  25846. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25847. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25848. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25849. * @param scene defines the hosting scene
  25850. * @param updatable defines if the mesh must be flagged as updatable
  25851. * @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)
  25852. * @returns a new Mesh
  25853. */
  25854. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25855. /**
  25856. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25857. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25858. * 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.
  25859. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25860. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25861. * Remember you can only change the shape positions, not their number when updating a polygon.
  25862. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25863. * @param name defines the name of the mesh to create
  25864. * @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
  25865. * @param scene defines the hosting scene
  25866. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25867. * @param updatable defines if the mesh must be flagged as updatable
  25868. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25869. * @param earcutInjection can be used to inject your own earcut reference
  25870. * @returns a new Mesh
  25871. */
  25872. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25873. /**
  25874. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25875. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25876. * @param name defines the name of the mesh to create
  25877. * @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
  25878. * @param depth defines the height of extrusion
  25879. * @param scene defines the hosting scene
  25880. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25881. * @param updatable defines if the mesh must be flagged as updatable
  25882. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25883. * @param earcutInjection can be used to inject your own earcut reference
  25884. * @returns a new Mesh
  25885. */
  25886. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25887. /**
  25888. * Creates an extruded shape mesh.
  25889. * 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
  25890. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25891. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25892. * @param name defines the name of the mesh to create
  25893. * @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
  25894. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25895. * @param scale is the value to scale the shape
  25896. * @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
  25897. * @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
  25898. * @param scene defines the hosting scene
  25899. * @param updatable defines if the mesh must be flagged as updatable
  25900. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25901. * @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)
  25902. * @returns a new Mesh
  25903. */
  25904. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25905. /**
  25906. * Creates an custom extruded shape mesh.
  25907. * The custom extrusion is a parametric shape.
  25908. * It has no predefined shape. Its final shape will depend on the input parameters.
  25909. * Please consider using the same method from the MeshBuilder class instead
  25910. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25911. * @param name defines the name of the mesh to create
  25912. * @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
  25913. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25914. * @param scaleFunction is a custom Javascript function called on each path point
  25915. * @param rotationFunction is a custom Javascript function called on each path point
  25916. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25917. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25918. * @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
  25919. * @param scene defines the hosting scene
  25920. * @param updatable defines if the mesh must be flagged as updatable
  25921. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25922. * @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)
  25923. * @returns a new Mesh
  25924. */
  25925. 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;
  25926. /**
  25927. * Creates lathe mesh.
  25928. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25929. * Please consider using the same method from the MeshBuilder class instead
  25930. * @param name defines the name of the mesh to create
  25931. * @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
  25932. * @param radius is the radius value of the lathe
  25933. * @param tessellation is the side number of the lathe.
  25934. * @param scene defines the hosting scene
  25935. * @param updatable defines if the mesh must be flagged as updatable
  25936. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25937. * @returns a new Mesh
  25938. */
  25939. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25940. /**
  25941. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25942. * @param name defines the name of the mesh to create
  25943. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25944. * @param scene defines the hosting scene
  25945. * @param updatable defines if the mesh must be flagged as updatable
  25946. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25947. * @returns a new Mesh
  25948. */
  25949. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25950. /**
  25951. * Creates a ground mesh.
  25952. * Please consider using the same method from the MeshBuilder class instead
  25953. * @param name defines the name of the mesh to create
  25954. * @param width set the width of the ground
  25955. * @param height set the height of the ground
  25956. * @param subdivisions sets the number of subdivisions per side
  25957. * @param scene defines the hosting scene
  25958. * @param updatable defines if the mesh must be flagged as updatable
  25959. * @returns a new Mesh
  25960. */
  25961. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25962. /**
  25963. * Creates a tiled ground mesh.
  25964. * Please consider using the same method from the MeshBuilder class instead
  25965. * @param name defines the name of the mesh to create
  25966. * @param xmin set the ground minimum X coordinate
  25967. * @param zmin set the ground minimum Y coordinate
  25968. * @param xmax set the ground maximum X coordinate
  25969. * @param zmax set the ground maximum Z coordinate
  25970. * @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
  25971. * @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
  25972. * @param scene defines the hosting scene
  25973. * @param updatable defines if the mesh must be flagged as updatable
  25974. * @returns a new Mesh
  25975. */
  25976. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25977. w: number;
  25978. h: number;
  25979. }, precision: {
  25980. w: number;
  25981. h: number;
  25982. }, scene: Scene, updatable?: boolean): Mesh;
  25983. /**
  25984. * Creates a ground mesh from a height map.
  25985. * Please consider using the same method from the MeshBuilder class instead
  25986. * @see http://doc.babylonjs.com/babylon101/height_map
  25987. * @param name defines the name of the mesh to create
  25988. * @param url sets the URL of the height map image resource
  25989. * @param width set the ground width size
  25990. * @param height set the ground height size
  25991. * @param subdivisions sets the number of subdivision per side
  25992. * @param minHeight is the minimum altitude on the ground
  25993. * @param maxHeight is the maximum altitude on the ground
  25994. * @param scene defines the hosting scene
  25995. * @param updatable defines if the mesh must be flagged as updatable
  25996. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25997. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25998. * @returns a new Mesh
  25999. */
  26000. 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;
  26001. /**
  26002. * Creates a tube mesh.
  26003. * The tube is a parametric shape.
  26004. * It has no predefined shape. Its final shape will depend on the input parameters.
  26005. * Please consider using the same method from the MeshBuilder class instead
  26006. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26007. * @param name defines the name of the mesh to create
  26008. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26009. * @param radius sets the tube radius size
  26010. * @param tessellation is the number of sides on the tubular surface
  26011. * @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
  26012. * @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
  26013. * @param scene defines the hosting scene
  26014. * @param updatable defines if the mesh must be flagged as updatable
  26015. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26016. * @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)
  26017. * @returns a new Mesh
  26018. */
  26019. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26020. (i: number, distance: number): number;
  26021. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26022. /**
  26023. * Creates a polyhedron mesh.
  26024. * Please consider using the same method from the MeshBuilder class instead.
  26025. * * 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
  26026. * * The parameter `size` (positive float, default 1) sets the polygon size
  26027. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26028. * * 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`
  26029. * * 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
  26030. * * 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)`)
  26031. * * 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
  26032. * * 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
  26033. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26034. * * If you create a double-sided mesh, you can choose what parts of 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
  26035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26036. * @param name defines the name of the mesh to create
  26037. * @param options defines the options used to create the mesh
  26038. * @param scene defines the hosting scene
  26039. * @returns a new Mesh
  26040. */
  26041. static CreatePolyhedron(name: string, options: {
  26042. type?: number;
  26043. size?: number;
  26044. sizeX?: number;
  26045. sizeY?: number;
  26046. sizeZ?: number;
  26047. custom?: any;
  26048. faceUV?: Vector4[];
  26049. faceColors?: Color4[];
  26050. updatable?: boolean;
  26051. sideOrientation?: number;
  26052. }, scene: Scene): Mesh;
  26053. /**
  26054. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26055. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26056. * * 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`)
  26057. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26058. * * 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
  26059. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26060. * * If you create a double-sided mesh, you can choose what parts of 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
  26061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26062. * @param name defines the name of the mesh
  26063. * @param options defines the options used to create the mesh
  26064. * @param scene defines the hosting scene
  26065. * @returns a new Mesh
  26066. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26067. */
  26068. static CreateIcoSphere(name: string, options: {
  26069. radius?: number;
  26070. flat?: boolean;
  26071. subdivisions?: number;
  26072. sideOrientation?: number;
  26073. updatable?: boolean;
  26074. }, scene: Scene): Mesh;
  26075. /**
  26076. * Creates a decal mesh.
  26077. * Please consider using the same method from the MeshBuilder class instead.
  26078. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26079. * @param name defines the name of the mesh
  26080. * @param sourceMesh defines the mesh receiving the decal
  26081. * @param position sets the position of the decal in world coordinates
  26082. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26083. * @param size sets the decal scaling
  26084. * @param angle sets the angle to rotate the decal
  26085. * @returns a new Mesh
  26086. */
  26087. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26088. /**
  26089. * Prepare internal position array for software CPU skinning
  26090. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26091. */
  26092. setPositionsForCPUSkinning(): Float32Array;
  26093. /**
  26094. * Prepare internal normal array for software CPU skinning
  26095. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26096. */
  26097. setNormalsForCPUSkinning(): Float32Array;
  26098. /**
  26099. * Updates the vertex buffer by applying transformation from the bones
  26100. * @param skeleton defines the skeleton to apply to current mesh
  26101. * @returns the current mesh
  26102. */
  26103. applySkeleton(skeleton: Skeleton): Mesh;
  26104. /**
  26105. * 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
  26106. * @param meshes defines the list of meshes to scan
  26107. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26108. */
  26109. static MinMax(meshes: AbstractMesh[]): {
  26110. min: Vector3;
  26111. max: Vector3;
  26112. };
  26113. /**
  26114. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26115. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26116. * @returns a vector3
  26117. */
  26118. static Center(meshesOrMinMaxVector: {
  26119. min: Vector3;
  26120. max: Vector3;
  26121. } | AbstractMesh[]): Vector3;
  26122. /**
  26123. * Merge the array of meshes into a single mesh for performance reasons.
  26124. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26125. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26126. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26127. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26128. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26129. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26130. * @returns a new mesh
  26131. */
  26132. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26133. /** @hidden */
  26134. addInstance(instance: InstancedMesh): void;
  26135. /** @hidden */
  26136. removeInstance(instance: InstancedMesh): void;
  26137. }
  26138. }
  26139. declare module "babylonjs/Cameras/camera" {
  26140. import { SmartArray } from "babylonjs/Misc/smartArray";
  26141. import { Observable } from "babylonjs/Misc/observable";
  26142. import { Nullable } from "babylonjs/types";
  26143. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26144. import { Scene } from "babylonjs/scene";
  26145. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26146. import { Node } from "babylonjs/node";
  26147. import { Mesh } from "babylonjs/Meshes/mesh";
  26148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26149. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26150. import { Viewport } from "babylonjs/Maths/math.viewport";
  26151. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26152. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26153. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26154. import { Ray } from "babylonjs/Culling/ray";
  26155. /**
  26156. * This is the base class of all the camera used in the application.
  26157. * @see http://doc.babylonjs.com/features/cameras
  26158. */
  26159. export class Camera extends Node {
  26160. /** @hidden */
  26161. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26162. /**
  26163. * This is the default projection mode used by the cameras.
  26164. * It helps recreating a feeling of perspective and better appreciate depth.
  26165. * This is the best way to simulate real life cameras.
  26166. */
  26167. static readonly PERSPECTIVE_CAMERA: number;
  26168. /**
  26169. * This helps creating camera with an orthographic mode.
  26170. * 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.
  26171. */
  26172. static readonly ORTHOGRAPHIC_CAMERA: number;
  26173. /**
  26174. * This is the default FOV mode for perspective cameras.
  26175. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26176. */
  26177. static readonly FOVMODE_VERTICAL_FIXED: number;
  26178. /**
  26179. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26180. */
  26181. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26182. /**
  26183. * This specifies ther is no need for a camera rig.
  26184. * Basically only one eye is rendered corresponding to the camera.
  26185. */
  26186. static readonly RIG_MODE_NONE: number;
  26187. /**
  26188. * Simulates a camera Rig with one blue eye and one red eye.
  26189. * This can be use with 3d blue and red glasses.
  26190. */
  26191. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26192. /**
  26193. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26194. */
  26195. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26196. /**
  26197. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26198. */
  26199. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26200. /**
  26201. * Defines that both eyes of the camera will be rendered over under each other.
  26202. */
  26203. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26204. /**
  26205. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26206. */
  26207. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26208. /**
  26209. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26210. */
  26211. static readonly RIG_MODE_VR: number;
  26212. /**
  26213. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26214. */
  26215. static readonly RIG_MODE_WEBVR: number;
  26216. /**
  26217. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26218. */
  26219. static readonly RIG_MODE_CUSTOM: number;
  26220. /**
  26221. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26222. */
  26223. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26224. /**
  26225. * Define the input manager associated with the camera.
  26226. */
  26227. inputs: CameraInputsManager<Camera>;
  26228. /** @hidden */
  26229. _position: Vector3;
  26230. /**
  26231. * Define the current local position of the camera in the scene
  26232. */
  26233. get position(): Vector3;
  26234. set position(newPosition: Vector3);
  26235. /**
  26236. * The vector the camera should consider as up.
  26237. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26238. */
  26239. upVector: Vector3;
  26240. /**
  26241. * Define the current limit on the left side for an orthographic camera
  26242. * In scene unit
  26243. */
  26244. orthoLeft: Nullable<number>;
  26245. /**
  26246. * Define the current limit on the right side for an orthographic camera
  26247. * In scene unit
  26248. */
  26249. orthoRight: Nullable<number>;
  26250. /**
  26251. * Define the current limit on the bottom side for an orthographic camera
  26252. * In scene unit
  26253. */
  26254. orthoBottom: Nullable<number>;
  26255. /**
  26256. * Define the current limit on the top side for an orthographic camera
  26257. * In scene unit
  26258. */
  26259. orthoTop: Nullable<number>;
  26260. /**
  26261. * Field Of View is set in Radians. (default is 0.8)
  26262. */
  26263. fov: number;
  26264. /**
  26265. * Define the minimum distance the camera can see from.
  26266. * This is important to note that the depth buffer are not infinite and the closer it starts
  26267. * the more your scene might encounter depth fighting issue.
  26268. */
  26269. minZ: number;
  26270. /**
  26271. * Define the maximum distance the camera can see to.
  26272. * This is important to note that the depth buffer are not infinite and the further it end
  26273. * the more your scene might encounter depth fighting issue.
  26274. */
  26275. maxZ: number;
  26276. /**
  26277. * Define the default inertia of the camera.
  26278. * This helps giving a smooth feeling to the camera movement.
  26279. */
  26280. inertia: number;
  26281. /**
  26282. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26283. */
  26284. mode: number;
  26285. /**
  26286. * Define whether the camera is intermediate.
  26287. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26288. */
  26289. isIntermediate: boolean;
  26290. /**
  26291. * Define the viewport of the camera.
  26292. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26293. */
  26294. viewport: Viewport;
  26295. /**
  26296. * Restricts the camera to viewing objects with the same layerMask.
  26297. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26298. */
  26299. layerMask: number;
  26300. /**
  26301. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26302. */
  26303. fovMode: number;
  26304. /**
  26305. * Rig mode of the camera.
  26306. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26307. * This is normally controlled byt the camera themselves as internal use.
  26308. */
  26309. cameraRigMode: number;
  26310. /**
  26311. * Defines the distance between both "eyes" in case of a RIG
  26312. */
  26313. interaxialDistance: number;
  26314. /**
  26315. * Defines if stereoscopic rendering is done side by side or over under.
  26316. */
  26317. isStereoscopicSideBySide: boolean;
  26318. /**
  26319. * 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
  26320. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26321. * else in the scene. (Eg. security camera)
  26322. *
  26323. * 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)
  26324. */
  26325. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26326. /**
  26327. * When set, the camera will render to this render target instead of the default canvas
  26328. *
  26329. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26330. */
  26331. outputRenderTarget: Nullable<RenderTargetTexture>;
  26332. /**
  26333. * Observable triggered when the camera view matrix has changed.
  26334. */
  26335. onViewMatrixChangedObservable: Observable<Camera>;
  26336. /**
  26337. * Observable triggered when the camera Projection matrix has changed.
  26338. */
  26339. onProjectionMatrixChangedObservable: Observable<Camera>;
  26340. /**
  26341. * Observable triggered when the inputs have been processed.
  26342. */
  26343. onAfterCheckInputsObservable: Observable<Camera>;
  26344. /**
  26345. * Observable triggered when reset has been called and applied to the camera.
  26346. */
  26347. onRestoreStateObservable: Observable<Camera>;
  26348. /**
  26349. * Is this camera a part of a rig system?
  26350. */
  26351. isRigCamera: boolean;
  26352. /**
  26353. * If isRigCamera set to true this will be set with the parent camera.
  26354. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26355. */
  26356. rigParent?: Camera;
  26357. /** @hidden */
  26358. _cameraRigParams: any;
  26359. /** @hidden */
  26360. _rigCameras: Camera[];
  26361. /** @hidden */
  26362. _rigPostProcess: Nullable<PostProcess>;
  26363. protected _webvrViewMatrix: Matrix;
  26364. /** @hidden */
  26365. _skipRendering: boolean;
  26366. /** @hidden */
  26367. _projectionMatrix: Matrix;
  26368. /** @hidden */
  26369. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26370. /** @hidden */
  26371. _activeMeshes: SmartArray<AbstractMesh>;
  26372. protected _globalPosition: Vector3;
  26373. /** @hidden */
  26374. _computedViewMatrix: Matrix;
  26375. private _doNotComputeProjectionMatrix;
  26376. private _transformMatrix;
  26377. private _frustumPlanes;
  26378. private _refreshFrustumPlanes;
  26379. private _storedFov;
  26380. private _stateStored;
  26381. /**
  26382. * Instantiates a new camera object.
  26383. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26384. * @see http://doc.babylonjs.com/features/cameras
  26385. * @param name Defines the name of the camera in the scene
  26386. * @param position Defines the position of the camera
  26387. * @param scene Defines the scene the camera belongs too
  26388. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26389. */
  26390. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26391. /**
  26392. * Store current camera state (fov, position, etc..)
  26393. * @returns the camera
  26394. */
  26395. storeState(): Camera;
  26396. /**
  26397. * Restores the camera state values if it has been stored. You must call storeState() first
  26398. */
  26399. protected _restoreStateValues(): boolean;
  26400. /**
  26401. * Restored camera state. You must call storeState() first.
  26402. * @returns true if restored and false otherwise
  26403. */
  26404. restoreState(): boolean;
  26405. /**
  26406. * Gets the class name of the camera.
  26407. * @returns the class name
  26408. */
  26409. getClassName(): string;
  26410. /** @hidden */
  26411. readonly _isCamera: boolean;
  26412. /**
  26413. * Gets a string representation of the camera useful for debug purpose.
  26414. * @param fullDetails Defines that a more verboe level of logging is required
  26415. * @returns the string representation
  26416. */
  26417. toString(fullDetails?: boolean): string;
  26418. /**
  26419. * Gets the current world space position of the camera.
  26420. */
  26421. get globalPosition(): Vector3;
  26422. /**
  26423. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26424. * @returns the active meshe list
  26425. */
  26426. getActiveMeshes(): SmartArray<AbstractMesh>;
  26427. /**
  26428. * Check whether a mesh is part of the current active mesh list of the camera
  26429. * @param mesh Defines the mesh to check
  26430. * @returns true if active, false otherwise
  26431. */
  26432. isActiveMesh(mesh: Mesh): boolean;
  26433. /**
  26434. * Is this camera ready to be used/rendered
  26435. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26436. * @return true if the camera is ready
  26437. */
  26438. isReady(completeCheck?: boolean): boolean;
  26439. /** @hidden */
  26440. _initCache(): void;
  26441. /** @hidden */
  26442. _updateCache(ignoreParentClass?: boolean): void;
  26443. /** @hidden */
  26444. _isSynchronized(): boolean;
  26445. /** @hidden */
  26446. _isSynchronizedViewMatrix(): boolean;
  26447. /** @hidden */
  26448. _isSynchronizedProjectionMatrix(): boolean;
  26449. /**
  26450. * Attach the input controls to a specific dom element to get the input from.
  26451. * @param element Defines the element the controls should be listened from
  26452. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26453. */
  26454. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26455. /**
  26456. * Detach the current controls from the specified dom element.
  26457. * @param element Defines the element to stop listening the inputs from
  26458. */
  26459. detachControl(element: HTMLElement): void;
  26460. /**
  26461. * Update the camera state according to the different inputs gathered during the frame.
  26462. */
  26463. update(): void;
  26464. /** @hidden */
  26465. _checkInputs(): void;
  26466. /** @hidden */
  26467. get rigCameras(): Camera[];
  26468. /**
  26469. * Gets the post process used by the rig cameras
  26470. */
  26471. get rigPostProcess(): Nullable<PostProcess>;
  26472. /**
  26473. * Internal, gets the first post proces.
  26474. * @returns the first post process to be run on this camera.
  26475. */
  26476. _getFirstPostProcess(): Nullable<PostProcess>;
  26477. private _cascadePostProcessesToRigCams;
  26478. /**
  26479. * Attach a post process to the camera.
  26480. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26481. * @param postProcess The post process to attach to the camera
  26482. * @param insertAt The position of the post process in case several of them are in use in the scene
  26483. * @returns the position the post process has been inserted at
  26484. */
  26485. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26486. /**
  26487. * Detach a post process to the camera.
  26488. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26489. * @param postProcess The post process to detach from the camera
  26490. */
  26491. detachPostProcess(postProcess: PostProcess): void;
  26492. /**
  26493. * Gets the current world matrix of the camera
  26494. */
  26495. getWorldMatrix(): Matrix;
  26496. /** @hidden */
  26497. _getViewMatrix(): Matrix;
  26498. /**
  26499. * Gets the current view matrix of the camera.
  26500. * @param force forces the camera to recompute the matrix without looking at the cached state
  26501. * @returns the view matrix
  26502. */
  26503. getViewMatrix(force?: boolean): Matrix;
  26504. /**
  26505. * Freeze the projection matrix.
  26506. * It will prevent the cache check of the camera projection compute and can speed up perf
  26507. * if no parameter of the camera are meant to change
  26508. * @param projection Defines manually a projection if necessary
  26509. */
  26510. freezeProjectionMatrix(projection?: Matrix): void;
  26511. /**
  26512. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26513. */
  26514. unfreezeProjectionMatrix(): void;
  26515. /**
  26516. * Gets the current projection matrix of the camera.
  26517. * @param force forces the camera to recompute the matrix without looking at the cached state
  26518. * @returns the projection matrix
  26519. */
  26520. getProjectionMatrix(force?: boolean): Matrix;
  26521. /**
  26522. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26523. * @returns a Matrix
  26524. */
  26525. getTransformationMatrix(): Matrix;
  26526. private _updateFrustumPlanes;
  26527. /**
  26528. * Checks if a cullable object (mesh...) is in the camera frustum
  26529. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26530. * @param target The object to check
  26531. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26532. * @returns true if the object is in frustum otherwise false
  26533. */
  26534. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26535. /**
  26536. * Checks if a cullable object (mesh...) is in the camera frustum
  26537. * Unlike isInFrustum this cheks the full bounding box
  26538. * @param target The object to check
  26539. * @returns true if the object is in frustum otherwise false
  26540. */
  26541. isCompletelyInFrustum(target: ICullable): boolean;
  26542. /**
  26543. * Gets a ray in the forward direction from the camera.
  26544. * @param length Defines the length of the ray to create
  26545. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26546. * @param origin Defines the start point of the ray which defaults to the camera position
  26547. * @returns the forward ray
  26548. */
  26549. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26550. /**
  26551. * Releases resources associated with this node.
  26552. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26553. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26554. */
  26555. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26556. /** @hidden */
  26557. _isLeftCamera: boolean;
  26558. /**
  26559. * Gets the left camera of a rig setup in case of Rigged Camera
  26560. */
  26561. get isLeftCamera(): boolean;
  26562. /** @hidden */
  26563. _isRightCamera: boolean;
  26564. /**
  26565. * Gets the right camera of a rig setup in case of Rigged Camera
  26566. */
  26567. get isRightCamera(): boolean;
  26568. /**
  26569. * Gets the left camera of a rig setup in case of Rigged Camera
  26570. */
  26571. get leftCamera(): Nullable<FreeCamera>;
  26572. /**
  26573. * Gets the right camera of a rig setup in case of Rigged Camera
  26574. */
  26575. get rightCamera(): Nullable<FreeCamera>;
  26576. /**
  26577. * Gets the left camera target of a rig setup in case of Rigged Camera
  26578. * @returns the target position
  26579. */
  26580. getLeftTarget(): Nullable<Vector3>;
  26581. /**
  26582. * Gets the right camera target of a rig setup in case of Rigged Camera
  26583. * @returns the target position
  26584. */
  26585. getRightTarget(): Nullable<Vector3>;
  26586. /**
  26587. * @hidden
  26588. */
  26589. setCameraRigMode(mode: number, rigParams: any): void;
  26590. /** @hidden */
  26591. static _setStereoscopicRigMode(camera: Camera): void;
  26592. /** @hidden */
  26593. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26594. /** @hidden */
  26595. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26596. /** @hidden */
  26597. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26598. /** @hidden */
  26599. _getVRProjectionMatrix(): Matrix;
  26600. protected _updateCameraRotationMatrix(): void;
  26601. protected _updateWebVRCameraRotationMatrix(): void;
  26602. /**
  26603. * This function MUST be overwritten by the different WebVR cameras available.
  26604. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26605. * @hidden
  26606. */
  26607. _getWebVRProjectionMatrix(): Matrix;
  26608. /**
  26609. * This function MUST be overwritten by the different WebVR cameras available.
  26610. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26611. * @hidden
  26612. */
  26613. _getWebVRViewMatrix(): Matrix;
  26614. /** @hidden */
  26615. setCameraRigParameter(name: string, value: any): void;
  26616. /**
  26617. * needs to be overridden by children so sub has required properties to be copied
  26618. * @hidden
  26619. */
  26620. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26621. /**
  26622. * May need to be overridden by children
  26623. * @hidden
  26624. */
  26625. _updateRigCameras(): void;
  26626. /** @hidden */
  26627. _setupInputs(): void;
  26628. /**
  26629. * Serialiaze the camera setup to a json represention
  26630. * @returns the JSON representation
  26631. */
  26632. serialize(): any;
  26633. /**
  26634. * Clones the current camera.
  26635. * @param name The cloned camera name
  26636. * @returns the cloned camera
  26637. */
  26638. clone(name: string): Camera;
  26639. /**
  26640. * Gets the direction of the camera relative to a given local axis.
  26641. * @param localAxis Defines the reference axis to provide a relative direction.
  26642. * @return the direction
  26643. */
  26644. getDirection(localAxis: Vector3): Vector3;
  26645. /**
  26646. * Returns the current camera absolute rotation
  26647. */
  26648. get absoluteRotation(): Quaternion;
  26649. /**
  26650. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26651. * @param localAxis Defines the reference axis to provide a relative direction.
  26652. * @param result Defines the vector to store the result in
  26653. */
  26654. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26655. /**
  26656. * Gets a camera constructor for a given camera type
  26657. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26658. * @param name The name of the camera the result will be able to instantiate
  26659. * @param scene The scene the result will construct the camera in
  26660. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26661. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26662. * @returns a factory method to construc the camera
  26663. */
  26664. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26665. /**
  26666. * Compute the world matrix of the camera.
  26667. * @returns the camera world matrix
  26668. */
  26669. computeWorldMatrix(): Matrix;
  26670. /**
  26671. * Parse a JSON and creates the camera from the parsed information
  26672. * @param parsedCamera The JSON to parse
  26673. * @param scene The scene to instantiate the camera in
  26674. * @returns the newly constructed camera
  26675. */
  26676. static Parse(parsedCamera: any, scene: Scene): Camera;
  26677. }
  26678. }
  26679. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26680. import { Nullable } from "babylonjs/types";
  26681. import { Scene } from "babylonjs/scene";
  26682. import { Vector4 } from "babylonjs/Maths/math.vector";
  26683. import { Mesh } from "babylonjs/Meshes/mesh";
  26684. /**
  26685. * Class containing static functions to help procedurally build meshes
  26686. */
  26687. export class DiscBuilder {
  26688. /**
  26689. * Creates a plane polygonal mesh. By default, this is a disc
  26690. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26691. * * 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
  26692. * * 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
  26693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26694. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26696. * @param name defines the name of the mesh
  26697. * @param options defines the options used to create the mesh
  26698. * @param scene defines the hosting scene
  26699. * @returns the plane polygonal mesh
  26700. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26701. */
  26702. static CreateDisc(name: string, options: {
  26703. radius?: number;
  26704. tessellation?: number;
  26705. arc?: number;
  26706. updatable?: boolean;
  26707. sideOrientation?: number;
  26708. frontUVs?: Vector4;
  26709. backUVs?: Vector4;
  26710. }, scene?: Nullable<Scene>): Mesh;
  26711. }
  26712. }
  26713. declare module "babylonjs/Materials/fresnelParameters" {
  26714. import { Color3 } from "babylonjs/Maths/math.color";
  26715. /**
  26716. * This represents all the required information to add a fresnel effect on a material:
  26717. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26718. */
  26719. export class FresnelParameters {
  26720. private _isEnabled;
  26721. /**
  26722. * Define if the fresnel effect is enable or not.
  26723. */
  26724. get isEnabled(): boolean;
  26725. set isEnabled(value: boolean);
  26726. /**
  26727. * Define the color used on edges (grazing angle)
  26728. */
  26729. leftColor: Color3;
  26730. /**
  26731. * Define the color used on center
  26732. */
  26733. rightColor: Color3;
  26734. /**
  26735. * Define bias applied to computed fresnel term
  26736. */
  26737. bias: number;
  26738. /**
  26739. * Defined the power exponent applied to fresnel term
  26740. */
  26741. power: number;
  26742. /**
  26743. * Clones the current fresnel and its valuues
  26744. * @returns a clone fresnel configuration
  26745. */
  26746. clone(): FresnelParameters;
  26747. /**
  26748. * Serializes the current fresnel parameters to a JSON representation.
  26749. * @return the JSON serialization
  26750. */
  26751. serialize(): any;
  26752. /**
  26753. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26754. * @param parsedFresnelParameters Define the JSON representation
  26755. * @returns the parsed parameters
  26756. */
  26757. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26758. }
  26759. }
  26760. declare module "babylonjs/Materials/pushMaterial" {
  26761. import { Nullable } from "babylonjs/types";
  26762. import { Scene } from "babylonjs/scene";
  26763. import { Matrix } from "babylonjs/Maths/math.vector";
  26764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26765. import { Mesh } from "babylonjs/Meshes/mesh";
  26766. import { Material } from "babylonjs/Materials/material";
  26767. import { Effect } from "babylonjs/Materials/effect";
  26768. /**
  26769. * Base class of materials working in push mode in babylon JS
  26770. * @hidden
  26771. */
  26772. export class PushMaterial extends Material {
  26773. protected _activeEffect: Effect;
  26774. protected _normalMatrix: Matrix;
  26775. /**
  26776. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26777. * This means that the material can keep using a previous shader while a new one is being compiled.
  26778. * This is mostly used when shader parallel compilation is supported (true by default)
  26779. */
  26780. allowShaderHotSwapping: boolean;
  26781. constructor(name: string, scene: Scene);
  26782. getEffect(): Effect;
  26783. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26784. /**
  26785. * Binds the given world matrix to the active effect
  26786. *
  26787. * @param world the matrix to bind
  26788. */
  26789. bindOnlyWorldMatrix(world: Matrix): void;
  26790. /**
  26791. * Binds the given normal matrix to the active effect
  26792. *
  26793. * @param normalMatrix the matrix to bind
  26794. */
  26795. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26796. bind(world: Matrix, mesh?: Mesh): void;
  26797. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26798. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26799. }
  26800. }
  26801. declare module "babylonjs/Materials/materialFlags" {
  26802. /**
  26803. * This groups all the flags used to control the materials channel.
  26804. */
  26805. export class MaterialFlags {
  26806. private static _DiffuseTextureEnabled;
  26807. /**
  26808. * Are diffuse textures enabled in the application.
  26809. */
  26810. static get DiffuseTextureEnabled(): boolean;
  26811. static set DiffuseTextureEnabled(value: boolean);
  26812. private static _AmbientTextureEnabled;
  26813. /**
  26814. * Are ambient textures enabled in the application.
  26815. */
  26816. static get AmbientTextureEnabled(): boolean;
  26817. static set AmbientTextureEnabled(value: boolean);
  26818. private static _OpacityTextureEnabled;
  26819. /**
  26820. * Are opacity textures enabled in the application.
  26821. */
  26822. static get OpacityTextureEnabled(): boolean;
  26823. static set OpacityTextureEnabled(value: boolean);
  26824. private static _ReflectionTextureEnabled;
  26825. /**
  26826. * Are reflection textures enabled in the application.
  26827. */
  26828. static get ReflectionTextureEnabled(): boolean;
  26829. static set ReflectionTextureEnabled(value: boolean);
  26830. private static _EmissiveTextureEnabled;
  26831. /**
  26832. * Are emissive textures enabled in the application.
  26833. */
  26834. static get EmissiveTextureEnabled(): boolean;
  26835. static set EmissiveTextureEnabled(value: boolean);
  26836. private static _SpecularTextureEnabled;
  26837. /**
  26838. * Are specular textures enabled in the application.
  26839. */
  26840. static get SpecularTextureEnabled(): boolean;
  26841. static set SpecularTextureEnabled(value: boolean);
  26842. private static _BumpTextureEnabled;
  26843. /**
  26844. * Are bump textures enabled in the application.
  26845. */
  26846. static get BumpTextureEnabled(): boolean;
  26847. static set BumpTextureEnabled(value: boolean);
  26848. private static _LightmapTextureEnabled;
  26849. /**
  26850. * Are lightmap textures enabled in the application.
  26851. */
  26852. static get LightmapTextureEnabled(): boolean;
  26853. static set LightmapTextureEnabled(value: boolean);
  26854. private static _RefractionTextureEnabled;
  26855. /**
  26856. * Are refraction textures enabled in the application.
  26857. */
  26858. static get RefractionTextureEnabled(): boolean;
  26859. static set RefractionTextureEnabled(value: boolean);
  26860. private static _ColorGradingTextureEnabled;
  26861. /**
  26862. * Are color grading textures enabled in the application.
  26863. */
  26864. static get ColorGradingTextureEnabled(): boolean;
  26865. static set ColorGradingTextureEnabled(value: boolean);
  26866. private static _FresnelEnabled;
  26867. /**
  26868. * Are fresnels enabled in the application.
  26869. */
  26870. static get FresnelEnabled(): boolean;
  26871. static set FresnelEnabled(value: boolean);
  26872. private static _ClearCoatTextureEnabled;
  26873. /**
  26874. * Are clear coat textures enabled in the application.
  26875. */
  26876. static get ClearCoatTextureEnabled(): boolean;
  26877. static set ClearCoatTextureEnabled(value: boolean);
  26878. private static _ClearCoatBumpTextureEnabled;
  26879. /**
  26880. * Are clear coat bump textures enabled in the application.
  26881. */
  26882. static get ClearCoatBumpTextureEnabled(): boolean;
  26883. static set ClearCoatBumpTextureEnabled(value: boolean);
  26884. private static _ClearCoatTintTextureEnabled;
  26885. /**
  26886. * Are clear coat tint textures enabled in the application.
  26887. */
  26888. static get ClearCoatTintTextureEnabled(): boolean;
  26889. static set ClearCoatTintTextureEnabled(value: boolean);
  26890. private static _SheenTextureEnabled;
  26891. /**
  26892. * Are sheen textures enabled in the application.
  26893. */
  26894. static get SheenTextureEnabled(): boolean;
  26895. static set SheenTextureEnabled(value: boolean);
  26896. private static _AnisotropicTextureEnabled;
  26897. /**
  26898. * Are anisotropic textures enabled in the application.
  26899. */
  26900. static get AnisotropicTextureEnabled(): boolean;
  26901. static set AnisotropicTextureEnabled(value: boolean);
  26902. private static _ThicknessTextureEnabled;
  26903. /**
  26904. * Are thickness textures enabled in the application.
  26905. */
  26906. static get ThicknessTextureEnabled(): boolean;
  26907. static set ThicknessTextureEnabled(value: boolean);
  26908. }
  26909. }
  26910. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26911. /** @hidden */
  26912. export var defaultFragmentDeclaration: {
  26913. name: string;
  26914. shader: string;
  26915. };
  26916. }
  26917. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26918. /** @hidden */
  26919. export var defaultUboDeclaration: {
  26920. name: string;
  26921. shader: string;
  26922. };
  26923. }
  26924. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26925. /** @hidden */
  26926. export var lightFragmentDeclaration: {
  26927. name: string;
  26928. shader: string;
  26929. };
  26930. }
  26931. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26932. /** @hidden */
  26933. export var lightUboDeclaration: {
  26934. name: string;
  26935. shader: string;
  26936. };
  26937. }
  26938. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26939. /** @hidden */
  26940. export var lightsFragmentFunctions: {
  26941. name: string;
  26942. shader: string;
  26943. };
  26944. }
  26945. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26946. /** @hidden */
  26947. export var shadowsFragmentFunctions: {
  26948. name: string;
  26949. shader: string;
  26950. };
  26951. }
  26952. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26953. /** @hidden */
  26954. export var fresnelFunction: {
  26955. name: string;
  26956. shader: string;
  26957. };
  26958. }
  26959. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26960. /** @hidden */
  26961. export var reflectionFunction: {
  26962. name: string;
  26963. shader: string;
  26964. };
  26965. }
  26966. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26967. /** @hidden */
  26968. export var bumpFragmentFunctions: {
  26969. name: string;
  26970. shader: string;
  26971. };
  26972. }
  26973. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26974. /** @hidden */
  26975. export var logDepthDeclaration: {
  26976. name: string;
  26977. shader: string;
  26978. };
  26979. }
  26980. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26981. /** @hidden */
  26982. export var bumpFragment: {
  26983. name: string;
  26984. shader: string;
  26985. };
  26986. }
  26987. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26988. /** @hidden */
  26989. export var depthPrePass: {
  26990. name: string;
  26991. shader: string;
  26992. };
  26993. }
  26994. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26995. /** @hidden */
  26996. export var lightFragment: {
  26997. name: string;
  26998. shader: string;
  26999. };
  27000. }
  27001. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27002. /** @hidden */
  27003. export var logDepthFragment: {
  27004. name: string;
  27005. shader: string;
  27006. };
  27007. }
  27008. declare module "babylonjs/Shaders/default.fragment" {
  27009. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27010. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27011. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27012. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27013. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27014. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27015. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27016. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27017. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27018. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27019. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27020. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27021. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27022. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27023. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27024. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27025. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27026. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27027. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27028. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27029. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27030. /** @hidden */
  27031. export var defaultPixelShader: {
  27032. name: string;
  27033. shader: string;
  27034. };
  27035. }
  27036. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27037. /** @hidden */
  27038. export var defaultVertexDeclaration: {
  27039. name: string;
  27040. shader: string;
  27041. };
  27042. }
  27043. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27044. /** @hidden */
  27045. export var bumpVertexDeclaration: {
  27046. name: string;
  27047. shader: string;
  27048. };
  27049. }
  27050. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27051. /** @hidden */
  27052. export var bumpVertex: {
  27053. name: string;
  27054. shader: string;
  27055. };
  27056. }
  27057. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27058. /** @hidden */
  27059. export var fogVertex: {
  27060. name: string;
  27061. shader: string;
  27062. };
  27063. }
  27064. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27065. /** @hidden */
  27066. export var shadowsVertex: {
  27067. name: string;
  27068. shader: string;
  27069. };
  27070. }
  27071. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27072. /** @hidden */
  27073. export var pointCloudVertex: {
  27074. name: string;
  27075. shader: string;
  27076. };
  27077. }
  27078. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27079. /** @hidden */
  27080. export var logDepthVertex: {
  27081. name: string;
  27082. shader: string;
  27083. };
  27084. }
  27085. declare module "babylonjs/Shaders/default.vertex" {
  27086. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27087. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27088. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27089. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27090. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27091. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27092. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27093. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27094. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27095. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27096. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27097. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27098. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27099. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27100. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27101. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27102. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27103. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27104. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27105. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27106. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27107. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27108. /** @hidden */
  27109. export var defaultVertexShader: {
  27110. name: string;
  27111. shader: string;
  27112. };
  27113. }
  27114. declare module "babylonjs/Materials/standardMaterial" {
  27115. import { SmartArray } from "babylonjs/Misc/smartArray";
  27116. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27117. import { Nullable } from "babylonjs/types";
  27118. import { Scene } from "babylonjs/scene";
  27119. import { Matrix } from "babylonjs/Maths/math.vector";
  27120. import { Color3 } from "babylonjs/Maths/math.color";
  27121. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27123. import { Mesh } from "babylonjs/Meshes/mesh";
  27124. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27125. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27126. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27127. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27128. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27129. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27130. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27131. import "babylonjs/Shaders/default.fragment";
  27132. import "babylonjs/Shaders/default.vertex";
  27133. /** @hidden */
  27134. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27135. MAINUV1: boolean;
  27136. MAINUV2: boolean;
  27137. DIFFUSE: boolean;
  27138. DIFFUSEDIRECTUV: number;
  27139. AMBIENT: boolean;
  27140. AMBIENTDIRECTUV: number;
  27141. OPACITY: boolean;
  27142. OPACITYDIRECTUV: number;
  27143. OPACITYRGB: boolean;
  27144. REFLECTION: boolean;
  27145. EMISSIVE: boolean;
  27146. EMISSIVEDIRECTUV: number;
  27147. SPECULAR: boolean;
  27148. SPECULARDIRECTUV: number;
  27149. BUMP: boolean;
  27150. BUMPDIRECTUV: number;
  27151. PARALLAX: boolean;
  27152. PARALLAXOCCLUSION: boolean;
  27153. SPECULAROVERALPHA: boolean;
  27154. CLIPPLANE: boolean;
  27155. CLIPPLANE2: boolean;
  27156. CLIPPLANE3: boolean;
  27157. CLIPPLANE4: boolean;
  27158. CLIPPLANE5: boolean;
  27159. CLIPPLANE6: boolean;
  27160. ALPHATEST: boolean;
  27161. DEPTHPREPASS: boolean;
  27162. ALPHAFROMDIFFUSE: boolean;
  27163. POINTSIZE: boolean;
  27164. FOG: boolean;
  27165. SPECULARTERM: boolean;
  27166. DIFFUSEFRESNEL: boolean;
  27167. OPACITYFRESNEL: boolean;
  27168. REFLECTIONFRESNEL: boolean;
  27169. REFRACTIONFRESNEL: boolean;
  27170. EMISSIVEFRESNEL: boolean;
  27171. FRESNEL: boolean;
  27172. NORMAL: boolean;
  27173. UV1: boolean;
  27174. UV2: boolean;
  27175. VERTEXCOLOR: boolean;
  27176. VERTEXALPHA: boolean;
  27177. NUM_BONE_INFLUENCERS: number;
  27178. BonesPerMesh: number;
  27179. BONETEXTURE: boolean;
  27180. INSTANCES: boolean;
  27181. GLOSSINESS: boolean;
  27182. ROUGHNESS: boolean;
  27183. EMISSIVEASILLUMINATION: boolean;
  27184. LINKEMISSIVEWITHDIFFUSE: boolean;
  27185. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27186. LIGHTMAP: boolean;
  27187. LIGHTMAPDIRECTUV: number;
  27188. OBJECTSPACE_NORMALMAP: boolean;
  27189. USELIGHTMAPASSHADOWMAP: boolean;
  27190. REFLECTIONMAP_3D: boolean;
  27191. REFLECTIONMAP_SPHERICAL: boolean;
  27192. REFLECTIONMAP_PLANAR: boolean;
  27193. REFLECTIONMAP_CUBIC: boolean;
  27194. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27195. REFLECTIONMAP_PROJECTION: boolean;
  27196. REFLECTIONMAP_SKYBOX: boolean;
  27197. REFLECTIONMAP_EXPLICIT: boolean;
  27198. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27199. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27200. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27201. INVERTCUBICMAP: boolean;
  27202. LOGARITHMICDEPTH: boolean;
  27203. REFRACTION: boolean;
  27204. REFRACTIONMAP_3D: boolean;
  27205. REFLECTIONOVERALPHA: boolean;
  27206. TWOSIDEDLIGHTING: boolean;
  27207. SHADOWFLOAT: boolean;
  27208. MORPHTARGETS: boolean;
  27209. MORPHTARGETS_NORMAL: boolean;
  27210. MORPHTARGETS_TANGENT: boolean;
  27211. MORPHTARGETS_UV: boolean;
  27212. NUM_MORPH_INFLUENCERS: number;
  27213. NONUNIFORMSCALING: boolean;
  27214. PREMULTIPLYALPHA: boolean;
  27215. IMAGEPROCESSING: boolean;
  27216. VIGNETTE: boolean;
  27217. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27218. VIGNETTEBLENDMODEOPAQUE: boolean;
  27219. TONEMAPPING: boolean;
  27220. TONEMAPPING_ACES: boolean;
  27221. CONTRAST: boolean;
  27222. COLORCURVES: boolean;
  27223. COLORGRADING: boolean;
  27224. COLORGRADING3D: boolean;
  27225. SAMPLER3DGREENDEPTH: boolean;
  27226. SAMPLER3DBGRMAP: boolean;
  27227. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27228. MULTIVIEW: boolean;
  27229. /**
  27230. * If the reflection texture on this material is in linear color space
  27231. * @hidden
  27232. */
  27233. IS_REFLECTION_LINEAR: boolean;
  27234. /**
  27235. * If the refraction texture on this material is in linear color space
  27236. * @hidden
  27237. */
  27238. IS_REFRACTION_LINEAR: boolean;
  27239. EXPOSURE: boolean;
  27240. constructor();
  27241. setReflectionMode(modeToEnable: string): void;
  27242. }
  27243. /**
  27244. * This is the default material used in Babylon. It is the best trade off between quality
  27245. * and performances.
  27246. * @see http://doc.babylonjs.com/babylon101/materials
  27247. */
  27248. export class StandardMaterial extends PushMaterial {
  27249. private _diffuseTexture;
  27250. /**
  27251. * The basic texture of the material as viewed under a light.
  27252. */
  27253. diffuseTexture: Nullable<BaseTexture>;
  27254. private _ambientTexture;
  27255. /**
  27256. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27257. */
  27258. ambientTexture: Nullable<BaseTexture>;
  27259. private _opacityTexture;
  27260. /**
  27261. * Define the transparency of the material from a texture.
  27262. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27263. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27264. */
  27265. opacityTexture: Nullable<BaseTexture>;
  27266. private _reflectionTexture;
  27267. /**
  27268. * Define the texture used to display the reflection.
  27269. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27270. */
  27271. reflectionTexture: Nullable<BaseTexture>;
  27272. private _emissiveTexture;
  27273. /**
  27274. * Define texture of the material as if self lit.
  27275. * This will be mixed in the final result even in the absence of light.
  27276. */
  27277. emissiveTexture: Nullable<BaseTexture>;
  27278. private _specularTexture;
  27279. /**
  27280. * Define how the color and intensity of the highlight given by the light in the material.
  27281. */
  27282. specularTexture: Nullable<BaseTexture>;
  27283. private _bumpTexture;
  27284. /**
  27285. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27286. * 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.
  27287. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27288. */
  27289. bumpTexture: Nullable<BaseTexture>;
  27290. private _lightmapTexture;
  27291. /**
  27292. * Complex lighting can be computationally expensive to compute at runtime.
  27293. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27294. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27295. */
  27296. lightmapTexture: Nullable<BaseTexture>;
  27297. private _refractionTexture;
  27298. /**
  27299. * Define the texture used to display the refraction.
  27300. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27301. */
  27302. refractionTexture: Nullable<BaseTexture>;
  27303. /**
  27304. * The color of the material lit by the environmental background lighting.
  27305. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27306. */
  27307. ambientColor: Color3;
  27308. /**
  27309. * The basic color of the material as viewed under a light.
  27310. */
  27311. diffuseColor: Color3;
  27312. /**
  27313. * Define how the color and intensity of the highlight given by the light in the material.
  27314. */
  27315. specularColor: Color3;
  27316. /**
  27317. * Define the color of the material as if self lit.
  27318. * This will be mixed in the final result even in the absence of light.
  27319. */
  27320. emissiveColor: Color3;
  27321. /**
  27322. * Defines how sharp are the highlights in the material.
  27323. * The bigger the value the sharper giving a more glossy feeling to the result.
  27324. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27325. */
  27326. specularPower: number;
  27327. private _useAlphaFromDiffuseTexture;
  27328. /**
  27329. * Does the transparency come from the diffuse texture alpha channel.
  27330. */
  27331. useAlphaFromDiffuseTexture: boolean;
  27332. private _useEmissiveAsIllumination;
  27333. /**
  27334. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27335. */
  27336. useEmissiveAsIllumination: boolean;
  27337. private _linkEmissiveWithDiffuse;
  27338. /**
  27339. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27340. * the emissive level when the final color is close to one.
  27341. */
  27342. linkEmissiveWithDiffuse: boolean;
  27343. private _useSpecularOverAlpha;
  27344. /**
  27345. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27346. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27347. */
  27348. useSpecularOverAlpha: boolean;
  27349. private _useReflectionOverAlpha;
  27350. /**
  27351. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27352. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27353. */
  27354. useReflectionOverAlpha: boolean;
  27355. private _disableLighting;
  27356. /**
  27357. * Does lights from the scene impacts this material.
  27358. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27359. */
  27360. disableLighting: boolean;
  27361. private _useObjectSpaceNormalMap;
  27362. /**
  27363. * Allows using an object space normal map (instead of tangent space).
  27364. */
  27365. useObjectSpaceNormalMap: boolean;
  27366. private _useParallax;
  27367. /**
  27368. * Is parallax enabled or not.
  27369. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27370. */
  27371. useParallax: boolean;
  27372. private _useParallaxOcclusion;
  27373. /**
  27374. * Is parallax occlusion enabled or not.
  27375. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27376. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27377. */
  27378. useParallaxOcclusion: boolean;
  27379. /**
  27380. * 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.
  27381. */
  27382. parallaxScaleBias: number;
  27383. private _roughness;
  27384. /**
  27385. * Helps to define how blurry the reflections should appears in the material.
  27386. */
  27387. roughness: number;
  27388. /**
  27389. * In case of refraction, define the value of the index of refraction.
  27390. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27391. */
  27392. indexOfRefraction: number;
  27393. /**
  27394. * Invert the refraction texture alongside the y axis.
  27395. * It can be useful with procedural textures or probe for instance.
  27396. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27397. */
  27398. invertRefractionY: boolean;
  27399. /**
  27400. * Defines the alpha limits in alpha test mode.
  27401. */
  27402. alphaCutOff: number;
  27403. private _useLightmapAsShadowmap;
  27404. /**
  27405. * In case of light mapping, define whether the map contains light or shadow informations.
  27406. */
  27407. useLightmapAsShadowmap: boolean;
  27408. private _diffuseFresnelParameters;
  27409. /**
  27410. * Define the diffuse fresnel parameters of the material.
  27411. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27412. */
  27413. diffuseFresnelParameters: FresnelParameters;
  27414. private _opacityFresnelParameters;
  27415. /**
  27416. * Define the opacity fresnel parameters of the material.
  27417. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27418. */
  27419. opacityFresnelParameters: FresnelParameters;
  27420. private _reflectionFresnelParameters;
  27421. /**
  27422. * Define the reflection fresnel parameters of the material.
  27423. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27424. */
  27425. reflectionFresnelParameters: FresnelParameters;
  27426. private _refractionFresnelParameters;
  27427. /**
  27428. * Define the refraction fresnel parameters of the material.
  27429. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27430. */
  27431. refractionFresnelParameters: FresnelParameters;
  27432. private _emissiveFresnelParameters;
  27433. /**
  27434. * Define the emissive fresnel parameters of the material.
  27435. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27436. */
  27437. emissiveFresnelParameters: FresnelParameters;
  27438. private _useReflectionFresnelFromSpecular;
  27439. /**
  27440. * If true automatically deducts the fresnels values from the material specularity.
  27441. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27442. */
  27443. useReflectionFresnelFromSpecular: boolean;
  27444. private _useGlossinessFromSpecularMapAlpha;
  27445. /**
  27446. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27447. */
  27448. useGlossinessFromSpecularMapAlpha: boolean;
  27449. private _maxSimultaneousLights;
  27450. /**
  27451. * Defines the maximum number of lights that can be used in the material
  27452. */
  27453. maxSimultaneousLights: number;
  27454. private _invertNormalMapX;
  27455. /**
  27456. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27457. */
  27458. invertNormalMapX: boolean;
  27459. private _invertNormalMapY;
  27460. /**
  27461. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27462. */
  27463. invertNormalMapY: boolean;
  27464. private _twoSidedLighting;
  27465. /**
  27466. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27467. */
  27468. twoSidedLighting: boolean;
  27469. /**
  27470. * Default configuration related to image processing available in the standard Material.
  27471. */
  27472. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27473. /**
  27474. * Gets the image processing configuration used either in this material.
  27475. */
  27476. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27477. /**
  27478. * Sets the Default image processing configuration used either in the this material.
  27479. *
  27480. * If sets to null, the scene one is in use.
  27481. */
  27482. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27483. /**
  27484. * Keep track of the image processing observer to allow dispose and replace.
  27485. */
  27486. private _imageProcessingObserver;
  27487. /**
  27488. * Attaches a new image processing configuration to the Standard Material.
  27489. * @param configuration
  27490. */
  27491. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27492. /**
  27493. * Gets wether the color curves effect is enabled.
  27494. */
  27495. get cameraColorCurvesEnabled(): boolean;
  27496. /**
  27497. * Sets wether the color curves effect is enabled.
  27498. */
  27499. set cameraColorCurvesEnabled(value: boolean);
  27500. /**
  27501. * Gets wether the color grading effect is enabled.
  27502. */
  27503. get cameraColorGradingEnabled(): boolean;
  27504. /**
  27505. * Gets wether the color grading effect is enabled.
  27506. */
  27507. set cameraColorGradingEnabled(value: boolean);
  27508. /**
  27509. * Gets wether tonemapping is enabled or not.
  27510. */
  27511. get cameraToneMappingEnabled(): boolean;
  27512. /**
  27513. * Sets wether tonemapping is enabled or not
  27514. */
  27515. set cameraToneMappingEnabled(value: boolean);
  27516. /**
  27517. * The camera exposure used on this material.
  27518. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27519. * This corresponds to a photographic exposure.
  27520. */
  27521. get cameraExposure(): number;
  27522. /**
  27523. * The camera exposure used on this material.
  27524. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27525. * This corresponds to a photographic exposure.
  27526. */
  27527. set cameraExposure(value: number);
  27528. /**
  27529. * Gets The camera contrast used on this material.
  27530. */
  27531. get cameraContrast(): number;
  27532. /**
  27533. * Sets The camera contrast used on this material.
  27534. */
  27535. set cameraContrast(value: number);
  27536. /**
  27537. * Gets the Color Grading 2D Lookup Texture.
  27538. */
  27539. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27540. /**
  27541. * Sets the Color Grading 2D Lookup Texture.
  27542. */
  27543. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27544. /**
  27545. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27546. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27547. * 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;
  27548. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27549. */
  27550. get cameraColorCurves(): Nullable<ColorCurves>;
  27551. /**
  27552. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27553. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27554. * 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;
  27555. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27556. */
  27557. set cameraColorCurves(value: Nullable<ColorCurves>);
  27558. /**
  27559. * Custom callback helping to override the default shader used in the material.
  27560. */
  27561. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27562. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27563. protected _worldViewProjectionMatrix: Matrix;
  27564. protected _globalAmbientColor: Color3;
  27565. protected _useLogarithmicDepth: boolean;
  27566. protected _rebuildInParallel: boolean;
  27567. /**
  27568. * Instantiates a new standard material.
  27569. * This is the default material used in Babylon. It is the best trade off between quality
  27570. * and performances.
  27571. * @see http://doc.babylonjs.com/babylon101/materials
  27572. * @param name Define the name of the material in the scene
  27573. * @param scene Define the scene the material belong to
  27574. */
  27575. constructor(name: string, scene: Scene);
  27576. /**
  27577. * Gets a boolean indicating that current material needs to register RTT
  27578. */
  27579. get hasRenderTargetTextures(): boolean;
  27580. /**
  27581. * Gets the current class name of the material e.g. "StandardMaterial"
  27582. * Mainly use in serialization.
  27583. * @returns the class name
  27584. */
  27585. getClassName(): string;
  27586. /**
  27587. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27588. * You can try switching to logarithmic depth.
  27589. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27590. */
  27591. get useLogarithmicDepth(): boolean;
  27592. set useLogarithmicDepth(value: boolean);
  27593. /**
  27594. * Specifies if the material will require alpha blending
  27595. * @returns a boolean specifying if alpha blending is needed
  27596. */
  27597. needAlphaBlending(): boolean;
  27598. /**
  27599. * Specifies if this material should be rendered in alpha test mode
  27600. * @returns a boolean specifying if an alpha test is needed.
  27601. */
  27602. needAlphaTesting(): boolean;
  27603. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27604. /**
  27605. * Get the texture used for alpha test purpose.
  27606. * @returns the diffuse texture in case of the standard material.
  27607. */
  27608. getAlphaTestTexture(): Nullable<BaseTexture>;
  27609. /**
  27610. * Get if the submesh is ready to be used and all its information available.
  27611. * Child classes can use it to update shaders
  27612. * @param mesh defines the mesh to check
  27613. * @param subMesh defines which submesh to check
  27614. * @param useInstances specifies that instances should be used
  27615. * @returns a boolean indicating that the submesh is ready or not
  27616. */
  27617. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27618. /**
  27619. * Builds the material UBO layouts.
  27620. * Used internally during the effect preparation.
  27621. */
  27622. buildUniformLayout(): void;
  27623. /**
  27624. * Unbinds the material from the mesh
  27625. */
  27626. unbind(): void;
  27627. /**
  27628. * Binds the submesh to this material by preparing the effect and shader to draw
  27629. * @param world defines the world transformation matrix
  27630. * @param mesh defines the mesh containing the submesh
  27631. * @param subMesh defines the submesh to bind the material to
  27632. */
  27633. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27634. /**
  27635. * Get the list of animatables in the material.
  27636. * @returns the list of animatables object used in the material
  27637. */
  27638. getAnimatables(): IAnimatable[];
  27639. /**
  27640. * Gets the active textures from the material
  27641. * @returns an array of textures
  27642. */
  27643. getActiveTextures(): BaseTexture[];
  27644. /**
  27645. * Specifies if the material uses a texture
  27646. * @param texture defines the texture to check against the material
  27647. * @returns a boolean specifying if the material uses the texture
  27648. */
  27649. hasTexture(texture: BaseTexture): boolean;
  27650. /**
  27651. * Disposes the material
  27652. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27653. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27654. */
  27655. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27656. /**
  27657. * Makes a duplicate of the material, and gives it a new name
  27658. * @param name defines the new name for the duplicated material
  27659. * @returns the cloned material
  27660. */
  27661. clone(name: string): StandardMaterial;
  27662. /**
  27663. * Serializes this material in a JSON representation
  27664. * @returns the serialized material object
  27665. */
  27666. serialize(): any;
  27667. /**
  27668. * Creates a standard material from parsed material data
  27669. * @param source defines the JSON representation of the material
  27670. * @param scene defines the hosting scene
  27671. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27672. * @returns a new standard material
  27673. */
  27674. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27675. /**
  27676. * Are diffuse textures enabled in the application.
  27677. */
  27678. static get DiffuseTextureEnabled(): boolean;
  27679. static set DiffuseTextureEnabled(value: boolean);
  27680. /**
  27681. * Are ambient textures enabled in the application.
  27682. */
  27683. static get AmbientTextureEnabled(): boolean;
  27684. static set AmbientTextureEnabled(value: boolean);
  27685. /**
  27686. * Are opacity textures enabled in the application.
  27687. */
  27688. static get OpacityTextureEnabled(): boolean;
  27689. static set OpacityTextureEnabled(value: boolean);
  27690. /**
  27691. * Are reflection textures enabled in the application.
  27692. */
  27693. static get ReflectionTextureEnabled(): boolean;
  27694. static set ReflectionTextureEnabled(value: boolean);
  27695. /**
  27696. * Are emissive textures enabled in the application.
  27697. */
  27698. static get EmissiveTextureEnabled(): boolean;
  27699. static set EmissiveTextureEnabled(value: boolean);
  27700. /**
  27701. * Are specular textures enabled in the application.
  27702. */
  27703. static get SpecularTextureEnabled(): boolean;
  27704. static set SpecularTextureEnabled(value: boolean);
  27705. /**
  27706. * Are bump textures enabled in the application.
  27707. */
  27708. static get BumpTextureEnabled(): boolean;
  27709. static set BumpTextureEnabled(value: boolean);
  27710. /**
  27711. * Are lightmap textures enabled in the application.
  27712. */
  27713. static get LightmapTextureEnabled(): boolean;
  27714. static set LightmapTextureEnabled(value: boolean);
  27715. /**
  27716. * Are refraction textures enabled in the application.
  27717. */
  27718. static get RefractionTextureEnabled(): boolean;
  27719. static set RefractionTextureEnabled(value: boolean);
  27720. /**
  27721. * Are color grading textures enabled in the application.
  27722. */
  27723. static get ColorGradingTextureEnabled(): boolean;
  27724. static set ColorGradingTextureEnabled(value: boolean);
  27725. /**
  27726. * Are fresnels enabled in the application.
  27727. */
  27728. static get FresnelEnabled(): boolean;
  27729. static set FresnelEnabled(value: boolean);
  27730. }
  27731. }
  27732. declare module "babylonjs/Particles/solidParticleSystem" {
  27733. import { Nullable } from "babylonjs/types";
  27734. import { Vector3 } from "babylonjs/Maths/math.vector";
  27735. import { Mesh } from "babylonjs/Meshes/mesh";
  27736. import { Scene, IDisposable } from "babylonjs/scene";
  27737. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27738. import { Material } from "babylonjs/Materials/material";
  27739. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27740. /**
  27741. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27742. *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.
  27743. * The SPS is also a particle system. It provides some methods to manage the particles.
  27744. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27745. *
  27746. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27747. */
  27748. export class SolidParticleSystem implements IDisposable {
  27749. /**
  27750. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27751. * Example : var p = SPS.particles[i];
  27752. */
  27753. particles: SolidParticle[];
  27754. /**
  27755. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27756. */
  27757. nbParticles: number;
  27758. /**
  27759. * If the particles must ever face the camera (default false). Useful for planar particles.
  27760. */
  27761. billboard: boolean;
  27762. /**
  27763. * Recompute normals when adding a shape
  27764. */
  27765. recomputeNormals: boolean;
  27766. /**
  27767. * This a counter ofr your own usage. It's not set by any SPS functions.
  27768. */
  27769. counter: number;
  27770. /**
  27771. * The SPS name. This name is also given to the underlying mesh.
  27772. */
  27773. name: string;
  27774. /**
  27775. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27776. */
  27777. mesh: Mesh;
  27778. /**
  27779. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27780. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27781. */
  27782. vars: any;
  27783. /**
  27784. * This array is populated when the SPS is set as 'pickable'.
  27785. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27786. * Each element of this array is an object `{idx: int, faceId: int}`.
  27787. * `idx` is the picked particle index in the `SPS.particles` array
  27788. * `faceId` is the picked face index counted within this particle.
  27789. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27790. */
  27791. pickedParticles: {
  27792. idx: number;
  27793. faceId: number;
  27794. }[];
  27795. /**
  27796. * This array is populated when `enableDepthSort` is set to true.
  27797. * Each element of this array is an instance of the class DepthSortedParticle.
  27798. */
  27799. depthSortedParticles: DepthSortedParticle[];
  27800. /**
  27801. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27802. * @hidden
  27803. */
  27804. _bSphereOnly: boolean;
  27805. /**
  27806. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27807. * @hidden
  27808. */
  27809. _bSphereRadiusFactor: number;
  27810. private _scene;
  27811. private _positions;
  27812. private _indices;
  27813. private _normals;
  27814. private _colors;
  27815. private _uvs;
  27816. private _indices32;
  27817. private _positions32;
  27818. private _normals32;
  27819. private _fixedNormal32;
  27820. private _colors32;
  27821. private _uvs32;
  27822. private _index;
  27823. private _updatable;
  27824. private _pickable;
  27825. private _isVisibilityBoxLocked;
  27826. private _alwaysVisible;
  27827. private _depthSort;
  27828. private _expandable;
  27829. private _shapeCounter;
  27830. private _copy;
  27831. private _color;
  27832. private _computeParticleColor;
  27833. private _computeParticleTexture;
  27834. private _computeParticleRotation;
  27835. private _computeParticleVertex;
  27836. private _computeBoundingBox;
  27837. private _depthSortParticles;
  27838. private _camera;
  27839. private _mustUnrotateFixedNormals;
  27840. private _particlesIntersect;
  27841. private _needs32Bits;
  27842. private _isNotBuilt;
  27843. private _lastParticleId;
  27844. private _idxOfId;
  27845. private _multimaterialEnabled;
  27846. private _useModelMaterial;
  27847. private _indicesByMaterial;
  27848. private _materialIndexes;
  27849. private _depthSortFunction;
  27850. private _materialSortFunction;
  27851. private _materials;
  27852. private _multimaterial;
  27853. private _materialIndexesById;
  27854. private _defaultMaterial;
  27855. private _autoUpdateSubMeshes;
  27856. /**
  27857. * Creates a SPS (Solid Particle System) object.
  27858. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27859. * @param scene (Scene) is the scene in which the SPS is added.
  27860. * @param options defines the options of the sps e.g.
  27861. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27862. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27863. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27864. * * 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.
  27865. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27866. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27867. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27868. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27869. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27870. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27871. */
  27872. constructor(name: string, scene: Scene, options?: {
  27873. updatable?: boolean;
  27874. isPickable?: boolean;
  27875. enableDepthSort?: boolean;
  27876. particleIntersection?: boolean;
  27877. boundingSphereOnly?: boolean;
  27878. bSphereRadiusFactor?: number;
  27879. expandable?: boolean;
  27880. useModelMaterial?: boolean;
  27881. enableMultiMaterial?: boolean;
  27882. });
  27883. /**
  27884. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27885. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27886. * @returns the created mesh
  27887. */
  27888. buildMesh(): Mesh;
  27889. /**
  27890. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27891. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27892. * Thus the particles generated from `digest()` have their property `position` set yet.
  27893. * @param mesh ( Mesh ) is the mesh to be digested
  27894. * @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
  27895. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27896. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27897. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27898. * @returns the current SPS
  27899. */
  27900. digest(mesh: Mesh, options?: {
  27901. facetNb?: number;
  27902. number?: number;
  27903. delta?: number;
  27904. storage?: [];
  27905. }): SolidParticleSystem;
  27906. /**
  27907. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27908. * @hidden
  27909. */
  27910. private _unrotateFixedNormals;
  27911. /**
  27912. * Resets the temporary working copy particle
  27913. * @hidden
  27914. */
  27915. private _resetCopy;
  27916. /**
  27917. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27918. * @param p the current index in the positions array to be updated
  27919. * @param ind the current index in the indices array
  27920. * @param shape a Vector3 array, the shape geometry
  27921. * @param positions the positions array to be updated
  27922. * @param meshInd the shape indices array
  27923. * @param indices the indices array to be updated
  27924. * @param meshUV the shape uv array
  27925. * @param uvs the uv array to be updated
  27926. * @param meshCol the shape color array
  27927. * @param colors the color array to be updated
  27928. * @param meshNor the shape normals array
  27929. * @param normals the normals array to be updated
  27930. * @param idx the particle index
  27931. * @param idxInShape the particle index in its shape
  27932. * @param options the addShape() method passed options
  27933. * @model the particle model
  27934. * @hidden
  27935. */
  27936. private _meshBuilder;
  27937. /**
  27938. * Returns a shape Vector3 array from positions float array
  27939. * @param positions float array
  27940. * @returns a vector3 array
  27941. * @hidden
  27942. */
  27943. private _posToShape;
  27944. /**
  27945. * Returns a shapeUV array from a float uvs (array deep copy)
  27946. * @param uvs as a float array
  27947. * @returns a shapeUV array
  27948. * @hidden
  27949. */
  27950. private _uvsToShapeUV;
  27951. /**
  27952. * Adds a new particle object in the particles array
  27953. * @param idx particle index in particles array
  27954. * @param id particle id
  27955. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27956. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27957. * @param model particle ModelShape object
  27958. * @param shapeId model shape identifier
  27959. * @param idxInShape index of the particle in the current model
  27960. * @param bInfo model bounding info object
  27961. * @param storage target storage array, if any
  27962. * @hidden
  27963. */
  27964. private _addParticle;
  27965. /**
  27966. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27967. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27968. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27969. * @param nb (positive integer) the number of particles to be created from this model
  27970. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27971. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27972. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27973. * @returns the number of shapes in the system
  27974. */
  27975. addShape(mesh: Mesh, nb: number, options?: {
  27976. positionFunction?: any;
  27977. vertexFunction?: any;
  27978. storage?: [];
  27979. }): number;
  27980. /**
  27981. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27982. * @hidden
  27983. */
  27984. private _rebuildParticle;
  27985. /**
  27986. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27987. * @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.
  27988. * @returns the SPS.
  27989. */
  27990. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27991. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27992. * Returns an array with the removed particles.
  27993. * 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.
  27994. * The SPS can't be empty so at least one particle needs to remain in place.
  27995. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27996. * @param start index of the first particle to remove
  27997. * @param end index of the last particle to remove (included)
  27998. * @returns an array populated with the removed particles
  27999. */
  28000. removeParticles(start: number, end: number): SolidParticle[];
  28001. /**
  28002. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28003. * @param solidParticleArray an array populated with Solid Particles objects
  28004. * @returns the SPS
  28005. */
  28006. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28007. /**
  28008. * Creates a new particle and modifies the SPS mesh geometry :
  28009. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28010. * - calls _addParticle() to populate the particle array
  28011. * factorized code from addShape() and insertParticlesFromArray()
  28012. * @param idx particle index in the particles array
  28013. * @param i particle index in its shape
  28014. * @param modelShape particle ModelShape object
  28015. * @param shape shape vertex array
  28016. * @param meshInd shape indices array
  28017. * @param meshUV shape uv array
  28018. * @param meshCol shape color array
  28019. * @param meshNor shape normals array
  28020. * @param bbInfo shape bounding info
  28021. * @param storage target particle storage
  28022. * @options addShape() passed options
  28023. * @hidden
  28024. */
  28025. private _insertNewParticle;
  28026. /**
  28027. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28028. * This method calls `updateParticle()` for each particle of the SPS.
  28029. * For an animated SPS, it is usually called within the render loop.
  28030. * 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.
  28031. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28032. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28033. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28034. * @returns the SPS.
  28035. */
  28036. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28037. /**
  28038. * Disposes the SPS.
  28039. */
  28040. dispose(): void;
  28041. /**
  28042. * Returns a SolidParticle object from its identifier : particle.id
  28043. * @param id (integer) the particle Id
  28044. * @returns the searched particle or null if not found in the SPS.
  28045. */
  28046. getParticleById(id: number): Nullable<SolidParticle>;
  28047. /**
  28048. * Returns a new array populated with the particles having the passed shapeId.
  28049. * @param shapeId (integer) the shape identifier
  28050. * @returns a new solid particle array
  28051. */
  28052. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28053. /**
  28054. * Populates the passed array "ref" with the particles having the passed shapeId.
  28055. * @param shapeId the shape identifier
  28056. * @returns the SPS
  28057. * @param ref
  28058. */
  28059. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28060. /**
  28061. * Computes the required SubMeshes according the materials assigned to the particles.
  28062. * @returns the solid particle system.
  28063. * Does nothing if called before the SPS mesh is built.
  28064. */
  28065. computeSubMeshes(): SolidParticleSystem;
  28066. /**
  28067. * Sorts the solid particles by material when MultiMaterial is enabled.
  28068. * Updates the indices32 array.
  28069. * Updates the indicesByMaterial array.
  28070. * Updates the mesh indices array.
  28071. * @returns the SPS
  28072. * @hidden
  28073. */
  28074. private _sortParticlesByMaterial;
  28075. /**
  28076. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28077. * @hidden
  28078. */
  28079. private _setMaterialIndexesById;
  28080. /**
  28081. * Returns an array with unique values of Materials from the passed array
  28082. * @param array the material array to be checked and filtered
  28083. * @hidden
  28084. */
  28085. private _filterUniqueMaterialId;
  28086. /**
  28087. * Sets a new Standard Material as _defaultMaterial if not already set.
  28088. * @hidden
  28089. */
  28090. private _setDefaultMaterial;
  28091. /**
  28092. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28093. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28094. * @returns the SPS.
  28095. */
  28096. refreshVisibleSize(): SolidParticleSystem;
  28097. /**
  28098. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28099. * @param size the size (float) of the visibility box
  28100. * note : this doesn't lock the SPS mesh bounding box.
  28101. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28102. */
  28103. setVisibilityBox(size: number): void;
  28104. /**
  28105. * Gets whether the SPS as always visible or not
  28106. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28107. */
  28108. get isAlwaysVisible(): boolean;
  28109. /**
  28110. * Sets the SPS as always visible or not
  28111. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28112. */
  28113. set isAlwaysVisible(val: boolean);
  28114. /**
  28115. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28116. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28117. */
  28118. set isVisibilityBoxLocked(val: boolean);
  28119. /**
  28120. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28121. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28122. */
  28123. get isVisibilityBoxLocked(): boolean;
  28124. /**
  28125. * Tells to `setParticles()` to compute the particle rotations or not.
  28126. * Default value : true. The SPS is faster when it's set to false.
  28127. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28128. */
  28129. set computeParticleRotation(val: boolean);
  28130. /**
  28131. * Tells to `setParticles()` to compute the particle colors or not.
  28132. * Default value : true. The SPS is faster when it's set to false.
  28133. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28134. */
  28135. set computeParticleColor(val: boolean);
  28136. set computeParticleTexture(val: boolean);
  28137. /**
  28138. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28139. * Default value : false. The SPS is faster when it's set to false.
  28140. * Note : the particle custom vertex positions aren't stored values.
  28141. */
  28142. set computeParticleVertex(val: boolean);
  28143. /**
  28144. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28145. */
  28146. set computeBoundingBox(val: boolean);
  28147. /**
  28148. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28149. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28150. * Default : `true`
  28151. */
  28152. set depthSortParticles(val: boolean);
  28153. /**
  28154. * Gets if `setParticles()` computes the particle rotations or not.
  28155. * Default value : true. The SPS is faster when it's set to false.
  28156. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28157. */
  28158. get computeParticleRotation(): boolean;
  28159. /**
  28160. * Gets if `setParticles()` computes the particle colors or not.
  28161. * Default value : true. The SPS is faster when it's set to false.
  28162. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28163. */
  28164. get computeParticleColor(): boolean;
  28165. /**
  28166. * Gets if `setParticles()` computes the particle textures or not.
  28167. * Default value : true. The SPS is faster when it's set to false.
  28168. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28169. */
  28170. get computeParticleTexture(): boolean;
  28171. /**
  28172. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28173. * Default value : false. The SPS is faster when it's set to false.
  28174. * Note : the particle custom vertex positions aren't stored values.
  28175. */
  28176. get computeParticleVertex(): boolean;
  28177. /**
  28178. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28179. */
  28180. get computeBoundingBox(): boolean;
  28181. /**
  28182. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28183. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28184. * Default : `true`
  28185. */
  28186. get depthSortParticles(): boolean;
  28187. /**
  28188. * Gets if the SPS is created as expandable at construction time.
  28189. * Default : `false`
  28190. */
  28191. get expandable(): boolean;
  28192. /**
  28193. * Gets if the SPS supports the Multi Materials
  28194. */
  28195. get multimaterialEnabled(): boolean;
  28196. /**
  28197. * Gets if the SPS uses the model materials for its own multimaterial.
  28198. */
  28199. get useModelMaterial(): boolean;
  28200. /**
  28201. * The SPS used material array.
  28202. */
  28203. get materials(): Material[];
  28204. /**
  28205. * Sets the SPS MultiMaterial from the passed materials.
  28206. * Note : the passed array is internally copied and not used then by reference.
  28207. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28208. */
  28209. setMultiMaterial(materials: Material[]): void;
  28210. /**
  28211. * The SPS computed multimaterial object
  28212. */
  28213. get multimaterial(): MultiMaterial;
  28214. set multimaterial(mm: MultiMaterial);
  28215. /**
  28216. * If the subMeshes must be updated on the next call to setParticles()
  28217. */
  28218. get autoUpdateSubMeshes(): boolean;
  28219. set autoUpdateSubMeshes(val: boolean);
  28220. /**
  28221. * This function does nothing. It may be overwritten to set all the particle first values.
  28222. * The SPS doesn't call this function, you may have to call it by your own.
  28223. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28224. */
  28225. initParticles(): void;
  28226. /**
  28227. * This function does nothing. It may be overwritten to recycle a particle.
  28228. * The SPS doesn't call this function, you may have to call it by your own.
  28229. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28230. * @param particle The particle to recycle
  28231. * @returns the recycled particle
  28232. */
  28233. recycleParticle(particle: SolidParticle): SolidParticle;
  28234. /**
  28235. * Updates a particle : this function should be overwritten by the user.
  28236. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28237. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28238. * @example : just set a particle position or velocity and recycle conditions
  28239. * @param particle The particle to update
  28240. * @returns the updated particle
  28241. */
  28242. updateParticle(particle: SolidParticle): SolidParticle;
  28243. /**
  28244. * Updates a vertex of a particle : it can be overwritten by the user.
  28245. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28246. * @param particle the current particle
  28247. * @param vertex the current index of the current particle
  28248. * @param pt the index of the current vertex in the particle shape
  28249. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28250. * @example : just set a vertex particle position
  28251. * @returns the updated vertex
  28252. */
  28253. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28254. /**
  28255. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28256. * This does nothing and may be overwritten by the user.
  28257. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28258. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28259. * @param update the boolean update value actually passed to setParticles()
  28260. */
  28261. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28262. /**
  28263. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28264. * This will be passed three parameters.
  28265. * This does nothing and may be overwritten by the user.
  28266. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28267. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28268. * @param update the boolean update value actually passed to setParticles()
  28269. */
  28270. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28271. }
  28272. }
  28273. declare module "babylonjs/Particles/solidParticle" {
  28274. import { Nullable } from "babylonjs/types";
  28275. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28276. import { Color4 } from "babylonjs/Maths/math.color";
  28277. import { Mesh } from "babylonjs/Meshes/mesh";
  28278. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28279. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28280. import { Plane } from "babylonjs/Maths/math.plane";
  28281. import { Material } from "babylonjs/Materials/material";
  28282. /**
  28283. * Represents one particle of a solid particle system.
  28284. */
  28285. export class SolidParticle {
  28286. /**
  28287. * particle global index
  28288. */
  28289. idx: number;
  28290. /**
  28291. * particle identifier
  28292. */
  28293. id: number;
  28294. /**
  28295. * The color of the particle
  28296. */
  28297. color: Nullable<Color4>;
  28298. /**
  28299. * The world space position of the particle.
  28300. */
  28301. position: Vector3;
  28302. /**
  28303. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28304. */
  28305. rotation: Vector3;
  28306. /**
  28307. * The world space rotation quaternion of the particle.
  28308. */
  28309. rotationQuaternion: Nullable<Quaternion>;
  28310. /**
  28311. * The scaling of the particle.
  28312. */
  28313. scaling: Vector3;
  28314. /**
  28315. * The uvs of the particle.
  28316. */
  28317. uvs: Vector4;
  28318. /**
  28319. * The current speed of the particle.
  28320. */
  28321. velocity: Vector3;
  28322. /**
  28323. * The pivot point in the particle local space.
  28324. */
  28325. pivot: Vector3;
  28326. /**
  28327. * Must the particle be translated from its pivot point in its local space ?
  28328. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28329. * Default : false
  28330. */
  28331. translateFromPivot: boolean;
  28332. /**
  28333. * Is the particle active or not ?
  28334. */
  28335. alive: boolean;
  28336. /**
  28337. * Is the particle visible or not ?
  28338. */
  28339. isVisible: boolean;
  28340. /**
  28341. * Index of this particle in the global "positions" array (Internal use)
  28342. * @hidden
  28343. */
  28344. _pos: number;
  28345. /**
  28346. * @hidden Index of this particle in the global "indices" array (Internal use)
  28347. */
  28348. _ind: number;
  28349. /**
  28350. * @hidden ModelShape of this particle (Internal use)
  28351. */
  28352. _model: ModelShape;
  28353. /**
  28354. * ModelShape id of this particle
  28355. */
  28356. shapeId: number;
  28357. /**
  28358. * Index of the particle in its shape id
  28359. */
  28360. idxInShape: number;
  28361. /**
  28362. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28363. */
  28364. _modelBoundingInfo: BoundingInfo;
  28365. /**
  28366. * @hidden Particle BoundingInfo object (Internal use)
  28367. */
  28368. _boundingInfo: BoundingInfo;
  28369. /**
  28370. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28371. */
  28372. _sps: SolidParticleSystem;
  28373. /**
  28374. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28375. */
  28376. _stillInvisible: boolean;
  28377. /**
  28378. * @hidden Last computed particle rotation matrix
  28379. */
  28380. _rotationMatrix: number[];
  28381. /**
  28382. * Parent particle Id, if any.
  28383. * Default null.
  28384. */
  28385. parentId: Nullable<number>;
  28386. /**
  28387. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28388. */
  28389. materialIndex: Nullable<number>;
  28390. /**
  28391. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28392. * The possible values are :
  28393. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28394. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28395. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28396. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28397. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28398. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28399. * */
  28400. cullingStrategy: number;
  28401. /**
  28402. * @hidden Internal global position in the SPS.
  28403. */
  28404. _globalPosition: Vector3;
  28405. /**
  28406. * Creates a Solid Particle object.
  28407. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28408. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28409. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28410. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28411. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28412. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28413. * @param shapeId (integer) is the model shape identifier in the SPS.
  28414. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28415. * @param sps defines the sps it is associated to
  28416. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28417. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28418. */
  28419. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28420. /**
  28421. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28422. * @param target the particle target
  28423. * @returns the current particle
  28424. */
  28425. copyToRef(target: SolidParticle): SolidParticle;
  28426. /**
  28427. * Legacy support, changed scale to scaling
  28428. */
  28429. get scale(): Vector3;
  28430. /**
  28431. * Legacy support, changed scale to scaling
  28432. */
  28433. set scale(scale: Vector3);
  28434. /**
  28435. * Legacy support, changed quaternion to rotationQuaternion
  28436. */
  28437. get quaternion(): Nullable<Quaternion>;
  28438. /**
  28439. * Legacy support, changed quaternion to rotationQuaternion
  28440. */
  28441. set quaternion(q: Nullable<Quaternion>);
  28442. /**
  28443. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28444. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28445. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28446. * @returns true if it intersects
  28447. */
  28448. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28449. /**
  28450. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28451. * A particle is in the frustum if its bounding box intersects the frustum
  28452. * @param frustumPlanes defines the frustum to test
  28453. * @returns true if the particle is in the frustum planes
  28454. */
  28455. isInFrustum(frustumPlanes: Plane[]): boolean;
  28456. /**
  28457. * get the rotation matrix of the particle
  28458. * @hidden
  28459. */
  28460. getRotationMatrix(m: Matrix): void;
  28461. }
  28462. /**
  28463. * Represents the shape of the model used by one particle of a solid particle system.
  28464. * SPS internal tool, don't use it manually.
  28465. */
  28466. export class ModelShape {
  28467. /**
  28468. * The shape id
  28469. * @hidden
  28470. */
  28471. shapeID: number;
  28472. /**
  28473. * flat array of model positions (internal use)
  28474. * @hidden
  28475. */
  28476. _shape: Vector3[];
  28477. /**
  28478. * flat array of model UVs (internal use)
  28479. * @hidden
  28480. */
  28481. _shapeUV: number[];
  28482. /**
  28483. * color array of the model
  28484. * @hidden
  28485. */
  28486. _shapeColors: number[];
  28487. /**
  28488. * indices array of the model
  28489. * @hidden
  28490. */
  28491. _indices: number[];
  28492. /**
  28493. * normals array of the model
  28494. * @hidden
  28495. */
  28496. _normals: number[];
  28497. /**
  28498. * length of the shape in the model indices array (internal use)
  28499. * @hidden
  28500. */
  28501. _indicesLength: number;
  28502. /**
  28503. * Custom position function (internal use)
  28504. * @hidden
  28505. */
  28506. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28507. /**
  28508. * Custom vertex function (internal use)
  28509. * @hidden
  28510. */
  28511. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28512. /**
  28513. * Model material (internal use)
  28514. * @hidden
  28515. */
  28516. _material: Nullable<Material>;
  28517. /**
  28518. * 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.
  28519. * SPS internal tool, don't use it manually.
  28520. * @hidden
  28521. */
  28522. 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>);
  28523. }
  28524. /**
  28525. * Represents a Depth Sorted Particle in the solid particle system.
  28526. * @hidden
  28527. */
  28528. export class DepthSortedParticle {
  28529. /**
  28530. * Index of the particle in the "indices" array
  28531. */
  28532. ind: number;
  28533. /**
  28534. * Length of the particle shape in the "indices" array
  28535. */
  28536. indicesLength: number;
  28537. /**
  28538. * Squared distance from the particle to the camera
  28539. */
  28540. sqDistance: number;
  28541. /**
  28542. * Material index when used with MultiMaterials
  28543. */
  28544. materialIndex: number;
  28545. /**
  28546. * Creates a new sorted particle
  28547. * @param materialIndex
  28548. */
  28549. constructor(ind: number, indLength: number, materialIndex: number);
  28550. }
  28551. }
  28552. declare module "babylonjs/Collisions/meshCollisionData" {
  28553. import { Collider } from "babylonjs/Collisions/collider";
  28554. import { Vector3 } from "babylonjs/Maths/math.vector";
  28555. import { Nullable } from "babylonjs/types";
  28556. import { Observer } from "babylonjs/Misc/observable";
  28557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28558. /**
  28559. * @hidden
  28560. */
  28561. export class _MeshCollisionData {
  28562. _checkCollisions: boolean;
  28563. _collisionMask: number;
  28564. _collisionGroup: number;
  28565. _collider: Nullable<Collider>;
  28566. _oldPositionForCollisions: Vector3;
  28567. _diffPositionForCollisions: Vector3;
  28568. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28569. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28570. }
  28571. }
  28572. declare module "babylonjs/Meshes/abstractMesh" {
  28573. import { Observable } from "babylonjs/Misc/observable";
  28574. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28575. import { Camera } from "babylonjs/Cameras/camera";
  28576. import { Scene, IDisposable } from "babylonjs/scene";
  28577. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28578. import { Node } from "babylonjs/node";
  28579. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28580. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28581. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28582. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28583. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28584. import { Material } from "babylonjs/Materials/material";
  28585. import { Light } from "babylonjs/Lights/light";
  28586. import { Skeleton } from "babylonjs/Bones/skeleton";
  28587. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28588. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28589. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28590. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28591. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28592. import { Plane } from "babylonjs/Maths/math.plane";
  28593. import { Ray } from "babylonjs/Culling/ray";
  28594. import { Collider } from "babylonjs/Collisions/collider";
  28595. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28596. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28597. /** @hidden */
  28598. class _FacetDataStorage {
  28599. facetPositions: Vector3[];
  28600. facetNormals: Vector3[];
  28601. facetPartitioning: number[][];
  28602. facetNb: number;
  28603. partitioningSubdivisions: number;
  28604. partitioningBBoxRatio: number;
  28605. facetDataEnabled: boolean;
  28606. facetParameters: any;
  28607. bbSize: Vector3;
  28608. subDiv: {
  28609. max: number;
  28610. X: number;
  28611. Y: number;
  28612. Z: number;
  28613. };
  28614. facetDepthSort: boolean;
  28615. facetDepthSortEnabled: boolean;
  28616. depthSortedIndices: IndicesArray;
  28617. depthSortedFacets: {
  28618. ind: number;
  28619. sqDistance: number;
  28620. }[];
  28621. facetDepthSortFunction: (f1: {
  28622. ind: number;
  28623. sqDistance: number;
  28624. }, f2: {
  28625. ind: number;
  28626. sqDistance: number;
  28627. }) => number;
  28628. facetDepthSortFrom: Vector3;
  28629. facetDepthSortOrigin: Vector3;
  28630. invertedMatrix: Matrix;
  28631. }
  28632. /**
  28633. * @hidden
  28634. **/
  28635. class _InternalAbstractMeshDataInfo {
  28636. _hasVertexAlpha: boolean;
  28637. _useVertexColors: boolean;
  28638. _numBoneInfluencers: number;
  28639. _applyFog: boolean;
  28640. _receiveShadows: boolean;
  28641. _facetData: _FacetDataStorage;
  28642. _visibility: number;
  28643. _skeleton: Nullable<Skeleton>;
  28644. _layerMask: number;
  28645. _computeBonesUsingShaders: boolean;
  28646. _isActive: boolean;
  28647. _onlyForInstances: boolean;
  28648. _isActiveIntermediate: boolean;
  28649. _onlyForInstancesIntermediate: boolean;
  28650. _actAsRegularMesh: boolean;
  28651. }
  28652. /**
  28653. * Class used to store all common mesh properties
  28654. */
  28655. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28656. /** No occlusion */
  28657. static OCCLUSION_TYPE_NONE: number;
  28658. /** Occlusion set to optimisitic */
  28659. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28660. /** Occlusion set to strict */
  28661. static OCCLUSION_TYPE_STRICT: number;
  28662. /** Use an accurante occlusion algorithm */
  28663. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28664. /** Use a conservative occlusion algorithm */
  28665. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28666. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28667. * Test order :
  28668. * Is the bounding sphere outside the frustum ?
  28669. * If not, are the bounding box vertices outside the frustum ?
  28670. * It not, then the cullable object is in the frustum.
  28671. */
  28672. static readonly CULLINGSTRATEGY_STANDARD: number;
  28673. /** Culling strategy : Bounding Sphere Only.
  28674. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28675. * It's also less accurate than the standard because some not visible objects can still be selected.
  28676. * Test : is the bounding sphere outside the frustum ?
  28677. * If not, then the cullable object is in the frustum.
  28678. */
  28679. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28680. /** Culling strategy : Optimistic Inclusion.
  28681. * This in an inclusion test first, then the standard exclusion test.
  28682. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28683. * 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.
  28684. * Anyway, it's as accurate as the standard strategy.
  28685. * Test :
  28686. * Is the cullable object bounding sphere center in the frustum ?
  28687. * If not, apply the default culling strategy.
  28688. */
  28689. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28690. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28691. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28692. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28693. * 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.
  28694. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28695. * Test :
  28696. * Is the cullable object bounding sphere center in the frustum ?
  28697. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28698. */
  28699. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28700. /**
  28701. * No billboard
  28702. */
  28703. static get BILLBOARDMODE_NONE(): number;
  28704. /** Billboard on X axis */
  28705. static get BILLBOARDMODE_X(): number;
  28706. /** Billboard on Y axis */
  28707. static get BILLBOARDMODE_Y(): number;
  28708. /** Billboard on Z axis */
  28709. static get BILLBOARDMODE_Z(): number;
  28710. /** Billboard on all axes */
  28711. static get BILLBOARDMODE_ALL(): number;
  28712. /** Billboard on using position instead of orientation */
  28713. static get BILLBOARDMODE_USE_POSITION(): number;
  28714. /** @hidden */
  28715. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28716. /**
  28717. * The culling strategy to use to check whether the mesh must be rendered or not.
  28718. * This value can be changed at any time and will be used on the next render mesh selection.
  28719. * The possible values are :
  28720. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28721. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28722. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28723. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28724. * Please read each static variable documentation to get details about the culling process.
  28725. * */
  28726. cullingStrategy: number;
  28727. /**
  28728. * Gets the number of facets in the mesh
  28729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28730. */
  28731. get facetNb(): number;
  28732. /**
  28733. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28734. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28735. */
  28736. get partitioningSubdivisions(): number;
  28737. set partitioningSubdivisions(nb: number);
  28738. /**
  28739. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28740. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28741. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28742. */
  28743. get partitioningBBoxRatio(): number;
  28744. set partitioningBBoxRatio(ratio: number);
  28745. /**
  28746. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28747. * Works only for updatable meshes.
  28748. * Doesn't work with multi-materials
  28749. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28750. */
  28751. get mustDepthSortFacets(): boolean;
  28752. set mustDepthSortFacets(sort: boolean);
  28753. /**
  28754. * The location (Vector3) where the facet depth sort must be computed from.
  28755. * By default, the active camera position.
  28756. * Used only when facet depth sort is enabled
  28757. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28758. */
  28759. get facetDepthSortFrom(): Vector3;
  28760. set facetDepthSortFrom(location: Vector3);
  28761. /**
  28762. * gets a boolean indicating if facetData is enabled
  28763. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28764. */
  28765. get isFacetDataEnabled(): boolean;
  28766. /** @hidden */
  28767. _updateNonUniformScalingState(value: boolean): boolean;
  28768. /**
  28769. * An event triggered when this mesh collides with another one
  28770. */
  28771. onCollideObservable: Observable<AbstractMesh>;
  28772. /** Set a function to call when this mesh collides with another one */
  28773. set onCollide(callback: () => void);
  28774. /**
  28775. * An event triggered when the collision's position changes
  28776. */
  28777. onCollisionPositionChangeObservable: Observable<Vector3>;
  28778. /** Set a function to call when the collision's position changes */
  28779. set onCollisionPositionChange(callback: () => void);
  28780. /**
  28781. * An event triggered when material is changed
  28782. */
  28783. onMaterialChangedObservable: Observable<AbstractMesh>;
  28784. /**
  28785. * Gets or sets the orientation for POV movement & rotation
  28786. */
  28787. definedFacingForward: boolean;
  28788. /** @hidden */
  28789. _occlusionQuery: Nullable<WebGLQuery>;
  28790. /** @hidden */
  28791. _renderingGroup: Nullable<RenderingGroup>;
  28792. /**
  28793. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28794. */
  28795. get visibility(): number;
  28796. /**
  28797. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28798. */
  28799. set visibility(value: number);
  28800. /** Gets or sets the alpha index used to sort transparent meshes
  28801. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28802. */
  28803. alphaIndex: number;
  28804. /**
  28805. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28806. */
  28807. isVisible: boolean;
  28808. /**
  28809. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28810. */
  28811. isPickable: boolean;
  28812. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28813. showSubMeshesBoundingBox: boolean;
  28814. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28815. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28816. */
  28817. isBlocker: boolean;
  28818. /**
  28819. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28820. */
  28821. enablePointerMoveEvents: boolean;
  28822. /**
  28823. * Specifies the rendering group id for this mesh (0 by default)
  28824. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28825. */
  28826. renderingGroupId: number;
  28827. private _material;
  28828. /** Gets or sets current material */
  28829. get material(): Nullable<Material>;
  28830. set material(value: Nullable<Material>);
  28831. /**
  28832. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28833. * @see http://doc.babylonjs.com/babylon101/shadows
  28834. */
  28835. get receiveShadows(): boolean;
  28836. set receiveShadows(value: boolean);
  28837. /** Defines color to use when rendering outline */
  28838. outlineColor: Color3;
  28839. /** Define width to use when rendering outline */
  28840. outlineWidth: number;
  28841. /** Defines color to use when rendering overlay */
  28842. overlayColor: Color3;
  28843. /** Defines alpha to use when rendering overlay */
  28844. overlayAlpha: number;
  28845. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28846. get hasVertexAlpha(): boolean;
  28847. set hasVertexAlpha(value: boolean);
  28848. /** 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) */
  28849. get useVertexColors(): boolean;
  28850. set useVertexColors(value: boolean);
  28851. /**
  28852. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28853. */
  28854. get computeBonesUsingShaders(): boolean;
  28855. set computeBonesUsingShaders(value: boolean);
  28856. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28857. get numBoneInfluencers(): number;
  28858. set numBoneInfluencers(value: number);
  28859. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28860. get applyFog(): boolean;
  28861. set applyFog(value: boolean);
  28862. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28863. useOctreeForRenderingSelection: boolean;
  28864. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28865. useOctreeForPicking: boolean;
  28866. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28867. useOctreeForCollisions: boolean;
  28868. /**
  28869. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28870. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28871. */
  28872. get layerMask(): number;
  28873. set layerMask(value: number);
  28874. /**
  28875. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28876. */
  28877. alwaysSelectAsActiveMesh: boolean;
  28878. /**
  28879. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28880. */
  28881. doNotSyncBoundingInfo: boolean;
  28882. /**
  28883. * Gets or sets the current action manager
  28884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28885. */
  28886. actionManager: Nullable<AbstractActionManager>;
  28887. private _meshCollisionData;
  28888. /**
  28889. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28890. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28891. */
  28892. ellipsoid: Vector3;
  28893. /**
  28894. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28895. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28896. */
  28897. ellipsoidOffset: Vector3;
  28898. /**
  28899. * Gets or sets a collision mask used to mask collisions (default is -1).
  28900. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28901. */
  28902. get collisionMask(): number;
  28903. set collisionMask(mask: number);
  28904. /**
  28905. * Gets or sets the current collision group mask (-1 by default).
  28906. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28907. */
  28908. get collisionGroup(): number;
  28909. set collisionGroup(mask: number);
  28910. /**
  28911. * Defines edge width used when edgesRenderer is enabled
  28912. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28913. */
  28914. edgesWidth: number;
  28915. /**
  28916. * Defines edge color used when edgesRenderer is enabled
  28917. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28918. */
  28919. edgesColor: Color4;
  28920. /** @hidden */
  28921. _edgesRenderer: Nullable<IEdgesRenderer>;
  28922. /** @hidden */
  28923. _masterMesh: Nullable<AbstractMesh>;
  28924. /** @hidden */
  28925. _boundingInfo: Nullable<BoundingInfo>;
  28926. /** @hidden */
  28927. _renderId: number;
  28928. /**
  28929. * Gets or sets the list of subMeshes
  28930. * @see http://doc.babylonjs.com/how_to/multi_materials
  28931. */
  28932. subMeshes: SubMesh[];
  28933. /** @hidden */
  28934. _intersectionsInProgress: AbstractMesh[];
  28935. /** @hidden */
  28936. _unIndexed: boolean;
  28937. /** @hidden */
  28938. _lightSources: Light[];
  28939. /** Gets the list of lights affecting that mesh */
  28940. get lightSources(): Light[];
  28941. /** @hidden */
  28942. get _positions(): Nullable<Vector3[]>;
  28943. /** @hidden */
  28944. _waitingData: {
  28945. lods: Nullable<any>;
  28946. actions: Nullable<any>;
  28947. freezeWorldMatrix: Nullable<boolean>;
  28948. };
  28949. /** @hidden */
  28950. _bonesTransformMatrices: Nullable<Float32Array>;
  28951. /** @hidden */
  28952. _transformMatrixTexture: Nullable<RawTexture>;
  28953. /**
  28954. * Gets or sets a skeleton to apply skining transformations
  28955. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28956. */
  28957. set skeleton(value: Nullable<Skeleton>);
  28958. get skeleton(): Nullable<Skeleton>;
  28959. /**
  28960. * An event triggered when the mesh is rebuilt.
  28961. */
  28962. onRebuildObservable: Observable<AbstractMesh>;
  28963. /**
  28964. * Creates a new AbstractMesh
  28965. * @param name defines the name of the mesh
  28966. * @param scene defines the hosting scene
  28967. */
  28968. constructor(name: string, scene?: Nullable<Scene>);
  28969. /**
  28970. * Returns the string "AbstractMesh"
  28971. * @returns "AbstractMesh"
  28972. */
  28973. getClassName(): string;
  28974. /**
  28975. * Gets a string representation of the current mesh
  28976. * @param fullDetails defines a boolean indicating if full details must be included
  28977. * @returns a string representation of the current mesh
  28978. */
  28979. toString(fullDetails?: boolean): string;
  28980. /**
  28981. * @hidden
  28982. */
  28983. protected _getEffectiveParent(): Nullable<Node>;
  28984. /** @hidden */
  28985. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28986. /** @hidden */
  28987. _rebuild(): void;
  28988. /** @hidden */
  28989. _resyncLightSources(): void;
  28990. /** @hidden */
  28991. _resyncLightSource(light: Light): void;
  28992. /** @hidden */
  28993. _unBindEffect(): void;
  28994. /** @hidden */
  28995. _removeLightSource(light: Light, dispose: boolean): void;
  28996. private _markSubMeshesAsDirty;
  28997. /** @hidden */
  28998. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28999. /** @hidden */
  29000. _markSubMeshesAsAttributesDirty(): void;
  29001. /** @hidden */
  29002. _markSubMeshesAsMiscDirty(): void;
  29003. /**
  29004. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29005. */
  29006. get scaling(): Vector3;
  29007. set scaling(newScaling: Vector3);
  29008. /**
  29009. * Returns true if the mesh is blocked. Implemented by child classes
  29010. */
  29011. get isBlocked(): boolean;
  29012. /**
  29013. * Returns the mesh itself by default. Implemented by child classes
  29014. * @param camera defines the camera to use to pick the right LOD level
  29015. * @returns the currentAbstractMesh
  29016. */
  29017. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29018. /**
  29019. * Returns 0 by default. Implemented by child classes
  29020. * @returns an integer
  29021. */
  29022. getTotalVertices(): number;
  29023. /**
  29024. * Returns a positive integer : the total number of indices in this mesh geometry.
  29025. * @returns the numner of indices or zero if the mesh has no geometry.
  29026. */
  29027. getTotalIndices(): number;
  29028. /**
  29029. * Returns null by default. Implemented by child classes
  29030. * @returns null
  29031. */
  29032. getIndices(): Nullable<IndicesArray>;
  29033. /**
  29034. * Returns the array of the requested vertex data kind. Implemented by child classes
  29035. * @param kind defines the vertex data kind to use
  29036. * @returns null
  29037. */
  29038. getVerticesData(kind: string): Nullable<FloatArray>;
  29039. /**
  29040. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29041. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29042. * Note that a new underlying VertexBuffer object is created each call.
  29043. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29044. * @param kind defines vertex data kind:
  29045. * * VertexBuffer.PositionKind
  29046. * * VertexBuffer.UVKind
  29047. * * VertexBuffer.UV2Kind
  29048. * * VertexBuffer.UV3Kind
  29049. * * VertexBuffer.UV4Kind
  29050. * * VertexBuffer.UV5Kind
  29051. * * VertexBuffer.UV6Kind
  29052. * * VertexBuffer.ColorKind
  29053. * * VertexBuffer.MatricesIndicesKind
  29054. * * VertexBuffer.MatricesIndicesExtraKind
  29055. * * VertexBuffer.MatricesWeightsKind
  29056. * * VertexBuffer.MatricesWeightsExtraKind
  29057. * @param data defines the data source
  29058. * @param updatable defines if the data must be flagged as updatable (or static)
  29059. * @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
  29060. * @returns the current mesh
  29061. */
  29062. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29063. /**
  29064. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29065. * If the mesh has no geometry, it is simply returned as it is.
  29066. * @param kind defines vertex data kind:
  29067. * * VertexBuffer.PositionKind
  29068. * * VertexBuffer.UVKind
  29069. * * VertexBuffer.UV2Kind
  29070. * * VertexBuffer.UV3Kind
  29071. * * VertexBuffer.UV4Kind
  29072. * * VertexBuffer.UV5Kind
  29073. * * VertexBuffer.UV6Kind
  29074. * * VertexBuffer.ColorKind
  29075. * * VertexBuffer.MatricesIndicesKind
  29076. * * VertexBuffer.MatricesIndicesExtraKind
  29077. * * VertexBuffer.MatricesWeightsKind
  29078. * * VertexBuffer.MatricesWeightsExtraKind
  29079. * @param data defines the data source
  29080. * @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
  29081. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29082. * @returns the current mesh
  29083. */
  29084. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29085. /**
  29086. * Sets the mesh indices,
  29087. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29088. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29089. * @param totalVertices Defines the total number of vertices
  29090. * @returns the current mesh
  29091. */
  29092. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29093. /**
  29094. * Gets a boolean indicating if specific vertex data is present
  29095. * @param kind defines the vertex data kind to use
  29096. * @returns true is data kind is present
  29097. */
  29098. isVerticesDataPresent(kind: string): boolean;
  29099. /**
  29100. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29101. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29102. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29103. * @returns a BoundingInfo
  29104. */
  29105. getBoundingInfo(): BoundingInfo;
  29106. /**
  29107. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29108. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29109. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29110. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29111. * @returns the current mesh
  29112. */
  29113. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29114. /**
  29115. * Overwrite the current bounding info
  29116. * @param boundingInfo defines the new bounding info
  29117. * @returns the current mesh
  29118. */
  29119. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29120. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29121. get useBones(): boolean;
  29122. /** @hidden */
  29123. _preActivate(): void;
  29124. /** @hidden */
  29125. _preActivateForIntermediateRendering(renderId: number): void;
  29126. /** @hidden */
  29127. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29128. /** @hidden */
  29129. _postActivate(): void;
  29130. /** @hidden */
  29131. _freeze(): void;
  29132. /** @hidden */
  29133. _unFreeze(): void;
  29134. /**
  29135. * Gets the current world matrix
  29136. * @returns a Matrix
  29137. */
  29138. getWorldMatrix(): Matrix;
  29139. /** @hidden */
  29140. _getWorldMatrixDeterminant(): number;
  29141. /**
  29142. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29143. */
  29144. get isAnInstance(): boolean;
  29145. /**
  29146. * Gets a boolean indicating if this mesh has instances
  29147. */
  29148. get hasInstances(): boolean;
  29149. /**
  29150. * Perform relative position change from the point of view of behind the front of the mesh.
  29151. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29152. * Supports definition of mesh facing forward or backward
  29153. * @param amountRight defines the distance on the right axis
  29154. * @param amountUp defines the distance on the up axis
  29155. * @param amountForward defines the distance on the forward axis
  29156. * @returns the current mesh
  29157. */
  29158. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29159. /**
  29160. * Calculate relative position change from the point of view of behind the front of the mesh.
  29161. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29162. * Supports definition of mesh facing forward or backward
  29163. * @param amountRight defines the distance on the right axis
  29164. * @param amountUp defines the distance on the up axis
  29165. * @param amountForward defines the distance on the forward axis
  29166. * @returns the new displacement vector
  29167. */
  29168. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29169. /**
  29170. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29171. * Supports definition of mesh facing forward or backward
  29172. * @param flipBack defines the flip
  29173. * @param twirlClockwise defines the twirl
  29174. * @param tiltRight defines the tilt
  29175. * @returns the current mesh
  29176. */
  29177. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29178. /**
  29179. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29180. * Supports definition of mesh facing forward or backward.
  29181. * @param flipBack defines the flip
  29182. * @param twirlClockwise defines the twirl
  29183. * @param tiltRight defines the tilt
  29184. * @returns the new rotation vector
  29185. */
  29186. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29187. /**
  29188. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29189. * This means the mesh underlying bounding box and sphere are recomputed.
  29190. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29191. * @returns the current mesh
  29192. */
  29193. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29194. /** @hidden */
  29195. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29196. /** @hidden */
  29197. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29198. /** @hidden */
  29199. _updateBoundingInfo(): AbstractMesh;
  29200. /** @hidden */
  29201. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29202. /** @hidden */
  29203. protected _afterComputeWorldMatrix(): void;
  29204. /** @hidden */
  29205. get _effectiveMesh(): AbstractMesh;
  29206. /**
  29207. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29208. * A mesh is in the frustum if its bounding box intersects the frustum
  29209. * @param frustumPlanes defines the frustum to test
  29210. * @returns true if the mesh is in the frustum planes
  29211. */
  29212. isInFrustum(frustumPlanes: Plane[]): boolean;
  29213. /**
  29214. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29215. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29216. * @param frustumPlanes defines the frustum to test
  29217. * @returns true if the mesh is completely in the frustum planes
  29218. */
  29219. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29220. /**
  29221. * True if the mesh intersects another mesh or a SolidParticle object
  29222. * @param mesh defines a target mesh or SolidParticle to test
  29223. * @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)
  29224. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29225. * @returns true if there is an intersection
  29226. */
  29227. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29228. /**
  29229. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29230. * @param point defines the point to test
  29231. * @returns true if there is an intersection
  29232. */
  29233. intersectsPoint(point: Vector3): boolean;
  29234. /**
  29235. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29236. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29237. */
  29238. get checkCollisions(): boolean;
  29239. set checkCollisions(collisionEnabled: boolean);
  29240. /**
  29241. * Gets Collider object used to compute collisions (not physics)
  29242. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29243. */
  29244. get collider(): Nullable<Collider>;
  29245. /**
  29246. * Move the mesh using collision engine
  29247. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29248. * @param displacement defines the requested displacement vector
  29249. * @returns the current mesh
  29250. */
  29251. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29252. private _onCollisionPositionChange;
  29253. /** @hidden */
  29254. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29255. /** @hidden */
  29256. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29257. /** @hidden */
  29258. _checkCollision(collider: Collider): AbstractMesh;
  29259. /** @hidden */
  29260. _generatePointsArray(): boolean;
  29261. /**
  29262. * Checks if the passed Ray intersects with the mesh
  29263. * @param ray defines the ray to use
  29264. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29265. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29266. * @returns the picking info
  29267. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29268. */
  29269. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29270. /**
  29271. * Clones the current mesh
  29272. * @param name defines the mesh name
  29273. * @param newParent defines the new mesh parent
  29274. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29275. * @returns the new mesh
  29276. */
  29277. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29278. /**
  29279. * Disposes all the submeshes of the current meshnp
  29280. * @returns the current mesh
  29281. */
  29282. releaseSubMeshes(): AbstractMesh;
  29283. /**
  29284. * Releases resources associated with this abstract mesh.
  29285. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29286. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29287. */
  29288. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29289. /**
  29290. * Adds the passed mesh as a child to the current mesh
  29291. * @param mesh defines the child mesh
  29292. * @returns the current mesh
  29293. */
  29294. addChild(mesh: AbstractMesh): AbstractMesh;
  29295. /**
  29296. * Removes the passed mesh from the current mesh children list
  29297. * @param mesh defines the child mesh
  29298. * @returns the current mesh
  29299. */
  29300. removeChild(mesh: AbstractMesh): AbstractMesh;
  29301. /** @hidden */
  29302. private _initFacetData;
  29303. /**
  29304. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29305. * This method can be called within the render loop.
  29306. * 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
  29307. * @returns the current mesh
  29308. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29309. */
  29310. updateFacetData(): AbstractMesh;
  29311. /**
  29312. * Returns the facetLocalNormals array.
  29313. * The normals are expressed in the mesh local spac
  29314. * @returns an array of Vector3
  29315. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29316. */
  29317. getFacetLocalNormals(): Vector3[];
  29318. /**
  29319. * Returns the facetLocalPositions array.
  29320. * The facet positions are expressed in the mesh local space
  29321. * @returns an array of Vector3
  29322. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29323. */
  29324. getFacetLocalPositions(): Vector3[];
  29325. /**
  29326. * Returns the facetLocalPartioning array
  29327. * @returns an array of array of numbers
  29328. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29329. */
  29330. getFacetLocalPartitioning(): number[][];
  29331. /**
  29332. * Returns the i-th facet position in the world system.
  29333. * This method allocates a new Vector3 per call
  29334. * @param i defines the facet index
  29335. * @returns a new Vector3
  29336. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29337. */
  29338. getFacetPosition(i: number): Vector3;
  29339. /**
  29340. * Sets the reference Vector3 with the i-th facet position in the world system
  29341. * @param i defines the facet index
  29342. * @param ref defines the target vector
  29343. * @returns the current mesh
  29344. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29345. */
  29346. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29347. /**
  29348. * Returns the i-th facet normal in the world system.
  29349. * This method allocates a new Vector3 per call
  29350. * @param i defines the facet index
  29351. * @returns a new Vector3
  29352. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29353. */
  29354. getFacetNormal(i: number): Vector3;
  29355. /**
  29356. * Sets the reference Vector3 with the i-th facet normal in the world system
  29357. * @param i defines the facet index
  29358. * @param ref defines the target vector
  29359. * @returns the current mesh
  29360. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29361. */
  29362. getFacetNormalToRef(i: number, ref: Vector3): this;
  29363. /**
  29364. * 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)
  29365. * @param x defines x coordinate
  29366. * @param y defines y coordinate
  29367. * @param z defines z coordinate
  29368. * @returns the array of facet indexes
  29369. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29370. */
  29371. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29372. /**
  29373. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29374. * @param projected sets as the (x,y,z) world projection on the facet
  29375. * @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
  29376. * @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
  29377. * @param x defines x coordinate
  29378. * @param y defines y coordinate
  29379. * @param z defines z coordinate
  29380. * @returns the face index if found (or null instead)
  29381. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29382. */
  29383. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29384. /**
  29385. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29386. * @param projected sets as the (x,y,z) local projection on the facet
  29387. * @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
  29388. * @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
  29389. * @param x defines x coordinate
  29390. * @param y defines y coordinate
  29391. * @param z defines z coordinate
  29392. * @returns the face index if found (or null instead)
  29393. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29394. */
  29395. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29396. /**
  29397. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29398. * @returns the parameters
  29399. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29400. */
  29401. getFacetDataParameters(): any;
  29402. /**
  29403. * Disables the feature FacetData and frees the related memory
  29404. * @returns the current mesh
  29405. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29406. */
  29407. disableFacetData(): AbstractMesh;
  29408. /**
  29409. * Updates the AbstractMesh indices array
  29410. * @param indices defines the data source
  29411. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29412. * @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)
  29413. * @returns the current mesh
  29414. */
  29415. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29416. /**
  29417. * Creates new normals data for the mesh
  29418. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29419. * @returns the current mesh
  29420. */
  29421. createNormals(updatable: boolean): AbstractMesh;
  29422. /**
  29423. * Align the mesh with a normal
  29424. * @param normal defines the normal to use
  29425. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29426. * @returns the current mesh
  29427. */
  29428. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29429. /** @hidden */
  29430. _checkOcclusionQuery(): boolean;
  29431. /**
  29432. * Disables the mesh edge rendering mode
  29433. * @returns the currentAbstractMesh
  29434. */
  29435. disableEdgesRendering(): AbstractMesh;
  29436. /**
  29437. * Enables the edge rendering mode on the mesh.
  29438. * This mode makes the mesh edges visible
  29439. * @param epsilon defines the maximal distance between two angles to detect a face
  29440. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29441. * @returns the currentAbstractMesh
  29442. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29443. */
  29444. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29445. }
  29446. }
  29447. declare module "babylonjs/Actions/actionEvent" {
  29448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29449. import { Nullable } from "babylonjs/types";
  29450. import { Sprite } from "babylonjs/Sprites/sprite";
  29451. import { Scene } from "babylonjs/scene";
  29452. import { Vector2 } from "babylonjs/Maths/math.vector";
  29453. /**
  29454. * Interface used to define ActionEvent
  29455. */
  29456. export interface IActionEvent {
  29457. /** The mesh or sprite that triggered the action */
  29458. source: any;
  29459. /** The X mouse cursor position at the time of the event */
  29460. pointerX: number;
  29461. /** The Y mouse cursor position at the time of the event */
  29462. pointerY: number;
  29463. /** The mesh that is currently pointed at (can be null) */
  29464. meshUnderPointer: Nullable<AbstractMesh>;
  29465. /** the original (browser) event that triggered the ActionEvent */
  29466. sourceEvent?: any;
  29467. /** additional data for the event */
  29468. additionalData?: any;
  29469. }
  29470. /**
  29471. * ActionEvent is the event being sent when an action is triggered.
  29472. */
  29473. export class ActionEvent implements IActionEvent {
  29474. /** The mesh or sprite that triggered the action */
  29475. source: any;
  29476. /** The X mouse cursor position at the time of the event */
  29477. pointerX: number;
  29478. /** The Y mouse cursor position at the time of the event */
  29479. pointerY: number;
  29480. /** The mesh that is currently pointed at (can be null) */
  29481. meshUnderPointer: Nullable<AbstractMesh>;
  29482. /** the original (browser) event that triggered the ActionEvent */
  29483. sourceEvent?: any;
  29484. /** additional data for the event */
  29485. additionalData?: any;
  29486. /**
  29487. * Creates a new ActionEvent
  29488. * @param source The mesh or sprite that triggered the action
  29489. * @param pointerX The X mouse cursor position at the time of the event
  29490. * @param pointerY The Y mouse cursor position at the time of the event
  29491. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29492. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29493. * @param additionalData additional data for the event
  29494. */
  29495. constructor(
  29496. /** The mesh or sprite that triggered the action */
  29497. source: any,
  29498. /** The X mouse cursor position at the time of the event */
  29499. pointerX: number,
  29500. /** The Y mouse cursor position at the time of the event */
  29501. pointerY: number,
  29502. /** The mesh that is currently pointed at (can be null) */
  29503. meshUnderPointer: Nullable<AbstractMesh>,
  29504. /** the original (browser) event that triggered the ActionEvent */
  29505. sourceEvent?: any,
  29506. /** additional data for the event */
  29507. additionalData?: any);
  29508. /**
  29509. * Helper function to auto-create an ActionEvent from a source mesh.
  29510. * @param source The source mesh that triggered the event
  29511. * @param evt The original (browser) event
  29512. * @param additionalData additional data for the event
  29513. * @returns the new ActionEvent
  29514. */
  29515. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29516. /**
  29517. * Helper function to auto-create an ActionEvent from a source sprite
  29518. * @param source The source sprite that triggered the event
  29519. * @param scene Scene associated with the sprite
  29520. * @param evt The original (browser) event
  29521. * @param additionalData additional data for the event
  29522. * @returns the new ActionEvent
  29523. */
  29524. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29525. /**
  29526. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29527. * @param scene the scene where the event occurred
  29528. * @param evt The original (browser) event
  29529. * @returns the new ActionEvent
  29530. */
  29531. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29532. /**
  29533. * Helper function to auto-create an ActionEvent from a primitive
  29534. * @param prim defines the target primitive
  29535. * @param pointerPos defines the pointer position
  29536. * @param evt The original (browser) event
  29537. * @param additionalData additional data for the event
  29538. * @returns the new ActionEvent
  29539. */
  29540. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29541. }
  29542. }
  29543. declare module "babylonjs/Actions/abstractActionManager" {
  29544. import { IDisposable } from "babylonjs/scene";
  29545. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29546. import { IAction } from "babylonjs/Actions/action";
  29547. import { Nullable } from "babylonjs/types";
  29548. /**
  29549. * Abstract class used to decouple action Manager from scene and meshes.
  29550. * Do not instantiate.
  29551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29552. */
  29553. export abstract class AbstractActionManager implements IDisposable {
  29554. /** Gets the list of active triggers */
  29555. static Triggers: {
  29556. [key: string]: number;
  29557. };
  29558. /** Gets the cursor to use when hovering items */
  29559. hoverCursor: string;
  29560. /** Gets the list of actions */
  29561. actions: IAction[];
  29562. /**
  29563. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29564. */
  29565. isRecursive: boolean;
  29566. /**
  29567. * Releases all associated resources
  29568. */
  29569. abstract dispose(): void;
  29570. /**
  29571. * Does this action manager has pointer triggers
  29572. */
  29573. abstract get hasPointerTriggers(): boolean;
  29574. /**
  29575. * Does this action manager has pick triggers
  29576. */
  29577. abstract get hasPickTriggers(): boolean;
  29578. /**
  29579. * Process a specific trigger
  29580. * @param trigger defines the trigger to process
  29581. * @param evt defines the event details to be processed
  29582. */
  29583. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29584. /**
  29585. * Does this action manager handles actions of any of the given triggers
  29586. * @param triggers defines the triggers to be tested
  29587. * @return a boolean indicating whether one (or more) of the triggers is handled
  29588. */
  29589. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29590. /**
  29591. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29592. * speed.
  29593. * @param triggerA defines the trigger to be tested
  29594. * @param triggerB defines the trigger to be tested
  29595. * @return a boolean indicating whether one (or more) of the triggers is handled
  29596. */
  29597. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29598. /**
  29599. * Does this action manager handles actions of a given trigger
  29600. * @param trigger defines the trigger to be tested
  29601. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29602. * @return whether the trigger is handled
  29603. */
  29604. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29605. /**
  29606. * Serialize this manager to a JSON object
  29607. * @param name defines the property name to store this manager
  29608. * @returns a JSON representation of this manager
  29609. */
  29610. abstract serialize(name: string): any;
  29611. /**
  29612. * Registers an action to this action manager
  29613. * @param action defines the action to be registered
  29614. * @return the action amended (prepared) after registration
  29615. */
  29616. abstract registerAction(action: IAction): Nullable<IAction>;
  29617. /**
  29618. * Unregisters an action to this action manager
  29619. * @param action defines the action to be unregistered
  29620. * @return a boolean indicating whether the action has been unregistered
  29621. */
  29622. abstract unregisterAction(action: IAction): Boolean;
  29623. /**
  29624. * Does exist one action manager with at least one trigger
  29625. **/
  29626. static get HasTriggers(): boolean;
  29627. /**
  29628. * Does exist one action manager with at least one pick trigger
  29629. **/
  29630. static get HasPickTriggers(): boolean;
  29631. /**
  29632. * Does exist one action manager that handles actions of a given trigger
  29633. * @param trigger defines the trigger to be tested
  29634. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29635. **/
  29636. static HasSpecificTrigger(trigger: number): boolean;
  29637. }
  29638. }
  29639. declare module "babylonjs/node" {
  29640. import { Scene } from "babylonjs/scene";
  29641. import { Nullable } from "babylonjs/types";
  29642. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29643. import { Engine } from "babylonjs/Engines/engine";
  29644. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29645. import { Observable } from "babylonjs/Misc/observable";
  29646. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29647. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29648. import { Animatable } from "babylonjs/Animations/animatable";
  29649. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29650. import { Animation } from "babylonjs/Animations/animation";
  29651. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29653. /**
  29654. * Defines how a node can be built from a string name.
  29655. */
  29656. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29657. /**
  29658. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29659. */
  29660. export class Node implements IBehaviorAware<Node> {
  29661. /** @hidden */
  29662. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29663. private static _NodeConstructors;
  29664. /**
  29665. * Add a new node constructor
  29666. * @param type defines the type name of the node to construct
  29667. * @param constructorFunc defines the constructor function
  29668. */
  29669. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29670. /**
  29671. * Returns a node constructor based on type name
  29672. * @param type defines the type name
  29673. * @param name defines the new node name
  29674. * @param scene defines the hosting scene
  29675. * @param options defines optional options to transmit to constructors
  29676. * @returns the new constructor or null
  29677. */
  29678. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29679. /**
  29680. * Gets or sets the name of the node
  29681. */
  29682. name: string;
  29683. /**
  29684. * Gets or sets the id of the node
  29685. */
  29686. id: string;
  29687. /**
  29688. * Gets or sets the unique id of the node
  29689. */
  29690. uniqueId: number;
  29691. /**
  29692. * Gets or sets a string used to store user defined state for the node
  29693. */
  29694. state: string;
  29695. /**
  29696. * Gets or sets an object used to store user defined information for the node
  29697. */
  29698. metadata: any;
  29699. /**
  29700. * For internal use only. Please do not use.
  29701. */
  29702. reservedDataStore: any;
  29703. /**
  29704. * List of inspectable custom properties (used by the Inspector)
  29705. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29706. */
  29707. inspectableCustomProperties: IInspectable[];
  29708. private _doNotSerialize;
  29709. /**
  29710. * Gets or sets a boolean used to define if the node must be serialized
  29711. */
  29712. get doNotSerialize(): boolean;
  29713. set doNotSerialize(value: boolean);
  29714. /** @hidden */
  29715. _isDisposed: boolean;
  29716. /**
  29717. * Gets a list of Animations associated with the node
  29718. */
  29719. animations: import("babylonjs/Animations/animation").Animation[];
  29720. protected _ranges: {
  29721. [name: string]: Nullable<AnimationRange>;
  29722. };
  29723. /**
  29724. * Callback raised when the node is ready to be used
  29725. */
  29726. onReady: Nullable<(node: Node) => void>;
  29727. private _isEnabled;
  29728. private _isParentEnabled;
  29729. private _isReady;
  29730. /** @hidden */
  29731. _currentRenderId: number;
  29732. private _parentUpdateId;
  29733. /** @hidden */
  29734. _childUpdateId: number;
  29735. /** @hidden */
  29736. _waitingParentId: Nullable<string>;
  29737. /** @hidden */
  29738. _scene: Scene;
  29739. /** @hidden */
  29740. _cache: any;
  29741. private _parentNode;
  29742. private _children;
  29743. /** @hidden */
  29744. _worldMatrix: Matrix;
  29745. /** @hidden */
  29746. _worldMatrixDeterminant: number;
  29747. /** @hidden */
  29748. _worldMatrixDeterminantIsDirty: boolean;
  29749. /** @hidden */
  29750. private _sceneRootNodesIndex;
  29751. /**
  29752. * Gets a boolean indicating if the node has been disposed
  29753. * @returns true if the node was disposed
  29754. */
  29755. isDisposed(): boolean;
  29756. /**
  29757. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29758. * @see https://doc.babylonjs.com/how_to/parenting
  29759. */
  29760. set parent(parent: Nullable<Node>);
  29761. get parent(): Nullable<Node>;
  29762. /** @hidden */
  29763. _addToSceneRootNodes(): void;
  29764. /** @hidden */
  29765. _removeFromSceneRootNodes(): void;
  29766. private _animationPropertiesOverride;
  29767. /**
  29768. * Gets or sets the animation properties override
  29769. */
  29770. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29771. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29772. /**
  29773. * Gets a string idenfifying the name of the class
  29774. * @returns "Node" string
  29775. */
  29776. getClassName(): string;
  29777. /** @hidden */
  29778. readonly _isNode: boolean;
  29779. /**
  29780. * An event triggered when the mesh is disposed
  29781. */
  29782. onDisposeObservable: Observable<Node>;
  29783. private _onDisposeObserver;
  29784. /**
  29785. * Sets a callback that will be raised when the node will be disposed
  29786. */
  29787. set onDispose(callback: () => void);
  29788. /**
  29789. * Creates a new Node
  29790. * @param name the name and id to be given to this node
  29791. * @param scene the scene this node will be added to
  29792. */
  29793. constructor(name: string, scene?: Nullable<Scene>);
  29794. /**
  29795. * Gets the scene of the node
  29796. * @returns a scene
  29797. */
  29798. getScene(): Scene;
  29799. /**
  29800. * Gets the engine of the node
  29801. * @returns a Engine
  29802. */
  29803. getEngine(): Engine;
  29804. private _behaviors;
  29805. /**
  29806. * Attach a behavior to the node
  29807. * @see http://doc.babylonjs.com/features/behaviour
  29808. * @param behavior defines the behavior to attach
  29809. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29810. * @returns the current Node
  29811. */
  29812. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29813. /**
  29814. * Remove an attached behavior
  29815. * @see http://doc.babylonjs.com/features/behaviour
  29816. * @param behavior defines the behavior to attach
  29817. * @returns the current Node
  29818. */
  29819. removeBehavior(behavior: Behavior<Node>): Node;
  29820. /**
  29821. * Gets the list of attached behaviors
  29822. * @see http://doc.babylonjs.com/features/behaviour
  29823. */
  29824. get behaviors(): Behavior<Node>[];
  29825. /**
  29826. * Gets an attached behavior by name
  29827. * @param name defines the name of the behavior to look for
  29828. * @see http://doc.babylonjs.com/features/behaviour
  29829. * @returns null if behavior was not found else the requested behavior
  29830. */
  29831. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29832. /**
  29833. * Returns the latest update of the World matrix
  29834. * @returns a Matrix
  29835. */
  29836. getWorldMatrix(): Matrix;
  29837. /** @hidden */
  29838. _getWorldMatrixDeterminant(): number;
  29839. /**
  29840. * Returns directly the latest state of the mesh World matrix.
  29841. * A Matrix is returned.
  29842. */
  29843. get worldMatrixFromCache(): Matrix;
  29844. /** @hidden */
  29845. _initCache(): void;
  29846. /** @hidden */
  29847. updateCache(force?: boolean): void;
  29848. /** @hidden */
  29849. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29850. /** @hidden */
  29851. _updateCache(ignoreParentClass?: boolean): void;
  29852. /** @hidden */
  29853. _isSynchronized(): boolean;
  29854. /** @hidden */
  29855. _markSyncedWithParent(): void;
  29856. /** @hidden */
  29857. isSynchronizedWithParent(): boolean;
  29858. /** @hidden */
  29859. isSynchronized(): boolean;
  29860. /**
  29861. * Is this node ready to be used/rendered
  29862. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29863. * @return true if the node is ready
  29864. */
  29865. isReady(completeCheck?: boolean): boolean;
  29866. /**
  29867. * Is this node enabled?
  29868. * 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
  29869. * @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
  29870. * @return whether this node (and its parent) is enabled
  29871. */
  29872. isEnabled(checkAncestors?: boolean): boolean;
  29873. /** @hidden */
  29874. protected _syncParentEnabledState(): void;
  29875. /**
  29876. * Set the enabled state of this node
  29877. * @param value defines the new enabled state
  29878. */
  29879. setEnabled(value: boolean): void;
  29880. /**
  29881. * Is this node a descendant of the given node?
  29882. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29883. * @param ancestor defines the parent node to inspect
  29884. * @returns a boolean indicating if this node is a descendant of the given node
  29885. */
  29886. isDescendantOf(ancestor: Node): boolean;
  29887. /** @hidden */
  29888. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29889. /**
  29890. * Will return all nodes that have this node as ascendant
  29891. * @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
  29892. * @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
  29893. * @return all children nodes of all types
  29894. */
  29895. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29896. /**
  29897. * Get all child-meshes of this node
  29898. * @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)
  29899. * @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
  29900. * @returns an array of AbstractMesh
  29901. */
  29902. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29903. /**
  29904. * Get all direct children of this node
  29905. * @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
  29906. * @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)
  29907. * @returns an array of Node
  29908. */
  29909. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29910. /** @hidden */
  29911. _setReady(state: boolean): void;
  29912. /**
  29913. * Get an animation by name
  29914. * @param name defines the name of the animation to look for
  29915. * @returns null if not found else the requested animation
  29916. */
  29917. getAnimationByName(name: string): Nullable<Animation>;
  29918. /**
  29919. * Creates an animation range for this node
  29920. * @param name defines the name of the range
  29921. * @param from defines the starting key
  29922. * @param to defines the end key
  29923. */
  29924. createAnimationRange(name: string, from: number, to: number): void;
  29925. /**
  29926. * Delete a specific animation range
  29927. * @param name defines the name of the range to delete
  29928. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29929. */
  29930. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29931. /**
  29932. * Get an animation range by name
  29933. * @param name defines the name of the animation range to look for
  29934. * @returns null if not found else the requested animation range
  29935. */
  29936. getAnimationRange(name: string): Nullable<AnimationRange>;
  29937. /**
  29938. * Gets the list of all animation ranges defined on this node
  29939. * @returns an array
  29940. */
  29941. getAnimationRanges(): Nullable<AnimationRange>[];
  29942. /**
  29943. * Will start the animation sequence
  29944. * @param name defines the range frames for animation sequence
  29945. * @param loop defines if the animation should loop (false by default)
  29946. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29947. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29948. * @returns the object created for this animation. If range does not exist, it will return null
  29949. */
  29950. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29951. /**
  29952. * Serialize animation ranges into a JSON compatible object
  29953. * @returns serialization object
  29954. */
  29955. serializeAnimationRanges(): any;
  29956. /**
  29957. * Computes the world matrix of the node
  29958. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29959. * @returns the world matrix
  29960. */
  29961. computeWorldMatrix(force?: boolean): Matrix;
  29962. /**
  29963. * Releases resources associated with this node.
  29964. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29965. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29966. */
  29967. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29968. /**
  29969. * Parse animation range data from a serialization object and store them into a given node
  29970. * @param node defines where to store the animation ranges
  29971. * @param parsedNode defines the serialization object to read data from
  29972. * @param scene defines the hosting scene
  29973. */
  29974. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29975. /**
  29976. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29977. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29978. * @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
  29979. * @returns the new bounding vectors
  29980. */
  29981. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29982. min: Vector3;
  29983. max: Vector3;
  29984. };
  29985. }
  29986. }
  29987. declare module "babylonjs/Animations/animation" {
  29988. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29989. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29990. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29991. import { Nullable } from "babylonjs/types";
  29992. import { Scene } from "babylonjs/scene";
  29993. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29994. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29995. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29996. import { Node } from "babylonjs/node";
  29997. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29998. import { Size } from "babylonjs/Maths/math.size";
  29999. import { Animatable } from "babylonjs/Animations/animatable";
  30000. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30001. /**
  30002. * @hidden
  30003. */
  30004. export class _IAnimationState {
  30005. key: number;
  30006. repeatCount: number;
  30007. workValue?: any;
  30008. loopMode?: number;
  30009. offsetValue?: any;
  30010. highLimitValue?: any;
  30011. }
  30012. /**
  30013. * Class used to store any kind of animation
  30014. */
  30015. export class Animation {
  30016. /**Name of the animation */
  30017. name: string;
  30018. /**Property to animate */
  30019. targetProperty: string;
  30020. /**The frames per second of the animation */
  30021. framePerSecond: number;
  30022. /**The data type of the animation */
  30023. dataType: number;
  30024. /**The loop mode of the animation */
  30025. loopMode?: number | undefined;
  30026. /**Specifies if blending should be enabled */
  30027. enableBlending?: boolean | undefined;
  30028. /**
  30029. * Use matrix interpolation instead of using direct key value when animating matrices
  30030. */
  30031. static AllowMatricesInterpolation: boolean;
  30032. /**
  30033. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30034. */
  30035. static AllowMatrixDecomposeForInterpolation: boolean;
  30036. /**
  30037. * Stores the key frames of the animation
  30038. */
  30039. private _keys;
  30040. /**
  30041. * Stores the easing function of the animation
  30042. */
  30043. private _easingFunction;
  30044. /**
  30045. * @hidden Internal use only
  30046. */
  30047. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30048. /**
  30049. * The set of event that will be linked to this animation
  30050. */
  30051. private _events;
  30052. /**
  30053. * Stores an array of target property paths
  30054. */
  30055. targetPropertyPath: string[];
  30056. /**
  30057. * Stores the blending speed of the animation
  30058. */
  30059. blendingSpeed: number;
  30060. /**
  30061. * Stores the animation ranges for the animation
  30062. */
  30063. private _ranges;
  30064. /**
  30065. * @hidden Internal use
  30066. */
  30067. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30068. /**
  30069. * Sets up an animation
  30070. * @param property The property to animate
  30071. * @param animationType The animation type to apply
  30072. * @param framePerSecond The frames per second of the animation
  30073. * @param easingFunction The easing function used in the animation
  30074. * @returns The created animation
  30075. */
  30076. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30077. /**
  30078. * Create and start an animation on a node
  30079. * @param name defines the name of the global animation that will be run on all nodes
  30080. * @param node defines the root node where the animation will take place
  30081. * @param targetProperty defines property to animate
  30082. * @param framePerSecond defines the number of frame per second yo use
  30083. * @param totalFrame defines the number of frames in total
  30084. * @param from defines the initial value
  30085. * @param to defines the final value
  30086. * @param loopMode defines which loop mode you want to use (off by default)
  30087. * @param easingFunction defines the easing function to use (linear by default)
  30088. * @param onAnimationEnd defines the callback to call when animation end
  30089. * @returns the animatable created for this animation
  30090. */
  30091. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30092. /**
  30093. * Create and start an animation on a node and its descendants
  30094. * @param name defines the name of the global animation that will be run on all nodes
  30095. * @param node defines the root node where the animation will take place
  30096. * @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
  30097. * @param targetProperty defines property to animate
  30098. * @param framePerSecond defines the number of frame per second to use
  30099. * @param totalFrame defines the number of frames in total
  30100. * @param from defines the initial value
  30101. * @param to defines the final value
  30102. * @param loopMode defines which loop mode you want to use (off by default)
  30103. * @param easingFunction defines the easing function to use (linear by default)
  30104. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30105. * @returns the list of animatables created for all nodes
  30106. * @example https://www.babylonjs-playground.com/#MH0VLI
  30107. */
  30108. 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[]>;
  30109. /**
  30110. * Creates a new animation, merges it with the existing animations and starts it
  30111. * @param name Name of the animation
  30112. * @param node Node which contains the scene that begins the animations
  30113. * @param targetProperty Specifies which property to animate
  30114. * @param framePerSecond The frames per second of the animation
  30115. * @param totalFrame The total number of frames
  30116. * @param from The frame at the beginning of the animation
  30117. * @param to The frame at the end of the animation
  30118. * @param loopMode Specifies the loop mode of the animation
  30119. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30120. * @param onAnimationEnd Callback to run once the animation is complete
  30121. * @returns Nullable animation
  30122. */
  30123. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30124. /**
  30125. * Transition property of an host to the target Value
  30126. * @param property The property to transition
  30127. * @param targetValue The target Value of the property
  30128. * @param host The object where the property to animate belongs
  30129. * @param scene Scene used to run the animation
  30130. * @param frameRate Framerate (in frame/s) to use
  30131. * @param transition The transition type we want to use
  30132. * @param duration The duration of the animation, in milliseconds
  30133. * @param onAnimationEnd Callback trigger at the end of the animation
  30134. * @returns Nullable animation
  30135. */
  30136. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30137. /**
  30138. * Return the array of runtime animations currently using this animation
  30139. */
  30140. get runtimeAnimations(): RuntimeAnimation[];
  30141. /**
  30142. * Specifies if any of the runtime animations are currently running
  30143. */
  30144. get hasRunningRuntimeAnimations(): boolean;
  30145. /**
  30146. * Initializes the animation
  30147. * @param name Name of the animation
  30148. * @param targetProperty Property to animate
  30149. * @param framePerSecond The frames per second of the animation
  30150. * @param dataType The data type of the animation
  30151. * @param loopMode The loop mode of the animation
  30152. * @param enableBlending Specifies if blending should be enabled
  30153. */
  30154. constructor(
  30155. /**Name of the animation */
  30156. name: string,
  30157. /**Property to animate */
  30158. targetProperty: string,
  30159. /**The frames per second of the animation */
  30160. framePerSecond: number,
  30161. /**The data type of the animation */
  30162. dataType: number,
  30163. /**The loop mode of the animation */
  30164. loopMode?: number | undefined,
  30165. /**Specifies if blending should be enabled */
  30166. enableBlending?: boolean | undefined);
  30167. /**
  30168. * Converts the animation to a string
  30169. * @param fullDetails support for multiple levels of logging within scene loading
  30170. * @returns String form of the animation
  30171. */
  30172. toString(fullDetails?: boolean): string;
  30173. /**
  30174. * Add an event to this animation
  30175. * @param event Event to add
  30176. */
  30177. addEvent(event: AnimationEvent): void;
  30178. /**
  30179. * Remove all events found at the given frame
  30180. * @param frame The frame to remove events from
  30181. */
  30182. removeEvents(frame: number): void;
  30183. /**
  30184. * Retrieves all the events from the animation
  30185. * @returns Events from the animation
  30186. */
  30187. getEvents(): AnimationEvent[];
  30188. /**
  30189. * Creates an animation range
  30190. * @param name Name of the animation range
  30191. * @param from Starting frame of the animation range
  30192. * @param to Ending frame of the animation
  30193. */
  30194. createRange(name: string, from: number, to: number): void;
  30195. /**
  30196. * Deletes an animation range by name
  30197. * @param name Name of the animation range to delete
  30198. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30199. */
  30200. deleteRange(name: string, deleteFrames?: boolean): void;
  30201. /**
  30202. * Gets the animation range by name, or null if not defined
  30203. * @param name Name of the animation range
  30204. * @returns Nullable animation range
  30205. */
  30206. getRange(name: string): Nullable<AnimationRange>;
  30207. /**
  30208. * Gets the key frames from the animation
  30209. * @returns The key frames of the animation
  30210. */
  30211. getKeys(): Array<IAnimationKey>;
  30212. /**
  30213. * Gets the highest frame rate of the animation
  30214. * @returns Highest frame rate of the animation
  30215. */
  30216. getHighestFrame(): number;
  30217. /**
  30218. * Gets the easing function of the animation
  30219. * @returns Easing function of the animation
  30220. */
  30221. getEasingFunction(): IEasingFunction;
  30222. /**
  30223. * Sets the easing function of the animation
  30224. * @param easingFunction A custom mathematical formula for animation
  30225. */
  30226. setEasingFunction(easingFunction: EasingFunction): void;
  30227. /**
  30228. * Interpolates a scalar linearly
  30229. * @param startValue Start value of the animation curve
  30230. * @param endValue End value of the animation curve
  30231. * @param gradient Scalar amount to interpolate
  30232. * @returns Interpolated scalar value
  30233. */
  30234. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30235. /**
  30236. * Interpolates a scalar cubically
  30237. * @param startValue Start value of the animation curve
  30238. * @param outTangent End tangent of the animation
  30239. * @param endValue End value of the animation curve
  30240. * @param inTangent Start tangent of the animation curve
  30241. * @param gradient Scalar amount to interpolate
  30242. * @returns Interpolated scalar value
  30243. */
  30244. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30245. /**
  30246. * Interpolates a quaternion using a spherical linear interpolation
  30247. * @param startValue Start value of the animation curve
  30248. * @param endValue End value of the animation curve
  30249. * @param gradient Scalar amount to interpolate
  30250. * @returns Interpolated quaternion value
  30251. */
  30252. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30253. /**
  30254. * Interpolates a quaternion cubically
  30255. * @param startValue Start value of the animation curve
  30256. * @param outTangent End tangent of the animation curve
  30257. * @param endValue End value of the animation curve
  30258. * @param inTangent Start tangent of the animation curve
  30259. * @param gradient Scalar amount to interpolate
  30260. * @returns Interpolated quaternion value
  30261. */
  30262. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30263. /**
  30264. * Interpolates a Vector3 linearl
  30265. * @param startValue Start value of the animation curve
  30266. * @param endValue End value of the animation curve
  30267. * @param gradient Scalar amount to interpolate
  30268. * @returns Interpolated scalar value
  30269. */
  30270. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30271. /**
  30272. * Interpolates a Vector3 cubically
  30273. * @param startValue Start value of the animation curve
  30274. * @param outTangent End tangent of the animation
  30275. * @param endValue End value of the animation curve
  30276. * @param inTangent Start tangent of the animation curve
  30277. * @param gradient Scalar amount to interpolate
  30278. * @returns InterpolatedVector3 value
  30279. */
  30280. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30281. /**
  30282. * Interpolates a Vector2 linearly
  30283. * @param startValue Start value of the animation curve
  30284. * @param endValue End value of the animation curve
  30285. * @param gradient Scalar amount to interpolate
  30286. * @returns Interpolated Vector2 value
  30287. */
  30288. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30289. /**
  30290. * Interpolates a Vector2 cubically
  30291. * @param startValue Start value of the animation curve
  30292. * @param outTangent End tangent of the animation
  30293. * @param endValue End value of the animation curve
  30294. * @param inTangent Start tangent of the animation curve
  30295. * @param gradient Scalar amount to interpolate
  30296. * @returns Interpolated Vector2 value
  30297. */
  30298. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30299. /**
  30300. * Interpolates a size linearly
  30301. * @param startValue Start value of the animation curve
  30302. * @param endValue End value of the animation curve
  30303. * @param gradient Scalar amount to interpolate
  30304. * @returns Interpolated Size value
  30305. */
  30306. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30307. /**
  30308. * Interpolates a Color3 linearly
  30309. * @param startValue Start value of the animation curve
  30310. * @param endValue End value of the animation curve
  30311. * @param gradient Scalar amount to interpolate
  30312. * @returns Interpolated Color3 value
  30313. */
  30314. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30315. /**
  30316. * Interpolates a Color4 linearly
  30317. * @param startValue Start value of the animation curve
  30318. * @param endValue End value of the animation curve
  30319. * @param gradient Scalar amount to interpolate
  30320. * @returns Interpolated Color3 value
  30321. */
  30322. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30323. /**
  30324. * @hidden Internal use only
  30325. */
  30326. _getKeyValue(value: any): any;
  30327. /**
  30328. * @hidden Internal use only
  30329. */
  30330. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30331. /**
  30332. * Defines the function to use to interpolate matrices
  30333. * @param startValue defines the start matrix
  30334. * @param endValue defines the end matrix
  30335. * @param gradient defines the gradient between both matrices
  30336. * @param result defines an optional target matrix where to store the interpolation
  30337. * @returns the interpolated matrix
  30338. */
  30339. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30340. /**
  30341. * Makes a copy of the animation
  30342. * @returns Cloned animation
  30343. */
  30344. clone(): Animation;
  30345. /**
  30346. * Sets the key frames of the animation
  30347. * @param values The animation key frames to set
  30348. */
  30349. setKeys(values: Array<IAnimationKey>): void;
  30350. /**
  30351. * Serializes the animation to an object
  30352. * @returns Serialized object
  30353. */
  30354. serialize(): any;
  30355. /**
  30356. * Float animation type
  30357. */
  30358. static readonly ANIMATIONTYPE_FLOAT: number;
  30359. /**
  30360. * Vector3 animation type
  30361. */
  30362. static readonly ANIMATIONTYPE_VECTOR3: number;
  30363. /**
  30364. * Quaternion animation type
  30365. */
  30366. static readonly ANIMATIONTYPE_QUATERNION: number;
  30367. /**
  30368. * Matrix animation type
  30369. */
  30370. static readonly ANIMATIONTYPE_MATRIX: number;
  30371. /**
  30372. * Color3 animation type
  30373. */
  30374. static readonly ANIMATIONTYPE_COLOR3: number;
  30375. /**
  30376. * Color3 animation type
  30377. */
  30378. static readonly ANIMATIONTYPE_COLOR4: number;
  30379. /**
  30380. * Vector2 animation type
  30381. */
  30382. static readonly ANIMATIONTYPE_VECTOR2: number;
  30383. /**
  30384. * Size animation type
  30385. */
  30386. static readonly ANIMATIONTYPE_SIZE: number;
  30387. /**
  30388. * Relative Loop Mode
  30389. */
  30390. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30391. /**
  30392. * Cycle Loop Mode
  30393. */
  30394. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30395. /**
  30396. * Constant Loop Mode
  30397. */
  30398. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30399. /** @hidden */
  30400. static _UniversalLerp(left: any, right: any, amount: number): any;
  30401. /**
  30402. * Parses an animation object and creates an animation
  30403. * @param parsedAnimation Parsed animation object
  30404. * @returns Animation object
  30405. */
  30406. static Parse(parsedAnimation: any): Animation;
  30407. /**
  30408. * Appends the serialized animations from the source animations
  30409. * @param source Source containing the animations
  30410. * @param destination Target to store the animations
  30411. */
  30412. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30413. }
  30414. }
  30415. declare module "babylonjs/Animations/animatable.interface" {
  30416. import { Nullable } from "babylonjs/types";
  30417. import { Animation } from "babylonjs/Animations/animation";
  30418. /**
  30419. * Interface containing an array of animations
  30420. */
  30421. export interface IAnimatable {
  30422. /**
  30423. * Array of animations
  30424. */
  30425. animations: Nullable<Array<Animation>>;
  30426. }
  30427. }
  30428. declare module "babylonjs/Misc/decorators" {
  30429. import { Nullable } from "babylonjs/types";
  30430. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30431. import { Scene } from "babylonjs/scene";
  30432. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30433. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30434. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30435. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30436. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30437. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30438. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30439. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30440. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30441. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30442. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30443. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30444. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30445. /**
  30446. * Decorator used to define property that can be serialized as reference to a camera
  30447. * @param sourceName defines the name of the property to decorate
  30448. */
  30449. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30450. /**
  30451. * Class used to help serialization objects
  30452. */
  30453. export class SerializationHelper {
  30454. /** @hidden */
  30455. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30456. /** @hidden */
  30457. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30458. /** @hidden */
  30459. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30460. /** @hidden */
  30461. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30462. /**
  30463. * Appends the serialized animations from the source animations
  30464. * @param source Source containing the animations
  30465. * @param destination Target to store the animations
  30466. */
  30467. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30468. /**
  30469. * Static function used to serialized a specific entity
  30470. * @param entity defines the entity to serialize
  30471. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30472. * @returns a JSON compatible object representing the serialization of the entity
  30473. */
  30474. static Serialize<T>(entity: T, serializationObject?: any): any;
  30475. /**
  30476. * Creates a new entity from a serialization data object
  30477. * @param creationFunction defines a function used to instanciated the new entity
  30478. * @param source defines the source serialization data
  30479. * @param scene defines the hosting scene
  30480. * @param rootUrl defines the root url for resources
  30481. * @returns a new entity
  30482. */
  30483. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30484. /**
  30485. * Clones an object
  30486. * @param creationFunction defines the function used to instanciate the new object
  30487. * @param source defines the source object
  30488. * @returns the cloned object
  30489. */
  30490. static Clone<T>(creationFunction: () => T, source: T): T;
  30491. /**
  30492. * Instanciates a new object based on a source one (some data will be shared between both object)
  30493. * @param creationFunction defines the function used to instanciate the new object
  30494. * @param source defines the source object
  30495. * @returns the new object
  30496. */
  30497. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30498. }
  30499. }
  30500. declare module "babylonjs/Misc/guid" {
  30501. /**
  30502. * Class used to manipulate GUIDs
  30503. */
  30504. export class GUID {
  30505. /**
  30506. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30507. * Be aware Math.random() could cause collisions, but:
  30508. * "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"
  30509. * @returns a pseudo random id
  30510. */
  30511. static RandomId(): string;
  30512. }
  30513. }
  30514. declare module "babylonjs/Materials/Textures/baseTexture" {
  30515. import { Observable } from "babylonjs/Misc/observable";
  30516. import { Nullable } from "babylonjs/types";
  30517. import { Scene } from "babylonjs/scene";
  30518. import { Matrix } from "babylonjs/Maths/math.vector";
  30519. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30520. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30521. import { ISize } from "babylonjs/Maths/math.size";
  30522. import "babylonjs/Misc/fileTools";
  30523. /**
  30524. * Base class of all the textures in babylon.
  30525. * It groups all the common properties the materials, post process, lights... might need
  30526. * in order to make a correct use of the texture.
  30527. */
  30528. export class BaseTexture implements IAnimatable {
  30529. /**
  30530. * Default anisotropic filtering level for the application.
  30531. * It is set to 4 as a good tradeoff between perf and quality.
  30532. */
  30533. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30534. /**
  30535. * Gets or sets the unique id of the texture
  30536. */
  30537. uniqueId: number;
  30538. /**
  30539. * Define the name of the texture.
  30540. */
  30541. name: string;
  30542. /**
  30543. * Gets or sets an object used to store user defined information.
  30544. */
  30545. metadata: any;
  30546. /**
  30547. * For internal use only. Please do not use.
  30548. */
  30549. reservedDataStore: any;
  30550. private _hasAlpha;
  30551. /**
  30552. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30553. */
  30554. set hasAlpha(value: boolean);
  30555. get hasAlpha(): boolean;
  30556. /**
  30557. * Defines if the alpha value should be determined via the rgb values.
  30558. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30559. */
  30560. getAlphaFromRGB: boolean;
  30561. /**
  30562. * Intensity or strength of the texture.
  30563. * It is commonly used by materials to fine tune the intensity of the texture
  30564. */
  30565. level: number;
  30566. /**
  30567. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30568. * This is part of the texture as textures usually maps to one uv set.
  30569. */
  30570. coordinatesIndex: number;
  30571. private _coordinatesMode;
  30572. /**
  30573. * How a texture is mapped.
  30574. *
  30575. * | Value | Type | Description |
  30576. * | ----- | ----------------------------------- | ----------- |
  30577. * | 0 | EXPLICIT_MODE | |
  30578. * | 1 | SPHERICAL_MODE | |
  30579. * | 2 | PLANAR_MODE | |
  30580. * | 3 | CUBIC_MODE | |
  30581. * | 4 | PROJECTION_MODE | |
  30582. * | 5 | SKYBOX_MODE | |
  30583. * | 6 | INVCUBIC_MODE | |
  30584. * | 7 | EQUIRECTANGULAR_MODE | |
  30585. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30586. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30587. */
  30588. set coordinatesMode(value: number);
  30589. get coordinatesMode(): number;
  30590. /**
  30591. * | Value | Type | Description |
  30592. * | ----- | ------------------ | ----------- |
  30593. * | 0 | CLAMP_ADDRESSMODE | |
  30594. * | 1 | WRAP_ADDRESSMODE | |
  30595. * | 2 | MIRROR_ADDRESSMODE | |
  30596. */
  30597. wrapU: number;
  30598. /**
  30599. * | Value | Type | Description |
  30600. * | ----- | ------------------ | ----------- |
  30601. * | 0 | CLAMP_ADDRESSMODE | |
  30602. * | 1 | WRAP_ADDRESSMODE | |
  30603. * | 2 | MIRROR_ADDRESSMODE | |
  30604. */
  30605. wrapV: number;
  30606. /**
  30607. * | Value | Type | Description |
  30608. * | ----- | ------------------ | ----------- |
  30609. * | 0 | CLAMP_ADDRESSMODE | |
  30610. * | 1 | WRAP_ADDRESSMODE | |
  30611. * | 2 | MIRROR_ADDRESSMODE | |
  30612. */
  30613. wrapR: number;
  30614. /**
  30615. * With compliant hardware and browser (supporting anisotropic filtering)
  30616. * this defines the level of anisotropic filtering in the texture.
  30617. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30618. */
  30619. anisotropicFilteringLevel: number;
  30620. /**
  30621. * Define if the texture is a cube texture or if false a 2d texture.
  30622. */
  30623. get isCube(): boolean;
  30624. set isCube(value: boolean);
  30625. /**
  30626. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30627. */
  30628. get is3D(): boolean;
  30629. set is3D(value: boolean);
  30630. /**
  30631. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30632. */
  30633. get is2DArray(): boolean;
  30634. set is2DArray(value: boolean);
  30635. /**
  30636. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30637. * HDR texture are usually stored in linear space.
  30638. * This only impacts the PBR and Background materials
  30639. */
  30640. gammaSpace: boolean;
  30641. /**
  30642. * Gets or sets whether or not the texture contains RGBD data.
  30643. */
  30644. get isRGBD(): boolean;
  30645. set isRGBD(value: boolean);
  30646. /**
  30647. * Is Z inverted in the texture (useful in a cube texture).
  30648. */
  30649. invertZ: boolean;
  30650. /**
  30651. * Are mip maps generated for this texture or not.
  30652. */
  30653. get noMipmap(): boolean;
  30654. /**
  30655. * @hidden
  30656. */
  30657. lodLevelInAlpha: boolean;
  30658. /**
  30659. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30660. */
  30661. get lodGenerationOffset(): number;
  30662. set lodGenerationOffset(value: number);
  30663. /**
  30664. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30665. */
  30666. get lodGenerationScale(): number;
  30667. set lodGenerationScale(value: number);
  30668. /**
  30669. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30670. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30671. * average roughness values.
  30672. */
  30673. get linearSpecularLOD(): boolean;
  30674. set linearSpecularLOD(value: boolean);
  30675. /**
  30676. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30677. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30678. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30679. */
  30680. get irradianceTexture(): Nullable<BaseTexture>;
  30681. set irradianceTexture(value: Nullable<BaseTexture>);
  30682. /**
  30683. * Define if the texture is a render target.
  30684. */
  30685. isRenderTarget: boolean;
  30686. /**
  30687. * Define the unique id of the texture in the scene.
  30688. */
  30689. get uid(): string;
  30690. /**
  30691. * Return a string representation of the texture.
  30692. * @returns the texture as a string
  30693. */
  30694. toString(): string;
  30695. /**
  30696. * Get the class name of the texture.
  30697. * @returns "BaseTexture"
  30698. */
  30699. getClassName(): string;
  30700. /**
  30701. * Define the list of animation attached to the texture.
  30702. */
  30703. animations: import("babylonjs/Animations/animation").Animation[];
  30704. /**
  30705. * An event triggered when the texture is disposed.
  30706. */
  30707. onDisposeObservable: Observable<BaseTexture>;
  30708. private _onDisposeObserver;
  30709. /**
  30710. * Callback triggered when the texture has been disposed.
  30711. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30712. */
  30713. set onDispose(callback: () => void);
  30714. /**
  30715. * Define the current state of the loading sequence when in delayed load mode.
  30716. */
  30717. delayLoadState: number;
  30718. private _scene;
  30719. /** @hidden */
  30720. _texture: Nullable<InternalTexture>;
  30721. private _uid;
  30722. /**
  30723. * Define if the texture is preventinga material to render or not.
  30724. * If not and the texture is not ready, the engine will use a default black texture instead.
  30725. */
  30726. get isBlocking(): boolean;
  30727. /**
  30728. * Instantiates a new BaseTexture.
  30729. * Base class of all the textures in babylon.
  30730. * It groups all the common properties the materials, post process, lights... might need
  30731. * in order to make a correct use of the texture.
  30732. * @param scene Define the scene the texture blongs to
  30733. */
  30734. constructor(scene: Nullable<Scene>);
  30735. /**
  30736. * Get the scene the texture belongs to.
  30737. * @returns the scene or null if undefined
  30738. */
  30739. getScene(): Nullable<Scene>;
  30740. /**
  30741. * Get the texture transform matrix used to offset tile the texture for istance.
  30742. * @returns the transformation matrix
  30743. */
  30744. getTextureMatrix(): Matrix;
  30745. /**
  30746. * Get the texture reflection matrix used to rotate/transform the reflection.
  30747. * @returns the reflection matrix
  30748. */
  30749. getReflectionTextureMatrix(): Matrix;
  30750. /**
  30751. * Get the underlying lower level texture from Babylon.
  30752. * @returns the insternal texture
  30753. */
  30754. getInternalTexture(): Nullable<InternalTexture>;
  30755. /**
  30756. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30757. * @returns true if ready or not blocking
  30758. */
  30759. isReadyOrNotBlocking(): boolean;
  30760. /**
  30761. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30762. * @returns true if fully ready
  30763. */
  30764. isReady(): boolean;
  30765. private _cachedSize;
  30766. /**
  30767. * Get the size of the texture.
  30768. * @returns the texture size.
  30769. */
  30770. getSize(): ISize;
  30771. /**
  30772. * Get the base size of the texture.
  30773. * It can be different from the size if the texture has been resized for POT for instance
  30774. * @returns the base size
  30775. */
  30776. getBaseSize(): ISize;
  30777. /**
  30778. * Update the sampling mode of the texture.
  30779. * Default is Trilinear mode.
  30780. *
  30781. * | Value | Type | Description |
  30782. * | ----- | ------------------ | ----------- |
  30783. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30784. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30785. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30786. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30787. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30788. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30789. * | 7 | NEAREST_LINEAR | |
  30790. * | 8 | NEAREST_NEAREST | |
  30791. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30792. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30793. * | 11 | LINEAR_LINEAR | |
  30794. * | 12 | LINEAR_NEAREST | |
  30795. *
  30796. * > _mag_: magnification filter (close to the viewer)
  30797. * > _min_: minification filter (far from the viewer)
  30798. * > _mip_: filter used between mip map levels
  30799. *@param samplingMode Define the new sampling mode of the texture
  30800. */
  30801. updateSamplingMode(samplingMode: number): void;
  30802. /**
  30803. * Scales the texture if is `canRescale()`
  30804. * @param ratio the resize factor we want to use to rescale
  30805. */
  30806. scale(ratio: number): void;
  30807. /**
  30808. * Get if the texture can rescale.
  30809. */
  30810. get canRescale(): boolean;
  30811. /** @hidden */
  30812. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30813. /** @hidden */
  30814. _rebuild(): void;
  30815. /**
  30816. * Triggers the load sequence in delayed load mode.
  30817. */
  30818. delayLoad(): void;
  30819. /**
  30820. * Clones the texture.
  30821. * @returns the cloned texture
  30822. */
  30823. clone(): Nullable<BaseTexture>;
  30824. /**
  30825. * Get the texture underlying type (INT, FLOAT...)
  30826. */
  30827. get textureType(): number;
  30828. /**
  30829. * Get the texture underlying format (RGB, RGBA...)
  30830. */
  30831. get textureFormat(): number;
  30832. /**
  30833. * Indicates that textures need to be re-calculated for all materials
  30834. */
  30835. protected _markAllSubMeshesAsTexturesDirty(): void;
  30836. /**
  30837. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30838. * This will returns an RGBA array buffer containing either in values (0-255) or
  30839. * float values (0-1) depending of the underlying buffer type.
  30840. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30841. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30842. * @param buffer defines a user defined buffer to fill with data (can be null)
  30843. * @returns The Array buffer containing the pixels data.
  30844. */
  30845. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30846. /**
  30847. * Release and destroy the underlying lower level texture aka internalTexture.
  30848. */
  30849. releaseInternalTexture(): void;
  30850. /** @hidden */
  30851. get _lodTextureHigh(): Nullable<BaseTexture>;
  30852. /** @hidden */
  30853. get _lodTextureMid(): Nullable<BaseTexture>;
  30854. /** @hidden */
  30855. get _lodTextureLow(): Nullable<BaseTexture>;
  30856. /**
  30857. * Dispose the texture and release its associated resources.
  30858. */
  30859. dispose(): void;
  30860. /**
  30861. * Serialize the texture into a JSON representation that can be parsed later on.
  30862. * @returns the JSON representation of the texture
  30863. */
  30864. serialize(): any;
  30865. /**
  30866. * Helper function to be called back once a list of texture contains only ready textures.
  30867. * @param textures Define the list of textures to wait for
  30868. * @param callback Define the callback triggered once the entire list will be ready
  30869. */
  30870. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30871. }
  30872. }
  30873. declare module "babylonjs/Materials/effect" {
  30874. import { Observable } from "babylonjs/Misc/observable";
  30875. import { Nullable } from "babylonjs/types";
  30876. import { IDisposable } from "babylonjs/scene";
  30877. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30878. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30879. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30880. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30881. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30882. import { Engine } from "babylonjs/Engines/engine";
  30883. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30884. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30885. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30886. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30887. /**
  30888. * Options to be used when creating an effect.
  30889. */
  30890. export interface IEffectCreationOptions {
  30891. /**
  30892. * Atrributes that will be used in the shader.
  30893. */
  30894. attributes: string[];
  30895. /**
  30896. * Uniform varible names that will be set in the shader.
  30897. */
  30898. uniformsNames: string[];
  30899. /**
  30900. * Uniform buffer variable names that will be set in the shader.
  30901. */
  30902. uniformBuffersNames: string[];
  30903. /**
  30904. * Sampler texture variable names that will be set in the shader.
  30905. */
  30906. samplers: string[];
  30907. /**
  30908. * Define statements that will be set in the shader.
  30909. */
  30910. defines: any;
  30911. /**
  30912. * Possible fallbacks for this effect to improve performance when needed.
  30913. */
  30914. fallbacks: Nullable<IEffectFallbacks>;
  30915. /**
  30916. * Callback that will be called when the shader is compiled.
  30917. */
  30918. onCompiled: Nullable<(effect: Effect) => void>;
  30919. /**
  30920. * Callback that will be called if an error occurs during shader compilation.
  30921. */
  30922. onError: Nullable<(effect: Effect, errors: string) => void>;
  30923. /**
  30924. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30925. */
  30926. indexParameters?: any;
  30927. /**
  30928. * Max number of lights that can be used in the shader.
  30929. */
  30930. maxSimultaneousLights?: number;
  30931. /**
  30932. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30933. */
  30934. transformFeedbackVaryings?: Nullable<string[]>;
  30935. }
  30936. /**
  30937. * Effect containing vertex and fragment shader that can be executed on an object.
  30938. */
  30939. export class Effect implements IDisposable {
  30940. /**
  30941. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30942. */
  30943. static ShadersRepository: string;
  30944. /**
  30945. * Name of the effect.
  30946. */
  30947. name: any;
  30948. /**
  30949. * String container all the define statements that should be set on the shader.
  30950. */
  30951. defines: string;
  30952. /**
  30953. * Callback that will be called when the shader is compiled.
  30954. */
  30955. onCompiled: Nullable<(effect: Effect) => void>;
  30956. /**
  30957. * Callback that will be called if an error occurs during shader compilation.
  30958. */
  30959. onError: Nullable<(effect: Effect, errors: string) => void>;
  30960. /**
  30961. * Callback that will be called when effect is bound.
  30962. */
  30963. onBind: Nullable<(effect: Effect) => void>;
  30964. /**
  30965. * Unique ID of the effect.
  30966. */
  30967. uniqueId: number;
  30968. /**
  30969. * Observable that will be called when the shader is compiled.
  30970. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30971. */
  30972. onCompileObservable: Observable<Effect>;
  30973. /**
  30974. * Observable that will be called if an error occurs during shader compilation.
  30975. */
  30976. onErrorObservable: Observable<Effect>;
  30977. /** @hidden */
  30978. _onBindObservable: Nullable<Observable<Effect>>;
  30979. /**
  30980. * @hidden
  30981. * Specifies if the effect was previously ready
  30982. */
  30983. _wasPreviouslyReady: boolean;
  30984. /**
  30985. * Observable that will be called when effect is bound.
  30986. */
  30987. get onBindObservable(): Observable<Effect>;
  30988. /** @hidden */
  30989. _bonesComputationForcedToCPU: boolean;
  30990. private static _uniqueIdSeed;
  30991. private _engine;
  30992. private _uniformBuffersNames;
  30993. private _uniformsNames;
  30994. private _samplerList;
  30995. private _samplers;
  30996. private _isReady;
  30997. private _compilationError;
  30998. private _allFallbacksProcessed;
  30999. private _attributesNames;
  31000. private _attributes;
  31001. private _attributeLocationByName;
  31002. private _uniforms;
  31003. /**
  31004. * Key for the effect.
  31005. * @hidden
  31006. */
  31007. _key: string;
  31008. private _indexParameters;
  31009. private _fallbacks;
  31010. private _vertexSourceCode;
  31011. private _fragmentSourceCode;
  31012. private _vertexSourceCodeOverride;
  31013. private _fragmentSourceCodeOverride;
  31014. private _transformFeedbackVaryings;
  31015. /**
  31016. * Compiled shader to webGL program.
  31017. * @hidden
  31018. */
  31019. _pipelineContext: Nullable<IPipelineContext>;
  31020. private _valueCache;
  31021. private static _baseCache;
  31022. /**
  31023. * Instantiates an effect.
  31024. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31025. * @param baseName Name of the effect.
  31026. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31027. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31028. * @param samplers List of sampler variables that will be passed to the shader.
  31029. * @param engine Engine to be used to render the effect
  31030. * @param defines Define statements to be added to the shader.
  31031. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31032. * @param onCompiled Callback that will be called when the shader is compiled.
  31033. * @param onError Callback that will be called if an error occurs during shader compilation.
  31034. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31035. */
  31036. 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);
  31037. private _useFinalCode;
  31038. /**
  31039. * Unique key for this effect
  31040. */
  31041. get key(): string;
  31042. /**
  31043. * If the effect has been compiled and prepared.
  31044. * @returns if the effect is compiled and prepared.
  31045. */
  31046. isReady(): boolean;
  31047. private _isReadyInternal;
  31048. /**
  31049. * The engine the effect was initialized with.
  31050. * @returns the engine.
  31051. */
  31052. getEngine(): Engine;
  31053. /**
  31054. * The pipeline context for this effect
  31055. * @returns the associated pipeline context
  31056. */
  31057. getPipelineContext(): Nullable<IPipelineContext>;
  31058. /**
  31059. * The set of names of attribute variables for the shader.
  31060. * @returns An array of attribute names.
  31061. */
  31062. getAttributesNames(): string[];
  31063. /**
  31064. * Returns the attribute at the given index.
  31065. * @param index The index of the attribute.
  31066. * @returns The location of the attribute.
  31067. */
  31068. getAttributeLocation(index: number): number;
  31069. /**
  31070. * Returns the attribute based on the name of the variable.
  31071. * @param name of the attribute to look up.
  31072. * @returns the attribute location.
  31073. */
  31074. getAttributeLocationByName(name: string): number;
  31075. /**
  31076. * The number of attributes.
  31077. * @returns the numnber of attributes.
  31078. */
  31079. getAttributesCount(): number;
  31080. /**
  31081. * Gets the index of a uniform variable.
  31082. * @param uniformName of the uniform to look up.
  31083. * @returns the index.
  31084. */
  31085. getUniformIndex(uniformName: string): number;
  31086. /**
  31087. * Returns the attribute based on the name of the variable.
  31088. * @param uniformName of the uniform to look up.
  31089. * @returns the location of the uniform.
  31090. */
  31091. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31092. /**
  31093. * Returns an array of sampler variable names
  31094. * @returns The array of sampler variable neames.
  31095. */
  31096. getSamplers(): string[];
  31097. /**
  31098. * The error from the last compilation.
  31099. * @returns the error string.
  31100. */
  31101. getCompilationError(): string;
  31102. /**
  31103. * Gets a boolean indicating that all fallbacks were used during compilation
  31104. * @returns true if all fallbacks were used
  31105. */
  31106. allFallbacksProcessed(): boolean;
  31107. /**
  31108. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31109. * @param func The callback to be used.
  31110. */
  31111. executeWhenCompiled(func: (effect: Effect) => void): void;
  31112. private _checkIsReady;
  31113. private _loadShader;
  31114. /**
  31115. * Recompiles the webGL program
  31116. * @param vertexSourceCode The source code for the vertex shader.
  31117. * @param fragmentSourceCode The source code for the fragment shader.
  31118. * @param onCompiled Callback called when completed.
  31119. * @param onError Callback called on error.
  31120. * @hidden
  31121. */
  31122. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31123. /**
  31124. * Prepares the effect
  31125. * @hidden
  31126. */
  31127. _prepareEffect(): void;
  31128. private _processCompilationErrors;
  31129. /**
  31130. * Checks if the effect is supported. (Must be called after compilation)
  31131. */
  31132. get isSupported(): boolean;
  31133. /**
  31134. * Binds a texture to the engine to be used as output of the shader.
  31135. * @param channel Name of the output variable.
  31136. * @param texture Texture to bind.
  31137. * @hidden
  31138. */
  31139. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31140. /**
  31141. * Sets a texture on the engine to be used in the shader.
  31142. * @param channel Name of the sampler variable.
  31143. * @param texture Texture to set.
  31144. */
  31145. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31146. /**
  31147. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31148. * @param channel Name of the sampler variable.
  31149. * @param texture Texture to set.
  31150. */
  31151. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31152. /**
  31153. * Sets an array of textures on the engine to be used in the shader.
  31154. * @param channel Name of the variable.
  31155. * @param textures Textures to set.
  31156. */
  31157. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31158. /**
  31159. * 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)
  31160. * @param channel Name of the sampler variable.
  31161. * @param postProcess Post process to get the input texture from.
  31162. */
  31163. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31164. /**
  31165. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31166. * 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)
  31167. * @param channel Name of the sampler variable.
  31168. * @param postProcess Post process to get the output texture from.
  31169. */
  31170. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31171. /** @hidden */
  31172. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31173. /** @hidden */
  31174. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31175. /** @hidden */
  31176. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31177. /** @hidden */
  31178. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31179. /**
  31180. * Binds a buffer to a uniform.
  31181. * @param buffer Buffer to bind.
  31182. * @param name Name of the uniform variable to bind to.
  31183. */
  31184. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31185. /**
  31186. * Binds block to a uniform.
  31187. * @param blockName Name of the block to bind.
  31188. * @param index Index to bind.
  31189. */
  31190. bindUniformBlock(blockName: string, index: number): void;
  31191. /**
  31192. * Sets an interger value on a uniform variable.
  31193. * @param uniformName Name of the variable.
  31194. * @param value Value to be set.
  31195. * @returns this effect.
  31196. */
  31197. setInt(uniformName: string, value: number): Effect;
  31198. /**
  31199. * Sets an int array on a uniform variable.
  31200. * @param uniformName Name of the variable.
  31201. * @param array array to be set.
  31202. * @returns this effect.
  31203. */
  31204. setIntArray(uniformName: string, array: Int32Array): Effect;
  31205. /**
  31206. * 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)
  31207. * @param uniformName Name of the variable.
  31208. * @param array array to be set.
  31209. * @returns this effect.
  31210. */
  31211. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31212. /**
  31213. * 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)
  31214. * @param uniformName Name of the variable.
  31215. * @param array array to be set.
  31216. * @returns this effect.
  31217. */
  31218. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31219. /**
  31220. * 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)
  31221. * @param uniformName Name of the variable.
  31222. * @param array array to be set.
  31223. * @returns this effect.
  31224. */
  31225. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31226. /**
  31227. * Sets an float array on a uniform variable.
  31228. * @param uniformName Name of the variable.
  31229. * @param array array to be set.
  31230. * @returns this effect.
  31231. */
  31232. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31233. /**
  31234. * 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)
  31235. * @param uniformName Name of the variable.
  31236. * @param array array to be set.
  31237. * @returns this effect.
  31238. */
  31239. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31240. /**
  31241. * 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)
  31242. * @param uniformName Name of the variable.
  31243. * @param array array to be set.
  31244. * @returns this effect.
  31245. */
  31246. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31247. /**
  31248. * 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)
  31249. * @param uniformName Name of the variable.
  31250. * @param array array to be set.
  31251. * @returns this effect.
  31252. */
  31253. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31254. /**
  31255. * Sets an array on a uniform variable.
  31256. * @param uniformName Name of the variable.
  31257. * @param array array to be set.
  31258. * @returns this effect.
  31259. */
  31260. setArray(uniformName: string, array: number[]): Effect;
  31261. /**
  31262. * 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)
  31263. * @param uniformName Name of the variable.
  31264. * @param array array to be set.
  31265. * @returns this effect.
  31266. */
  31267. setArray2(uniformName: string, array: number[]): Effect;
  31268. /**
  31269. * 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)
  31270. * @param uniformName Name of the variable.
  31271. * @param array array to be set.
  31272. * @returns this effect.
  31273. */
  31274. setArray3(uniformName: string, array: number[]): Effect;
  31275. /**
  31276. * 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)
  31277. * @param uniformName Name of the variable.
  31278. * @param array array to be set.
  31279. * @returns this effect.
  31280. */
  31281. setArray4(uniformName: string, array: number[]): Effect;
  31282. /**
  31283. * Sets matrices on a uniform variable.
  31284. * @param uniformName Name of the variable.
  31285. * @param matrices matrices to be set.
  31286. * @returns this effect.
  31287. */
  31288. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31289. /**
  31290. * Sets matrix on a uniform variable.
  31291. * @param uniformName Name of the variable.
  31292. * @param matrix matrix to be set.
  31293. * @returns this effect.
  31294. */
  31295. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31296. /**
  31297. * 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)
  31298. * @param uniformName Name of the variable.
  31299. * @param matrix matrix to be set.
  31300. * @returns this effect.
  31301. */
  31302. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31303. /**
  31304. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31305. * @param uniformName Name of the variable.
  31306. * @param matrix matrix to be set.
  31307. * @returns this effect.
  31308. */
  31309. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31310. /**
  31311. * Sets a float on a uniform variable.
  31312. * @param uniformName Name of the variable.
  31313. * @param value value to be set.
  31314. * @returns this effect.
  31315. */
  31316. setFloat(uniformName: string, value: number): Effect;
  31317. /**
  31318. * Sets a boolean on a uniform variable.
  31319. * @param uniformName Name of the variable.
  31320. * @param bool value to be set.
  31321. * @returns this effect.
  31322. */
  31323. setBool(uniformName: string, bool: boolean): Effect;
  31324. /**
  31325. * Sets a Vector2 on a uniform variable.
  31326. * @param uniformName Name of the variable.
  31327. * @param vector2 vector2 to be set.
  31328. * @returns this effect.
  31329. */
  31330. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31331. /**
  31332. * Sets a float2 on a uniform variable.
  31333. * @param uniformName Name of the variable.
  31334. * @param x First float in float2.
  31335. * @param y Second float in float2.
  31336. * @returns this effect.
  31337. */
  31338. setFloat2(uniformName: string, x: number, y: number): Effect;
  31339. /**
  31340. * Sets a Vector3 on a uniform variable.
  31341. * @param uniformName Name of the variable.
  31342. * @param vector3 Value to be set.
  31343. * @returns this effect.
  31344. */
  31345. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31346. /**
  31347. * Sets a float3 on a uniform variable.
  31348. * @param uniformName Name of the variable.
  31349. * @param x First float in float3.
  31350. * @param y Second float in float3.
  31351. * @param z Third float in float3.
  31352. * @returns this effect.
  31353. */
  31354. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31355. /**
  31356. * Sets a Vector4 on a uniform variable.
  31357. * @param uniformName Name of the variable.
  31358. * @param vector4 Value to be set.
  31359. * @returns this effect.
  31360. */
  31361. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31362. /**
  31363. * Sets a float4 on a uniform variable.
  31364. * @param uniformName Name of the variable.
  31365. * @param x First float in float4.
  31366. * @param y Second float in float4.
  31367. * @param z Third float in float4.
  31368. * @param w Fourth float in float4.
  31369. * @returns this effect.
  31370. */
  31371. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31372. /**
  31373. * Sets a Color3 on a uniform variable.
  31374. * @param uniformName Name of the variable.
  31375. * @param color3 Value to be set.
  31376. * @returns this effect.
  31377. */
  31378. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31379. /**
  31380. * Sets a Color4 on a uniform variable.
  31381. * @param uniformName Name of the variable.
  31382. * @param color3 Value to be set.
  31383. * @param alpha Alpha value to be set.
  31384. * @returns this effect.
  31385. */
  31386. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31387. /**
  31388. * Sets a Color4 on a uniform variable
  31389. * @param uniformName defines the name of the variable
  31390. * @param color4 defines the value to be set
  31391. * @returns this effect.
  31392. */
  31393. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31394. /** Release all associated resources */
  31395. dispose(): void;
  31396. /**
  31397. * This function will add a new shader to the shader store
  31398. * @param name the name of the shader
  31399. * @param pixelShader optional pixel shader content
  31400. * @param vertexShader optional vertex shader content
  31401. */
  31402. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31403. /**
  31404. * Store of each shader (The can be looked up using effect.key)
  31405. */
  31406. static ShadersStore: {
  31407. [key: string]: string;
  31408. };
  31409. /**
  31410. * Store of each included file for a shader (The can be looked up using effect.key)
  31411. */
  31412. static IncludesShadersStore: {
  31413. [key: string]: string;
  31414. };
  31415. /**
  31416. * Resets the cache of effects.
  31417. */
  31418. static ResetCache(): void;
  31419. }
  31420. }
  31421. declare module "babylonjs/Engines/engineCapabilities" {
  31422. /**
  31423. * Interface used to describe the capabilities of the engine relatively to the current browser
  31424. */
  31425. export interface EngineCapabilities {
  31426. /** Maximum textures units per fragment shader */
  31427. maxTexturesImageUnits: number;
  31428. /** Maximum texture units per vertex shader */
  31429. maxVertexTextureImageUnits: number;
  31430. /** Maximum textures units in the entire pipeline */
  31431. maxCombinedTexturesImageUnits: number;
  31432. /** Maximum texture size */
  31433. maxTextureSize: number;
  31434. /** Maximum texture samples */
  31435. maxSamples?: number;
  31436. /** Maximum cube texture size */
  31437. maxCubemapTextureSize: number;
  31438. /** Maximum render texture size */
  31439. maxRenderTextureSize: number;
  31440. /** Maximum number of vertex attributes */
  31441. maxVertexAttribs: number;
  31442. /** Maximum number of varyings */
  31443. maxVaryingVectors: number;
  31444. /** Maximum number of uniforms per vertex shader */
  31445. maxVertexUniformVectors: number;
  31446. /** Maximum number of uniforms per fragment shader */
  31447. maxFragmentUniformVectors: number;
  31448. /** Defines if standard derivates (dx/dy) are supported */
  31449. standardDerivatives: boolean;
  31450. /** Defines if s3tc texture compression is supported */
  31451. s3tc?: WEBGL_compressed_texture_s3tc;
  31452. /** Defines if pvrtc texture compression is supported */
  31453. pvrtc: any;
  31454. /** Defines if etc1 texture compression is supported */
  31455. etc1: any;
  31456. /** Defines if etc2 texture compression is supported */
  31457. etc2: any;
  31458. /** Defines if astc texture compression is supported */
  31459. astc: any;
  31460. /** Defines if float textures are supported */
  31461. textureFloat: boolean;
  31462. /** Defines if vertex array objects are supported */
  31463. vertexArrayObject: boolean;
  31464. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31465. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31466. /** Gets the maximum level of anisotropy supported */
  31467. maxAnisotropy: number;
  31468. /** Defines if instancing is supported */
  31469. instancedArrays: boolean;
  31470. /** Defines if 32 bits indices are supported */
  31471. uintIndices: boolean;
  31472. /** Defines if high precision shaders are supported */
  31473. highPrecisionShaderSupported: boolean;
  31474. /** Defines if depth reading in the fragment shader is supported */
  31475. fragmentDepthSupported: boolean;
  31476. /** Defines if float texture linear filtering is supported*/
  31477. textureFloatLinearFiltering: boolean;
  31478. /** Defines if rendering to float textures is supported */
  31479. textureFloatRender: boolean;
  31480. /** Defines if half float textures are supported*/
  31481. textureHalfFloat: boolean;
  31482. /** Defines if half float texture linear filtering is supported*/
  31483. textureHalfFloatLinearFiltering: boolean;
  31484. /** Defines if rendering to half float textures is supported */
  31485. textureHalfFloatRender: boolean;
  31486. /** Defines if textureLOD shader command is supported */
  31487. textureLOD: boolean;
  31488. /** Defines if draw buffers extension is supported */
  31489. drawBuffersExtension: boolean;
  31490. /** Defines if depth textures are supported */
  31491. depthTextureExtension: boolean;
  31492. /** Defines if float color buffer are supported */
  31493. colorBufferFloat: boolean;
  31494. /** Gets disjoint timer query extension (null if not supported) */
  31495. timerQuery?: EXT_disjoint_timer_query;
  31496. /** Defines if timestamp can be used with timer query */
  31497. canUseTimestampForTimerQuery: boolean;
  31498. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31499. multiview?: any;
  31500. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31501. oculusMultiview?: any;
  31502. /** Function used to let the system compiles shaders in background */
  31503. parallelShaderCompile?: {
  31504. COMPLETION_STATUS_KHR: number;
  31505. };
  31506. /** Max number of texture samples for MSAA */
  31507. maxMSAASamples: number;
  31508. /** Defines if the blend min max extension is supported */
  31509. blendMinMax: boolean;
  31510. }
  31511. }
  31512. declare module "babylonjs/States/depthCullingState" {
  31513. import { Nullable } from "babylonjs/types";
  31514. /**
  31515. * @hidden
  31516. **/
  31517. export class DepthCullingState {
  31518. private _isDepthTestDirty;
  31519. private _isDepthMaskDirty;
  31520. private _isDepthFuncDirty;
  31521. private _isCullFaceDirty;
  31522. private _isCullDirty;
  31523. private _isZOffsetDirty;
  31524. private _isFrontFaceDirty;
  31525. private _depthTest;
  31526. private _depthMask;
  31527. private _depthFunc;
  31528. private _cull;
  31529. private _cullFace;
  31530. private _zOffset;
  31531. private _frontFace;
  31532. /**
  31533. * Initializes the state.
  31534. */
  31535. constructor();
  31536. get isDirty(): boolean;
  31537. get zOffset(): number;
  31538. set zOffset(value: number);
  31539. get cullFace(): Nullable<number>;
  31540. set cullFace(value: Nullable<number>);
  31541. get cull(): Nullable<boolean>;
  31542. set cull(value: Nullable<boolean>);
  31543. get depthFunc(): Nullable<number>;
  31544. set depthFunc(value: Nullable<number>);
  31545. get depthMask(): boolean;
  31546. set depthMask(value: boolean);
  31547. get depthTest(): boolean;
  31548. set depthTest(value: boolean);
  31549. get frontFace(): Nullable<number>;
  31550. set frontFace(value: Nullable<number>);
  31551. reset(): void;
  31552. apply(gl: WebGLRenderingContext): void;
  31553. }
  31554. }
  31555. declare module "babylonjs/States/stencilState" {
  31556. /**
  31557. * @hidden
  31558. **/
  31559. export class StencilState {
  31560. /** 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 */
  31561. static readonly ALWAYS: number;
  31562. /** Passed to stencilOperation to specify that stencil value must be kept */
  31563. static readonly KEEP: number;
  31564. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31565. static readonly REPLACE: number;
  31566. private _isStencilTestDirty;
  31567. private _isStencilMaskDirty;
  31568. private _isStencilFuncDirty;
  31569. private _isStencilOpDirty;
  31570. private _stencilTest;
  31571. private _stencilMask;
  31572. private _stencilFunc;
  31573. private _stencilFuncRef;
  31574. private _stencilFuncMask;
  31575. private _stencilOpStencilFail;
  31576. private _stencilOpDepthFail;
  31577. private _stencilOpStencilDepthPass;
  31578. get isDirty(): boolean;
  31579. get stencilFunc(): number;
  31580. set stencilFunc(value: number);
  31581. get stencilFuncRef(): number;
  31582. set stencilFuncRef(value: number);
  31583. get stencilFuncMask(): number;
  31584. set stencilFuncMask(value: number);
  31585. get stencilOpStencilFail(): number;
  31586. set stencilOpStencilFail(value: number);
  31587. get stencilOpDepthFail(): number;
  31588. set stencilOpDepthFail(value: number);
  31589. get stencilOpStencilDepthPass(): number;
  31590. set stencilOpStencilDepthPass(value: number);
  31591. get stencilMask(): number;
  31592. set stencilMask(value: number);
  31593. get stencilTest(): boolean;
  31594. set stencilTest(value: boolean);
  31595. constructor();
  31596. reset(): void;
  31597. apply(gl: WebGLRenderingContext): void;
  31598. }
  31599. }
  31600. declare module "babylonjs/States/alphaCullingState" {
  31601. /**
  31602. * @hidden
  31603. **/
  31604. export class AlphaState {
  31605. private _isAlphaBlendDirty;
  31606. private _isBlendFunctionParametersDirty;
  31607. private _isBlendEquationParametersDirty;
  31608. private _isBlendConstantsDirty;
  31609. private _alphaBlend;
  31610. private _blendFunctionParameters;
  31611. private _blendEquationParameters;
  31612. private _blendConstants;
  31613. /**
  31614. * Initializes the state.
  31615. */
  31616. constructor();
  31617. get isDirty(): boolean;
  31618. get alphaBlend(): boolean;
  31619. set alphaBlend(value: boolean);
  31620. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31621. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31622. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31623. reset(): void;
  31624. apply(gl: WebGLRenderingContext): void;
  31625. }
  31626. }
  31627. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31628. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31629. /** @hidden */
  31630. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31631. attributeProcessor(attribute: string): string;
  31632. varyingProcessor(varying: string, isFragment: boolean): string;
  31633. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31634. }
  31635. }
  31636. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31637. /**
  31638. * Interface for attribute information associated with buffer instanciation
  31639. */
  31640. export interface InstancingAttributeInfo {
  31641. /**
  31642. * Name of the GLSL attribute
  31643. * if attribute index is not specified, this is used to retrieve the index from the effect
  31644. */
  31645. attributeName: string;
  31646. /**
  31647. * Index/offset of the attribute in the vertex shader
  31648. * if not specified, this will be computes from the name.
  31649. */
  31650. index?: number;
  31651. /**
  31652. * size of the attribute, 1, 2, 3 or 4
  31653. */
  31654. attributeSize: number;
  31655. /**
  31656. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31657. */
  31658. offset: number;
  31659. /**
  31660. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31661. * default to 1
  31662. */
  31663. divisor?: number;
  31664. /**
  31665. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31666. * default is FLOAT
  31667. */
  31668. attributeType?: number;
  31669. /**
  31670. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31671. */
  31672. normalized?: boolean;
  31673. }
  31674. }
  31675. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31676. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31677. import { Nullable } from "babylonjs/types";
  31678. module "babylonjs/Engines/thinEngine" {
  31679. interface ThinEngine {
  31680. /**
  31681. * Update a video texture
  31682. * @param texture defines the texture to update
  31683. * @param video defines the video element to use
  31684. * @param invertY defines if data must be stored with Y axis inverted
  31685. */
  31686. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31687. }
  31688. }
  31689. }
  31690. declare module "babylonjs/Materials/Textures/videoTexture" {
  31691. import { Observable } from "babylonjs/Misc/observable";
  31692. import { Nullable } from "babylonjs/types";
  31693. import { Scene } from "babylonjs/scene";
  31694. import { Texture } from "babylonjs/Materials/Textures/texture";
  31695. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31696. /**
  31697. * Settings for finer control over video usage
  31698. */
  31699. export interface VideoTextureSettings {
  31700. /**
  31701. * Applies `autoplay` to video, if specified
  31702. */
  31703. autoPlay?: boolean;
  31704. /**
  31705. * Applies `loop` to video, if specified
  31706. */
  31707. loop?: boolean;
  31708. /**
  31709. * Automatically updates internal texture from video at every frame in the render loop
  31710. */
  31711. autoUpdateTexture: boolean;
  31712. /**
  31713. * Image src displayed during the video loading or until the user interacts with the video.
  31714. */
  31715. poster?: string;
  31716. }
  31717. /**
  31718. * If you want to display a video in your scene, this is the special texture for that.
  31719. * This special texture works similar to other textures, with the exception of a few parameters.
  31720. * @see https://doc.babylonjs.com/how_to/video_texture
  31721. */
  31722. export class VideoTexture extends Texture {
  31723. /**
  31724. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31725. */
  31726. readonly autoUpdateTexture: boolean;
  31727. /**
  31728. * The video instance used by the texture internally
  31729. */
  31730. readonly video: HTMLVideoElement;
  31731. private _onUserActionRequestedObservable;
  31732. /**
  31733. * Event triggerd when a dom action is required by the user to play the video.
  31734. * This happens due to recent changes in browser policies preventing video to auto start.
  31735. */
  31736. get onUserActionRequestedObservable(): Observable<Texture>;
  31737. private _generateMipMaps;
  31738. private _engine;
  31739. private _stillImageCaptured;
  31740. private _displayingPosterTexture;
  31741. private _settings;
  31742. private _createInternalTextureOnEvent;
  31743. private _frameId;
  31744. private _currentSrc;
  31745. /**
  31746. * Creates a video texture.
  31747. * If you want to display a video in your scene, this is the special texture for that.
  31748. * This special texture works similar to other textures, with the exception of a few parameters.
  31749. * @see https://doc.babylonjs.com/how_to/video_texture
  31750. * @param name optional name, will detect from video source, if not defined
  31751. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31752. * @param scene is obviously the current scene.
  31753. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31754. * @param invertY is false by default but can be used to invert video on Y axis
  31755. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31756. * @param settings allows finer control over video usage
  31757. */
  31758. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31759. private _getName;
  31760. private _getVideo;
  31761. private _createInternalTexture;
  31762. private reset;
  31763. /**
  31764. * @hidden Internal method to initiate `update`.
  31765. */
  31766. _rebuild(): void;
  31767. /**
  31768. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31769. */
  31770. update(): void;
  31771. /**
  31772. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31773. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31774. */
  31775. updateTexture(isVisible: boolean): void;
  31776. protected _updateInternalTexture: () => void;
  31777. /**
  31778. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31779. * @param url New url.
  31780. */
  31781. updateURL(url: string): void;
  31782. /**
  31783. * Clones the texture.
  31784. * @returns the cloned texture
  31785. */
  31786. clone(): VideoTexture;
  31787. /**
  31788. * Dispose the texture and release its associated resources.
  31789. */
  31790. dispose(): void;
  31791. /**
  31792. * Creates a video texture straight from a stream.
  31793. * @param scene Define the scene the texture should be created in
  31794. * @param stream Define the stream the texture should be created from
  31795. * @returns The created video texture as a promise
  31796. */
  31797. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31798. /**
  31799. * Creates a video texture straight from your WebCam video feed.
  31800. * @param scene Define the scene the texture should be created in
  31801. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31802. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31803. * @returns The created video texture as a promise
  31804. */
  31805. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31806. minWidth: number;
  31807. maxWidth: number;
  31808. minHeight: number;
  31809. maxHeight: number;
  31810. deviceId: string;
  31811. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31812. /**
  31813. * Creates a video texture straight from your WebCam video feed.
  31814. * @param scene Define the scene the texture should be created in
  31815. * @param onReady Define a callback to triggered once the texture will be ready
  31816. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31817. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31818. */
  31819. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31820. minWidth: number;
  31821. maxWidth: number;
  31822. minHeight: number;
  31823. maxHeight: number;
  31824. deviceId: string;
  31825. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31826. }
  31827. }
  31828. declare module "babylonjs/Engines/thinEngine" {
  31829. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31830. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31831. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31832. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31833. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31834. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31835. import { Observable } from "babylonjs/Misc/observable";
  31836. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31837. import { StencilState } from "babylonjs/States/stencilState";
  31838. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31839. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31840. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31841. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31842. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31843. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31844. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31845. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31846. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31847. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31848. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31849. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31850. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31851. import { WebRequest } from "babylonjs/Misc/webRequest";
  31852. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31853. /**
  31854. * Defines the interface used by objects working like Scene
  31855. * @hidden
  31856. */
  31857. export interface ISceneLike {
  31858. _addPendingData(data: any): void;
  31859. _removePendingData(data: any): void;
  31860. offlineProvider: IOfflineProvider;
  31861. }
  31862. /** Interface defining initialization parameters for Engine class */
  31863. export interface EngineOptions extends WebGLContextAttributes {
  31864. /**
  31865. * Defines if the engine should no exceed a specified device ratio
  31866. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31867. */
  31868. limitDeviceRatio?: number;
  31869. /**
  31870. * Defines if webvr should be enabled automatically
  31871. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31872. */
  31873. autoEnableWebVR?: boolean;
  31874. /**
  31875. * Defines if webgl2 should be turned off even if supported
  31876. * @see http://doc.babylonjs.com/features/webgl2
  31877. */
  31878. disableWebGL2Support?: boolean;
  31879. /**
  31880. * Defines if webaudio should be initialized as well
  31881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31882. */
  31883. audioEngine?: boolean;
  31884. /**
  31885. * Defines if animations should run using a deterministic lock step
  31886. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31887. */
  31888. deterministicLockstep?: boolean;
  31889. /** Defines the maximum steps to use with deterministic lock step mode */
  31890. lockstepMaxSteps?: number;
  31891. /** Defines the seconds between each deterministic lock step */
  31892. timeStep?: number;
  31893. /**
  31894. * Defines that engine should ignore context lost events
  31895. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31896. */
  31897. doNotHandleContextLost?: boolean;
  31898. /**
  31899. * Defines that engine should ignore modifying touch action attribute and style
  31900. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31901. */
  31902. doNotHandleTouchAction?: boolean;
  31903. /**
  31904. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31905. */
  31906. useHighPrecisionFloats?: boolean;
  31907. }
  31908. /**
  31909. * The base engine class (root of all engines)
  31910. */
  31911. export class ThinEngine {
  31912. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31913. static ExceptionList: ({
  31914. key: string;
  31915. capture: string;
  31916. captureConstraint: number;
  31917. targets: string[];
  31918. } | {
  31919. key: string;
  31920. capture: null;
  31921. captureConstraint: null;
  31922. targets: string[];
  31923. })[];
  31924. /** @hidden */
  31925. static _TextureLoaders: IInternalTextureLoader[];
  31926. /**
  31927. * Returns the current npm package of the sdk
  31928. */
  31929. static get NpmPackage(): string;
  31930. /**
  31931. * Returns the current version of the framework
  31932. */
  31933. static get Version(): string;
  31934. /**
  31935. * Returns a string describing the current engine
  31936. */
  31937. get description(): string;
  31938. /**
  31939. * Gets or sets the epsilon value used by collision engine
  31940. */
  31941. static CollisionsEpsilon: number;
  31942. /**
  31943. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31944. */
  31945. static get ShadersRepository(): string;
  31946. static set ShadersRepository(value: string);
  31947. /** @hidden */
  31948. _shaderProcessor: IShaderProcessor;
  31949. /**
  31950. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31951. */
  31952. forcePOTTextures: boolean;
  31953. /**
  31954. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31955. */
  31956. isFullscreen: boolean;
  31957. /**
  31958. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31959. */
  31960. cullBackFaces: boolean;
  31961. /**
  31962. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31963. */
  31964. renderEvenInBackground: boolean;
  31965. /**
  31966. * Gets or sets a boolean indicating that cache can be kept between frames
  31967. */
  31968. preventCacheWipeBetweenFrames: boolean;
  31969. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31970. validateShaderPrograms: boolean;
  31971. /**
  31972. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31973. * This can provide greater z depth for distant objects.
  31974. */
  31975. useReverseDepthBuffer: boolean;
  31976. /**
  31977. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31978. */
  31979. disableUniformBuffers: boolean;
  31980. /** @hidden */
  31981. _uniformBuffers: UniformBuffer[];
  31982. /**
  31983. * Gets a boolean indicating that the engine supports uniform buffers
  31984. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31985. */
  31986. get supportsUniformBuffers(): boolean;
  31987. /** @hidden */
  31988. _gl: WebGLRenderingContext;
  31989. /** @hidden */
  31990. _webGLVersion: number;
  31991. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31992. protected _windowIsBackground: boolean;
  31993. protected _creationOptions: EngineOptions;
  31994. protected _highPrecisionShadersAllowed: boolean;
  31995. /** @hidden */
  31996. get _shouldUseHighPrecisionShader(): boolean;
  31997. /**
  31998. * Gets a boolean indicating that only power of 2 textures are supported
  31999. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32000. */
  32001. get needPOTTextures(): boolean;
  32002. /** @hidden */
  32003. _badOS: boolean;
  32004. /** @hidden */
  32005. _badDesktopOS: boolean;
  32006. private _hardwareScalingLevel;
  32007. /** @hidden */
  32008. _caps: EngineCapabilities;
  32009. private _isStencilEnable;
  32010. private _glVersion;
  32011. private _glRenderer;
  32012. private _glVendor;
  32013. /** @hidden */
  32014. _videoTextureSupported: boolean;
  32015. protected _renderingQueueLaunched: boolean;
  32016. protected _activeRenderLoops: (() => void)[];
  32017. /**
  32018. * Observable signaled when a context lost event is raised
  32019. */
  32020. onContextLostObservable: Observable<ThinEngine>;
  32021. /**
  32022. * Observable signaled when a context restored event is raised
  32023. */
  32024. onContextRestoredObservable: Observable<ThinEngine>;
  32025. private _onContextLost;
  32026. private _onContextRestored;
  32027. protected _contextWasLost: boolean;
  32028. /** @hidden */
  32029. _doNotHandleContextLost: boolean;
  32030. /**
  32031. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32032. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32033. */
  32034. get doNotHandleContextLost(): boolean;
  32035. set doNotHandleContextLost(value: boolean);
  32036. /**
  32037. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32038. */
  32039. disableVertexArrayObjects: boolean;
  32040. /** @hidden */
  32041. protected _colorWrite: boolean;
  32042. /** @hidden */
  32043. protected _colorWriteChanged: boolean;
  32044. /** @hidden */
  32045. protected _depthCullingState: DepthCullingState;
  32046. /** @hidden */
  32047. protected _stencilState: StencilState;
  32048. /** @hidden */
  32049. _alphaState: AlphaState;
  32050. /** @hidden */
  32051. _alphaMode: number;
  32052. /** @hidden */
  32053. _alphaEquation: number;
  32054. /** @hidden */
  32055. _internalTexturesCache: InternalTexture[];
  32056. /** @hidden */
  32057. protected _activeChannel: number;
  32058. private _currentTextureChannel;
  32059. /** @hidden */
  32060. protected _boundTexturesCache: {
  32061. [key: string]: Nullable<InternalTexture>;
  32062. };
  32063. /** @hidden */
  32064. protected _currentEffect: Nullable<Effect>;
  32065. /** @hidden */
  32066. protected _currentProgram: Nullable<WebGLProgram>;
  32067. private _compiledEffects;
  32068. private _vertexAttribArraysEnabled;
  32069. /** @hidden */
  32070. protected _cachedViewport: Nullable<IViewportLike>;
  32071. private _cachedVertexArrayObject;
  32072. /** @hidden */
  32073. protected _cachedVertexBuffers: any;
  32074. /** @hidden */
  32075. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32076. /** @hidden */
  32077. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32078. /** @hidden */
  32079. _currentRenderTarget: Nullable<InternalTexture>;
  32080. private _uintIndicesCurrentlySet;
  32081. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32082. /** @hidden */
  32083. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32084. private _currentBufferPointers;
  32085. private _currentInstanceLocations;
  32086. private _currentInstanceBuffers;
  32087. private _textureUnits;
  32088. /** @hidden */
  32089. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32090. /** @hidden */
  32091. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32092. /** @hidden */
  32093. _boundRenderFunction: any;
  32094. private _vaoRecordInProgress;
  32095. private _mustWipeVertexAttributes;
  32096. private _emptyTexture;
  32097. private _emptyCubeTexture;
  32098. private _emptyTexture3D;
  32099. private _emptyTexture2DArray;
  32100. /** @hidden */
  32101. _frameHandler: number;
  32102. private _nextFreeTextureSlots;
  32103. private _maxSimultaneousTextures;
  32104. private _activeRequests;
  32105. protected _texturesSupported: string[];
  32106. /** @hidden */
  32107. _textureFormatInUse: Nullable<string>;
  32108. protected get _supportsHardwareTextureRescaling(): boolean;
  32109. private _framebufferDimensionsObject;
  32110. /**
  32111. * sets the object from which width and height will be taken from when getting render width and height
  32112. * Will fallback to the gl object
  32113. * @param dimensions the framebuffer width and height that will be used.
  32114. */
  32115. set framebufferDimensionsObject(dimensions: Nullable<{
  32116. framebufferWidth: number;
  32117. framebufferHeight: number;
  32118. }>);
  32119. /**
  32120. * Gets the list of texture formats supported
  32121. */
  32122. get texturesSupported(): Array<string>;
  32123. /**
  32124. * Gets the list of texture formats in use
  32125. */
  32126. get textureFormatInUse(): Nullable<string>;
  32127. /**
  32128. * Gets the current viewport
  32129. */
  32130. get currentViewport(): Nullable<IViewportLike>;
  32131. /**
  32132. * Gets the default empty texture
  32133. */
  32134. get emptyTexture(): InternalTexture;
  32135. /**
  32136. * Gets the default empty 3D texture
  32137. */
  32138. get emptyTexture3D(): InternalTexture;
  32139. /**
  32140. * Gets the default empty 2D array texture
  32141. */
  32142. get emptyTexture2DArray(): InternalTexture;
  32143. /**
  32144. * Gets the default empty cube texture
  32145. */
  32146. get emptyCubeTexture(): InternalTexture;
  32147. /**
  32148. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32149. */
  32150. readonly premultipliedAlpha: boolean;
  32151. /**
  32152. * Observable event triggered before each texture is initialized
  32153. */
  32154. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32155. /**
  32156. * Creates a new engine
  32157. * @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
  32158. * @param antialias defines enable antialiasing (default: false)
  32159. * @param options defines further options to be sent to the getContext() function
  32160. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32161. */
  32162. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32163. private _rebuildInternalTextures;
  32164. private _rebuildEffects;
  32165. /**
  32166. * Gets a boolean indicating if all created effects are ready
  32167. * @returns true if all effects are ready
  32168. */
  32169. areAllEffectsReady(): boolean;
  32170. protected _rebuildBuffers(): void;
  32171. private _initGLContext;
  32172. /**
  32173. * Gets version of the current webGL context
  32174. */
  32175. get webGLVersion(): number;
  32176. /**
  32177. * Gets a string idenfifying the name of the class
  32178. * @returns "Engine" string
  32179. */
  32180. getClassName(): string;
  32181. /**
  32182. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32183. */
  32184. get isStencilEnable(): boolean;
  32185. /** @hidden */
  32186. _prepareWorkingCanvas(): void;
  32187. /**
  32188. * Reset the texture cache to empty state
  32189. */
  32190. resetTextureCache(): void;
  32191. /**
  32192. * Gets an object containing information about the current webGL context
  32193. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32194. */
  32195. getGlInfo(): {
  32196. vendor: string;
  32197. renderer: string;
  32198. version: string;
  32199. };
  32200. /**
  32201. * Defines the hardware scaling level.
  32202. * By default the hardware scaling level is computed from the window device ratio.
  32203. * 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.
  32204. * @param level defines the level to use
  32205. */
  32206. setHardwareScalingLevel(level: number): void;
  32207. /**
  32208. * Gets the current hardware scaling level.
  32209. * By default the hardware scaling level is computed from the window device ratio.
  32210. * 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.
  32211. * @returns a number indicating the current hardware scaling level
  32212. */
  32213. getHardwareScalingLevel(): number;
  32214. /**
  32215. * Gets the list of loaded textures
  32216. * @returns an array containing all loaded textures
  32217. */
  32218. getLoadedTexturesCache(): InternalTexture[];
  32219. /**
  32220. * Gets the object containing all engine capabilities
  32221. * @returns the EngineCapabilities object
  32222. */
  32223. getCaps(): EngineCapabilities;
  32224. /**
  32225. * stop executing a render loop function and remove it from the execution array
  32226. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32227. */
  32228. stopRenderLoop(renderFunction?: () => void): void;
  32229. /** @hidden */
  32230. _renderLoop(): void;
  32231. /**
  32232. * Gets the HTML canvas attached with the current webGL context
  32233. * @returns a HTML canvas
  32234. */
  32235. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32236. /**
  32237. * Gets host window
  32238. * @returns the host window object
  32239. */
  32240. getHostWindow(): Nullable<Window>;
  32241. /**
  32242. * Gets the current render width
  32243. * @param useScreen defines if screen size must be used (or the current render target if any)
  32244. * @returns a number defining the current render width
  32245. */
  32246. getRenderWidth(useScreen?: boolean): number;
  32247. /**
  32248. * Gets the current render height
  32249. * @param useScreen defines if screen size must be used (or the current render target if any)
  32250. * @returns a number defining the current render height
  32251. */
  32252. getRenderHeight(useScreen?: boolean): number;
  32253. /**
  32254. * Can be used to override the current requestAnimationFrame requester.
  32255. * @hidden
  32256. */
  32257. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32258. /**
  32259. * Register and execute a render loop. The engine can have more than one render function
  32260. * @param renderFunction defines the function to continuously execute
  32261. */
  32262. runRenderLoop(renderFunction: () => void): void;
  32263. /**
  32264. * Clear the current render buffer or the current render target (if any is set up)
  32265. * @param color defines the color to use
  32266. * @param backBuffer defines if the back buffer must be cleared
  32267. * @param depth defines if the depth buffer must be cleared
  32268. * @param stencil defines if the stencil buffer must be cleared
  32269. */
  32270. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32271. private _viewportCached;
  32272. /** @hidden */
  32273. _viewport(x: number, y: number, width: number, height: number): void;
  32274. /**
  32275. * Set the WebGL's viewport
  32276. * @param viewport defines the viewport element to be used
  32277. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32278. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32279. */
  32280. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32281. /**
  32282. * Begin a new frame
  32283. */
  32284. beginFrame(): void;
  32285. /**
  32286. * Enf the current frame
  32287. */
  32288. endFrame(): void;
  32289. /**
  32290. * Resize the view according to the canvas' size
  32291. */
  32292. resize(): void;
  32293. /**
  32294. * Force a specific size of the canvas
  32295. * @param width defines the new canvas' width
  32296. * @param height defines the new canvas' height
  32297. */
  32298. setSize(width: number, height: number): void;
  32299. /**
  32300. * Binds the frame buffer to the specified texture.
  32301. * @param texture The texture to render to or null for the default canvas
  32302. * @param faceIndex The face of the texture to render to in case of cube texture
  32303. * @param requiredWidth The width of the target to render to
  32304. * @param requiredHeight The height of the target to render to
  32305. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32306. * @param lodLevel defines the lod level to bind to the frame buffer
  32307. * @param layer defines the 2d array index to bind to frame buffer to
  32308. */
  32309. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32310. /** @hidden */
  32311. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32312. /**
  32313. * Unbind the current render target texture from the webGL context
  32314. * @param texture defines the render target texture to unbind
  32315. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32316. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32317. */
  32318. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32319. /**
  32320. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32321. */
  32322. flushFramebuffer(): void;
  32323. /**
  32324. * Unbind the current render target and bind the default framebuffer
  32325. */
  32326. restoreDefaultFramebuffer(): void;
  32327. /** @hidden */
  32328. protected _resetVertexBufferBinding(): void;
  32329. /**
  32330. * Creates a vertex buffer
  32331. * @param data the data for the vertex buffer
  32332. * @returns the new WebGL static buffer
  32333. */
  32334. createVertexBuffer(data: DataArray): DataBuffer;
  32335. private _createVertexBuffer;
  32336. /**
  32337. * Creates a dynamic vertex buffer
  32338. * @param data the data for the dynamic vertex buffer
  32339. * @returns the new WebGL dynamic buffer
  32340. */
  32341. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32342. protected _resetIndexBufferBinding(): void;
  32343. /**
  32344. * Creates a new index buffer
  32345. * @param indices defines the content of the index buffer
  32346. * @param updatable defines if the index buffer must be updatable
  32347. * @returns a new webGL buffer
  32348. */
  32349. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32350. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32351. /**
  32352. * Bind a webGL buffer to the webGL context
  32353. * @param buffer defines the buffer to bind
  32354. */
  32355. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32356. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32357. private bindBuffer;
  32358. /**
  32359. * update the bound buffer with the given data
  32360. * @param data defines the data to update
  32361. */
  32362. updateArrayBuffer(data: Float32Array): void;
  32363. private _vertexAttribPointer;
  32364. /** @hidden */
  32365. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32366. private _bindVertexBuffersAttributes;
  32367. /**
  32368. * Records a vertex array object
  32369. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32370. * @param vertexBuffers defines the list of vertex buffers to store
  32371. * @param indexBuffer defines the index buffer to store
  32372. * @param effect defines the effect to store
  32373. * @returns the new vertex array object
  32374. */
  32375. recordVertexArrayObject(vertexBuffers: {
  32376. [key: string]: VertexBuffer;
  32377. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32378. /**
  32379. * Bind a specific vertex array object
  32380. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32381. * @param vertexArrayObject defines the vertex array object to bind
  32382. * @param indexBuffer defines the index buffer to bind
  32383. */
  32384. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32385. /**
  32386. * Bind webGl buffers directly to the webGL context
  32387. * @param vertexBuffer defines the vertex buffer to bind
  32388. * @param indexBuffer defines the index buffer to bind
  32389. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32390. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32391. * @param effect defines the effect associated with the vertex buffer
  32392. */
  32393. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32394. private _unbindVertexArrayObject;
  32395. /**
  32396. * Bind a list of vertex buffers to the webGL context
  32397. * @param vertexBuffers defines the list of vertex buffers to bind
  32398. * @param indexBuffer defines the index buffer to bind
  32399. * @param effect defines the effect associated with the vertex buffers
  32400. */
  32401. bindBuffers(vertexBuffers: {
  32402. [key: string]: Nullable<VertexBuffer>;
  32403. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32404. /**
  32405. * Unbind all instance attributes
  32406. */
  32407. unbindInstanceAttributes(): void;
  32408. /**
  32409. * Release and free the memory of a vertex array object
  32410. * @param vao defines the vertex array object to delete
  32411. */
  32412. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32413. /** @hidden */
  32414. _releaseBuffer(buffer: DataBuffer): boolean;
  32415. protected _deleteBuffer(buffer: DataBuffer): void;
  32416. /**
  32417. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32418. * @param instancesBuffer defines the webGL buffer to update and bind
  32419. * @param data defines the data to store in the buffer
  32420. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32421. */
  32422. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32423. /**
  32424. * Bind the content of a webGL buffer used with instantiation
  32425. * @param instancesBuffer defines the webGL buffer to bind
  32426. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32427. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32428. */
  32429. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32430. /**
  32431. * Disable the instance attribute corresponding to the name in parameter
  32432. * @param name defines the name of the attribute to disable
  32433. */
  32434. disableInstanceAttributeByName(name: string): void;
  32435. /**
  32436. * Disable the instance attribute corresponding to the location in parameter
  32437. * @param attributeLocation defines the attribute location of the attribute to disable
  32438. */
  32439. disableInstanceAttribute(attributeLocation: number): void;
  32440. /**
  32441. * Disable the attribute corresponding to the location in parameter
  32442. * @param attributeLocation defines the attribute location of the attribute to disable
  32443. */
  32444. disableAttributeByIndex(attributeLocation: number): void;
  32445. /**
  32446. * Send a draw order
  32447. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32448. * @param indexStart defines the starting index
  32449. * @param indexCount defines the number of index to draw
  32450. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32451. */
  32452. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32453. /**
  32454. * Draw a list of points
  32455. * @param verticesStart defines the index of first vertex to draw
  32456. * @param verticesCount defines the count of vertices to draw
  32457. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32458. */
  32459. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32460. /**
  32461. * Draw a list of unindexed primitives
  32462. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32463. * @param verticesStart defines the index of first vertex to draw
  32464. * @param verticesCount defines the count of vertices to draw
  32465. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32466. */
  32467. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32468. /**
  32469. * Draw a list of indexed primitives
  32470. * @param fillMode defines the primitive to use
  32471. * @param indexStart defines the starting index
  32472. * @param indexCount defines the number of index to draw
  32473. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32474. */
  32475. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32476. /**
  32477. * Draw a list of unindexed primitives
  32478. * @param fillMode defines the primitive to use
  32479. * @param verticesStart defines the index of first vertex to draw
  32480. * @param verticesCount defines the count of vertices to draw
  32481. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32482. */
  32483. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32484. private _drawMode;
  32485. /** @hidden */
  32486. protected _reportDrawCall(): void;
  32487. /** @hidden */
  32488. _releaseEffect(effect: Effect): void;
  32489. /** @hidden */
  32490. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32491. /**
  32492. * Create a new effect (used to store vertex/fragment shaders)
  32493. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32494. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32495. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32496. * @param samplers defines an array of string used to represent textures
  32497. * @param defines defines the string containing the defines to use to compile the shaders
  32498. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32499. * @param onCompiled defines a function to call when the effect creation is successful
  32500. * @param onError defines a function to call when the effect creation has failed
  32501. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32502. * @returns the new Effect
  32503. */
  32504. 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;
  32505. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32506. private _compileShader;
  32507. private _compileRawShader;
  32508. /**
  32509. * Directly creates a webGL program
  32510. * @param pipelineContext defines the pipeline context to attach to
  32511. * @param vertexCode defines the vertex shader code to use
  32512. * @param fragmentCode defines the fragment shader code to use
  32513. * @param context defines the webGL context to use (if not set, the current one will be used)
  32514. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32515. * @returns the new webGL program
  32516. */
  32517. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32518. /**
  32519. * Creates a webGL program
  32520. * @param pipelineContext defines the pipeline context to attach to
  32521. * @param vertexCode defines the vertex shader code to use
  32522. * @param fragmentCode defines the fragment shader code to use
  32523. * @param defines defines the string containing the defines to use to compile the shaders
  32524. * @param context defines the webGL context to use (if not set, the current one will be used)
  32525. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32526. * @returns the new webGL program
  32527. */
  32528. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32529. /**
  32530. * Creates a new pipeline context
  32531. * @returns the new pipeline
  32532. */
  32533. createPipelineContext(): IPipelineContext;
  32534. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32535. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32536. /** @hidden */
  32537. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32538. /** @hidden */
  32539. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32540. /** @hidden */
  32541. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32542. /**
  32543. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32544. * @param pipelineContext defines the pipeline context to use
  32545. * @param uniformsNames defines the list of uniform names
  32546. * @returns an array of webGL uniform locations
  32547. */
  32548. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32549. /**
  32550. * Gets the lsit of active attributes for a given webGL program
  32551. * @param pipelineContext defines the pipeline context to use
  32552. * @param attributesNames defines the list of attribute names to get
  32553. * @returns an array of indices indicating the offset of each attribute
  32554. */
  32555. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32556. /**
  32557. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32558. * @param effect defines the effect to activate
  32559. */
  32560. enableEffect(effect: Nullable<Effect>): void;
  32561. /**
  32562. * Set the value of an uniform to a number (int)
  32563. * @param uniform defines the webGL uniform location where to store the value
  32564. * @param value defines the int number to store
  32565. */
  32566. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32567. /**
  32568. * Set the value of an uniform to an array of int32
  32569. * @param uniform defines the webGL uniform location where to store the value
  32570. * @param array defines the array of int32 to store
  32571. */
  32572. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32573. /**
  32574. * Set the value of an uniform to an array of int32 (stored as vec2)
  32575. * @param uniform defines the webGL uniform location where to store the value
  32576. * @param array defines the array of int32 to store
  32577. */
  32578. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32579. /**
  32580. * Set the value of an uniform to an array of int32 (stored as vec3)
  32581. * @param uniform defines the webGL uniform location where to store the value
  32582. * @param array defines the array of int32 to store
  32583. */
  32584. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32585. /**
  32586. * Set the value of an uniform to an array of int32 (stored as vec4)
  32587. * @param uniform defines the webGL uniform location where to store the value
  32588. * @param array defines the array of int32 to store
  32589. */
  32590. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32591. /**
  32592. * Set the value of an uniform to an array of number
  32593. * @param uniform defines the webGL uniform location where to store the value
  32594. * @param array defines the array of number to store
  32595. */
  32596. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32597. /**
  32598. * Set the value of an uniform to an array of number (stored as vec2)
  32599. * @param uniform defines the webGL uniform location where to store the value
  32600. * @param array defines the array of number to store
  32601. */
  32602. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32603. /**
  32604. * Set the value of an uniform to an array of number (stored as vec3)
  32605. * @param uniform defines the webGL uniform location where to store the value
  32606. * @param array defines the array of number to store
  32607. */
  32608. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32609. /**
  32610. * Set the value of an uniform to an array of number (stored as vec4)
  32611. * @param uniform defines the webGL uniform location where to store the value
  32612. * @param array defines the array of number to store
  32613. */
  32614. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32615. /**
  32616. * Set the value of an uniform to an array of float32 (stored as matrices)
  32617. * @param uniform defines the webGL uniform location where to store the value
  32618. * @param matrices defines the array of float32 to store
  32619. */
  32620. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32621. /**
  32622. * Set the value of an uniform to a matrix (3x3)
  32623. * @param uniform defines the webGL uniform location where to store the value
  32624. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32625. */
  32626. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32627. /**
  32628. * Set the value of an uniform to a matrix (2x2)
  32629. * @param uniform defines the webGL uniform location where to store the value
  32630. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32631. */
  32632. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32633. /**
  32634. * Set the value of an uniform to a number (float)
  32635. * @param uniform defines the webGL uniform location where to store the value
  32636. * @param value defines the float number to store
  32637. */
  32638. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32639. /**
  32640. * Set the value of an uniform to a vec2
  32641. * @param uniform defines the webGL uniform location where to store the value
  32642. * @param x defines the 1st component of the value
  32643. * @param y defines the 2nd component of the value
  32644. */
  32645. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32646. /**
  32647. * Set the value of an uniform to a vec3
  32648. * @param uniform defines the webGL uniform location where to store the value
  32649. * @param x defines the 1st component of the value
  32650. * @param y defines the 2nd component of the value
  32651. * @param z defines the 3rd component of the value
  32652. */
  32653. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32654. /**
  32655. * Set the value of an uniform to a vec4
  32656. * @param uniform defines the webGL uniform location where to store the value
  32657. * @param x defines the 1st component of the value
  32658. * @param y defines the 2nd component of the value
  32659. * @param z defines the 3rd component of the value
  32660. * @param w defines the 4th component of the value
  32661. */
  32662. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32663. /**
  32664. * Apply all cached states (depth, culling, stencil and alpha)
  32665. */
  32666. applyStates(): void;
  32667. /**
  32668. * Enable or disable color writing
  32669. * @param enable defines the state to set
  32670. */
  32671. setColorWrite(enable: boolean): void;
  32672. /**
  32673. * Gets a boolean indicating if color writing is enabled
  32674. * @returns the current color writing state
  32675. */
  32676. getColorWrite(): boolean;
  32677. /**
  32678. * Gets the depth culling state manager
  32679. */
  32680. get depthCullingState(): DepthCullingState;
  32681. /**
  32682. * Gets the alpha state manager
  32683. */
  32684. get alphaState(): AlphaState;
  32685. /**
  32686. * Gets the stencil state manager
  32687. */
  32688. get stencilState(): StencilState;
  32689. /**
  32690. * Clears the list of texture accessible through engine.
  32691. * This can help preventing texture load conflict due to name collision.
  32692. */
  32693. clearInternalTexturesCache(): void;
  32694. /**
  32695. * Force the entire cache to be cleared
  32696. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32697. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32698. */
  32699. wipeCaches(bruteForce?: boolean): void;
  32700. /** @hidden */
  32701. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32702. min: number;
  32703. mag: number;
  32704. };
  32705. /** @hidden */
  32706. _createTexture(): WebGLTexture;
  32707. /**
  32708. * Usually called from Texture.ts.
  32709. * Passed information to create a WebGLTexture
  32710. * @param urlArg defines a value which contains one of the following:
  32711. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32712. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32713. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32714. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32715. * @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)
  32716. * @param scene needed for loading to the correct scene
  32717. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32718. * @param onLoad optional callback to be called upon successful completion
  32719. * @param onError optional callback to be called upon failure
  32720. * @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
  32721. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32722. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32723. * @param forcedExtension defines the extension to use to pick the right loader
  32724. * @param mimeType defines an optional mime type
  32725. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32726. */
  32727. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  32728. /**
  32729. * Loads an image as an HTMLImageElement.
  32730. * @param input url string, ArrayBuffer, or Blob to load
  32731. * @param onLoad callback called when the image successfully loads
  32732. * @param onError callback called when the image fails to load
  32733. * @param offlineProvider offline provider for caching
  32734. * @param mimeType optional mime type
  32735. * @returns the HTMLImageElement of the loaded image
  32736. * @hidden
  32737. */
  32738. 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>;
  32739. /**
  32740. * @hidden
  32741. */
  32742. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32743. /**
  32744. * Creates a raw texture
  32745. * @param data defines the data to store in the texture
  32746. * @param width defines the width of the texture
  32747. * @param height defines the height of the texture
  32748. * @param format defines the format of the data
  32749. * @param generateMipMaps defines if the engine should generate the mip levels
  32750. * @param invertY defines if data must be stored with Y axis inverted
  32751. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32752. * @param compression defines the compression used (null by default)
  32753. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32754. * @returns the raw texture inside an InternalTexture
  32755. */
  32756. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32757. /**
  32758. * Creates a new raw cube texture
  32759. * @param data defines the array of data to use to create each face
  32760. * @param size defines the size of the textures
  32761. * @param format defines the format of the data
  32762. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32763. * @param generateMipMaps defines if the engine should generate the mip levels
  32764. * @param invertY defines if data must be stored with Y axis inverted
  32765. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32766. * @param compression defines the compression used (null by default)
  32767. * @returns the cube texture as an InternalTexture
  32768. */
  32769. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32770. /**
  32771. * Creates a new raw 3D texture
  32772. * @param data defines the data used to create the texture
  32773. * @param width defines the width of the texture
  32774. * @param height defines the height of the texture
  32775. * @param depth defines the depth of the texture
  32776. * @param format defines the format of the texture
  32777. * @param generateMipMaps defines if the engine must generate mip levels
  32778. * @param invertY defines if data must be stored with Y axis inverted
  32779. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32780. * @param compression defines the compressed used (can be null)
  32781. * @param textureType defines the compressed used (can be null)
  32782. * @returns a new raw 3D texture (stored in an InternalTexture)
  32783. */
  32784. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32785. /**
  32786. * Creates a new raw 2D array texture
  32787. * @param data defines the data used to create the texture
  32788. * @param width defines the width of the texture
  32789. * @param height defines the height of the texture
  32790. * @param depth defines the number of layers of the texture
  32791. * @param format defines the format of the texture
  32792. * @param generateMipMaps defines if the engine must generate mip levels
  32793. * @param invertY defines if data must be stored with Y axis inverted
  32794. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32795. * @param compression defines the compressed used (can be null)
  32796. * @param textureType defines the compressed used (can be null)
  32797. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32798. */
  32799. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32800. private _unpackFlipYCached;
  32801. /**
  32802. * In case you are sharing the context with other applications, it might
  32803. * be interested to not cache the unpack flip y state to ensure a consistent
  32804. * value would be set.
  32805. */
  32806. enableUnpackFlipYCached: boolean;
  32807. /** @hidden */
  32808. _unpackFlipY(value: boolean): void;
  32809. /** @hidden */
  32810. _getUnpackAlignement(): number;
  32811. private _getTextureTarget;
  32812. /**
  32813. * Update the sampling mode of a given texture
  32814. * @param samplingMode defines the required sampling mode
  32815. * @param texture defines the texture to update
  32816. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32817. */
  32818. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32819. /**
  32820. * Update the sampling mode of a given texture
  32821. * @param texture defines the texture to update
  32822. * @param wrapU defines the texture wrap mode of the u coordinates
  32823. * @param wrapV defines the texture wrap mode of the v coordinates
  32824. * @param wrapR defines the texture wrap mode of the r coordinates
  32825. */
  32826. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32827. /** @hidden */
  32828. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32829. width: number;
  32830. height: number;
  32831. layers?: number;
  32832. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32833. /** @hidden */
  32834. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32835. /** @hidden */
  32836. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32837. /**
  32838. * Update a portion of an internal texture
  32839. * @param texture defines the texture to update
  32840. * @param imageData defines the data to store into the texture
  32841. * @param xOffset defines the x coordinates of the update rectangle
  32842. * @param yOffset defines the y coordinates of the update rectangle
  32843. * @param width defines the width of the update rectangle
  32844. * @param height defines the height of the update rectangle
  32845. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32846. * @param lod defines the lod level to update (0 by default)
  32847. */
  32848. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32849. /** @hidden */
  32850. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32851. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32852. private _prepareWebGLTexture;
  32853. /** @hidden */
  32854. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32855. private _getDepthStencilBuffer;
  32856. /** @hidden */
  32857. _releaseFramebufferObjects(texture: InternalTexture): void;
  32858. /** @hidden */
  32859. _releaseTexture(texture: InternalTexture): void;
  32860. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32861. protected _setProgram(program: WebGLProgram): void;
  32862. protected _boundUniforms: {
  32863. [key: number]: WebGLUniformLocation;
  32864. };
  32865. /**
  32866. * Binds an effect to the webGL context
  32867. * @param effect defines the effect to bind
  32868. */
  32869. bindSamplers(effect: Effect): void;
  32870. private _activateCurrentTexture;
  32871. /** @hidden */
  32872. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32873. /** @hidden */
  32874. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32875. /**
  32876. * Unbind all textures from the webGL context
  32877. */
  32878. unbindAllTextures(): void;
  32879. /**
  32880. * Sets a texture to the according uniform.
  32881. * @param channel The texture channel
  32882. * @param uniform The uniform to set
  32883. * @param texture The texture to apply
  32884. */
  32885. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32886. private _bindSamplerUniformToChannel;
  32887. private _getTextureWrapMode;
  32888. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32889. /**
  32890. * Sets an array of texture to the webGL context
  32891. * @param channel defines the channel where the texture array must be set
  32892. * @param uniform defines the associated uniform location
  32893. * @param textures defines the array of textures to bind
  32894. */
  32895. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32896. /** @hidden */
  32897. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32898. private _setTextureParameterFloat;
  32899. private _setTextureParameterInteger;
  32900. /**
  32901. * Unbind all vertex attributes from the webGL context
  32902. */
  32903. unbindAllAttributes(): void;
  32904. /**
  32905. * 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
  32906. */
  32907. releaseEffects(): void;
  32908. /**
  32909. * Dispose and release all associated resources
  32910. */
  32911. dispose(): void;
  32912. /**
  32913. * Attach a new callback raised when context lost event is fired
  32914. * @param callback defines the callback to call
  32915. */
  32916. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32917. /**
  32918. * Attach a new callback raised when context restored event is fired
  32919. * @param callback defines the callback to call
  32920. */
  32921. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32922. /**
  32923. * Get the current error code of the webGL context
  32924. * @returns the error code
  32925. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32926. */
  32927. getError(): number;
  32928. private _canRenderToFloatFramebuffer;
  32929. private _canRenderToHalfFloatFramebuffer;
  32930. private _canRenderToFramebuffer;
  32931. /** @hidden */
  32932. _getWebGLTextureType(type: number): number;
  32933. /** @hidden */
  32934. _getInternalFormat(format: number): number;
  32935. /** @hidden */
  32936. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32937. /** @hidden */
  32938. _getRGBAMultiSampleBufferFormat(type: number): number;
  32939. /** @hidden */
  32940. _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;
  32941. /**
  32942. * Loads a file from a url
  32943. * @param url url to load
  32944. * @param onSuccess callback called when the file successfully loads
  32945. * @param onProgress callback called while file is loading (if the server supports this mode)
  32946. * @param offlineProvider defines the offline provider for caching
  32947. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32948. * @param onError callback called when the file fails to load
  32949. * @returns a file request object
  32950. * @hidden
  32951. */
  32952. 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;
  32953. /**
  32954. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32955. * @param x defines the x coordinate of the rectangle where pixels must be read
  32956. * @param y defines the y coordinate of the rectangle where pixels must be read
  32957. * @param width defines the width of the rectangle where pixels must be read
  32958. * @param height defines the height of the rectangle where pixels must be read
  32959. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32960. * @returns a Uint8Array containing RGBA colors
  32961. */
  32962. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32963. private static _isSupported;
  32964. /**
  32965. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32966. * @returns true if the engine can be created
  32967. * @ignorenaming
  32968. */
  32969. static isSupported(): boolean;
  32970. /**
  32971. * Find the next highest power of two.
  32972. * @param x Number to start search from.
  32973. * @return Next highest power of two.
  32974. */
  32975. static CeilingPOT(x: number): number;
  32976. /**
  32977. * Find the next lowest power of two.
  32978. * @param x Number to start search from.
  32979. * @return Next lowest power of two.
  32980. */
  32981. static FloorPOT(x: number): number;
  32982. /**
  32983. * Find the nearest power of two.
  32984. * @param x Number to start search from.
  32985. * @return Next nearest power of two.
  32986. */
  32987. static NearestPOT(x: number): number;
  32988. /**
  32989. * Get the closest exponent of two
  32990. * @param value defines the value to approximate
  32991. * @param max defines the maximum value to return
  32992. * @param mode defines how to define the closest value
  32993. * @returns closest exponent of two of the given value
  32994. */
  32995. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32996. /**
  32997. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32998. * @param func - the function to be called
  32999. * @param requester - the object that will request the next frame. Falls back to window.
  33000. * @returns frame number
  33001. */
  33002. static QueueNewFrame(func: () => void, requester?: any): number;
  33003. /**
  33004. * Gets host document
  33005. * @returns the host document object
  33006. */
  33007. getHostDocument(): Nullable<Document>;
  33008. }
  33009. }
  33010. declare module "babylonjs/Maths/sphericalPolynomial" {
  33011. import { Vector3 } from "babylonjs/Maths/math.vector";
  33012. import { Color3 } from "babylonjs/Maths/math.color";
  33013. /**
  33014. * Class representing spherical harmonics coefficients to the 3rd degree
  33015. */
  33016. export class SphericalHarmonics {
  33017. /**
  33018. * Defines whether or not the harmonics have been prescaled for rendering.
  33019. */
  33020. preScaled: boolean;
  33021. /**
  33022. * The l0,0 coefficients of the spherical harmonics
  33023. */
  33024. l00: Vector3;
  33025. /**
  33026. * The l1,-1 coefficients of the spherical harmonics
  33027. */
  33028. l1_1: Vector3;
  33029. /**
  33030. * The l1,0 coefficients of the spherical harmonics
  33031. */
  33032. l10: Vector3;
  33033. /**
  33034. * The l1,1 coefficients of the spherical harmonics
  33035. */
  33036. l11: Vector3;
  33037. /**
  33038. * The l2,-2 coefficients of the spherical harmonics
  33039. */
  33040. l2_2: Vector3;
  33041. /**
  33042. * The l2,-1 coefficients of the spherical harmonics
  33043. */
  33044. l2_1: Vector3;
  33045. /**
  33046. * The l2,0 coefficients of the spherical harmonics
  33047. */
  33048. l20: Vector3;
  33049. /**
  33050. * The l2,1 coefficients of the spherical harmonics
  33051. */
  33052. l21: Vector3;
  33053. /**
  33054. * The l2,2 coefficients of the spherical harmonics
  33055. */
  33056. l22: Vector3;
  33057. /**
  33058. * Adds a light to the spherical harmonics
  33059. * @param direction the direction of the light
  33060. * @param color the color of the light
  33061. * @param deltaSolidAngle the delta solid angle of the light
  33062. */
  33063. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33064. /**
  33065. * Scales the spherical harmonics by the given amount
  33066. * @param scale the amount to scale
  33067. */
  33068. scaleInPlace(scale: number): void;
  33069. /**
  33070. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33071. *
  33072. * ```
  33073. * E_lm = A_l * L_lm
  33074. * ```
  33075. *
  33076. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33077. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33078. * the scaling factors are given in equation 9.
  33079. */
  33080. convertIncidentRadianceToIrradiance(): void;
  33081. /**
  33082. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33083. *
  33084. * ```
  33085. * L = (1/pi) * E * rho
  33086. * ```
  33087. *
  33088. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33089. */
  33090. convertIrradianceToLambertianRadiance(): void;
  33091. /**
  33092. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33093. * required operations at run time.
  33094. *
  33095. * This is simply done by scaling back the SH with Ylm constants parameter.
  33096. * The trigonometric part being applied by the shader at run time.
  33097. */
  33098. preScaleForRendering(): void;
  33099. /**
  33100. * Constructs a spherical harmonics from an array.
  33101. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33102. * @returns the spherical harmonics
  33103. */
  33104. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33105. /**
  33106. * Gets the spherical harmonics from polynomial
  33107. * @param polynomial the spherical polynomial
  33108. * @returns the spherical harmonics
  33109. */
  33110. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33111. }
  33112. /**
  33113. * Class representing spherical polynomial coefficients to the 3rd degree
  33114. */
  33115. export class SphericalPolynomial {
  33116. private _harmonics;
  33117. /**
  33118. * The spherical harmonics used to create the polynomials.
  33119. */
  33120. get preScaledHarmonics(): SphericalHarmonics;
  33121. /**
  33122. * The x coefficients of the spherical polynomial
  33123. */
  33124. x: Vector3;
  33125. /**
  33126. * The y coefficients of the spherical polynomial
  33127. */
  33128. y: Vector3;
  33129. /**
  33130. * The z coefficients of the spherical polynomial
  33131. */
  33132. z: Vector3;
  33133. /**
  33134. * The xx coefficients of the spherical polynomial
  33135. */
  33136. xx: Vector3;
  33137. /**
  33138. * The yy coefficients of the spherical polynomial
  33139. */
  33140. yy: Vector3;
  33141. /**
  33142. * The zz coefficients of the spherical polynomial
  33143. */
  33144. zz: Vector3;
  33145. /**
  33146. * The xy coefficients of the spherical polynomial
  33147. */
  33148. xy: Vector3;
  33149. /**
  33150. * The yz coefficients of the spherical polynomial
  33151. */
  33152. yz: Vector3;
  33153. /**
  33154. * The zx coefficients of the spherical polynomial
  33155. */
  33156. zx: Vector3;
  33157. /**
  33158. * Adds an ambient color to the spherical polynomial
  33159. * @param color the color to add
  33160. */
  33161. addAmbient(color: Color3): void;
  33162. /**
  33163. * Scales the spherical polynomial by the given amount
  33164. * @param scale the amount to scale
  33165. */
  33166. scaleInPlace(scale: number): void;
  33167. /**
  33168. * Gets the spherical polynomial from harmonics
  33169. * @param harmonics the spherical harmonics
  33170. * @returns the spherical polynomial
  33171. */
  33172. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33173. /**
  33174. * Constructs a spherical polynomial from an array.
  33175. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33176. * @returns the spherical polynomial
  33177. */
  33178. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33179. }
  33180. }
  33181. declare module "babylonjs/Materials/Textures/internalTexture" {
  33182. import { Observable } from "babylonjs/Misc/observable";
  33183. import { Nullable, int } from "babylonjs/types";
  33184. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33185. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33186. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33187. /**
  33188. * Defines the source of the internal texture
  33189. */
  33190. export enum InternalTextureSource {
  33191. /**
  33192. * The source of the texture data is unknown
  33193. */
  33194. Unknown = 0,
  33195. /**
  33196. * Texture data comes from an URL
  33197. */
  33198. Url = 1,
  33199. /**
  33200. * Texture data is only used for temporary storage
  33201. */
  33202. Temp = 2,
  33203. /**
  33204. * Texture data comes from raw data (ArrayBuffer)
  33205. */
  33206. Raw = 3,
  33207. /**
  33208. * Texture content is dynamic (video or dynamic texture)
  33209. */
  33210. Dynamic = 4,
  33211. /**
  33212. * Texture content is generated by rendering to it
  33213. */
  33214. RenderTarget = 5,
  33215. /**
  33216. * Texture content is part of a multi render target process
  33217. */
  33218. MultiRenderTarget = 6,
  33219. /**
  33220. * Texture data comes from a cube data file
  33221. */
  33222. Cube = 7,
  33223. /**
  33224. * Texture data comes from a raw cube data
  33225. */
  33226. CubeRaw = 8,
  33227. /**
  33228. * Texture data come from a prefiltered cube data file
  33229. */
  33230. CubePrefiltered = 9,
  33231. /**
  33232. * Texture content is raw 3D data
  33233. */
  33234. Raw3D = 10,
  33235. /**
  33236. * Texture content is raw 2D array data
  33237. */
  33238. Raw2DArray = 11,
  33239. /**
  33240. * Texture content is a depth texture
  33241. */
  33242. Depth = 12,
  33243. /**
  33244. * Texture data comes from a raw cube data encoded with RGBD
  33245. */
  33246. CubeRawRGBD = 13
  33247. }
  33248. /**
  33249. * Class used to store data associated with WebGL texture data for the engine
  33250. * This class should not be used directly
  33251. */
  33252. export class InternalTexture {
  33253. /** @hidden */
  33254. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33255. /**
  33256. * Defines if the texture is ready
  33257. */
  33258. isReady: boolean;
  33259. /**
  33260. * Defines if the texture is a cube texture
  33261. */
  33262. isCube: boolean;
  33263. /**
  33264. * Defines if the texture contains 3D data
  33265. */
  33266. is3D: boolean;
  33267. /**
  33268. * Defines if the texture contains 2D array data
  33269. */
  33270. is2DArray: boolean;
  33271. /**
  33272. * Defines if the texture contains multiview data
  33273. */
  33274. isMultiview: boolean;
  33275. /**
  33276. * Gets the URL used to load this texture
  33277. */
  33278. url: string;
  33279. /**
  33280. * Gets the sampling mode of the texture
  33281. */
  33282. samplingMode: number;
  33283. /**
  33284. * Gets a boolean indicating if the texture needs mipmaps generation
  33285. */
  33286. generateMipMaps: boolean;
  33287. /**
  33288. * Gets the number of samples used by the texture (WebGL2+ only)
  33289. */
  33290. samples: number;
  33291. /**
  33292. * Gets the type of the texture (int, float...)
  33293. */
  33294. type: number;
  33295. /**
  33296. * Gets the format of the texture (RGB, RGBA...)
  33297. */
  33298. format: number;
  33299. /**
  33300. * Observable called when the texture is loaded
  33301. */
  33302. onLoadedObservable: Observable<InternalTexture>;
  33303. /**
  33304. * Gets the width of the texture
  33305. */
  33306. width: number;
  33307. /**
  33308. * Gets the height of the texture
  33309. */
  33310. height: number;
  33311. /**
  33312. * Gets the depth of the texture
  33313. */
  33314. depth: number;
  33315. /**
  33316. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33317. */
  33318. baseWidth: number;
  33319. /**
  33320. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33321. */
  33322. baseHeight: number;
  33323. /**
  33324. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33325. */
  33326. baseDepth: number;
  33327. /**
  33328. * Gets a boolean indicating if the texture is inverted on Y axis
  33329. */
  33330. invertY: boolean;
  33331. /** @hidden */
  33332. _invertVScale: boolean;
  33333. /** @hidden */
  33334. _associatedChannel: number;
  33335. /** @hidden */
  33336. _source: InternalTextureSource;
  33337. /** @hidden */
  33338. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33339. /** @hidden */
  33340. _bufferView: Nullable<ArrayBufferView>;
  33341. /** @hidden */
  33342. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33343. /** @hidden */
  33344. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33345. /** @hidden */
  33346. _size: number;
  33347. /** @hidden */
  33348. _extension: string;
  33349. /** @hidden */
  33350. _files: Nullable<string[]>;
  33351. /** @hidden */
  33352. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33353. /** @hidden */
  33354. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33355. /** @hidden */
  33356. _framebuffer: Nullable<WebGLFramebuffer>;
  33357. /** @hidden */
  33358. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33359. /** @hidden */
  33360. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33361. /** @hidden */
  33362. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33363. /** @hidden */
  33364. _attachments: Nullable<number[]>;
  33365. /** @hidden */
  33366. _cachedCoordinatesMode: Nullable<number>;
  33367. /** @hidden */
  33368. _cachedWrapU: Nullable<number>;
  33369. /** @hidden */
  33370. _cachedWrapV: Nullable<number>;
  33371. /** @hidden */
  33372. _cachedWrapR: Nullable<number>;
  33373. /** @hidden */
  33374. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33375. /** @hidden */
  33376. _isDisabled: boolean;
  33377. /** @hidden */
  33378. _compression: Nullable<string>;
  33379. /** @hidden */
  33380. _generateStencilBuffer: boolean;
  33381. /** @hidden */
  33382. _generateDepthBuffer: boolean;
  33383. /** @hidden */
  33384. _comparisonFunction: number;
  33385. /** @hidden */
  33386. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33387. /** @hidden */
  33388. _lodGenerationScale: number;
  33389. /** @hidden */
  33390. _lodGenerationOffset: number;
  33391. /** @hidden */
  33392. _depthStencilTexture: Nullable<InternalTexture>;
  33393. /** @hidden */
  33394. _colorTextureArray: Nullable<WebGLTexture>;
  33395. /** @hidden */
  33396. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33397. /** @hidden */
  33398. _lodTextureHigh: Nullable<BaseTexture>;
  33399. /** @hidden */
  33400. _lodTextureMid: Nullable<BaseTexture>;
  33401. /** @hidden */
  33402. _lodTextureLow: Nullable<BaseTexture>;
  33403. /** @hidden */
  33404. _isRGBD: boolean;
  33405. /** @hidden */
  33406. _linearSpecularLOD: boolean;
  33407. /** @hidden */
  33408. _irradianceTexture: Nullable<BaseTexture>;
  33409. /** @hidden */
  33410. _webGLTexture: Nullable<WebGLTexture>;
  33411. /** @hidden */
  33412. _references: number;
  33413. private _engine;
  33414. /**
  33415. * Gets the Engine the texture belongs to.
  33416. * @returns The babylon engine
  33417. */
  33418. getEngine(): ThinEngine;
  33419. /**
  33420. * Gets the data source type of the texture
  33421. */
  33422. get source(): InternalTextureSource;
  33423. /**
  33424. * Creates a new InternalTexture
  33425. * @param engine defines the engine to use
  33426. * @param source defines the type of data that will be used
  33427. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33428. */
  33429. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33430. /**
  33431. * Increments the number of references (ie. the number of Texture that point to it)
  33432. */
  33433. incrementReferences(): void;
  33434. /**
  33435. * Change the size of the texture (not the size of the content)
  33436. * @param width defines the new width
  33437. * @param height defines the new height
  33438. * @param depth defines the new depth (1 by default)
  33439. */
  33440. updateSize(width: int, height: int, depth?: int): void;
  33441. /** @hidden */
  33442. _rebuild(): void;
  33443. /** @hidden */
  33444. _swapAndDie(target: InternalTexture): void;
  33445. /**
  33446. * Dispose the current allocated resources
  33447. */
  33448. dispose(): void;
  33449. }
  33450. }
  33451. declare module "babylonjs/Audio/analyser" {
  33452. import { Scene } from "babylonjs/scene";
  33453. /**
  33454. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33456. */
  33457. export class Analyser {
  33458. /**
  33459. * Gets or sets the smoothing
  33460. * @ignorenaming
  33461. */
  33462. SMOOTHING: number;
  33463. /**
  33464. * Gets or sets the FFT table size
  33465. * @ignorenaming
  33466. */
  33467. FFT_SIZE: number;
  33468. /**
  33469. * Gets or sets the bar graph amplitude
  33470. * @ignorenaming
  33471. */
  33472. BARGRAPHAMPLITUDE: number;
  33473. /**
  33474. * Gets or sets the position of the debug canvas
  33475. * @ignorenaming
  33476. */
  33477. DEBUGCANVASPOS: {
  33478. x: number;
  33479. y: number;
  33480. };
  33481. /**
  33482. * Gets or sets the debug canvas size
  33483. * @ignorenaming
  33484. */
  33485. DEBUGCANVASSIZE: {
  33486. width: number;
  33487. height: number;
  33488. };
  33489. private _byteFreqs;
  33490. private _byteTime;
  33491. private _floatFreqs;
  33492. private _webAudioAnalyser;
  33493. private _debugCanvas;
  33494. private _debugCanvasContext;
  33495. private _scene;
  33496. private _registerFunc;
  33497. private _audioEngine;
  33498. /**
  33499. * Creates a new analyser
  33500. * @param scene defines hosting scene
  33501. */
  33502. constructor(scene: Scene);
  33503. /**
  33504. * Get the number of data values you will have to play with for the visualization
  33505. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33506. * @returns a number
  33507. */
  33508. getFrequencyBinCount(): number;
  33509. /**
  33510. * Gets the current frequency data as a byte array
  33511. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33512. * @returns a Uint8Array
  33513. */
  33514. getByteFrequencyData(): Uint8Array;
  33515. /**
  33516. * Gets the current waveform as a byte array
  33517. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33518. * @returns a Uint8Array
  33519. */
  33520. getByteTimeDomainData(): Uint8Array;
  33521. /**
  33522. * Gets the current frequency data as a float array
  33523. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33524. * @returns a Float32Array
  33525. */
  33526. getFloatFrequencyData(): Float32Array;
  33527. /**
  33528. * Renders the debug canvas
  33529. */
  33530. drawDebugCanvas(): void;
  33531. /**
  33532. * Stops rendering the debug canvas and removes it
  33533. */
  33534. stopDebugCanvas(): void;
  33535. /**
  33536. * Connects two audio nodes
  33537. * @param inputAudioNode defines first node to connect
  33538. * @param outputAudioNode defines second node to connect
  33539. */
  33540. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33541. /**
  33542. * Releases all associated resources
  33543. */
  33544. dispose(): void;
  33545. }
  33546. }
  33547. declare module "babylonjs/Audio/audioEngine" {
  33548. import { IDisposable } from "babylonjs/scene";
  33549. import { Analyser } from "babylonjs/Audio/analyser";
  33550. import { Nullable } from "babylonjs/types";
  33551. import { Observable } from "babylonjs/Misc/observable";
  33552. /**
  33553. * This represents an audio engine and it is responsible
  33554. * to play, synchronize and analyse sounds throughout the application.
  33555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33556. */
  33557. export interface IAudioEngine extends IDisposable {
  33558. /**
  33559. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33560. */
  33561. readonly canUseWebAudio: boolean;
  33562. /**
  33563. * Gets the current AudioContext if available.
  33564. */
  33565. readonly audioContext: Nullable<AudioContext>;
  33566. /**
  33567. * The master gain node defines the global audio volume of your audio engine.
  33568. */
  33569. readonly masterGain: GainNode;
  33570. /**
  33571. * Gets whether or not mp3 are supported by your browser.
  33572. */
  33573. readonly isMP3supported: boolean;
  33574. /**
  33575. * Gets whether or not ogg are supported by your browser.
  33576. */
  33577. readonly isOGGsupported: boolean;
  33578. /**
  33579. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33580. * @ignoreNaming
  33581. */
  33582. WarnedWebAudioUnsupported: boolean;
  33583. /**
  33584. * Defines if the audio engine relies on a custom unlocked button.
  33585. * In this case, the embedded button will not be displayed.
  33586. */
  33587. useCustomUnlockedButton: boolean;
  33588. /**
  33589. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33590. */
  33591. readonly unlocked: boolean;
  33592. /**
  33593. * Event raised when audio has been unlocked on the browser.
  33594. */
  33595. onAudioUnlockedObservable: Observable<AudioEngine>;
  33596. /**
  33597. * Event raised when audio has been locked on the browser.
  33598. */
  33599. onAudioLockedObservable: Observable<AudioEngine>;
  33600. /**
  33601. * Flags the audio engine in Locked state.
  33602. * This happens due to new browser policies preventing audio to autoplay.
  33603. */
  33604. lock(): void;
  33605. /**
  33606. * Unlocks the audio engine once a user action has been done on the dom.
  33607. * This is helpful to resume play once browser policies have been satisfied.
  33608. */
  33609. unlock(): void;
  33610. }
  33611. /**
  33612. * This represents the default audio engine used in babylon.
  33613. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33614. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33615. */
  33616. export class AudioEngine implements IAudioEngine {
  33617. private _audioContext;
  33618. private _audioContextInitialized;
  33619. private _muteButton;
  33620. private _hostElement;
  33621. /**
  33622. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33623. */
  33624. canUseWebAudio: boolean;
  33625. /**
  33626. * The master gain node defines the global audio volume of your audio engine.
  33627. */
  33628. masterGain: GainNode;
  33629. /**
  33630. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33631. * @ignoreNaming
  33632. */
  33633. WarnedWebAudioUnsupported: boolean;
  33634. /**
  33635. * Gets whether or not mp3 are supported by your browser.
  33636. */
  33637. isMP3supported: boolean;
  33638. /**
  33639. * Gets whether or not ogg are supported by your browser.
  33640. */
  33641. isOGGsupported: boolean;
  33642. /**
  33643. * Gets whether audio has been unlocked on the device.
  33644. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33645. * a user interaction has happened.
  33646. */
  33647. unlocked: boolean;
  33648. /**
  33649. * Defines if the audio engine relies on a custom unlocked button.
  33650. * In this case, the embedded button will not be displayed.
  33651. */
  33652. useCustomUnlockedButton: boolean;
  33653. /**
  33654. * Event raised when audio has been unlocked on the browser.
  33655. */
  33656. onAudioUnlockedObservable: Observable<AudioEngine>;
  33657. /**
  33658. * Event raised when audio has been locked on the browser.
  33659. */
  33660. onAudioLockedObservable: Observable<AudioEngine>;
  33661. /**
  33662. * Gets the current AudioContext if available.
  33663. */
  33664. get audioContext(): Nullable<AudioContext>;
  33665. private _connectedAnalyser;
  33666. /**
  33667. * Instantiates a new audio engine.
  33668. *
  33669. * There should be only one per page as some browsers restrict the number
  33670. * of audio contexts you can create.
  33671. * @param hostElement defines the host element where to display the mute icon if necessary
  33672. */
  33673. constructor(hostElement?: Nullable<HTMLElement>);
  33674. /**
  33675. * Flags the audio engine in Locked state.
  33676. * This happens due to new browser policies preventing audio to autoplay.
  33677. */
  33678. lock(): void;
  33679. /**
  33680. * Unlocks the audio engine once a user action has been done on the dom.
  33681. * This is helpful to resume play once browser policies have been satisfied.
  33682. */
  33683. unlock(): void;
  33684. private _resumeAudioContext;
  33685. private _initializeAudioContext;
  33686. private _tryToRun;
  33687. private _triggerRunningState;
  33688. private _triggerSuspendedState;
  33689. private _displayMuteButton;
  33690. private _moveButtonToTopLeft;
  33691. private _onResize;
  33692. private _hideMuteButton;
  33693. /**
  33694. * Destroy and release the resources associated with the audio ccontext.
  33695. */
  33696. dispose(): void;
  33697. /**
  33698. * Gets the global volume sets on the master gain.
  33699. * @returns the global volume if set or -1 otherwise
  33700. */
  33701. getGlobalVolume(): number;
  33702. /**
  33703. * Sets the global volume of your experience (sets on the master gain).
  33704. * @param newVolume Defines the new global volume of the application
  33705. */
  33706. setGlobalVolume(newVolume: number): void;
  33707. /**
  33708. * Connect the audio engine to an audio analyser allowing some amazing
  33709. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33711. * @param analyser The analyser to connect to the engine
  33712. */
  33713. connectToAnalyser(analyser: Analyser): void;
  33714. }
  33715. }
  33716. declare module "babylonjs/Loading/loadingScreen" {
  33717. /**
  33718. * Interface used to present a loading screen while loading a scene
  33719. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33720. */
  33721. export interface ILoadingScreen {
  33722. /**
  33723. * Function called to display the loading screen
  33724. */
  33725. displayLoadingUI: () => void;
  33726. /**
  33727. * Function called to hide the loading screen
  33728. */
  33729. hideLoadingUI: () => void;
  33730. /**
  33731. * Gets or sets the color to use for the background
  33732. */
  33733. loadingUIBackgroundColor: string;
  33734. /**
  33735. * Gets or sets the text to display while loading
  33736. */
  33737. loadingUIText: string;
  33738. }
  33739. /**
  33740. * Class used for the default loading screen
  33741. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33742. */
  33743. export class DefaultLoadingScreen implements ILoadingScreen {
  33744. private _renderingCanvas;
  33745. private _loadingText;
  33746. private _loadingDivBackgroundColor;
  33747. private _loadingDiv;
  33748. private _loadingTextDiv;
  33749. /** Gets or sets the logo url to use for the default loading screen */
  33750. static DefaultLogoUrl: string;
  33751. /** Gets or sets the spinner url to use for the default loading screen */
  33752. static DefaultSpinnerUrl: string;
  33753. /**
  33754. * Creates a new default loading screen
  33755. * @param _renderingCanvas defines the canvas used to render the scene
  33756. * @param _loadingText defines the default text to display
  33757. * @param _loadingDivBackgroundColor defines the default background color
  33758. */
  33759. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33760. /**
  33761. * Function called to display the loading screen
  33762. */
  33763. displayLoadingUI(): void;
  33764. /**
  33765. * Function called to hide the loading screen
  33766. */
  33767. hideLoadingUI(): void;
  33768. /**
  33769. * Gets or sets the text to display while loading
  33770. */
  33771. set loadingUIText(text: string);
  33772. get loadingUIText(): string;
  33773. /**
  33774. * Gets or sets the color to use for the background
  33775. */
  33776. get loadingUIBackgroundColor(): string;
  33777. set loadingUIBackgroundColor(color: string);
  33778. private _resizeLoadingUI;
  33779. }
  33780. }
  33781. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33782. /**
  33783. * Interface for any object that can request an animation frame
  33784. */
  33785. export interface ICustomAnimationFrameRequester {
  33786. /**
  33787. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33788. */
  33789. renderFunction?: Function;
  33790. /**
  33791. * Called to request the next frame to render to
  33792. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33793. */
  33794. requestAnimationFrame: Function;
  33795. /**
  33796. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33797. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33798. */
  33799. requestID?: number;
  33800. }
  33801. }
  33802. declare module "babylonjs/Misc/performanceMonitor" {
  33803. /**
  33804. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33805. */
  33806. export class PerformanceMonitor {
  33807. private _enabled;
  33808. private _rollingFrameTime;
  33809. private _lastFrameTimeMs;
  33810. /**
  33811. * constructor
  33812. * @param frameSampleSize The number of samples required to saturate the sliding window
  33813. */
  33814. constructor(frameSampleSize?: number);
  33815. /**
  33816. * Samples current frame
  33817. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33818. */
  33819. sampleFrame(timeMs?: number): void;
  33820. /**
  33821. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33822. */
  33823. get averageFrameTime(): number;
  33824. /**
  33825. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33826. */
  33827. get averageFrameTimeVariance(): number;
  33828. /**
  33829. * Returns the frame time of the most recent frame
  33830. */
  33831. get instantaneousFrameTime(): number;
  33832. /**
  33833. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33834. */
  33835. get averageFPS(): number;
  33836. /**
  33837. * Returns the average framerate in frames per second using the most recent frame time
  33838. */
  33839. get instantaneousFPS(): number;
  33840. /**
  33841. * Returns true if enough samples have been taken to completely fill the sliding window
  33842. */
  33843. get isSaturated(): boolean;
  33844. /**
  33845. * Enables contributions to the sliding window sample set
  33846. */
  33847. enable(): void;
  33848. /**
  33849. * Disables contributions to the sliding window sample set
  33850. * Samples will not be interpolated over the disabled period
  33851. */
  33852. disable(): void;
  33853. /**
  33854. * Returns true if sampling is enabled
  33855. */
  33856. get isEnabled(): boolean;
  33857. /**
  33858. * Resets performance monitor
  33859. */
  33860. reset(): void;
  33861. }
  33862. /**
  33863. * RollingAverage
  33864. *
  33865. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33866. */
  33867. export class RollingAverage {
  33868. /**
  33869. * Current average
  33870. */
  33871. average: number;
  33872. /**
  33873. * Current variance
  33874. */
  33875. variance: number;
  33876. protected _samples: Array<number>;
  33877. protected _sampleCount: number;
  33878. protected _pos: number;
  33879. protected _m2: number;
  33880. /**
  33881. * constructor
  33882. * @param length The number of samples required to saturate the sliding window
  33883. */
  33884. constructor(length: number);
  33885. /**
  33886. * Adds a sample to the sample set
  33887. * @param v The sample value
  33888. */
  33889. add(v: number): void;
  33890. /**
  33891. * Returns previously added values or null if outside of history or outside the sliding window domain
  33892. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33893. * @return Value previously recorded with add() or null if outside of range
  33894. */
  33895. history(i: number): number;
  33896. /**
  33897. * Returns true if enough samples have been taken to completely fill the sliding window
  33898. * @return true if sample-set saturated
  33899. */
  33900. isSaturated(): boolean;
  33901. /**
  33902. * Resets the rolling average (equivalent to 0 samples taken so far)
  33903. */
  33904. reset(): void;
  33905. /**
  33906. * Wraps a value around the sample range boundaries
  33907. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33908. * @return Wrapped position in sample range
  33909. */
  33910. protected _wrapPosition(i: number): number;
  33911. }
  33912. }
  33913. declare module "babylonjs/Misc/perfCounter" {
  33914. /**
  33915. * This class is used to track a performance counter which is number based.
  33916. * The user has access to many properties which give statistics of different nature.
  33917. *
  33918. * The implementer can track two kinds of Performance Counter: time and count.
  33919. * 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.
  33920. * 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.
  33921. */
  33922. export class PerfCounter {
  33923. /**
  33924. * Gets or sets a global boolean to turn on and off all the counters
  33925. */
  33926. static Enabled: boolean;
  33927. /**
  33928. * Returns the smallest value ever
  33929. */
  33930. get min(): number;
  33931. /**
  33932. * Returns the biggest value ever
  33933. */
  33934. get max(): number;
  33935. /**
  33936. * Returns the average value since the performance counter is running
  33937. */
  33938. get average(): number;
  33939. /**
  33940. * Returns the average value of the last second the counter was monitored
  33941. */
  33942. get lastSecAverage(): number;
  33943. /**
  33944. * Returns the current value
  33945. */
  33946. get current(): number;
  33947. /**
  33948. * Gets the accumulated total
  33949. */
  33950. get total(): number;
  33951. /**
  33952. * Gets the total value count
  33953. */
  33954. get count(): number;
  33955. /**
  33956. * Creates a new counter
  33957. */
  33958. constructor();
  33959. /**
  33960. * Call this method to start monitoring a new frame.
  33961. * 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.
  33962. */
  33963. fetchNewFrame(): void;
  33964. /**
  33965. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33966. * @param newCount the count value to add to the monitored count
  33967. * @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.
  33968. */
  33969. addCount(newCount: number, fetchResult: boolean): void;
  33970. /**
  33971. * Start monitoring this performance counter
  33972. */
  33973. beginMonitoring(): void;
  33974. /**
  33975. * Compute the time lapsed since the previous beginMonitoring() call.
  33976. * @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
  33977. */
  33978. endMonitoring(newFrame?: boolean): void;
  33979. private _fetchResult;
  33980. private _startMonitoringTime;
  33981. private _min;
  33982. private _max;
  33983. private _average;
  33984. private _current;
  33985. private _totalValueCount;
  33986. private _totalAccumulated;
  33987. private _lastSecAverage;
  33988. private _lastSecAccumulated;
  33989. private _lastSecTime;
  33990. private _lastSecValueCount;
  33991. }
  33992. }
  33993. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33994. module "babylonjs/Engines/thinEngine" {
  33995. interface ThinEngine {
  33996. /**
  33997. * Sets alpha constants used by some alpha blending modes
  33998. * @param r defines the red component
  33999. * @param g defines the green component
  34000. * @param b defines the blue component
  34001. * @param a defines the alpha component
  34002. */
  34003. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34004. /**
  34005. * Sets the current alpha mode
  34006. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34007. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34008. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34009. */
  34010. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34011. /**
  34012. * Gets the current alpha mode
  34013. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34014. * @returns the current alpha mode
  34015. */
  34016. getAlphaMode(): number;
  34017. /**
  34018. * Sets the current alpha equation
  34019. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34020. */
  34021. setAlphaEquation(equation: number): void;
  34022. /**
  34023. * Gets the current alpha equation.
  34024. * @returns the current alpha equation
  34025. */
  34026. getAlphaEquation(): number;
  34027. }
  34028. }
  34029. }
  34030. declare module "babylonjs/Engines/engine" {
  34031. import { Observable } from "babylonjs/Misc/observable";
  34032. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34033. import { Scene } from "babylonjs/scene";
  34034. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34035. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34036. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34037. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34038. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34039. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34040. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34041. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34042. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34043. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34044. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34045. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34046. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34047. import "babylonjs/Engines/Extensions/engine.alpha";
  34048. import { Material } from "babylonjs/Materials/material";
  34049. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34050. /**
  34051. * Defines the interface used by display changed events
  34052. */
  34053. export interface IDisplayChangedEventArgs {
  34054. /** Gets the vrDisplay object (if any) */
  34055. vrDisplay: Nullable<any>;
  34056. /** Gets a boolean indicating if webVR is supported */
  34057. vrSupported: boolean;
  34058. }
  34059. /**
  34060. * Defines the interface used by objects containing a viewport (like a camera)
  34061. */
  34062. interface IViewportOwnerLike {
  34063. /**
  34064. * Gets or sets the viewport
  34065. */
  34066. viewport: IViewportLike;
  34067. }
  34068. /**
  34069. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34070. */
  34071. export class Engine extends ThinEngine {
  34072. /** Defines that alpha blending is disabled */
  34073. static readonly ALPHA_DISABLE: number;
  34074. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34075. static readonly ALPHA_ADD: number;
  34076. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34077. static readonly ALPHA_COMBINE: number;
  34078. /** Defines that alpha blending to DEST - SRC * DEST */
  34079. static readonly ALPHA_SUBTRACT: number;
  34080. /** Defines that alpha blending to SRC * DEST */
  34081. static readonly ALPHA_MULTIPLY: number;
  34082. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34083. static readonly ALPHA_MAXIMIZED: number;
  34084. /** Defines that alpha blending to SRC + DEST */
  34085. static readonly ALPHA_ONEONE: number;
  34086. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34087. static readonly ALPHA_PREMULTIPLIED: number;
  34088. /**
  34089. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34090. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34091. */
  34092. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34093. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34094. static readonly ALPHA_INTERPOLATE: number;
  34095. /**
  34096. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34097. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34098. */
  34099. static readonly ALPHA_SCREENMODE: number;
  34100. /** Defines that the ressource is not delayed*/
  34101. static readonly DELAYLOADSTATE_NONE: number;
  34102. /** Defines that the ressource was successfully delay loaded */
  34103. static readonly DELAYLOADSTATE_LOADED: number;
  34104. /** Defines that the ressource is currently delay loading */
  34105. static readonly DELAYLOADSTATE_LOADING: number;
  34106. /** Defines that the ressource is delayed and has not started loading */
  34107. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34108. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34109. static readonly NEVER: number;
  34110. /** 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 */
  34111. static readonly ALWAYS: number;
  34112. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34113. static readonly LESS: number;
  34114. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34115. static readonly EQUAL: number;
  34116. /** 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 */
  34117. static readonly LEQUAL: number;
  34118. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34119. static readonly GREATER: number;
  34120. /** 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 */
  34121. static readonly GEQUAL: number;
  34122. /** 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 */
  34123. static readonly NOTEQUAL: number;
  34124. /** Passed to stencilOperation to specify that stencil value must be kept */
  34125. static readonly KEEP: number;
  34126. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34127. static readonly REPLACE: number;
  34128. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34129. static readonly INCR: number;
  34130. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34131. static readonly DECR: number;
  34132. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34133. static readonly INVERT: number;
  34134. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34135. static readonly INCR_WRAP: number;
  34136. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34137. static readonly DECR_WRAP: number;
  34138. /** Texture is not repeating outside of 0..1 UVs */
  34139. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34140. /** Texture is repeating outside of 0..1 UVs */
  34141. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34142. /** Texture is repeating and mirrored */
  34143. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34144. /** ALPHA */
  34145. static readonly TEXTUREFORMAT_ALPHA: number;
  34146. /** LUMINANCE */
  34147. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34148. /** LUMINANCE_ALPHA */
  34149. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34150. /** RGB */
  34151. static readonly TEXTUREFORMAT_RGB: number;
  34152. /** RGBA */
  34153. static readonly TEXTUREFORMAT_RGBA: number;
  34154. /** RED */
  34155. static readonly TEXTUREFORMAT_RED: number;
  34156. /** RED (2nd reference) */
  34157. static readonly TEXTUREFORMAT_R: number;
  34158. /** RG */
  34159. static readonly TEXTUREFORMAT_RG: number;
  34160. /** RED_INTEGER */
  34161. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34162. /** RED_INTEGER (2nd reference) */
  34163. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34164. /** RG_INTEGER */
  34165. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34166. /** RGB_INTEGER */
  34167. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34168. /** RGBA_INTEGER */
  34169. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34170. /** UNSIGNED_BYTE */
  34171. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34172. /** UNSIGNED_BYTE (2nd reference) */
  34173. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34174. /** FLOAT */
  34175. static readonly TEXTURETYPE_FLOAT: number;
  34176. /** HALF_FLOAT */
  34177. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34178. /** BYTE */
  34179. static readonly TEXTURETYPE_BYTE: number;
  34180. /** SHORT */
  34181. static readonly TEXTURETYPE_SHORT: number;
  34182. /** UNSIGNED_SHORT */
  34183. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34184. /** INT */
  34185. static readonly TEXTURETYPE_INT: number;
  34186. /** UNSIGNED_INT */
  34187. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34188. /** UNSIGNED_SHORT_4_4_4_4 */
  34189. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34190. /** UNSIGNED_SHORT_5_5_5_1 */
  34191. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34192. /** UNSIGNED_SHORT_5_6_5 */
  34193. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34194. /** UNSIGNED_INT_2_10_10_10_REV */
  34195. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34196. /** UNSIGNED_INT_24_8 */
  34197. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34198. /** UNSIGNED_INT_10F_11F_11F_REV */
  34199. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34200. /** UNSIGNED_INT_5_9_9_9_REV */
  34201. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34202. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34203. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34204. /** nearest is mag = nearest and min = nearest and mip = linear */
  34205. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34206. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34207. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34208. /** Trilinear is mag = linear and min = linear and mip = linear */
  34209. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34210. /** nearest is mag = nearest and min = nearest and mip = linear */
  34211. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34212. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34213. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34214. /** Trilinear is mag = linear and min = linear and mip = linear */
  34215. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34216. /** mag = nearest and min = nearest and mip = nearest */
  34217. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34218. /** mag = nearest and min = linear and mip = nearest */
  34219. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34220. /** mag = nearest and min = linear and mip = linear */
  34221. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34222. /** mag = nearest and min = linear and mip = none */
  34223. static readonly TEXTURE_NEAREST_LINEAR: number;
  34224. /** mag = nearest and min = nearest and mip = none */
  34225. static readonly TEXTURE_NEAREST_NEAREST: number;
  34226. /** mag = linear and min = nearest and mip = nearest */
  34227. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34228. /** mag = linear and min = nearest and mip = linear */
  34229. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34230. /** mag = linear and min = linear and mip = none */
  34231. static readonly TEXTURE_LINEAR_LINEAR: number;
  34232. /** mag = linear and min = nearest and mip = none */
  34233. static readonly TEXTURE_LINEAR_NEAREST: number;
  34234. /** Explicit coordinates mode */
  34235. static readonly TEXTURE_EXPLICIT_MODE: number;
  34236. /** Spherical coordinates mode */
  34237. static readonly TEXTURE_SPHERICAL_MODE: number;
  34238. /** Planar coordinates mode */
  34239. static readonly TEXTURE_PLANAR_MODE: number;
  34240. /** Cubic coordinates mode */
  34241. static readonly TEXTURE_CUBIC_MODE: number;
  34242. /** Projection coordinates mode */
  34243. static readonly TEXTURE_PROJECTION_MODE: number;
  34244. /** Skybox coordinates mode */
  34245. static readonly TEXTURE_SKYBOX_MODE: number;
  34246. /** Inverse Cubic coordinates mode */
  34247. static readonly TEXTURE_INVCUBIC_MODE: number;
  34248. /** Equirectangular coordinates mode */
  34249. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34250. /** Equirectangular Fixed coordinates mode */
  34251. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34252. /** Equirectangular Fixed Mirrored coordinates mode */
  34253. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34254. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34255. static readonly SCALEMODE_FLOOR: number;
  34256. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34257. static readonly SCALEMODE_NEAREST: number;
  34258. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34259. static readonly SCALEMODE_CEILING: number;
  34260. /**
  34261. * Returns the current npm package of the sdk
  34262. */
  34263. static get NpmPackage(): string;
  34264. /**
  34265. * Returns the current version of the framework
  34266. */
  34267. static get Version(): string;
  34268. /** Gets the list of created engines */
  34269. static get Instances(): Engine[];
  34270. /**
  34271. * Gets the latest created engine
  34272. */
  34273. static get LastCreatedEngine(): Nullable<Engine>;
  34274. /**
  34275. * Gets the latest created scene
  34276. */
  34277. static get LastCreatedScene(): Nullable<Scene>;
  34278. /**
  34279. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34280. * @param flag defines which part of the materials must be marked as dirty
  34281. * @param predicate defines a predicate used to filter which materials should be affected
  34282. */
  34283. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34284. /**
  34285. * Method called to create the default loading screen.
  34286. * This can be overriden in your own app.
  34287. * @param canvas The rendering canvas element
  34288. * @returns The loading screen
  34289. */
  34290. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34291. /**
  34292. * Method called to create the default rescale post process on each engine.
  34293. */
  34294. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34295. /**
  34296. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34297. **/
  34298. enableOfflineSupport: boolean;
  34299. /**
  34300. * 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)
  34301. **/
  34302. disableManifestCheck: boolean;
  34303. /**
  34304. * Gets the list of created scenes
  34305. */
  34306. scenes: Scene[];
  34307. /**
  34308. * Event raised when a new scene is created
  34309. */
  34310. onNewSceneAddedObservable: Observable<Scene>;
  34311. /**
  34312. * Gets the list of created postprocesses
  34313. */
  34314. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34315. /**
  34316. * Gets a boolean indicating if the pointer is currently locked
  34317. */
  34318. isPointerLock: boolean;
  34319. /**
  34320. * Observable event triggered each time the rendering canvas is resized
  34321. */
  34322. onResizeObservable: Observable<Engine>;
  34323. /**
  34324. * Observable event triggered each time the canvas loses focus
  34325. */
  34326. onCanvasBlurObservable: Observable<Engine>;
  34327. /**
  34328. * Observable event triggered each time the canvas gains focus
  34329. */
  34330. onCanvasFocusObservable: Observable<Engine>;
  34331. /**
  34332. * Observable event triggered each time the canvas receives pointerout event
  34333. */
  34334. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34335. /**
  34336. * Observable raised when the engine begins a new frame
  34337. */
  34338. onBeginFrameObservable: Observable<Engine>;
  34339. /**
  34340. * If set, will be used to request the next animation frame for the render loop
  34341. */
  34342. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34343. /**
  34344. * Observable raised when the engine ends the current frame
  34345. */
  34346. onEndFrameObservable: Observable<Engine>;
  34347. /**
  34348. * Observable raised when the engine is about to compile a shader
  34349. */
  34350. onBeforeShaderCompilationObservable: Observable<Engine>;
  34351. /**
  34352. * Observable raised when the engine has jsut compiled a shader
  34353. */
  34354. onAfterShaderCompilationObservable: Observable<Engine>;
  34355. /**
  34356. * Gets the audio engine
  34357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34358. * @ignorenaming
  34359. */
  34360. static audioEngine: IAudioEngine;
  34361. /**
  34362. * Default AudioEngine factory responsible of creating the Audio Engine.
  34363. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34364. */
  34365. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34366. /**
  34367. * Default offline support factory responsible of creating a tool used to store data locally.
  34368. * By default, this will create a Database object if the workload has been embedded.
  34369. */
  34370. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34371. private _loadingScreen;
  34372. private _pointerLockRequested;
  34373. private _dummyFramebuffer;
  34374. private _rescalePostProcess;
  34375. private _deterministicLockstep;
  34376. private _lockstepMaxSteps;
  34377. private _timeStep;
  34378. protected get _supportsHardwareTextureRescaling(): boolean;
  34379. private _fps;
  34380. private _deltaTime;
  34381. /** @hidden */
  34382. _drawCalls: PerfCounter;
  34383. /** 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 */
  34384. canvasTabIndex: number;
  34385. /**
  34386. * Turn this value on if you want to pause FPS computation when in background
  34387. */
  34388. disablePerformanceMonitorInBackground: boolean;
  34389. private _performanceMonitor;
  34390. /**
  34391. * Gets the performance monitor attached to this engine
  34392. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34393. */
  34394. get performanceMonitor(): PerformanceMonitor;
  34395. private _onFocus;
  34396. private _onBlur;
  34397. private _onCanvasPointerOut;
  34398. private _onCanvasBlur;
  34399. private _onCanvasFocus;
  34400. private _onFullscreenChange;
  34401. private _onPointerLockChange;
  34402. /**
  34403. * Gets the HTML element used to attach event listeners
  34404. * @returns a HTML element
  34405. */
  34406. getInputElement(): Nullable<HTMLElement>;
  34407. /**
  34408. * Creates a new engine
  34409. * @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
  34410. * @param antialias defines enable antialiasing (default: false)
  34411. * @param options defines further options to be sent to the getContext() function
  34412. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34413. */
  34414. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34415. /**
  34416. * Gets current aspect ratio
  34417. * @param viewportOwner defines the camera to use to get the aspect ratio
  34418. * @param useScreen defines if screen size must be used (or the current render target if any)
  34419. * @returns a number defining the aspect ratio
  34420. */
  34421. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34422. /**
  34423. * Gets current screen aspect ratio
  34424. * @returns a number defining the aspect ratio
  34425. */
  34426. getScreenAspectRatio(): number;
  34427. /**
  34428. * Gets the client rect of the HTML canvas attached with the current webGL context
  34429. * @returns a client rectanglee
  34430. */
  34431. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34432. /**
  34433. * Gets the client rect of the HTML element used for events
  34434. * @returns a client rectanglee
  34435. */
  34436. getInputElementClientRect(): Nullable<ClientRect>;
  34437. /**
  34438. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34439. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34440. * @returns true if engine is in deterministic lock step mode
  34441. */
  34442. isDeterministicLockStep(): boolean;
  34443. /**
  34444. * Gets the max steps when engine is running in deterministic lock step
  34445. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34446. * @returns the max steps
  34447. */
  34448. getLockstepMaxSteps(): number;
  34449. /**
  34450. * Returns the time in ms between steps when using deterministic lock step.
  34451. * @returns time step in (ms)
  34452. */
  34453. getTimeStep(): number;
  34454. /**
  34455. * Force the mipmap generation for the given render target texture
  34456. * @param texture defines the render target texture to use
  34457. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34458. */
  34459. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34460. /** States */
  34461. /**
  34462. * Set various states to the webGL context
  34463. * @param culling defines backface culling state
  34464. * @param zOffset defines the value to apply to zOffset (0 by default)
  34465. * @param force defines if states must be applied even if cache is up to date
  34466. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34467. */
  34468. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34469. /**
  34470. * Set the z offset to apply to current rendering
  34471. * @param value defines the offset to apply
  34472. */
  34473. setZOffset(value: number): void;
  34474. /**
  34475. * Gets the current value of the zOffset
  34476. * @returns the current zOffset state
  34477. */
  34478. getZOffset(): number;
  34479. /**
  34480. * Enable or disable depth buffering
  34481. * @param enable defines the state to set
  34482. */
  34483. setDepthBuffer(enable: boolean): void;
  34484. /**
  34485. * Gets a boolean indicating if depth writing is enabled
  34486. * @returns the current depth writing state
  34487. */
  34488. getDepthWrite(): boolean;
  34489. /**
  34490. * Enable or disable depth writing
  34491. * @param enable defines the state to set
  34492. */
  34493. setDepthWrite(enable: boolean): void;
  34494. /**
  34495. * Gets a boolean indicating if stencil buffer is enabled
  34496. * @returns the current stencil buffer state
  34497. */
  34498. getStencilBuffer(): boolean;
  34499. /**
  34500. * Enable or disable the stencil buffer
  34501. * @param enable defines if the stencil buffer must be enabled or disabled
  34502. */
  34503. setStencilBuffer(enable: boolean): void;
  34504. /**
  34505. * Gets the current stencil mask
  34506. * @returns a number defining the new stencil mask to use
  34507. */
  34508. getStencilMask(): number;
  34509. /**
  34510. * Sets the current stencil mask
  34511. * @param mask defines the new stencil mask to use
  34512. */
  34513. setStencilMask(mask: number): void;
  34514. /**
  34515. * Gets the current stencil function
  34516. * @returns a number defining the stencil function to use
  34517. */
  34518. getStencilFunction(): number;
  34519. /**
  34520. * Gets the current stencil reference value
  34521. * @returns a number defining the stencil reference value to use
  34522. */
  34523. getStencilFunctionReference(): number;
  34524. /**
  34525. * Gets the current stencil mask
  34526. * @returns a number defining the stencil mask to use
  34527. */
  34528. getStencilFunctionMask(): number;
  34529. /**
  34530. * Sets the current stencil function
  34531. * @param stencilFunc defines the new stencil function to use
  34532. */
  34533. setStencilFunction(stencilFunc: number): void;
  34534. /**
  34535. * Sets the current stencil reference
  34536. * @param reference defines the new stencil reference to use
  34537. */
  34538. setStencilFunctionReference(reference: number): void;
  34539. /**
  34540. * Sets the current stencil mask
  34541. * @param mask defines the new stencil mask to use
  34542. */
  34543. setStencilFunctionMask(mask: number): void;
  34544. /**
  34545. * Gets the current stencil operation when stencil fails
  34546. * @returns a number defining stencil operation to use when stencil fails
  34547. */
  34548. getStencilOperationFail(): number;
  34549. /**
  34550. * Gets the current stencil operation when depth fails
  34551. * @returns a number defining stencil operation to use when depth fails
  34552. */
  34553. getStencilOperationDepthFail(): number;
  34554. /**
  34555. * Gets the current stencil operation when stencil passes
  34556. * @returns a number defining stencil operation to use when stencil passes
  34557. */
  34558. getStencilOperationPass(): number;
  34559. /**
  34560. * Sets the stencil operation to use when stencil fails
  34561. * @param operation defines the stencil operation to use when stencil fails
  34562. */
  34563. setStencilOperationFail(operation: number): void;
  34564. /**
  34565. * Sets the stencil operation to use when depth fails
  34566. * @param operation defines the stencil operation to use when depth fails
  34567. */
  34568. setStencilOperationDepthFail(operation: number): void;
  34569. /**
  34570. * Sets the stencil operation to use when stencil passes
  34571. * @param operation defines the stencil operation to use when stencil passes
  34572. */
  34573. setStencilOperationPass(operation: number): void;
  34574. /**
  34575. * Sets a boolean indicating if the dithering state is enabled or disabled
  34576. * @param value defines the dithering state
  34577. */
  34578. setDitheringState(value: boolean): void;
  34579. /**
  34580. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34581. * @param value defines the rasterizer state
  34582. */
  34583. setRasterizerState(value: boolean): void;
  34584. /**
  34585. * Gets the current depth function
  34586. * @returns a number defining the depth function
  34587. */
  34588. getDepthFunction(): Nullable<number>;
  34589. /**
  34590. * Sets the current depth function
  34591. * @param depthFunc defines the function to use
  34592. */
  34593. setDepthFunction(depthFunc: number): void;
  34594. /**
  34595. * Sets the current depth function to GREATER
  34596. */
  34597. setDepthFunctionToGreater(): void;
  34598. /**
  34599. * Sets the current depth function to GEQUAL
  34600. */
  34601. setDepthFunctionToGreaterOrEqual(): void;
  34602. /**
  34603. * Sets the current depth function to LESS
  34604. */
  34605. setDepthFunctionToLess(): void;
  34606. /**
  34607. * Sets the current depth function to LEQUAL
  34608. */
  34609. setDepthFunctionToLessOrEqual(): void;
  34610. private _cachedStencilBuffer;
  34611. private _cachedStencilFunction;
  34612. private _cachedStencilMask;
  34613. private _cachedStencilOperationPass;
  34614. private _cachedStencilOperationFail;
  34615. private _cachedStencilOperationDepthFail;
  34616. private _cachedStencilReference;
  34617. /**
  34618. * Caches the the state of the stencil buffer
  34619. */
  34620. cacheStencilState(): void;
  34621. /**
  34622. * Restores the state of the stencil buffer
  34623. */
  34624. restoreStencilState(): void;
  34625. /**
  34626. * Directly set the WebGL Viewport
  34627. * @param x defines the x coordinate of the viewport (in screen space)
  34628. * @param y defines the y coordinate of the viewport (in screen space)
  34629. * @param width defines the width of the viewport (in screen space)
  34630. * @param height defines the height of the viewport (in screen space)
  34631. * @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
  34632. */
  34633. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34634. /**
  34635. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34636. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34637. * @param y defines the y-coordinate of the corner of the clear rectangle
  34638. * @param width defines the width of the clear rectangle
  34639. * @param height defines the height of the clear rectangle
  34640. * @param clearColor defines the clear color
  34641. */
  34642. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34643. /**
  34644. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34645. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34646. * @param y defines the y-coordinate of the corner of the clear rectangle
  34647. * @param width defines the width of the clear rectangle
  34648. * @param height defines the height of the clear rectangle
  34649. */
  34650. enableScissor(x: number, y: number, width: number, height: number): void;
  34651. /**
  34652. * Disable previously set scissor test rectangle
  34653. */
  34654. disableScissor(): void;
  34655. protected _reportDrawCall(): void;
  34656. /**
  34657. * Initializes a webVR display and starts listening to display change events
  34658. * The onVRDisplayChangedObservable will be notified upon these changes
  34659. * @returns The onVRDisplayChangedObservable
  34660. */
  34661. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34662. /** @hidden */
  34663. _prepareVRComponent(): void;
  34664. /** @hidden */
  34665. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34666. /** @hidden */
  34667. _submitVRFrame(): void;
  34668. /**
  34669. * Call this function to leave webVR mode
  34670. * Will do nothing if webVR is not supported or if there is no webVR device
  34671. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34672. */
  34673. disableVR(): void;
  34674. /**
  34675. * Gets a boolean indicating that the system is in VR mode and is presenting
  34676. * @returns true if VR mode is engaged
  34677. */
  34678. isVRPresenting(): boolean;
  34679. /** @hidden */
  34680. _requestVRFrame(): void;
  34681. /** @hidden */
  34682. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34683. /**
  34684. * Gets the source code of the vertex shader associated with a specific webGL program
  34685. * @param program defines the program to use
  34686. * @returns a string containing the source code of the vertex shader associated with the program
  34687. */
  34688. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34689. /**
  34690. * Gets the source code of the fragment shader associated with a specific webGL program
  34691. * @param program defines the program to use
  34692. * @returns a string containing the source code of the fragment shader associated with the program
  34693. */
  34694. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34695. /**
  34696. * Sets a depth stencil texture from a render target to the according uniform.
  34697. * @param channel The texture channel
  34698. * @param uniform The uniform to set
  34699. * @param texture The render target texture containing the depth stencil texture to apply
  34700. */
  34701. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34702. /**
  34703. * Sets a texture to the webGL context from a postprocess
  34704. * @param channel defines the channel to use
  34705. * @param postProcess defines the source postprocess
  34706. */
  34707. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34708. /**
  34709. * Binds the output of the passed in post process to the texture channel specified
  34710. * @param channel The channel the texture should be bound to
  34711. * @param postProcess The post process which's output should be bound
  34712. */
  34713. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34714. /** @hidden */
  34715. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34716. protected _rebuildBuffers(): void;
  34717. /** @hidden */
  34718. _renderFrame(): void;
  34719. _renderLoop(): void;
  34720. /** @hidden */
  34721. _renderViews(): boolean;
  34722. /**
  34723. * Toggle full screen mode
  34724. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34725. */
  34726. switchFullscreen(requestPointerLock: boolean): void;
  34727. /**
  34728. * Enters full screen mode
  34729. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34730. */
  34731. enterFullscreen(requestPointerLock: boolean): void;
  34732. /**
  34733. * Exits full screen mode
  34734. */
  34735. exitFullscreen(): void;
  34736. /**
  34737. * Enters Pointerlock mode
  34738. */
  34739. enterPointerlock(): void;
  34740. /**
  34741. * Exits Pointerlock mode
  34742. */
  34743. exitPointerlock(): void;
  34744. /**
  34745. * Begin a new frame
  34746. */
  34747. beginFrame(): void;
  34748. /**
  34749. * Enf the current frame
  34750. */
  34751. endFrame(): void;
  34752. resize(): void;
  34753. /**
  34754. * Force a specific size of the canvas
  34755. * @param width defines the new canvas' width
  34756. * @param height defines the new canvas' height
  34757. */
  34758. setSize(width: number, height: number): void;
  34759. /**
  34760. * Updates a dynamic vertex buffer.
  34761. * @param vertexBuffer the vertex buffer to update
  34762. * @param data the data used to update the vertex buffer
  34763. * @param byteOffset the byte offset of the data
  34764. * @param byteLength the byte length of the data
  34765. */
  34766. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34767. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34768. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34769. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34770. _releaseTexture(texture: InternalTexture): void;
  34771. /**
  34772. * @hidden
  34773. * Rescales a texture
  34774. * @param source input texutre
  34775. * @param destination destination texture
  34776. * @param scene scene to use to render the resize
  34777. * @param internalFormat format to use when resizing
  34778. * @param onComplete callback to be called when resize has completed
  34779. */
  34780. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34781. /**
  34782. * Gets the current framerate
  34783. * @returns a number representing the framerate
  34784. */
  34785. getFps(): number;
  34786. /**
  34787. * Gets the time spent between current and previous frame
  34788. * @returns a number representing the delta time in ms
  34789. */
  34790. getDeltaTime(): number;
  34791. private _measureFps;
  34792. /** @hidden */
  34793. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34794. /**
  34795. * Update a dynamic index buffer
  34796. * @param indexBuffer defines the target index buffer
  34797. * @param indices defines the data to update
  34798. * @param offset defines the offset in the target index buffer where update should start
  34799. */
  34800. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34801. /**
  34802. * Updates the sample count of a render target texture
  34803. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34804. * @param texture defines the texture to update
  34805. * @param samples defines the sample count to set
  34806. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34807. */
  34808. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34809. /**
  34810. * Updates a depth texture Comparison Mode and Function.
  34811. * If the comparison Function is equal to 0, the mode will be set to none.
  34812. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34813. * @param texture The texture to set the comparison function for
  34814. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34815. */
  34816. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34817. /**
  34818. * Creates a webGL buffer to use with instanciation
  34819. * @param capacity defines the size of the buffer
  34820. * @returns the webGL buffer
  34821. */
  34822. createInstancesBuffer(capacity: number): DataBuffer;
  34823. /**
  34824. * Delete a webGL buffer used with instanciation
  34825. * @param buffer defines the webGL buffer to delete
  34826. */
  34827. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34828. private _clientWaitAsync;
  34829. /** @hidden */
  34830. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34831. /** @hidden */
  34832. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34833. dispose(): void;
  34834. private _disableTouchAction;
  34835. /**
  34836. * Display the loading screen
  34837. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34838. */
  34839. displayLoadingUI(): void;
  34840. /**
  34841. * Hide the loading screen
  34842. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34843. */
  34844. hideLoadingUI(): void;
  34845. /**
  34846. * Gets the current loading screen object
  34847. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34848. */
  34849. get loadingScreen(): ILoadingScreen;
  34850. /**
  34851. * Sets the current loading screen object
  34852. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34853. */
  34854. set loadingScreen(loadingScreen: ILoadingScreen);
  34855. /**
  34856. * Sets the current loading screen text
  34857. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34858. */
  34859. set loadingUIText(text: string);
  34860. /**
  34861. * Sets the current loading screen background color
  34862. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34863. */
  34864. set loadingUIBackgroundColor(color: string);
  34865. /** Pointerlock and fullscreen */
  34866. /**
  34867. * Ask the browser to promote the current element to pointerlock mode
  34868. * @param element defines the DOM element to promote
  34869. */
  34870. static _RequestPointerlock(element: HTMLElement): void;
  34871. /**
  34872. * Asks the browser to exit pointerlock mode
  34873. */
  34874. static _ExitPointerlock(): void;
  34875. /**
  34876. * Ask the browser to promote the current element to fullscreen rendering mode
  34877. * @param element defines the DOM element to promote
  34878. */
  34879. static _RequestFullscreen(element: HTMLElement): void;
  34880. /**
  34881. * Asks the browser to exit fullscreen mode
  34882. */
  34883. static _ExitFullscreen(): void;
  34884. }
  34885. }
  34886. declare module "babylonjs/Engines/engineStore" {
  34887. import { Nullable } from "babylonjs/types";
  34888. import { Engine } from "babylonjs/Engines/engine";
  34889. import { Scene } from "babylonjs/scene";
  34890. /**
  34891. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34892. * during the life time of the application.
  34893. */
  34894. export class EngineStore {
  34895. /** Gets the list of created engines */
  34896. static Instances: import("babylonjs/Engines/engine").Engine[];
  34897. /** @hidden */
  34898. static _LastCreatedScene: Nullable<Scene>;
  34899. /**
  34900. * Gets the latest created engine
  34901. */
  34902. static get LastCreatedEngine(): Nullable<Engine>;
  34903. /**
  34904. * Gets the latest created scene
  34905. */
  34906. static get LastCreatedScene(): Nullable<Scene>;
  34907. /**
  34908. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34909. * @ignorenaming
  34910. */
  34911. static UseFallbackTexture: boolean;
  34912. /**
  34913. * Texture content used if a texture cannot loaded
  34914. * @ignorenaming
  34915. */
  34916. static FallbackTexture: string;
  34917. }
  34918. }
  34919. declare module "babylonjs/Misc/promise" {
  34920. /**
  34921. * Helper class that provides a small promise polyfill
  34922. */
  34923. export class PromisePolyfill {
  34924. /**
  34925. * Static function used to check if the polyfill is required
  34926. * If this is the case then the function will inject the polyfill to window.Promise
  34927. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34928. */
  34929. static Apply(force?: boolean): void;
  34930. }
  34931. }
  34932. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34933. /**
  34934. * Interface for screenshot methods with describe argument called `size` as object with options
  34935. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34936. */
  34937. export interface IScreenshotSize {
  34938. /**
  34939. * number in pixels for canvas height
  34940. */
  34941. height?: number;
  34942. /**
  34943. * multiplier allowing render at a higher or lower resolution
  34944. * If value is defined then height and width will be ignored and taken from camera
  34945. */
  34946. precision?: number;
  34947. /**
  34948. * number in pixels for canvas width
  34949. */
  34950. width?: number;
  34951. }
  34952. }
  34953. declare module "babylonjs/Misc/tools" {
  34954. import { Nullable, float } from "babylonjs/types";
  34955. import { DomManagement } from "babylonjs/Misc/domManagement";
  34956. import { WebRequest } from "babylonjs/Misc/webRequest";
  34957. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34958. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34959. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34960. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34961. import { Camera } from "babylonjs/Cameras/camera";
  34962. import { Engine } from "babylonjs/Engines/engine";
  34963. interface IColor4Like {
  34964. r: float;
  34965. g: float;
  34966. b: float;
  34967. a: float;
  34968. }
  34969. /**
  34970. * Class containing a set of static utilities functions
  34971. */
  34972. export class Tools {
  34973. /**
  34974. * Gets or sets the base URL to use to load assets
  34975. */
  34976. static get BaseUrl(): string;
  34977. static set BaseUrl(value: string);
  34978. /**
  34979. * Enable/Disable Custom HTTP Request Headers globally.
  34980. * default = false
  34981. * @see CustomRequestHeaders
  34982. */
  34983. static UseCustomRequestHeaders: boolean;
  34984. /**
  34985. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34986. * i.e. when loading files, where the server/service expects an Authorization header
  34987. */
  34988. static CustomRequestHeaders: {
  34989. [key: string]: string;
  34990. };
  34991. /**
  34992. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34993. */
  34994. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34995. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34996. /**
  34997. * Default behaviour for cors in the application.
  34998. * It can be a string if the expected behavior is identical in the entire app.
  34999. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35000. */
  35001. static get CorsBehavior(): string | ((url: string | string[]) => string);
  35002. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  35003. /**
  35004. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35005. * @ignorenaming
  35006. */
  35007. static get UseFallbackTexture(): boolean;
  35008. static set UseFallbackTexture(value: boolean);
  35009. /**
  35010. * Use this object to register external classes like custom textures or material
  35011. * to allow the laoders to instantiate them
  35012. */
  35013. static get RegisteredExternalClasses(): {
  35014. [key: string]: Object;
  35015. };
  35016. static set RegisteredExternalClasses(classes: {
  35017. [key: string]: Object;
  35018. });
  35019. /**
  35020. * Texture content used if a texture cannot loaded
  35021. * @ignorenaming
  35022. */
  35023. static get fallbackTexture(): string;
  35024. static set fallbackTexture(value: string);
  35025. /**
  35026. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35027. * @param u defines the coordinate on X axis
  35028. * @param v defines the coordinate on Y axis
  35029. * @param width defines the width of the source data
  35030. * @param height defines the height of the source data
  35031. * @param pixels defines the source byte array
  35032. * @param color defines the output color
  35033. */
  35034. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35035. /**
  35036. * Interpolates between a and b via alpha
  35037. * @param a The lower value (returned when alpha = 0)
  35038. * @param b The upper value (returned when alpha = 1)
  35039. * @param alpha The interpolation-factor
  35040. * @return The mixed value
  35041. */
  35042. static Mix(a: number, b: number, alpha: number): number;
  35043. /**
  35044. * Tries to instantiate a new object from a given class name
  35045. * @param className defines the class name to instantiate
  35046. * @returns the new object or null if the system was not able to do the instantiation
  35047. */
  35048. static Instantiate(className: string): any;
  35049. /**
  35050. * Provides a slice function that will work even on IE
  35051. * @param data defines the array to slice
  35052. * @param start defines the start of the data (optional)
  35053. * @param end defines the end of the data (optional)
  35054. * @returns the new sliced array
  35055. */
  35056. static Slice<T>(data: T, start?: number, end?: number): T;
  35057. /**
  35058. * Polyfill for setImmediate
  35059. * @param action defines the action to execute after the current execution block
  35060. */
  35061. static SetImmediate(action: () => void): void;
  35062. /**
  35063. * Function indicating if a number is an exponent of 2
  35064. * @param value defines the value to test
  35065. * @returns true if the value is an exponent of 2
  35066. */
  35067. static IsExponentOfTwo(value: number): boolean;
  35068. private static _tmpFloatArray;
  35069. /**
  35070. * Returns the nearest 32-bit single precision float representation of a Number
  35071. * @param value A Number. If the parameter is of a different type, it will get converted
  35072. * to a number or to NaN if it cannot be converted
  35073. * @returns number
  35074. */
  35075. static FloatRound(value: number): number;
  35076. /**
  35077. * Extracts the filename from a path
  35078. * @param path defines the path to use
  35079. * @returns the filename
  35080. */
  35081. static GetFilename(path: string): string;
  35082. /**
  35083. * Extracts the "folder" part of a path (everything before the filename).
  35084. * @param uri The URI to extract the info from
  35085. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35086. * @returns The "folder" part of the path
  35087. */
  35088. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35089. /**
  35090. * Extracts text content from a DOM element hierarchy
  35091. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35092. */
  35093. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35094. /**
  35095. * Convert an angle in radians to degrees
  35096. * @param angle defines the angle to convert
  35097. * @returns the angle in degrees
  35098. */
  35099. static ToDegrees(angle: number): number;
  35100. /**
  35101. * Convert an angle in degrees to radians
  35102. * @param angle defines the angle to convert
  35103. * @returns the angle in radians
  35104. */
  35105. static ToRadians(angle: number): number;
  35106. /**
  35107. * Returns an array if obj is not an array
  35108. * @param obj defines the object to evaluate as an array
  35109. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35110. * @returns either obj directly if obj is an array or a new array containing obj
  35111. */
  35112. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35113. /**
  35114. * Gets the pointer prefix to use
  35115. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35116. */
  35117. static GetPointerPrefix(): string;
  35118. /**
  35119. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35120. * @param url define the url we are trying
  35121. * @param element define the dom element where to configure the cors policy
  35122. */
  35123. static SetCorsBehavior(url: string | string[], element: {
  35124. crossOrigin: string | null;
  35125. }): void;
  35126. /**
  35127. * Removes unwanted characters from an url
  35128. * @param url defines the url to clean
  35129. * @returns the cleaned url
  35130. */
  35131. static CleanUrl(url: string): string;
  35132. /**
  35133. * Gets or sets a function used to pre-process url before using them to load assets
  35134. */
  35135. static get PreprocessUrl(): (url: string) => string;
  35136. static set PreprocessUrl(processor: (url: string) => string);
  35137. /**
  35138. * Loads an image as an HTMLImageElement.
  35139. * @param input url string, ArrayBuffer, or Blob to load
  35140. * @param onLoad callback called when the image successfully loads
  35141. * @param onError callback called when the image fails to load
  35142. * @param offlineProvider offline provider for caching
  35143. * @param mimeType optional mime type
  35144. * @returns the HTMLImageElement of the loaded image
  35145. */
  35146. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35147. /**
  35148. * Loads a file from a url
  35149. * @param url url string, ArrayBuffer, or Blob to load
  35150. * @param onSuccess callback called when the file successfully loads
  35151. * @param onProgress callback called while file is loading (if the server supports this mode)
  35152. * @param offlineProvider defines the offline provider for caching
  35153. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35154. * @param onError callback called when the file fails to load
  35155. * @returns a file request object
  35156. */
  35157. 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;
  35158. /**
  35159. * Loads a file from a url
  35160. * @param url the file url to load
  35161. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35162. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35163. */
  35164. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35165. /**
  35166. * Load a script (identified by an url). When the url returns, the
  35167. * content of this file is added into a new script element, attached to the DOM (body element)
  35168. * @param scriptUrl defines the url of the script to laod
  35169. * @param onSuccess defines the callback called when the script is loaded
  35170. * @param onError defines the callback to call if an error occurs
  35171. * @param scriptId defines the id of the script element
  35172. */
  35173. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35174. /**
  35175. * Load an asynchronous script (identified by an url). When the url returns, the
  35176. * content of this file is added into a new script element, attached to the DOM (body element)
  35177. * @param scriptUrl defines the url of the script to laod
  35178. * @param scriptId defines the id of the script element
  35179. * @returns a promise request object
  35180. */
  35181. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35182. /**
  35183. * Loads a file from a blob
  35184. * @param fileToLoad defines the blob to use
  35185. * @param callback defines the callback to call when data is loaded
  35186. * @param progressCallback defines the callback to call during loading process
  35187. * @returns a file request object
  35188. */
  35189. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35190. /**
  35191. * Reads a file from a File object
  35192. * @param file defines the file to load
  35193. * @param onSuccess defines the callback to call when data is loaded
  35194. * @param onProgress defines the callback to call during loading process
  35195. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35196. * @param onError defines the callback to call when an error occurs
  35197. * @returns a file request object
  35198. */
  35199. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35200. /**
  35201. * Creates a data url from a given string content
  35202. * @param content defines the content to convert
  35203. * @returns the new data url link
  35204. */
  35205. static FileAsURL(content: string): string;
  35206. /**
  35207. * Format the given number to a specific decimal format
  35208. * @param value defines the number to format
  35209. * @param decimals defines the number of decimals to use
  35210. * @returns the formatted string
  35211. */
  35212. static Format(value: number, decimals?: number): string;
  35213. /**
  35214. * Tries to copy an object by duplicating every property
  35215. * @param source defines the source object
  35216. * @param destination defines the target object
  35217. * @param doNotCopyList defines a list of properties to avoid
  35218. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35219. */
  35220. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35221. /**
  35222. * Gets a boolean indicating if the given object has no own property
  35223. * @param obj defines the object to test
  35224. * @returns true if object has no own property
  35225. */
  35226. static IsEmpty(obj: any): boolean;
  35227. /**
  35228. * Function used to register events at window level
  35229. * @param windowElement defines the Window object to use
  35230. * @param events defines the events to register
  35231. */
  35232. static RegisterTopRootEvents(windowElement: Window, events: {
  35233. name: string;
  35234. handler: Nullable<(e: FocusEvent) => any>;
  35235. }[]): void;
  35236. /**
  35237. * Function used to unregister events from window level
  35238. * @param windowElement defines the Window object to use
  35239. * @param events defines the events to unregister
  35240. */
  35241. static UnregisterTopRootEvents(windowElement: Window, events: {
  35242. name: string;
  35243. handler: Nullable<(e: FocusEvent) => any>;
  35244. }[]): void;
  35245. /**
  35246. * @ignore
  35247. */
  35248. static _ScreenshotCanvas: HTMLCanvasElement;
  35249. /**
  35250. * Dumps the current bound framebuffer
  35251. * @param width defines the rendering width
  35252. * @param height defines the rendering height
  35253. * @param engine defines the hosting engine
  35254. * @param successCallback defines the callback triggered once the data are available
  35255. * @param mimeType defines the mime type of the result
  35256. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35257. */
  35258. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35259. /**
  35260. * Converts the canvas data to blob.
  35261. * This acts as a polyfill for browsers not supporting the to blob function.
  35262. * @param canvas Defines the canvas to extract the data from
  35263. * @param successCallback Defines the callback triggered once the data are available
  35264. * @param mimeType Defines the mime type of the result
  35265. */
  35266. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35267. /**
  35268. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35269. * @param successCallback defines the callback triggered once the data are available
  35270. * @param mimeType defines the mime type of the result
  35271. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35272. */
  35273. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35274. /**
  35275. * Downloads a blob in the browser
  35276. * @param blob defines the blob to download
  35277. * @param fileName defines the name of the downloaded file
  35278. */
  35279. static Download(blob: Blob, fileName: string): void;
  35280. /**
  35281. * Captures a screenshot of the current rendering
  35282. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35283. * @param engine defines the rendering engine
  35284. * @param camera defines the source camera
  35285. * @param size This parameter can be set to a single number or to an object with the
  35286. * following (optional) properties: precision, width, height. If a single number is passed,
  35287. * it will be used for both width and height. If an object is passed, the screenshot size
  35288. * will be derived from the parameters. The precision property is a multiplier allowing
  35289. * rendering at a higher or lower resolution
  35290. * @param successCallback defines the callback receives a single parameter which contains the
  35291. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35292. * src parameter of an <img> to display it
  35293. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35294. * Check your browser for supported MIME types
  35295. */
  35296. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35297. /**
  35298. * Captures a screenshot of the current rendering
  35299. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35300. * @param engine defines the rendering engine
  35301. * @param camera defines the source camera
  35302. * @param size This parameter can be set to a single number or to an object with the
  35303. * following (optional) properties: precision, width, height. If a single number is passed,
  35304. * it will be used for both width and height. If an object is passed, the screenshot size
  35305. * will be derived from the parameters. The precision property is a multiplier allowing
  35306. * rendering at a higher or lower resolution
  35307. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35308. * Check your browser for supported MIME types
  35309. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35310. * to the src parameter of an <img> to display it
  35311. */
  35312. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35313. /**
  35314. * Generates an image screenshot from the specified camera.
  35315. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35316. * @param engine The engine to use for rendering
  35317. * @param camera The camera to use for rendering
  35318. * @param size This parameter can be set to a single number or to an object with the
  35319. * following (optional) properties: precision, width, height. If a single number is passed,
  35320. * it will be used for both width and height. If an object is passed, the screenshot size
  35321. * will be derived from the parameters. The precision property is a multiplier allowing
  35322. * rendering at a higher or lower resolution
  35323. * @param successCallback The callback receives a single parameter which contains the
  35324. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35325. * src parameter of an <img> to display it
  35326. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35327. * Check your browser for supported MIME types
  35328. * @param samples Texture samples (default: 1)
  35329. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35330. * @param fileName A name for for the downloaded file.
  35331. */
  35332. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35333. /**
  35334. * Generates an image screenshot from the specified camera.
  35335. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35336. * @param engine The engine to use for rendering
  35337. * @param camera The camera to use for rendering
  35338. * @param size This parameter can be set to a single number or to an object with the
  35339. * following (optional) properties: precision, width, height. If a single number is passed,
  35340. * it will be used for both width and height. If an object is passed, the screenshot size
  35341. * will be derived from the parameters. The precision property is a multiplier allowing
  35342. * rendering at a higher or lower resolution
  35343. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35344. * Check your browser for supported MIME types
  35345. * @param samples Texture samples (default: 1)
  35346. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35347. * @param fileName A name for for the downloaded file.
  35348. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35349. * to the src parameter of an <img> to display it
  35350. */
  35351. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35352. /**
  35353. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35354. * Be aware Math.random() could cause collisions, but:
  35355. * "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"
  35356. * @returns a pseudo random id
  35357. */
  35358. static RandomId(): string;
  35359. /**
  35360. * Test if the given uri is a base64 string
  35361. * @param uri The uri to test
  35362. * @return True if the uri is a base64 string or false otherwise
  35363. */
  35364. static IsBase64(uri: string): boolean;
  35365. /**
  35366. * Decode the given base64 uri.
  35367. * @param uri The uri to decode
  35368. * @return The decoded base64 data.
  35369. */
  35370. static DecodeBase64(uri: string): ArrayBuffer;
  35371. /**
  35372. * Gets the absolute url.
  35373. * @param url the input url
  35374. * @return the absolute url
  35375. */
  35376. static GetAbsoluteUrl(url: string): string;
  35377. /**
  35378. * No log
  35379. */
  35380. static readonly NoneLogLevel: number;
  35381. /**
  35382. * Only message logs
  35383. */
  35384. static readonly MessageLogLevel: number;
  35385. /**
  35386. * Only warning logs
  35387. */
  35388. static readonly WarningLogLevel: number;
  35389. /**
  35390. * Only error logs
  35391. */
  35392. static readonly ErrorLogLevel: number;
  35393. /**
  35394. * All logs
  35395. */
  35396. static readonly AllLogLevel: number;
  35397. /**
  35398. * Gets a value indicating the number of loading errors
  35399. * @ignorenaming
  35400. */
  35401. static get errorsCount(): number;
  35402. /**
  35403. * Callback called when a new log is added
  35404. */
  35405. static OnNewCacheEntry: (entry: string) => void;
  35406. /**
  35407. * Log a message to the console
  35408. * @param message defines the message to log
  35409. */
  35410. static Log(message: string): void;
  35411. /**
  35412. * Write a warning message to the console
  35413. * @param message defines the message to log
  35414. */
  35415. static Warn(message: string): void;
  35416. /**
  35417. * Write an error message to the console
  35418. * @param message defines the message to log
  35419. */
  35420. static Error(message: string): void;
  35421. /**
  35422. * Gets current log cache (list of logs)
  35423. */
  35424. static get LogCache(): string;
  35425. /**
  35426. * Clears the log cache
  35427. */
  35428. static ClearLogCache(): void;
  35429. /**
  35430. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35431. */
  35432. static set LogLevels(level: number);
  35433. /**
  35434. * Checks if the window object exists
  35435. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35436. */
  35437. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35438. /**
  35439. * No performance log
  35440. */
  35441. static readonly PerformanceNoneLogLevel: number;
  35442. /**
  35443. * Use user marks to log performance
  35444. */
  35445. static readonly PerformanceUserMarkLogLevel: number;
  35446. /**
  35447. * Log performance to the console
  35448. */
  35449. static readonly PerformanceConsoleLogLevel: number;
  35450. private static _performance;
  35451. /**
  35452. * Sets the current performance log level
  35453. */
  35454. static set PerformanceLogLevel(level: number);
  35455. private static _StartPerformanceCounterDisabled;
  35456. private static _EndPerformanceCounterDisabled;
  35457. private static _StartUserMark;
  35458. private static _EndUserMark;
  35459. private static _StartPerformanceConsole;
  35460. private static _EndPerformanceConsole;
  35461. /**
  35462. * Starts a performance counter
  35463. */
  35464. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35465. /**
  35466. * Ends a specific performance coutner
  35467. */
  35468. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35469. /**
  35470. * Gets either window.performance.now() if supported or Date.now() else
  35471. */
  35472. static get Now(): number;
  35473. /**
  35474. * This method will return the name of the class used to create the instance of the given object.
  35475. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35476. * @param object the object to get the class name from
  35477. * @param isType defines if the object is actually a type
  35478. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35479. */
  35480. static GetClassName(object: any, isType?: boolean): string;
  35481. /**
  35482. * Gets the first element of an array satisfying a given predicate
  35483. * @param array defines the array to browse
  35484. * @param predicate defines the predicate to use
  35485. * @returns null if not found or the element
  35486. */
  35487. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35488. /**
  35489. * This method will return the name of the full name of the class, including its owning module (if any).
  35490. * 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).
  35491. * @param object the object to get the class name from
  35492. * @param isType defines if the object is actually a type
  35493. * @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.
  35494. * @ignorenaming
  35495. */
  35496. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35497. /**
  35498. * Returns a promise that resolves after the given amount of time.
  35499. * @param delay Number of milliseconds to delay
  35500. * @returns Promise that resolves after the given amount of time
  35501. */
  35502. static DelayAsync(delay: number): Promise<void>;
  35503. /**
  35504. * Utility function to detect if the current user agent is Safari
  35505. * @returns whether or not the current user agent is safari
  35506. */
  35507. static IsSafari(): boolean;
  35508. }
  35509. /**
  35510. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35511. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35512. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35513. * @param name The name of the class, case should be preserved
  35514. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35515. */
  35516. export function className(name: string, module?: string): (target: Object) => void;
  35517. /**
  35518. * An implementation of a loop for asynchronous functions.
  35519. */
  35520. export class AsyncLoop {
  35521. /**
  35522. * Defines the number of iterations for the loop
  35523. */
  35524. iterations: number;
  35525. /**
  35526. * Defines the current index of the loop.
  35527. */
  35528. index: number;
  35529. private _done;
  35530. private _fn;
  35531. private _successCallback;
  35532. /**
  35533. * Constructor.
  35534. * @param iterations the number of iterations.
  35535. * @param func the function to run each iteration
  35536. * @param successCallback the callback that will be called upon succesful execution
  35537. * @param offset starting offset.
  35538. */
  35539. constructor(
  35540. /**
  35541. * Defines the number of iterations for the loop
  35542. */
  35543. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35544. /**
  35545. * Execute the next iteration. Must be called after the last iteration was finished.
  35546. */
  35547. executeNext(): void;
  35548. /**
  35549. * Break the loop and run the success callback.
  35550. */
  35551. breakLoop(): void;
  35552. /**
  35553. * Create and run an async loop.
  35554. * @param iterations the number of iterations.
  35555. * @param fn the function to run each iteration
  35556. * @param successCallback the callback that will be called upon succesful execution
  35557. * @param offset starting offset.
  35558. * @returns the created async loop object
  35559. */
  35560. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35561. /**
  35562. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35563. * @param iterations total number of iterations
  35564. * @param syncedIterations number of synchronous iterations in each async iteration.
  35565. * @param fn the function to call each iteration.
  35566. * @param callback a success call back that will be called when iterating stops.
  35567. * @param breakFunction a break condition (optional)
  35568. * @param timeout timeout settings for the setTimeout function. default - 0.
  35569. * @returns the created async loop object
  35570. */
  35571. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35572. }
  35573. }
  35574. declare module "babylonjs/Misc/stringDictionary" {
  35575. import { Nullable } from "babylonjs/types";
  35576. /**
  35577. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35578. * The underlying implementation relies on an associative array to ensure the best performances.
  35579. * The value can be anything including 'null' but except 'undefined'
  35580. */
  35581. export class StringDictionary<T> {
  35582. /**
  35583. * This will clear this dictionary and copy the content from the 'source' one.
  35584. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35585. * @param source the dictionary to take the content from and copy to this dictionary
  35586. */
  35587. copyFrom(source: StringDictionary<T>): void;
  35588. /**
  35589. * Get a value based from its key
  35590. * @param key the given key to get the matching value from
  35591. * @return the value if found, otherwise undefined is returned
  35592. */
  35593. get(key: string): T | undefined;
  35594. /**
  35595. * Get a value from its key or add it if it doesn't exist.
  35596. * This method will ensure you that a given key/data will be present in the dictionary.
  35597. * @param key the given key to get the matching value from
  35598. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35599. * The factory will only be invoked if there's no data for the given key.
  35600. * @return the value corresponding to the key.
  35601. */
  35602. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35603. /**
  35604. * Get a value from its key if present in the dictionary otherwise add it
  35605. * @param key the key to get the value from
  35606. * @param val if there's no such key/value pair in the dictionary add it with this value
  35607. * @return the value corresponding to the key
  35608. */
  35609. getOrAdd(key: string, val: T): T;
  35610. /**
  35611. * Check if there's a given key in the dictionary
  35612. * @param key the key to check for
  35613. * @return true if the key is present, false otherwise
  35614. */
  35615. contains(key: string): boolean;
  35616. /**
  35617. * Add a new key and its corresponding value
  35618. * @param key the key to add
  35619. * @param value the value corresponding to the key
  35620. * @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
  35621. */
  35622. add(key: string, value: T): boolean;
  35623. /**
  35624. * Update a specific value associated to a key
  35625. * @param key defines the key to use
  35626. * @param value defines the value to store
  35627. * @returns true if the value was updated (or false if the key was not found)
  35628. */
  35629. set(key: string, value: T): boolean;
  35630. /**
  35631. * Get the element of the given key and remove it from the dictionary
  35632. * @param key defines the key to search
  35633. * @returns the value associated with the key or null if not found
  35634. */
  35635. getAndRemove(key: string): Nullable<T>;
  35636. /**
  35637. * Remove a key/value from the dictionary.
  35638. * @param key the key to remove
  35639. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35640. */
  35641. remove(key: string): boolean;
  35642. /**
  35643. * Clear the whole content of the dictionary
  35644. */
  35645. clear(): void;
  35646. /**
  35647. * Gets the current count
  35648. */
  35649. get count(): number;
  35650. /**
  35651. * Execute a callback on each key/val of the dictionary.
  35652. * Note that you can remove any element in this dictionary in the callback implementation
  35653. * @param callback the callback to execute on a given key/value pair
  35654. */
  35655. forEach(callback: (key: string, val: T) => void): void;
  35656. /**
  35657. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35658. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35659. * Note that you can remove any element in this dictionary in the callback implementation
  35660. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35661. * @returns the first item
  35662. */
  35663. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35664. private _count;
  35665. private _data;
  35666. }
  35667. }
  35668. declare module "babylonjs/Collisions/collisionCoordinator" {
  35669. import { Nullable } from "babylonjs/types";
  35670. import { Scene } from "babylonjs/scene";
  35671. import { Vector3 } from "babylonjs/Maths/math.vector";
  35672. import { Collider } from "babylonjs/Collisions/collider";
  35673. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35674. /** @hidden */
  35675. export interface ICollisionCoordinator {
  35676. createCollider(): Collider;
  35677. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35678. init(scene: Scene): void;
  35679. }
  35680. /** @hidden */
  35681. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35682. private _scene;
  35683. private _scaledPosition;
  35684. private _scaledVelocity;
  35685. private _finalPosition;
  35686. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35687. createCollider(): Collider;
  35688. init(scene: Scene): void;
  35689. private _collideWithWorld;
  35690. }
  35691. }
  35692. declare module "babylonjs/Inputs/scene.inputManager" {
  35693. import { Nullable } from "babylonjs/types";
  35694. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35695. import { Vector2 } from "babylonjs/Maths/math.vector";
  35696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35697. import { Scene } from "babylonjs/scene";
  35698. /**
  35699. * Class used to manage all inputs for the scene.
  35700. */
  35701. export class InputManager {
  35702. /** The distance in pixel that you have to move to prevent some events */
  35703. static DragMovementThreshold: number;
  35704. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35705. static LongPressDelay: number;
  35706. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35707. static DoubleClickDelay: number;
  35708. /** If you need to check double click without raising a single click at first click, enable this flag */
  35709. static ExclusiveDoubleClickMode: boolean;
  35710. private _wheelEventName;
  35711. private _onPointerMove;
  35712. private _onPointerDown;
  35713. private _onPointerUp;
  35714. private _initClickEvent;
  35715. private _initActionManager;
  35716. private _delayedSimpleClick;
  35717. private _delayedSimpleClickTimeout;
  35718. private _previousDelayedSimpleClickTimeout;
  35719. private _meshPickProceed;
  35720. private _previousButtonPressed;
  35721. private _currentPickResult;
  35722. private _previousPickResult;
  35723. private _totalPointersPressed;
  35724. private _doubleClickOccured;
  35725. private _pointerOverMesh;
  35726. private _pickedDownMesh;
  35727. private _pickedUpMesh;
  35728. private _pointerX;
  35729. private _pointerY;
  35730. private _unTranslatedPointerX;
  35731. private _unTranslatedPointerY;
  35732. private _startingPointerPosition;
  35733. private _previousStartingPointerPosition;
  35734. private _startingPointerTime;
  35735. private _previousStartingPointerTime;
  35736. private _pointerCaptures;
  35737. private _onKeyDown;
  35738. private _onKeyUp;
  35739. private _onCanvasFocusObserver;
  35740. private _onCanvasBlurObserver;
  35741. private _scene;
  35742. /**
  35743. * Creates a new InputManager
  35744. * @param scene defines the hosting scene
  35745. */
  35746. constructor(scene: Scene);
  35747. /**
  35748. * Gets the mesh that is currently under the pointer
  35749. */
  35750. get meshUnderPointer(): Nullable<AbstractMesh>;
  35751. /**
  35752. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35753. */
  35754. get unTranslatedPointer(): Vector2;
  35755. /**
  35756. * Gets or sets the current on-screen X position of the pointer
  35757. */
  35758. get pointerX(): number;
  35759. set pointerX(value: number);
  35760. /**
  35761. * Gets or sets the current on-screen Y position of the pointer
  35762. */
  35763. get pointerY(): number;
  35764. set pointerY(value: number);
  35765. private _updatePointerPosition;
  35766. private _processPointerMove;
  35767. private _setRayOnPointerInfo;
  35768. private _checkPrePointerObservable;
  35769. /**
  35770. * Use this method to simulate a pointer move on a mesh
  35771. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35772. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35773. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35774. */
  35775. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35776. /**
  35777. * Use this method to simulate a pointer down on a mesh
  35778. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35779. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35780. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35781. */
  35782. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35783. private _processPointerDown;
  35784. /** @hidden */
  35785. _isPointerSwiping(): boolean;
  35786. /**
  35787. * Use this method to simulate a pointer up on a mesh
  35788. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35789. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35790. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35791. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35792. */
  35793. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35794. private _processPointerUp;
  35795. /**
  35796. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35797. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35798. * @returns true if the pointer was captured
  35799. */
  35800. isPointerCaptured(pointerId?: number): boolean;
  35801. /**
  35802. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35803. * @param attachUp defines if you want to attach events to pointerup
  35804. * @param attachDown defines if you want to attach events to pointerdown
  35805. * @param attachMove defines if you want to attach events to pointermove
  35806. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35807. */
  35808. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35809. /**
  35810. * Detaches all event handlers
  35811. */
  35812. detachControl(): void;
  35813. /**
  35814. * Force the value of meshUnderPointer
  35815. * @param mesh defines the mesh to use
  35816. */
  35817. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35818. /**
  35819. * Gets the mesh under the pointer
  35820. * @returns a Mesh or null if no mesh is under the pointer
  35821. */
  35822. getPointerOverMesh(): Nullable<AbstractMesh>;
  35823. }
  35824. }
  35825. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35826. /**
  35827. * Helper class used to generate session unique ID
  35828. */
  35829. export class UniqueIdGenerator {
  35830. private static _UniqueIdCounter;
  35831. /**
  35832. * Gets an unique (relatively to the current scene) Id
  35833. */
  35834. static get UniqueId(): number;
  35835. }
  35836. }
  35837. declare module "babylonjs/Animations/animationGroup" {
  35838. import { Animatable } from "babylonjs/Animations/animatable";
  35839. import { Animation } from "babylonjs/Animations/animation";
  35840. import { Scene, IDisposable } from "babylonjs/scene";
  35841. import { Observable } from "babylonjs/Misc/observable";
  35842. import { Nullable } from "babylonjs/types";
  35843. import "babylonjs/Animations/animatable";
  35844. /**
  35845. * This class defines the direct association between an animation and a target
  35846. */
  35847. export class TargetedAnimation {
  35848. /**
  35849. * Animation to perform
  35850. */
  35851. animation: Animation;
  35852. /**
  35853. * Target to animate
  35854. */
  35855. target: any;
  35856. /**
  35857. * Serialize the object
  35858. * @returns the JSON object representing the current entity
  35859. */
  35860. serialize(): any;
  35861. }
  35862. /**
  35863. * Use this class to create coordinated animations on multiple targets
  35864. */
  35865. export class AnimationGroup implements IDisposable {
  35866. /** The name of the animation group */
  35867. name: string;
  35868. private _scene;
  35869. private _targetedAnimations;
  35870. private _animatables;
  35871. private _from;
  35872. private _to;
  35873. private _isStarted;
  35874. private _isPaused;
  35875. private _speedRatio;
  35876. private _loopAnimation;
  35877. /**
  35878. * Gets or sets the unique id of the node
  35879. */
  35880. uniqueId: number;
  35881. /**
  35882. * This observable will notify when one animation have ended
  35883. */
  35884. onAnimationEndObservable: Observable<TargetedAnimation>;
  35885. /**
  35886. * Observer raised when one animation loops
  35887. */
  35888. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35889. /**
  35890. * Observer raised when all animations have looped
  35891. */
  35892. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35893. /**
  35894. * This observable will notify when all animations have ended.
  35895. */
  35896. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35897. /**
  35898. * This observable will notify when all animations have paused.
  35899. */
  35900. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35901. /**
  35902. * This observable will notify when all animations are playing.
  35903. */
  35904. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35905. /**
  35906. * Gets the first frame
  35907. */
  35908. get from(): number;
  35909. /**
  35910. * Gets the last frame
  35911. */
  35912. get to(): number;
  35913. /**
  35914. * Define if the animations are started
  35915. */
  35916. get isStarted(): boolean;
  35917. /**
  35918. * Gets a value indicating that the current group is playing
  35919. */
  35920. get isPlaying(): boolean;
  35921. /**
  35922. * Gets or sets the speed ratio to use for all animations
  35923. */
  35924. get speedRatio(): number;
  35925. /**
  35926. * Gets or sets the speed ratio to use for all animations
  35927. */
  35928. set speedRatio(value: number);
  35929. /**
  35930. * Gets or sets if all animations should loop or not
  35931. */
  35932. get loopAnimation(): boolean;
  35933. set loopAnimation(value: boolean);
  35934. /**
  35935. * Gets the targeted animations for this animation group
  35936. */
  35937. get targetedAnimations(): Array<TargetedAnimation>;
  35938. /**
  35939. * returning the list of animatables controlled by this animation group.
  35940. */
  35941. get animatables(): Array<Animatable>;
  35942. /**
  35943. * Instantiates a new Animation Group.
  35944. * This helps managing several animations at once.
  35945. * @see http://doc.babylonjs.com/how_to/group
  35946. * @param name Defines the name of the group
  35947. * @param scene Defines the scene the group belongs to
  35948. */
  35949. constructor(
  35950. /** The name of the animation group */
  35951. name: string, scene?: Nullable<Scene>);
  35952. /**
  35953. * Add an animation (with its target) in the group
  35954. * @param animation defines the animation we want to add
  35955. * @param target defines the target of the animation
  35956. * @returns the TargetedAnimation object
  35957. */
  35958. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35959. /**
  35960. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35961. * It can add constant keys at begin or end
  35962. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35963. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35964. * @returns the animation group
  35965. */
  35966. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35967. private _animationLoopCount;
  35968. private _animationLoopFlags;
  35969. private _processLoop;
  35970. /**
  35971. * Start all animations on given targets
  35972. * @param loop defines if animations must loop
  35973. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35974. * @param from defines the from key (optional)
  35975. * @param to defines the to key (optional)
  35976. * @returns the current animation group
  35977. */
  35978. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35979. /**
  35980. * Pause all animations
  35981. * @returns the animation group
  35982. */
  35983. pause(): AnimationGroup;
  35984. /**
  35985. * Play all animations to initial state
  35986. * This function will start() the animations if they were not started or will restart() them if they were paused
  35987. * @param loop defines if animations must loop
  35988. * @returns the animation group
  35989. */
  35990. play(loop?: boolean): AnimationGroup;
  35991. /**
  35992. * Reset all animations to initial state
  35993. * @returns the animation group
  35994. */
  35995. reset(): AnimationGroup;
  35996. /**
  35997. * Restart animations from key 0
  35998. * @returns the animation group
  35999. */
  36000. restart(): AnimationGroup;
  36001. /**
  36002. * Stop all animations
  36003. * @returns the animation group
  36004. */
  36005. stop(): AnimationGroup;
  36006. /**
  36007. * Set animation weight for all animatables
  36008. * @param weight defines the weight to use
  36009. * @return the animationGroup
  36010. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36011. */
  36012. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36013. /**
  36014. * Synchronize and normalize all animatables with a source animatable
  36015. * @param root defines the root animatable to synchronize with
  36016. * @return the animationGroup
  36017. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36018. */
  36019. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36020. /**
  36021. * Goes to a specific frame in this animation group
  36022. * @param frame the frame number to go to
  36023. * @return the animationGroup
  36024. */
  36025. goToFrame(frame: number): AnimationGroup;
  36026. /**
  36027. * Dispose all associated resources
  36028. */
  36029. dispose(): void;
  36030. private _checkAnimationGroupEnded;
  36031. /**
  36032. * Clone the current animation group and returns a copy
  36033. * @param newName defines the name of the new group
  36034. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36035. * @returns the new aniamtion group
  36036. */
  36037. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36038. /**
  36039. * Serializes the animationGroup to an object
  36040. * @returns Serialized object
  36041. */
  36042. serialize(): any;
  36043. /**
  36044. * Returns a new AnimationGroup object parsed from the source provided.
  36045. * @param parsedAnimationGroup defines the source
  36046. * @param scene defines the scene that will receive the animationGroup
  36047. * @returns a new AnimationGroup
  36048. */
  36049. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36050. /**
  36051. * Returns the string "AnimationGroup"
  36052. * @returns "AnimationGroup"
  36053. */
  36054. getClassName(): string;
  36055. /**
  36056. * Creates a detailled string about the object
  36057. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36058. * @returns a string representing the object
  36059. */
  36060. toString(fullDetails?: boolean): string;
  36061. }
  36062. }
  36063. declare module "babylonjs/scene" {
  36064. import { Nullable } from "babylonjs/types";
  36065. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36066. import { Observable } from "babylonjs/Misc/observable";
  36067. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36068. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36069. import { Geometry } from "babylonjs/Meshes/geometry";
  36070. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36071. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36073. import { Mesh } from "babylonjs/Meshes/mesh";
  36074. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36075. import { Bone } from "babylonjs/Bones/bone";
  36076. import { Skeleton } from "babylonjs/Bones/skeleton";
  36077. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36078. import { Camera } from "babylonjs/Cameras/camera";
  36079. import { AbstractScene } from "babylonjs/abstractScene";
  36080. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36081. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36082. import { Material } from "babylonjs/Materials/material";
  36083. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36084. import { Effect } from "babylonjs/Materials/effect";
  36085. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36086. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36087. import { Light } from "babylonjs/Lights/light";
  36088. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36089. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36090. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36091. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36092. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36093. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36094. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36095. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36096. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36097. import { Engine } from "babylonjs/Engines/engine";
  36098. import { Node } from "babylonjs/node";
  36099. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36100. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36101. import { WebRequest } from "babylonjs/Misc/webRequest";
  36102. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36103. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36104. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36105. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36106. import { Plane } from "babylonjs/Maths/math.plane";
  36107. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36108. import { Ray } from "babylonjs/Culling/ray";
  36109. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36110. import { Animation } from "babylonjs/Animations/animation";
  36111. import { Animatable } from "babylonjs/Animations/animatable";
  36112. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36113. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36114. import { Collider } from "babylonjs/Collisions/collider";
  36115. /**
  36116. * Define an interface for all classes that will hold resources
  36117. */
  36118. export interface IDisposable {
  36119. /**
  36120. * Releases all held resources
  36121. */
  36122. dispose(): void;
  36123. }
  36124. /** Interface defining initialization parameters for Scene class */
  36125. export interface SceneOptions {
  36126. /**
  36127. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36128. * It will improve performance when the number of geometries becomes important.
  36129. */
  36130. useGeometryUniqueIdsMap?: boolean;
  36131. /**
  36132. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36133. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36134. */
  36135. useMaterialMeshMap?: boolean;
  36136. /**
  36137. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36138. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36139. */
  36140. useClonedMeshMap?: boolean;
  36141. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36142. virtual?: boolean;
  36143. }
  36144. /**
  36145. * Represents a scene to be rendered by the engine.
  36146. * @see http://doc.babylonjs.com/features/scene
  36147. */
  36148. export class Scene extends AbstractScene implements IAnimatable {
  36149. /** The fog is deactivated */
  36150. static readonly FOGMODE_NONE: number;
  36151. /** The fog density is following an exponential function */
  36152. static readonly FOGMODE_EXP: number;
  36153. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36154. static readonly FOGMODE_EXP2: number;
  36155. /** The fog density is following a linear function. */
  36156. static readonly FOGMODE_LINEAR: number;
  36157. /**
  36158. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36159. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36160. */
  36161. static MinDeltaTime: number;
  36162. /**
  36163. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36164. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36165. */
  36166. static MaxDeltaTime: number;
  36167. /**
  36168. * Factory used to create the default material.
  36169. * @param name The name of the material to create
  36170. * @param scene The scene to create the material for
  36171. * @returns The default material
  36172. */
  36173. static DefaultMaterialFactory(scene: Scene): Material;
  36174. /**
  36175. * Factory used to create the a collision coordinator.
  36176. * @returns The collision coordinator
  36177. */
  36178. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36179. /** @hidden */
  36180. _inputManager: InputManager;
  36181. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36182. cameraToUseForPointers: Nullable<Camera>;
  36183. /** @hidden */
  36184. readonly _isScene: boolean;
  36185. /** @hidden */
  36186. _blockEntityCollection: boolean;
  36187. /**
  36188. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36189. */
  36190. autoClear: boolean;
  36191. /**
  36192. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36193. */
  36194. autoClearDepthAndStencil: boolean;
  36195. /**
  36196. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36197. */
  36198. clearColor: Color4;
  36199. /**
  36200. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36201. */
  36202. ambientColor: Color3;
  36203. /**
  36204. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36205. * It should only be one of the following (if not the default embedded one):
  36206. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36207. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36208. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36209. * The material properties need to be setup according to the type of texture in use.
  36210. */
  36211. environmentBRDFTexture: BaseTexture;
  36212. /** @hidden */
  36213. protected _environmentTexture: Nullable<BaseTexture>;
  36214. /**
  36215. * Texture used in all pbr material as the reflection texture.
  36216. * As in the majority of the scene they are the same (exception for multi room and so on),
  36217. * this is easier to reference from here than from all the materials.
  36218. */
  36219. get environmentTexture(): Nullable<BaseTexture>;
  36220. /**
  36221. * Texture used in all pbr material as the reflection texture.
  36222. * As in the majority of the scene they are the same (exception for multi room and so on),
  36223. * this is easier to set here than in all the materials.
  36224. */
  36225. set environmentTexture(value: Nullable<BaseTexture>);
  36226. /** @hidden */
  36227. protected _environmentIntensity: number;
  36228. /**
  36229. * Intensity of the environment in all pbr material.
  36230. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36231. * As in the majority of the scene they are the same (exception for multi room and so on),
  36232. * this is easier to reference from here than from all the materials.
  36233. */
  36234. get environmentIntensity(): number;
  36235. /**
  36236. * Intensity of the environment in all pbr material.
  36237. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36238. * As in the majority of the scene they are the same (exception for multi room and so on),
  36239. * this is easier to set here than in all the materials.
  36240. */
  36241. set environmentIntensity(value: number);
  36242. /** @hidden */
  36243. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36244. /**
  36245. * Default image processing configuration used either in the rendering
  36246. * Forward main pass or through the imageProcessingPostProcess if present.
  36247. * As in the majority of the scene they are the same (exception for multi camera),
  36248. * this is easier to reference from here than from all the materials and post process.
  36249. *
  36250. * No setter as we it is a shared configuration, you can set the values instead.
  36251. */
  36252. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36253. private _forceWireframe;
  36254. /**
  36255. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36256. */
  36257. set forceWireframe(value: boolean);
  36258. get forceWireframe(): boolean;
  36259. private _skipFrustumClipping;
  36260. /**
  36261. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36262. */
  36263. set skipFrustumClipping(value: boolean);
  36264. get skipFrustumClipping(): boolean;
  36265. private _forcePointsCloud;
  36266. /**
  36267. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36268. */
  36269. set forcePointsCloud(value: boolean);
  36270. get forcePointsCloud(): boolean;
  36271. /**
  36272. * Gets or sets the active clipplane 1
  36273. */
  36274. clipPlane: Nullable<Plane>;
  36275. /**
  36276. * Gets or sets the active clipplane 2
  36277. */
  36278. clipPlane2: Nullable<Plane>;
  36279. /**
  36280. * Gets or sets the active clipplane 3
  36281. */
  36282. clipPlane3: Nullable<Plane>;
  36283. /**
  36284. * Gets or sets the active clipplane 4
  36285. */
  36286. clipPlane4: Nullable<Plane>;
  36287. /**
  36288. * Gets or sets the active clipplane 5
  36289. */
  36290. clipPlane5: Nullable<Plane>;
  36291. /**
  36292. * Gets or sets the active clipplane 6
  36293. */
  36294. clipPlane6: Nullable<Plane>;
  36295. /**
  36296. * Gets or sets a boolean indicating if animations are enabled
  36297. */
  36298. animationsEnabled: boolean;
  36299. private _animationPropertiesOverride;
  36300. /**
  36301. * Gets or sets the animation properties override
  36302. */
  36303. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36304. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36305. /**
  36306. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36307. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36308. */
  36309. useConstantAnimationDeltaTime: boolean;
  36310. /**
  36311. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36312. * Please note that it requires to run a ray cast through the scene on every frame
  36313. */
  36314. constantlyUpdateMeshUnderPointer: boolean;
  36315. /**
  36316. * Defines the HTML cursor to use when hovering over interactive elements
  36317. */
  36318. hoverCursor: string;
  36319. /**
  36320. * Defines the HTML default cursor to use (empty by default)
  36321. */
  36322. defaultCursor: string;
  36323. /**
  36324. * Defines whether cursors are handled by the scene.
  36325. */
  36326. doNotHandleCursors: boolean;
  36327. /**
  36328. * This is used to call preventDefault() on pointer down
  36329. * in order to block unwanted artifacts like system double clicks
  36330. */
  36331. preventDefaultOnPointerDown: boolean;
  36332. /**
  36333. * This is used to call preventDefault() on pointer up
  36334. * in order to block unwanted artifacts like system double clicks
  36335. */
  36336. preventDefaultOnPointerUp: boolean;
  36337. /**
  36338. * Gets or sets user defined metadata
  36339. */
  36340. metadata: any;
  36341. /**
  36342. * For internal use only. Please do not use.
  36343. */
  36344. reservedDataStore: any;
  36345. /**
  36346. * Gets the name of the plugin used to load this scene (null by default)
  36347. */
  36348. loadingPluginName: string;
  36349. /**
  36350. * Use this array to add regular expressions used to disable offline support for specific urls
  36351. */
  36352. disableOfflineSupportExceptionRules: RegExp[];
  36353. /**
  36354. * An event triggered when the scene is disposed.
  36355. */
  36356. onDisposeObservable: Observable<Scene>;
  36357. private _onDisposeObserver;
  36358. /** Sets a function to be executed when this scene is disposed. */
  36359. set onDispose(callback: () => void);
  36360. /**
  36361. * An event triggered before rendering the scene (right after animations and physics)
  36362. */
  36363. onBeforeRenderObservable: Observable<Scene>;
  36364. private _onBeforeRenderObserver;
  36365. /** Sets a function to be executed before rendering this scene */
  36366. set beforeRender(callback: Nullable<() => void>);
  36367. /**
  36368. * An event triggered after rendering the scene
  36369. */
  36370. onAfterRenderObservable: Observable<Scene>;
  36371. /**
  36372. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36373. */
  36374. onAfterRenderCameraObservable: Observable<Camera>;
  36375. private _onAfterRenderObserver;
  36376. /** Sets a function to be executed after rendering this scene */
  36377. set afterRender(callback: Nullable<() => void>);
  36378. /**
  36379. * An event triggered before animating the scene
  36380. */
  36381. onBeforeAnimationsObservable: Observable<Scene>;
  36382. /**
  36383. * An event triggered after animations processing
  36384. */
  36385. onAfterAnimationsObservable: Observable<Scene>;
  36386. /**
  36387. * An event triggered before draw calls are ready to be sent
  36388. */
  36389. onBeforeDrawPhaseObservable: Observable<Scene>;
  36390. /**
  36391. * An event triggered after draw calls have been sent
  36392. */
  36393. onAfterDrawPhaseObservable: Observable<Scene>;
  36394. /**
  36395. * An event triggered when the scene is ready
  36396. */
  36397. onReadyObservable: Observable<Scene>;
  36398. /**
  36399. * An event triggered before rendering a camera
  36400. */
  36401. onBeforeCameraRenderObservable: Observable<Camera>;
  36402. private _onBeforeCameraRenderObserver;
  36403. /** Sets a function to be executed before rendering a camera*/
  36404. set beforeCameraRender(callback: () => void);
  36405. /**
  36406. * An event triggered after rendering a camera
  36407. */
  36408. onAfterCameraRenderObservable: Observable<Camera>;
  36409. private _onAfterCameraRenderObserver;
  36410. /** Sets a function to be executed after rendering a camera*/
  36411. set afterCameraRender(callback: () => void);
  36412. /**
  36413. * An event triggered when active meshes evaluation is about to start
  36414. */
  36415. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36416. /**
  36417. * An event triggered when active meshes evaluation is done
  36418. */
  36419. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36420. /**
  36421. * An event triggered when particles rendering is about to start
  36422. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36423. */
  36424. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36425. /**
  36426. * An event triggered when particles rendering is done
  36427. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36428. */
  36429. onAfterParticlesRenderingObservable: Observable<Scene>;
  36430. /**
  36431. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36432. */
  36433. onDataLoadedObservable: Observable<Scene>;
  36434. /**
  36435. * An event triggered when a camera is created
  36436. */
  36437. onNewCameraAddedObservable: Observable<Camera>;
  36438. /**
  36439. * An event triggered when a camera is removed
  36440. */
  36441. onCameraRemovedObservable: Observable<Camera>;
  36442. /**
  36443. * An event triggered when a light is created
  36444. */
  36445. onNewLightAddedObservable: Observable<Light>;
  36446. /**
  36447. * An event triggered when a light is removed
  36448. */
  36449. onLightRemovedObservable: Observable<Light>;
  36450. /**
  36451. * An event triggered when a geometry is created
  36452. */
  36453. onNewGeometryAddedObservable: Observable<Geometry>;
  36454. /**
  36455. * An event triggered when a geometry is removed
  36456. */
  36457. onGeometryRemovedObservable: Observable<Geometry>;
  36458. /**
  36459. * An event triggered when a transform node is created
  36460. */
  36461. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36462. /**
  36463. * An event triggered when a transform node is removed
  36464. */
  36465. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36466. /**
  36467. * An event triggered when a mesh is created
  36468. */
  36469. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36470. /**
  36471. * An event triggered when a mesh is removed
  36472. */
  36473. onMeshRemovedObservable: Observable<AbstractMesh>;
  36474. /**
  36475. * An event triggered when a skeleton is created
  36476. */
  36477. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36478. /**
  36479. * An event triggered when a skeleton is removed
  36480. */
  36481. onSkeletonRemovedObservable: Observable<Skeleton>;
  36482. /**
  36483. * An event triggered when a material is created
  36484. */
  36485. onNewMaterialAddedObservable: Observable<Material>;
  36486. /**
  36487. * An event triggered when a material is removed
  36488. */
  36489. onMaterialRemovedObservable: Observable<Material>;
  36490. /**
  36491. * An event triggered when a texture is created
  36492. */
  36493. onNewTextureAddedObservable: Observable<BaseTexture>;
  36494. /**
  36495. * An event triggered when a texture is removed
  36496. */
  36497. onTextureRemovedObservable: Observable<BaseTexture>;
  36498. /**
  36499. * An event triggered when render targets are about to be rendered
  36500. * Can happen multiple times per frame.
  36501. */
  36502. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36503. /**
  36504. * An event triggered when render targets were rendered.
  36505. * Can happen multiple times per frame.
  36506. */
  36507. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36508. /**
  36509. * An event triggered before calculating deterministic simulation step
  36510. */
  36511. onBeforeStepObservable: Observable<Scene>;
  36512. /**
  36513. * An event triggered after calculating deterministic simulation step
  36514. */
  36515. onAfterStepObservable: Observable<Scene>;
  36516. /**
  36517. * An event triggered when the activeCamera property is updated
  36518. */
  36519. onActiveCameraChanged: Observable<Scene>;
  36520. /**
  36521. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36522. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36523. * 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)
  36524. */
  36525. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36526. /**
  36527. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36528. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36529. * 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)
  36530. */
  36531. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36532. /**
  36533. * This Observable will when a mesh has been imported into the scene.
  36534. */
  36535. onMeshImportedObservable: Observable<AbstractMesh>;
  36536. /**
  36537. * This Observable will when an animation file has been imported into the scene.
  36538. */
  36539. onAnimationFileImportedObservable: Observable<Scene>;
  36540. /**
  36541. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36542. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36543. */
  36544. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36545. /** @hidden */
  36546. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36547. /**
  36548. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36549. */
  36550. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36551. /**
  36552. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36553. */
  36554. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36555. /**
  36556. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36557. */
  36558. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36559. /** Callback called when a pointer move is detected */
  36560. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36561. /** Callback called when a pointer down is detected */
  36562. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36563. /** Callback called when a pointer up is detected */
  36564. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36565. /** Callback called when a pointer pick is detected */
  36566. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36567. /**
  36568. * 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).
  36569. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36570. */
  36571. onPrePointerObservable: Observable<PointerInfoPre>;
  36572. /**
  36573. * Observable event triggered each time an input event is received from the rendering canvas
  36574. */
  36575. onPointerObservable: Observable<PointerInfo>;
  36576. /**
  36577. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36578. */
  36579. get unTranslatedPointer(): Vector2;
  36580. /**
  36581. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36582. */
  36583. static get DragMovementThreshold(): number;
  36584. static set DragMovementThreshold(value: number);
  36585. /**
  36586. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36587. */
  36588. static get LongPressDelay(): number;
  36589. static set LongPressDelay(value: number);
  36590. /**
  36591. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36592. */
  36593. static get DoubleClickDelay(): number;
  36594. static set DoubleClickDelay(value: number);
  36595. /** If you need to check double click without raising a single click at first click, enable this flag */
  36596. static get ExclusiveDoubleClickMode(): boolean;
  36597. static set ExclusiveDoubleClickMode(value: boolean);
  36598. /** @hidden */
  36599. _mirroredCameraPosition: Nullable<Vector3>;
  36600. /**
  36601. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36602. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36603. */
  36604. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36605. /**
  36606. * Observable event triggered each time an keyboard event is received from the hosting window
  36607. */
  36608. onKeyboardObservable: Observable<KeyboardInfo>;
  36609. private _useRightHandedSystem;
  36610. /**
  36611. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36612. */
  36613. set useRightHandedSystem(value: boolean);
  36614. get useRightHandedSystem(): boolean;
  36615. private _timeAccumulator;
  36616. private _currentStepId;
  36617. private _currentInternalStep;
  36618. /**
  36619. * Sets the step Id used by deterministic lock step
  36620. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36621. * @param newStepId defines the step Id
  36622. */
  36623. setStepId(newStepId: number): void;
  36624. /**
  36625. * Gets the step Id used by deterministic lock step
  36626. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36627. * @returns the step Id
  36628. */
  36629. getStepId(): number;
  36630. /**
  36631. * Gets the internal step used by deterministic lock step
  36632. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36633. * @returns the internal step
  36634. */
  36635. getInternalStep(): number;
  36636. private _fogEnabled;
  36637. /**
  36638. * Gets or sets a boolean indicating if fog is enabled on this scene
  36639. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36640. * (Default is true)
  36641. */
  36642. set fogEnabled(value: boolean);
  36643. get fogEnabled(): boolean;
  36644. private _fogMode;
  36645. /**
  36646. * Gets or sets the fog mode to use
  36647. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36648. * | mode | value |
  36649. * | --- | --- |
  36650. * | FOGMODE_NONE | 0 |
  36651. * | FOGMODE_EXP | 1 |
  36652. * | FOGMODE_EXP2 | 2 |
  36653. * | FOGMODE_LINEAR | 3 |
  36654. */
  36655. set fogMode(value: number);
  36656. get fogMode(): number;
  36657. /**
  36658. * Gets or sets the fog color to use
  36659. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36660. * (Default is Color3(0.2, 0.2, 0.3))
  36661. */
  36662. fogColor: Color3;
  36663. /**
  36664. * Gets or sets the fog density to use
  36665. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36666. * (Default is 0.1)
  36667. */
  36668. fogDensity: number;
  36669. /**
  36670. * Gets or sets the fog start distance to use
  36671. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36672. * (Default is 0)
  36673. */
  36674. fogStart: number;
  36675. /**
  36676. * Gets or sets the fog end distance to use
  36677. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36678. * (Default is 1000)
  36679. */
  36680. fogEnd: number;
  36681. private _shadowsEnabled;
  36682. /**
  36683. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36684. */
  36685. set shadowsEnabled(value: boolean);
  36686. get shadowsEnabled(): boolean;
  36687. private _lightsEnabled;
  36688. /**
  36689. * Gets or sets a boolean indicating if lights are enabled on this scene
  36690. */
  36691. set lightsEnabled(value: boolean);
  36692. get lightsEnabled(): boolean;
  36693. /** All of the active cameras added to this scene. */
  36694. activeCameras: Camera[];
  36695. /** @hidden */
  36696. _activeCamera: Nullable<Camera>;
  36697. /** Gets or sets the current active camera */
  36698. get activeCamera(): Nullable<Camera>;
  36699. set activeCamera(value: Nullable<Camera>);
  36700. private _defaultMaterial;
  36701. /** The default material used on meshes when no material is affected */
  36702. get defaultMaterial(): Material;
  36703. /** The default material used on meshes when no material is affected */
  36704. set defaultMaterial(value: Material);
  36705. private _texturesEnabled;
  36706. /**
  36707. * Gets or sets a boolean indicating if textures are enabled on this scene
  36708. */
  36709. set texturesEnabled(value: boolean);
  36710. get texturesEnabled(): boolean;
  36711. /**
  36712. * Gets or sets a boolean indicating if particles are enabled on this scene
  36713. */
  36714. particlesEnabled: boolean;
  36715. /**
  36716. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36717. */
  36718. spritesEnabled: boolean;
  36719. private _skeletonsEnabled;
  36720. /**
  36721. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36722. */
  36723. set skeletonsEnabled(value: boolean);
  36724. get skeletonsEnabled(): boolean;
  36725. /**
  36726. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36727. */
  36728. lensFlaresEnabled: boolean;
  36729. /**
  36730. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36731. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36732. */
  36733. collisionsEnabled: boolean;
  36734. private _collisionCoordinator;
  36735. /** @hidden */
  36736. get collisionCoordinator(): ICollisionCoordinator;
  36737. /**
  36738. * Defines the gravity applied to this scene (used only for collisions)
  36739. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36740. */
  36741. gravity: Vector3;
  36742. /**
  36743. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36744. */
  36745. postProcessesEnabled: boolean;
  36746. /**
  36747. * The list of postprocesses added to the scene
  36748. */
  36749. postProcesses: PostProcess[];
  36750. /**
  36751. * Gets the current postprocess manager
  36752. */
  36753. postProcessManager: PostProcessManager;
  36754. /**
  36755. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36756. */
  36757. renderTargetsEnabled: boolean;
  36758. /**
  36759. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36760. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36761. */
  36762. dumpNextRenderTargets: boolean;
  36763. /**
  36764. * The list of user defined render targets added to the scene
  36765. */
  36766. customRenderTargets: RenderTargetTexture[];
  36767. /**
  36768. * Defines if texture loading must be delayed
  36769. * If true, textures will only be loaded when they need to be rendered
  36770. */
  36771. useDelayedTextureLoading: boolean;
  36772. /**
  36773. * Gets the list of meshes imported to the scene through SceneLoader
  36774. */
  36775. importedMeshesFiles: String[];
  36776. /**
  36777. * Gets or sets a boolean indicating if probes are enabled on this scene
  36778. */
  36779. probesEnabled: boolean;
  36780. /**
  36781. * Gets or sets the current offline provider to use to store scene data
  36782. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36783. */
  36784. offlineProvider: IOfflineProvider;
  36785. /**
  36786. * Gets or sets the action manager associated with the scene
  36787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36788. */
  36789. actionManager: AbstractActionManager;
  36790. private _meshesForIntersections;
  36791. /**
  36792. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36793. */
  36794. proceduralTexturesEnabled: boolean;
  36795. private _engine;
  36796. private _totalVertices;
  36797. /** @hidden */
  36798. _activeIndices: PerfCounter;
  36799. /** @hidden */
  36800. _activeParticles: PerfCounter;
  36801. /** @hidden */
  36802. _activeBones: PerfCounter;
  36803. private _animationRatio;
  36804. /** @hidden */
  36805. _animationTimeLast: number;
  36806. /** @hidden */
  36807. _animationTime: number;
  36808. /**
  36809. * Gets or sets a general scale for animation speed
  36810. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36811. */
  36812. animationTimeScale: number;
  36813. /** @hidden */
  36814. _cachedMaterial: Nullable<Material>;
  36815. /** @hidden */
  36816. _cachedEffect: Nullable<Effect>;
  36817. /** @hidden */
  36818. _cachedVisibility: Nullable<number>;
  36819. private _renderId;
  36820. private _frameId;
  36821. private _executeWhenReadyTimeoutId;
  36822. private _intermediateRendering;
  36823. private _viewUpdateFlag;
  36824. private _projectionUpdateFlag;
  36825. /** @hidden */
  36826. _toBeDisposed: Nullable<IDisposable>[];
  36827. private _activeRequests;
  36828. /** @hidden */
  36829. _pendingData: any[];
  36830. private _isDisposed;
  36831. /**
  36832. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36833. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36834. */
  36835. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36836. private _activeMeshes;
  36837. private _processedMaterials;
  36838. private _renderTargets;
  36839. /** @hidden */
  36840. _activeParticleSystems: SmartArray<IParticleSystem>;
  36841. private _activeSkeletons;
  36842. private _softwareSkinnedMeshes;
  36843. private _renderingManager;
  36844. /** @hidden */
  36845. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36846. private _transformMatrix;
  36847. private _sceneUbo;
  36848. /** @hidden */
  36849. _viewMatrix: Matrix;
  36850. private _projectionMatrix;
  36851. /** @hidden */
  36852. _forcedViewPosition: Nullable<Vector3>;
  36853. /** @hidden */
  36854. _frustumPlanes: Plane[];
  36855. /**
  36856. * Gets the list of frustum planes (built from the active camera)
  36857. */
  36858. get frustumPlanes(): Plane[];
  36859. /**
  36860. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36861. * This is useful if there are more lights that the maximum simulteanous authorized
  36862. */
  36863. requireLightSorting: boolean;
  36864. /** @hidden */
  36865. readonly useMaterialMeshMap: boolean;
  36866. /** @hidden */
  36867. readonly useClonedMeshMap: boolean;
  36868. private _externalData;
  36869. private _uid;
  36870. /**
  36871. * @hidden
  36872. * Backing store of defined scene components.
  36873. */
  36874. _components: ISceneComponent[];
  36875. /**
  36876. * @hidden
  36877. * Backing store of defined scene components.
  36878. */
  36879. _serializableComponents: ISceneSerializableComponent[];
  36880. /**
  36881. * List of components to register on the next registration step.
  36882. */
  36883. private _transientComponents;
  36884. /**
  36885. * Registers the transient components if needed.
  36886. */
  36887. private _registerTransientComponents;
  36888. /**
  36889. * @hidden
  36890. * Add a component to the scene.
  36891. * Note that the ccomponent could be registered on th next frame if this is called after
  36892. * the register component stage.
  36893. * @param component Defines the component to add to the scene
  36894. */
  36895. _addComponent(component: ISceneComponent): void;
  36896. /**
  36897. * @hidden
  36898. * Gets a component from the scene.
  36899. * @param name defines the name of the component to retrieve
  36900. * @returns the component or null if not present
  36901. */
  36902. _getComponent(name: string): Nullable<ISceneComponent>;
  36903. /**
  36904. * @hidden
  36905. * Defines the actions happening before camera updates.
  36906. */
  36907. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36908. /**
  36909. * @hidden
  36910. * Defines the actions happening before clear the canvas.
  36911. */
  36912. _beforeClearStage: Stage<SimpleStageAction>;
  36913. /**
  36914. * @hidden
  36915. * Defines the actions when collecting render targets for the frame.
  36916. */
  36917. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36918. /**
  36919. * @hidden
  36920. * Defines the actions happening for one camera in the frame.
  36921. */
  36922. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36923. /**
  36924. * @hidden
  36925. * Defines the actions happening during the per mesh ready checks.
  36926. */
  36927. _isReadyForMeshStage: Stage<MeshStageAction>;
  36928. /**
  36929. * @hidden
  36930. * Defines the actions happening before evaluate active mesh checks.
  36931. */
  36932. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36933. /**
  36934. * @hidden
  36935. * Defines the actions happening during the evaluate sub mesh checks.
  36936. */
  36937. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36938. /**
  36939. * @hidden
  36940. * Defines the actions happening during the active mesh stage.
  36941. */
  36942. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36943. /**
  36944. * @hidden
  36945. * Defines the actions happening during the per camera render target step.
  36946. */
  36947. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36948. /**
  36949. * @hidden
  36950. * Defines the actions happening just before the active camera is drawing.
  36951. */
  36952. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36953. /**
  36954. * @hidden
  36955. * Defines the actions happening just before a render target is drawing.
  36956. */
  36957. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36958. /**
  36959. * @hidden
  36960. * Defines the actions happening just before a rendering group is drawing.
  36961. */
  36962. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36963. /**
  36964. * @hidden
  36965. * Defines the actions happening just before a mesh is drawing.
  36966. */
  36967. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36968. /**
  36969. * @hidden
  36970. * Defines the actions happening just after a mesh has been drawn.
  36971. */
  36972. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36973. /**
  36974. * @hidden
  36975. * Defines the actions happening just after a rendering group has been drawn.
  36976. */
  36977. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36978. /**
  36979. * @hidden
  36980. * Defines the actions happening just after the active camera has been drawn.
  36981. */
  36982. _afterCameraDrawStage: Stage<CameraStageAction>;
  36983. /**
  36984. * @hidden
  36985. * Defines the actions happening just after a render target has been drawn.
  36986. */
  36987. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36988. /**
  36989. * @hidden
  36990. * Defines the actions happening just after rendering all cameras and computing intersections.
  36991. */
  36992. _afterRenderStage: Stage<SimpleStageAction>;
  36993. /**
  36994. * @hidden
  36995. * Defines the actions happening when a pointer move event happens.
  36996. */
  36997. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36998. /**
  36999. * @hidden
  37000. * Defines the actions happening when a pointer down event happens.
  37001. */
  37002. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37003. /**
  37004. * @hidden
  37005. * Defines the actions happening when a pointer up event happens.
  37006. */
  37007. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37008. /**
  37009. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37010. */
  37011. private geometriesByUniqueId;
  37012. /**
  37013. * Creates a new Scene
  37014. * @param engine defines the engine to use to render this scene
  37015. * @param options defines the scene options
  37016. */
  37017. constructor(engine: Engine, options?: SceneOptions);
  37018. /**
  37019. * Gets a string idenfifying the name of the class
  37020. * @returns "Scene" string
  37021. */
  37022. getClassName(): string;
  37023. private _defaultMeshCandidates;
  37024. /**
  37025. * @hidden
  37026. */
  37027. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37028. private _defaultSubMeshCandidates;
  37029. /**
  37030. * @hidden
  37031. */
  37032. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37033. /**
  37034. * Sets the default candidate providers for the scene.
  37035. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37036. * and getCollidingSubMeshCandidates to their default function
  37037. */
  37038. setDefaultCandidateProviders(): void;
  37039. /**
  37040. * Gets the mesh that is currently under the pointer
  37041. */
  37042. get meshUnderPointer(): Nullable<AbstractMesh>;
  37043. /**
  37044. * Gets or sets the current on-screen X position of the pointer
  37045. */
  37046. get pointerX(): number;
  37047. set pointerX(value: number);
  37048. /**
  37049. * Gets or sets the current on-screen Y position of the pointer
  37050. */
  37051. get pointerY(): number;
  37052. set pointerY(value: number);
  37053. /**
  37054. * Gets the cached material (ie. the latest rendered one)
  37055. * @returns the cached material
  37056. */
  37057. getCachedMaterial(): Nullable<Material>;
  37058. /**
  37059. * Gets the cached effect (ie. the latest rendered one)
  37060. * @returns the cached effect
  37061. */
  37062. getCachedEffect(): Nullable<Effect>;
  37063. /**
  37064. * Gets the cached visibility state (ie. the latest rendered one)
  37065. * @returns the cached visibility state
  37066. */
  37067. getCachedVisibility(): Nullable<number>;
  37068. /**
  37069. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37070. * @param material defines the current material
  37071. * @param effect defines the current effect
  37072. * @param visibility defines the current visibility state
  37073. * @returns true if one parameter is not cached
  37074. */
  37075. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37076. /**
  37077. * Gets the engine associated with the scene
  37078. * @returns an Engine
  37079. */
  37080. getEngine(): Engine;
  37081. /**
  37082. * Gets the total number of vertices rendered per frame
  37083. * @returns the total number of vertices rendered per frame
  37084. */
  37085. getTotalVertices(): number;
  37086. /**
  37087. * Gets the performance counter for total vertices
  37088. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37089. */
  37090. get totalVerticesPerfCounter(): PerfCounter;
  37091. /**
  37092. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37093. * @returns the total number of active indices rendered per frame
  37094. */
  37095. getActiveIndices(): number;
  37096. /**
  37097. * Gets the performance counter for active indices
  37098. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37099. */
  37100. get totalActiveIndicesPerfCounter(): PerfCounter;
  37101. /**
  37102. * Gets the total number of active particles rendered per frame
  37103. * @returns the total number of active particles rendered per frame
  37104. */
  37105. getActiveParticles(): number;
  37106. /**
  37107. * Gets the performance counter for active particles
  37108. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37109. */
  37110. get activeParticlesPerfCounter(): PerfCounter;
  37111. /**
  37112. * Gets the total number of active bones rendered per frame
  37113. * @returns the total number of active bones rendered per frame
  37114. */
  37115. getActiveBones(): number;
  37116. /**
  37117. * Gets the performance counter for active bones
  37118. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37119. */
  37120. get activeBonesPerfCounter(): PerfCounter;
  37121. /**
  37122. * Gets the array of active meshes
  37123. * @returns an array of AbstractMesh
  37124. */
  37125. getActiveMeshes(): SmartArray<AbstractMesh>;
  37126. /**
  37127. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37128. * @returns a number
  37129. */
  37130. getAnimationRatio(): number;
  37131. /**
  37132. * Gets an unique Id for the current render phase
  37133. * @returns a number
  37134. */
  37135. getRenderId(): number;
  37136. /**
  37137. * Gets an unique Id for the current frame
  37138. * @returns a number
  37139. */
  37140. getFrameId(): number;
  37141. /** Call this function if you want to manually increment the render Id*/
  37142. incrementRenderId(): void;
  37143. private _createUbo;
  37144. /**
  37145. * Use this method to simulate a pointer move on a mesh
  37146. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37147. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37148. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37149. * @returns the current scene
  37150. */
  37151. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37152. /**
  37153. * Use this method to simulate a pointer down on a mesh
  37154. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37155. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37156. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37157. * @returns the current scene
  37158. */
  37159. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37160. /**
  37161. * Use this method to simulate a pointer up on a mesh
  37162. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37163. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37164. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37165. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37166. * @returns the current scene
  37167. */
  37168. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37169. /**
  37170. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37171. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37172. * @returns true if the pointer was captured
  37173. */
  37174. isPointerCaptured(pointerId?: number): boolean;
  37175. /**
  37176. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37177. * @param attachUp defines if you want to attach events to pointerup
  37178. * @param attachDown defines if you want to attach events to pointerdown
  37179. * @param attachMove defines if you want to attach events to pointermove
  37180. */
  37181. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37182. /** Detaches all event handlers*/
  37183. detachControl(): void;
  37184. /**
  37185. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37186. * Delay loaded resources are not taking in account
  37187. * @return true if all required resources are ready
  37188. */
  37189. isReady(): boolean;
  37190. /** Resets all cached information relative to material (including effect and visibility) */
  37191. resetCachedMaterial(): void;
  37192. /**
  37193. * Registers a function to be called before every frame render
  37194. * @param func defines the function to register
  37195. */
  37196. registerBeforeRender(func: () => void): void;
  37197. /**
  37198. * Unregisters a function called before every frame render
  37199. * @param func defines the function to unregister
  37200. */
  37201. unregisterBeforeRender(func: () => void): void;
  37202. /**
  37203. * Registers a function to be called after every frame render
  37204. * @param func defines the function to register
  37205. */
  37206. registerAfterRender(func: () => void): void;
  37207. /**
  37208. * Unregisters a function called after every frame render
  37209. * @param func defines the function to unregister
  37210. */
  37211. unregisterAfterRender(func: () => void): void;
  37212. private _executeOnceBeforeRender;
  37213. /**
  37214. * The provided function will run before render once and will be disposed afterwards.
  37215. * A timeout delay can be provided so that the function will be executed in N ms.
  37216. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37217. * @param func The function to be executed.
  37218. * @param timeout optional delay in ms
  37219. */
  37220. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37221. /** @hidden */
  37222. _addPendingData(data: any): void;
  37223. /** @hidden */
  37224. _removePendingData(data: any): void;
  37225. /**
  37226. * Returns the number of items waiting to be loaded
  37227. * @returns the number of items waiting to be loaded
  37228. */
  37229. getWaitingItemsCount(): number;
  37230. /**
  37231. * Returns a boolean indicating if the scene is still loading data
  37232. */
  37233. get isLoading(): boolean;
  37234. /**
  37235. * Registers a function to be executed when the scene is ready
  37236. * @param {Function} func - the function to be executed
  37237. */
  37238. executeWhenReady(func: () => void): void;
  37239. /**
  37240. * Returns a promise that resolves when the scene is ready
  37241. * @returns A promise that resolves when the scene is ready
  37242. */
  37243. whenReadyAsync(): Promise<void>;
  37244. /** @hidden */
  37245. _checkIsReady(): void;
  37246. /**
  37247. * Gets all animatable attached to the scene
  37248. */
  37249. get animatables(): Animatable[];
  37250. /**
  37251. * Resets the last animation time frame.
  37252. * Useful to override when animations start running when loading a scene for the first time.
  37253. */
  37254. resetLastAnimationTimeFrame(): void;
  37255. /**
  37256. * Gets the current view matrix
  37257. * @returns a Matrix
  37258. */
  37259. getViewMatrix(): Matrix;
  37260. /**
  37261. * Gets the current projection matrix
  37262. * @returns a Matrix
  37263. */
  37264. getProjectionMatrix(): Matrix;
  37265. /**
  37266. * Gets the current transform matrix
  37267. * @returns a Matrix made of View * Projection
  37268. */
  37269. getTransformMatrix(): Matrix;
  37270. /**
  37271. * Sets the current transform matrix
  37272. * @param viewL defines the View matrix to use
  37273. * @param projectionL defines the Projection matrix to use
  37274. * @param viewR defines the right View matrix to use (if provided)
  37275. * @param projectionR defines the right Projection matrix to use (if provided)
  37276. */
  37277. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37278. /**
  37279. * Gets the uniform buffer used to store scene data
  37280. * @returns a UniformBuffer
  37281. */
  37282. getSceneUniformBuffer(): UniformBuffer;
  37283. /**
  37284. * Gets an unique (relatively to the current scene) Id
  37285. * @returns an unique number for the scene
  37286. */
  37287. getUniqueId(): number;
  37288. /**
  37289. * Add a mesh to the list of scene's meshes
  37290. * @param newMesh defines the mesh to add
  37291. * @param recursive if all child meshes should also be added to the scene
  37292. */
  37293. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37294. /**
  37295. * Remove a mesh for the list of scene's meshes
  37296. * @param toRemove defines the mesh to remove
  37297. * @param recursive if all child meshes should also be removed from the scene
  37298. * @returns the index where the mesh was in the mesh list
  37299. */
  37300. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37301. /**
  37302. * Add a transform node to the list of scene's transform nodes
  37303. * @param newTransformNode defines the transform node to add
  37304. */
  37305. addTransformNode(newTransformNode: TransformNode): void;
  37306. /**
  37307. * Remove a transform node for the list of scene's transform nodes
  37308. * @param toRemove defines the transform node to remove
  37309. * @returns the index where the transform node was in the transform node list
  37310. */
  37311. removeTransformNode(toRemove: TransformNode): number;
  37312. /**
  37313. * Remove a skeleton for the list of scene's skeletons
  37314. * @param toRemove defines the skeleton to remove
  37315. * @returns the index where the skeleton was in the skeleton list
  37316. */
  37317. removeSkeleton(toRemove: Skeleton): number;
  37318. /**
  37319. * Remove a morph target for the list of scene's morph targets
  37320. * @param toRemove defines the morph target to remove
  37321. * @returns the index where the morph target was in the morph target list
  37322. */
  37323. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37324. /**
  37325. * Remove a light for the list of scene's lights
  37326. * @param toRemove defines the light to remove
  37327. * @returns the index where the light was in the light list
  37328. */
  37329. removeLight(toRemove: Light): number;
  37330. /**
  37331. * Remove a camera for the list of scene's cameras
  37332. * @param toRemove defines the camera to remove
  37333. * @returns the index where the camera was in the camera list
  37334. */
  37335. removeCamera(toRemove: Camera): number;
  37336. /**
  37337. * Remove a particle system for the list of scene's particle systems
  37338. * @param toRemove defines the particle system to remove
  37339. * @returns the index where the particle system was in the particle system list
  37340. */
  37341. removeParticleSystem(toRemove: IParticleSystem): number;
  37342. /**
  37343. * Remove a animation for the list of scene's animations
  37344. * @param toRemove defines the animation to remove
  37345. * @returns the index where the animation was in the animation list
  37346. */
  37347. removeAnimation(toRemove: Animation): number;
  37348. /**
  37349. * Will stop the animation of the given target
  37350. * @param target - the target
  37351. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37352. * @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)
  37353. */
  37354. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37355. /**
  37356. * Removes the given animation group from this scene.
  37357. * @param toRemove The animation group to remove
  37358. * @returns The index of the removed animation group
  37359. */
  37360. removeAnimationGroup(toRemove: AnimationGroup): number;
  37361. /**
  37362. * Removes the given multi-material from this scene.
  37363. * @param toRemove The multi-material to remove
  37364. * @returns The index of the removed multi-material
  37365. */
  37366. removeMultiMaterial(toRemove: MultiMaterial): number;
  37367. /**
  37368. * Removes the given material from this scene.
  37369. * @param toRemove The material to remove
  37370. * @returns The index of the removed material
  37371. */
  37372. removeMaterial(toRemove: Material): number;
  37373. /**
  37374. * Removes the given action manager from this scene.
  37375. * @param toRemove The action manager to remove
  37376. * @returns The index of the removed action manager
  37377. */
  37378. removeActionManager(toRemove: AbstractActionManager): number;
  37379. /**
  37380. * Removes the given texture from this scene.
  37381. * @param toRemove The texture to remove
  37382. * @returns The index of the removed texture
  37383. */
  37384. removeTexture(toRemove: BaseTexture): number;
  37385. /**
  37386. * Adds the given light to this scene
  37387. * @param newLight The light to add
  37388. */
  37389. addLight(newLight: Light): void;
  37390. /**
  37391. * Sorts the list list based on light priorities
  37392. */
  37393. sortLightsByPriority(): void;
  37394. /**
  37395. * Adds the given camera to this scene
  37396. * @param newCamera The camera to add
  37397. */
  37398. addCamera(newCamera: Camera): void;
  37399. /**
  37400. * Adds the given skeleton to this scene
  37401. * @param newSkeleton The skeleton to add
  37402. */
  37403. addSkeleton(newSkeleton: Skeleton): void;
  37404. /**
  37405. * Adds the given particle system to this scene
  37406. * @param newParticleSystem The particle system to add
  37407. */
  37408. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37409. /**
  37410. * Adds the given animation to this scene
  37411. * @param newAnimation The animation to add
  37412. */
  37413. addAnimation(newAnimation: Animation): void;
  37414. /**
  37415. * Adds the given animation group to this scene.
  37416. * @param newAnimationGroup The animation group to add
  37417. */
  37418. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37419. /**
  37420. * Adds the given multi-material to this scene
  37421. * @param newMultiMaterial The multi-material to add
  37422. */
  37423. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37424. /**
  37425. * Adds the given material to this scene
  37426. * @param newMaterial The material to add
  37427. */
  37428. addMaterial(newMaterial: Material): void;
  37429. /**
  37430. * Adds the given morph target to this scene
  37431. * @param newMorphTargetManager The morph target to add
  37432. */
  37433. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37434. /**
  37435. * Adds the given geometry to this scene
  37436. * @param newGeometry The geometry to add
  37437. */
  37438. addGeometry(newGeometry: Geometry): void;
  37439. /**
  37440. * Adds the given action manager to this scene
  37441. * @param newActionManager The action manager to add
  37442. */
  37443. addActionManager(newActionManager: AbstractActionManager): void;
  37444. /**
  37445. * Adds the given texture to this scene.
  37446. * @param newTexture The texture to add
  37447. */
  37448. addTexture(newTexture: BaseTexture): void;
  37449. /**
  37450. * Switch active camera
  37451. * @param newCamera defines the new active camera
  37452. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37453. */
  37454. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37455. /**
  37456. * sets the active camera of the scene using its ID
  37457. * @param id defines the camera's ID
  37458. * @return the new active camera or null if none found.
  37459. */
  37460. setActiveCameraByID(id: string): Nullable<Camera>;
  37461. /**
  37462. * sets the active camera of the scene using its name
  37463. * @param name defines the camera's name
  37464. * @returns the new active camera or null if none found.
  37465. */
  37466. setActiveCameraByName(name: string): Nullable<Camera>;
  37467. /**
  37468. * get an animation group using its name
  37469. * @param name defines the material's name
  37470. * @return the animation group or null if none found.
  37471. */
  37472. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37473. /**
  37474. * Get a material using its unique id
  37475. * @param uniqueId defines the material's unique id
  37476. * @return the material or null if none found.
  37477. */
  37478. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37479. /**
  37480. * get a material using its id
  37481. * @param id defines the material's ID
  37482. * @return the material or null if none found.
  37483. */
  37484. getMaterialByID(id: string): Nullable<Material>;
  37485. /**
  37486. * Gets a the last added material using a given id
  37487. * @param id defines the material's ID
  37488. * @return the last material with the given id or null if none found.
  37489. */
  37490. getLastMaterialByID(id: string): Nullable<Material>;
  37491. /**
  37492. * Gets a material using its name
  37493. * @param name defines the material's name
  37494. * @return the material or null if none found.
  37495. */
  37496. getMaterialByName(name: string): Nullable<Material>;
  37497. /**
  37498. * Get a texture using its unique id
  37499. * @param uniqueId defines the texture's unique id
  37500. * @return the texture or null if none found.
  37501. */
  37502. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37503. /**
  37504. * Gets a camera using its id
  37505. * @param id defines the id to look for
  37506. * @returns the camera or null if not found
  37507. */
  37508. getCameraByID(id: string): Nullable<Camera>;
  37509. /**
  37510. * Gets a camera using its unique id
  37511. * @param uniqueId defines the unique id to look for
  37512. * @returns the camera or null if not found
  37513. */
  37514. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37515. /**
  37516. * Gets a camera using its name
  37517. * @param name defines the camera's name
  37518. * @return the camera or null if none found.
  37519. */
  37520. getCameraByName(name: string): Nullable<Camera>;
  37521. /**
  37522. * Gets a bone using its id
  37523. * @param id defines the bone's id
  37524. * @return the bone or null if not found
  37525. */
  37526. getBoneByID(id: string): Nullable<Bone>;
  37527. /**
  37528. * Gets a bone using its id
  37529. * @param name defines the bone's name
  37530. * @return the bone or null if not found
  37531. */
  37532. getBoneByName(name: string): Nullable<Bone>;
  37533. /**
  37534. * Gets a light node using its name
  37535. * @param name defines the the light's name
  37536. * @return the light or null if none found.
  37537. */
  37538. getLightByName(name: string): Nullable<Light>;
  37539. /**
  37540. * Gets a light node using its id
  37541. * @param id defines the light's id
  37542. * @return the light or null if none found.
  37543. */
  37544. getLightByID(id: string): Nullable<Light>;
  37545. /**
  37546. * Gets a light node using its scene-generated unique ID
  37547. * @param uniqueId defines the light's unique id
  37548. * @return the light or null if none found.
  37549. */
  37550. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37551. /**
  37552. * Gets a particle system by id
  37553. * @param id defines the particle system id
  37554. * @return the corresponding system or null if none found
  37555. */
  37556. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37557. /**
  37558. * Gets a geometry using its ID
  37559. * @param id defines the geometry's id
  37560. * @return the geometry or null if none found.
  37561. */
  37562. getGeometryByID(id: string): Nullable<Geometry>;
  37563. private _getGeometryByUniqueID;
  37564. /**
  37565. * Add a new geometry to this scene
  37566. * @param geometry defines the geometry to be added to the scene.
  37567. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37568. * @return a boolean defining if the geometry was added or not
  37569. */
  37570. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37571. /**
  37572. * Removes an existing geometry
  37573. * @param geometry defines the geometry to be removed from the scene
  37574. * @return a boolean defining if the geometry was removed or not
  37575. */
  37576. removeGeometry(geometry: Geometry): boolean;
  37577. /**
  37578. * Gets the list of geometries attached to the scene
  37579. * @returns an array of Geometry
  37580. */
  37581. getGeometries(): Geometry[];
  37582. /**
  37583. * Gets the first added mesh found of a given ID
  37584. * @param id defines the id to search for
  37585. * @return the mesh found or null if not found at all
  37586. */
  37587. getMeshByID(id: string): Nullable<AbstractMesh>;
  37588. /**
  37589. * Gets a list of meshes using their id
  37590. * @param id defines the id to search for
  37591. * @returns a list of meshes
  37592. */
  37593. getMeshesByID(id: string): Array<AbstractMesh>;
  37594. /**
  37595. * Gets the first added transform node found of a given ID
  37596. * @param id defines the id to search for
  37597. * @return the found transform node or null if not found at all.
  37598. */
  37599. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37600. /**
  37601. * Gets a transform node with its auto-generated unique id
  37602. * @param uniqueId efines the unique id to search for
  37603. * @return the found transform node or null if not found at all.
  37604. */
  37605. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37606. /**
  37607. * Gets a list of transform nodes using their id
  37608. * @param id defines the id to search for
  37609. * @returns a list of transform nodes
  37610. */
  37611. getTransformNodesByID(id: string): Array<TransformNode>;
  37612. /**
  37613. * Gets a mesh with its auto-generated unique id
  37614. * @param uniqueId defines the unique id to search for
  37615. * @return the found mesh or null if not found at all.
  37616. */
  37617. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37618. /**
  37619. * Gets a the last added mesh using a given id
  37620. * @param id defines the id to search for
  37621. * @return the found mesh or null if not found at all.
  37622. */
  37623. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37624. /**
  37625. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37626. * @param id defines the id to search for
  37627. * @return the found node or null if not found at all
  37628. */
  37629. getLastEntryByID(id: string): Nullable<Node>;
  37630. /**
  37631. * Gets a node (Mesh, Camera, Light) using a given id
  37632. * @param id defines the id to search for
  37633. * @return the found node or null if not found at all
  37634. */
  37635. getNodeByID(id: string): Nullable<Node>;
  37636. /**
  37637. * Gets a node (Mesh, Camera, Light) using a given name
  37638. * @param name defines the name to search for
  37639. * @return the found node or null if not found at all.
  37640. */
  37641. getNodeByName(name: string): Nullable<Node>;
  37642. /**
  37643. * Gets a mesh using a given name
  37644. * @param name defines the name to search for
  37645. * @return the found mesh or null if not found at all.
  37646. */
  37647. getMeshByName(name: string): Nullable<AbstractMesh>;
  37648. /**
  37649. * Gets a transform node using a given name
  37650. * @param name defines the name to search for
  37651. * @return the found transform node or null if not found at all.
  37652. */
  37653. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37654. /**
  37655. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37656. * @param id defines the id to search for
  37657. * @return the found skeleton or null if not found at all.
  37658. */
  37659. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37660. /**
  37661. * Gets a skeleton using a given auto generated unique id
  37662. * @param uniqueId defines the unique id to search for
  37663. * @return the found skeleton or null if not found at all.
  37664. */
  37665. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37666. /**
  37667. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37668. * @param id defines the id to search for
  37669. * @return the found skeleton or null if not found at all.
  37670. */
  37671. getSkeletonById(id: string): Nullable<Skeleton>;
  37672. /**
  37673. * Gets a skeleton using a given name
  37674. * @param name defines the name to search for
  37675. * @return the found skeleton or null if not found at all.
  37676. */
  37677. getSkeletonByName(name: string): Nullable<Skeleton>;
  37678. /**
  37679. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37680. * @param id defines the id to search for
  37681. * @return the found morph target manager or null if not found at all.
  37682. */
  37683. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37684. /**
  37685. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37686. * @param id defines the id to search for
  37687. * @return the found morph target or null if not found at all.
  37688. */
  37689. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37690. /**
  37691. * Gets a boolean indicating if the given mesh is active
  37692. * @param mesh defines the mesh to look for
  37693. * @returns true if the mesh is in the active list
  37694. */
  37695. isActiveMesh(mesh: AbstractMesh): boolean;
  37696. /**
  37697. * Return a unique id as a string which can serve as an identifier for the scene
  37698. */
  37699. get uid(): string;
  37700. /**
  37701. * Add an externaly attached data from its key.
  37702. * This method call will fail and return false, if such key already exists.
  37703. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37704. * @param key the unique key that identifies the data
  37705. * @param data the data object to associate to the key for this Engine instance
  37706. * @return true if no such key were already present and the data was added successfully, false otherwise
  37707. */
  37708. addExternalData<T>(key: string, data: T): boolean;
  37709. /**
  37710. * Get an externaly attached data from its key
  37711. * @param key the unique key that identifies the data
  37712. * @return the associated data, if present (can be null), or undefined if not present
  37713. */
  37714. getExternalData<T>(key: string): Nullable<T>;
  37715. /**
  37716. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37717. * @param key the unique key that identifies the data
  37718. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37719. * @return the associated data, can be null if the factory returned null.
  37720. */
  37721. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37722. /**
  37723. * Remove an externaly attached data from the Engine instance
  37724. * @param key the unique key that identifies the data
  37725. * @return true if the data was successfully removed, false if it doesn't exist
  37726. */
  37727. removeExternalData(key: string): boolean;
  37728. private _evaluateSubMesh;
  37729. /**
  37730. * Clear the processed materials smart array preventing retention point in material dispose.
  37731. */
  37732. freeProcessedMaterials(): void;
  37733. private _preventFreeActiveMeshesAndRenderingGroups;
  37734. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37735. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37736. * when disposing several meshes in a row or a hierarchy of meshes.
  37737. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37738. */
  37739. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37740. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37741. /**
  37742. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37743. */
  37744. freeActiveMeshes(): void;
  37745. /**
  37746. * Clear the info related to rendering groups preventing retention points during dispose.
  37747. */
  37748. freeRenderingGroups(): void;
  37749. /** @hidden */
  37750. _isInIntermediateRendering(): boolean;
  37751. /**
  37752. * Lambda returning the list of potentially active meshes.
  37753. */
  37754. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37755. /**
  37756. * Lambda returning the list of potentially active sub meshes.
  37757. */
  37758. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37759. /**
  37760. * Lambda returning the list of potentially intersecting sub meshes.
  37761. */
  37762. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37763. /**
  37764. * Lambda returning the list of potentially colliding sub meshes.
  37765. */
  37766. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37767. private _activeMeshesFrozen;
  37768. private _skipEvaluateActiveMeshesCompletely;
  37769. /**
  37770. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37771. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37772. * @returns the current scene
  37773. */
  37774. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37775. /**
  37776. * Use this function to restart evaluating active meshes on every frame
  37777. * @returns the current scene
  37778. */
  37779. unfreezeActiveMeshes(): Scene;
  37780. private _evaluateActiveMeshes;
  37781. private _activeMesh;
  37782. /**
  37783. * Update the transform matrix to update from the current active camera
  37784. * @param force defines a boolean used to force the update even if cache is up to date
  37785. */
  37786. updateTransformMatrix(force?: boolean): void;
  37787. private _bindFrameBuffer;
  37788. /** @hidden */
  37789. _allowPostProcessClearColor: boolean;
  37790. /** @hidden */
  37791. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37792. private _processSubCameras;
  37793. private _checkIntersections;
  37794. /** @hidden */
  37795. _advancePhysicsEngineStep(step: number): void;
  37796. /**
  37797. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37798. */
  37799. getDeterministicFrameTime: () => number;
  37800. /** @hidden */
  37801. _animate(): void;
  37802. /** Execute all animations (for a frame) */
  37803. animate(): void;
  37804. /**
  37805. * Render the scene
  37806. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37807. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37808. */
  37809. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37810. /**
  37811. * Freeze all materials
  37812. * A frozen material will not be updatable but should be faster to render
  37813. */
  37814. freezeMaterials(): void;
  37815. /**
  37816. * Unfreeze all materials
  37817. * A frozen material will not be updatable but should be faster to render
  37818. */
  37819. unfreezeMaterials(): void;
  37820. /**
  37821. * Releases all held ressources
  37822. */
  37823. dispose(): void;
  37824. /**
  37825. * Gets if the scene is already disposed
  37826. */
  37827. get isDisposed(): boolean;
  37828. /**
  37829. * Call this function to reduce memory footprint of the scene.
  37830. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37831. */
  37832. clearCachedVertexData(): void;
  37833. /**
  37834. * This function will remove the local cached buffer data from texture.
  37835. * It will save memory but will prevent the texture from being rebuilt
  37836. */
  37837. cleanCachedTextureBuffer(): void;
  37838. /**
  37839. * Get the world extend vectors with an optional filter
  37840. *
  37841. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37842. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37843. */
  37844. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37845. min: Vector3;
  37846. max: Vector3;
  37847. };
  37848. /**
  37849. * Creates a ray that can be used to pick in the scene
  37850. * @param x defines the x coordinate of the origin (on-screen)
  37851. * @param y defines the y coordinate of the origin (on-screen)
  37852. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37853. * @param camera defines the camera to use for the picking
  37854. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37855. * @returns a Ray
  37856. */
  37857. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37858. /**
  37859. * Creates a ray that can be used to pick in the scene
  37860. * @param x defines the x coordinate of the origin (on-screen)
  37861. * @param y defines the y coordinate of the origin (on-screen)
  37862. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37863. * @param result defines the ray where to store the picking ray
  37864. * @param camera defines the camera to use for the picking
  37865. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37866. * @returns the current scene
  37867. */
  37868. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37869. /**
  37870. * Creates a ray that can be used to pick in the scene
  37871. * @param x defines the x coordinate of the origin (on-screen)
  37872. * @param y defines the y coordinate of the origin (on-screen)
  37873. * @param camera defines the camera to use for the picking
  37874. * @returns a Ray
  37875. */
  37876. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37877. /**
  37878. * Creates a ray that can be used to pick in the scene
  37879. * @param x defines the x coordinate of the origin (on-screen)
  37880. * @param y defines the y coordinate of the origin (on-screen)
  37881. * @param result defines the ray where to store the picking ray
  37882. * @param camera defines the camera to use for the picking
  37883. * @returns the current scene
  37884. */
  37885. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37886. /** Launch a ray to try to pick a mesh in the scene
  37887. * @param x position on screen
  37888. * @param y position on screen
  37889. * @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
  37890. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37891. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37892. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37893. * @returns a PickingInfo
  37894. */
  37895. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37896. /** Use the given ray to pick a mesh in the scene
  37897. * @param ray The ray to use to pick meshes
  37898. * @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
  37899. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37900. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37901. * @returns a PickingInfo
  37902. */
  37903. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37904. /**
  37905. * Launch a ray to try to pick a mesh in the scene
  37906. * @param x X position on screen
  37907. * @param y Y position on screen
  37908. * @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
  37909. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37910. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37911. * @returns an array of PickingInfo
  37912. */
  37913. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37914. /**
  37915. * Launch a ray to try to pick a mesh in the scene
  37916. * @param ray Ray to use
  37917. * @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
  37918. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37919. * @returns an array of PickingInfo
  37920. */
  37921. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37922. /**
  37923. * Force the value of meshUnderPointer
  37924. * @param mesh defines the mesh to use
  37925. */
  37926. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37927. /**
  37928. * Gets the mesh under the pointer
  37929. * @returns a Mesh or null if no mesh is under the pointer
  37930. */
  37931. getPointerOverMesh(): Nullable<AbstractMesh>;
  37932. /** @hidden */
  37933. _rebuildGeometries(): void;
  37934. /** @hidden */
  37935. _rebuildTextures(): void;
  37936. private _getByTags;
  37937. /**
  37938. * Get a list of meshes by tags
  37939. * @param tagsQuery defines the tags query to use
  37940. * @param forEach defines a predicate used to filter results
  37941. * @returns an array of Mesh
  37942. */
  37943. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37944. /**
  37945. * Get a list of cameras by tags
  37946. * @param tagsQuery defines the tags query to use
  37947. * @param forEach defines a predicate used to filter results
  37948. * @returns an array of Camera
  37949. */
  37950. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37951. /**
  37952. * Get a list of lights by tags
  37953. * @param tagsQuery defines the tags query to use
  37954. * @param forEach defines a predicate used to filter results
  37955. * @returns an array of Light
  37956. */
  37957. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37958. /**
  37959. * Get a list of materials by tags
  37960. * @param tagsQuery defines the tags query to use
  37961. * @param forEach defines a predicate used to filter results
  37962. * @returns an array of Material
  37963. */
  37964. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37965. /**
  37966. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37967. * This allowed control for front to back rendering or reversly depending of the special needs.
  37968. *
  37969. * @param renderingGroupId The rendering group id corresponding to its index
  37970. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37971. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37972. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37973. */
  37974. 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;
  37975. /**
  37976. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37977. *
  37978. * @param renderingGroupId The rendering group id corresponding to its index
  37979. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37980. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37981. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37982. */
  37983. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37984. /**
  37985. * Gets the current auto clear configuration for one rendering group of the rendering
  37986. * manager.
  37987. * @param index the rendering group index to get the information for
  37988. * @returns The auto clear setup for the requested rendering group
  37989. */
  37990. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37991. private _blockMaterialDirtyMechanism;
  37992. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37993. get blockMaterialDirtyMechanism(): boolean;
  37994. set blockMaterialDirtyMechanism(value: boolean);
  37995. /**
  37996. * Will flag all materials as dirty to trigger new shader compilation
  37997. * @param flag defines the flag used to specify which material part must be marked as dirty
  37998. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37999. */
  38000. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38001. /** @hidden */
  38002. _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;
  38003. /** @hidden */
  38004. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38005. /** @hidden */
  38006. _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;
  38007. /** @hidden */
  38008. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38009. /** @hidden */
  38010. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38011. /** @hidden */
  38012. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38013. }
  38014. }
  38015. declare module "babylonjs/assetContainer" {
  38016. import { AbstractScene } from "babylonjs/abstractScene";
  38017. import { Scene } from "babylonjs/scene";
  38018. import { Mesh } from "babylonjs/Meshes/mesh";
  38019. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38020. import { Skeleton } from "babylonjs/Bones/skeleton";
  38021. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38022. import { Animatable } from "babylonjs/Animations/animatable";
  38023. import { Nullable } from "babylonjs/types";
  38024. import { Node } from "babylonjs/node";
  38025. /**
  38026. * Set of assets to keep when moving a scene into an asset container.
  38027. */
  38028. export class KeepAssets extends AbstractScene {
  38029. }
  38030. /**
  38031. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38032. */
  38033. export class InstantiatedEntries {
  38034. /**
  38035. * List of new root nodes (eg. nodes with no parent)
  38036. */
  38037. rootNodes: TransformNode[];
  38038. /**
  38039. * List of new skeletons
  38040. */
  38041. skeletons: Skeleton[];
  38042. /**
  38043. * List of new animation groups
  38044. */
  38045. animationGroups: AnimationGroup[];
  38046. }
  38047. /**
  38048. * Container with a set of assets that can be added or removed from a scene.
  38049. */
  38050. export class AssetContainer extends AbstractScene {
  38051. private _wasAddedToScene;
  38052. /**
  38053. * The scene the AssetContainer belongs to.
  38054. */
  38055. scene: Scene;
  38056. /**
  38057. * Instantiates an AssetContainer.
  38058. * @param scene The scene the AssetContainer belongs to.
  38059. */
  38060. constructor(scene: Scene);
  38061. /**
  38062. * Instantiate or clone all meshes and add the new ones to the scene.
  38063. * Skeletons and animation groups will all be cloned
  38064. * @param nameFunction defines an optional function used to get new names for clones
  38065. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38066. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38067. */
  38068. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38069. /**
  38070. * Adds all the assets from the container to the scene.
  38071. */
  38072. addAllToScene(): void;
  38073. /**
  38074. * Removes all the assets in the container from the scene
  38075. */
  38076. removeAllFromScene(): void;
  38077. /**
  38078. * Disposes all the assets in the container
  38079. */
  38080. dispose(): void;
  38081. private _moveAssets;
  38082. /**
  38083. * Removes all the assets contained in the scene and adds them to the container.
  38084. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38085. */
  38086. moveAllFromScene(keepAssets?: KeepAssets): void;
  38087. /**
  38088. * 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.
  38089. * @returns the root mesh
  38090. */
  38091. createRootMesh(): Mesh;
  38092. /**
  38093. * Merge animations from this asset container into a scene
  38094. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38095. * @param animatables set of animatables to retarget to a node from the scene
  38096. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38097. */
  38098. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38099. }
  38100. }
  38101. declare module "babylonjs/abstractScene" {
  38102. import { Scene } from "babylonjs/scene";
  38103. import { Nullable } from "babylonjs/types";
  38104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38105. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38106. import { Geometry } from "babylonjs/Meshes/geometry";
  38107. import { Skeleton } from "babylonjs/Bones/skeleton";
  38108. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38109. import { AssetContainer } from "babylonjs/assetContainer";
  38110. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38111. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38112. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38113. import { Material } from "babylonjs/Materials/material";
  38114. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38115. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38116. import { Camera } from "babylonjs/Cameras/camera";
  38117. import { Light } from "babylonjs/Lights/light";
  38118. import { Node } from "babylonjs/node";
  38119. import { Animation } from "babylonjs/Animations/animation";
  38120. /**
  38121. * Defines how the parser contract is defined.
  38122. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38123. */
  38124. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38125. /**
  38126. * Defines how the individual parser contract is defined.
  38127. * These parser can parse an individual asset
  38128. */
  38129. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38130. /**
  38131. * Base class of the scene acting as a container for the different elements composing a scene.
  38132. * This class is dynamically extended by the different components of the scene increasing
  38133. * flexibility and reducing coupling
  38134. */
  38135. export abstract class AbstractScene {
  38136. /**
  38137. * Stores the list of available parsers in the application.
  38138. */
  38139. private static _BabylonFileParsers;
  38140. /**
  38141. * Stores the list of available individual parsers in the application.
  38142. */
  38143. private static _IndividualBabylonFileParsers;
  38144. /**
  38145. * Adds a parser in the list of available ones
  38146. * @param name Defines the name of the parser
  38147. * @param parser Defines the parser to add
  38148. */
  38149. static AddParser(name: string, parser: BabylonFileParser): void;
  38150. /**
  38151. * Gets a general parser from the list of avaialble ones
  38152. * @param name Defines the name of the parser
  38153. * @returns the requested parser or null
  38154. */
  38155. static GetParser(name: string): Nullable<BabylonFileParser>;
  38156. /**
  38157. * Adds n individual parser in the list of available ones
  38158. * @param name Defines the name of the parser
  38159. * @param parser Defines the parser to add
  38160. */
  38161. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38162. /**
  38163. * Gets an individual parser from the list of avaialble ones
  38164. * @param name Defines the name of the parser
  38165. * @returns the requested parser or null
  38166. */
  38167. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38168. /**
  38169. * Parser json data and populate both a scene and its associated container object
  38170. * @param jsonData Defines the data to parse
  38171. * @param scene Defines the scene to parse the data for
  38172. * @param container Defines the container attached to the parsing sequence
  38173. * @param rootUrl Defines the root url of the data
  38174. */
  38175. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38176. /**
  38177. * Gets the list of root nodes (ie. nodes with no parent)
  38178. */
  38179. rootNodes: Node[];
  38180. /** All of the cameras added to this scene
  38181. * @see http://doc.babylonjs.com/babylon101/cameras
  38182. */
  38183. cameras: Camera[];
  38184. /**
  38185. * All of the lights added to this scene
  38186. * @see http://doc.babylonjs.com/babylon101/lights
  38187. */
  38188. lights: Light[];
  38189. /**
  38190. * All of the (abstract) meshes added to this scene
  38191. */
  38192. meshes: AbstractMesh[];
  38193. /**
  38194. * The list of skeletons added to the scene
  38195. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38196. */
  38197. skeletons: Skeleton[];
  38198. /**
  38199. * All of the particle systems added to this scene
  38200. * @see http://doc.babylonjs.com/babylon101/particles
  38201. */
  38202. particleSystems: IParticleSystem[];
  38203. /**
  38204. * Gets a list of Animations associated with the scene
  38205. */
  38206. animations: Animation[];
  38207. /**
  38208. * All of the animation groups added to this scene
  38209. * @see http://doc.babylonjs.com/how_to/group
  38210. */
  38211. animationGroups: AnimationGroup[];
  38212. /**
  38213. * All of the multi-materials added to this scene
  38214. * @see http://doc.babylonjs.com/how_to/multi_materials
  38215. */
  38216. multiMaterials: MultiMaterial[];
  38217. /**
  38218. * All of the materials added to this scene
  38219. * In the context of a Scene, it is not supposed to be modified manually.
  38220. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38221. * Note also that the order of the Material within the array is not significant and might change.
  38222. * @see http://doc.babylonjs.com/babylon101/materials
  38223. */
  38224. materials: Material[];
  38225. /**
  38226. * The list of morph target managers added to the scene
  38227. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38228. */
  38229. morphTargetManagers: MorphTargetManager[];
  38230. /**
  38231. * The list of geometries used in the scene.
  38232. */
  38233. geometries: Geometry[];
  38234. /**
  38235. * All of the tranform nodes added to this scene
  38236. * In the context of a Scene, it is not supposed to be modified manually.
  38237. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38238. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38239. * @see http://doc.babylonjs.com/how_to/transformnode
  38240. */
  38241. transformNodes: TransformNode[];
  38242. /**
  38243. * ActionManagers available on the scene.
  38244. */
  38245. actionManagers: AbstractActionManager[];
  38246. /**
  38247. * Textures to keep.
  38248. */
  38249. textures: BaseTexture[];
  38250. /**
  38251. * Environment texture for the scene
  38252. */
  38253. environmentTexture: Nullable<BaseTexture>;
  38254. /**
  38255. * @returns all meshes, lights, cameras, transformNodes and bones
  38256. */
  38257. getNodes(): Array<Node>;
  38258. }
  38259. }
  38260. declare module "babylonjs/Audio/sound" {
  38261. import { Observable } from "babylonjs/Misc/observable";
  38262. import { Vector3 } from "babylonjs/Maths/math.vector";
  38263. import { Nullable } from "babylonjs/types";
  38264. import { Scene } from "babylonjs/scene";
  38265. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38266. /**
  38267. * Interface used to define options for Sound class
  38268. */
  38269. export interface ISoundOptions {
  38270. /**
  38271. * Does the sound autoplay once loaded.
  38272. */
  38273. autoplay?: boolean;
  38274. /**
  38275. * Does the sound loop after it finishes playing once.
  38276. */
  38277. loop?: boolean;
  38278. /**
  38279. * Sound's volume
  38280. */
  38281. volume?: number;
  38282. /**
  38283. * Is it a spatial sound?
  38284. */
  38285. spatialSound?: boolean;
  38286. /**
  38287. * Maximum distance to hear that sound
  38288. */
  38289. maxDistance?: number;
  38290. /**
  38291. * Uses user defined attenuation function
  38292. */
  38293. useCustomAttenuation?: boolean;
  38294. /**
  38295. * Define the roll off factor of spatial sounds.
  38296. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38297. */
  38298. rolloffFactor?: number;
  38299. /**
  38300. * Define the reference distance the sound should be heard perfectly.
  38301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38302. */
  38303. refDistance?: number;
  38304. /**
  38305. * Define the distance attenuation model the sound will follow.
  38306. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38307. */
  38308. distanceModel?: string;
  38309. /**
  38310. * Defines the playback speed (1 by default)
  38311. */
  38312. playbackRate?: number;
  38313. /**
  38314. * Defines if the sound is from a streaming source
  38315. */
  38316. streaming?: boolean;
  38317. /**
  38318. * Defines an optional length (in seconds) inside the sound file
  38319. */
  38320. length?: number;
  38321. /**
  38322. * Defines an optional offset (in seconds) inside the sound file
  38323. */
  38324. offset?: number;
  38325. /**
  38326. * If true, URLs will not be required to state the audio file codec to use.
  38327. */
  38328. skipCodecCheck?: boolean;
  38329. }
  38330. /**
  38331. * Defines a sound that can be played in the application.
  38332. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38333. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38334. */
  38335. export class Sound {
  38336. /**
  38337. * The name of the sound in the scene.
  38338. */
  38339. name: string;
  38340. /**
  38341. * Does the sound autoplay once loaded.
  38342. */
  38343. autoplay: boolean;
  38344. /**
  38345. * Does the sound loop after it finishes playing once.
  38346. */
  38347. loop: boolean;
  38348. /**
  38349. * Does the sound use a custom attenuation curve to simulate the falloff
  38350. * happening when the source gets further away from the camera.
  38351. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38352. */
  38353. useCustomAttenuation: boolean;
  38354. /**
  38355. * The sound track id this sound belongs to.
  38356. */
  38357. soundTrackId: number;
  38358. /**
  38359. * Is this sound currently played.
  38360. */
  38361. isPlaying: boolean;
  38362. /**
  38363. * Is this sound currently paused.
  38364. */
  38365. isPaused: boolean;
  38366. /**
  38367. * Does this sound enables spatial sound.
  38368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38369. */
  38370. spatialSound: boolean;
  38371. /**
  38372. * Define the reference distance the sound should be heard perfectly.
  38373. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38374. */
  38375. refDistance: number;
  38376. /**
  38377. * Define the roll off factor of spatial sounds.
  38378. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38379. */
  38380. rolloffFactor: number;
  38381. /**
  38382. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38383. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38384. */
  38385. maxDistance: number;
  38386. /**
  38387. * Define the distance attenuation model the sound will follow.
  38388. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38389. */
  38390. distanceModel: string;
  38391. /**
  38392. * @hidden
  38393. * Back Compat
  38394. **/
  38395. onended: () => any;
  38396. /**
  38397. * Observable event when the current playing sound finishes.
  38398. */
  38399. onEndedObservable: Observable<Sound>;
  38400. private _panningModel;
  38401. private _playbackRate;
  38402. private _streaming;
  38403. private _startTime;
  38404. private _startOffset;
  38405. private _position;
  38406. /** @hidden */
  38407. _positionInEmitterSpace: boolean;
  38408. private _localDirection;
  38409. private _volume;
  38410. private _isReadyToPlay;
  38411. private _isDirectional;
  38412. private _readyToPlayCallback;
  38413. private _audioBuffer;
  38414. private _soundSource;
  38415. private _streamingSource;
  38416. private _soundPanner;
  38417. private _soundGain;
  38418. private _inputAudioNode;
  38419. private _outputAudioNode;
  38420. private _coneInnerAngle;
  38421. private _coneOuterAngle;
  38422. private _coneOuterGain;
  38423. private _scene;
  38424. private _connectedTransformNode;
  38425. private _customAttenuationFunction;
  38426. private _registerFunc;
  38427. private _isOutputConnected;
  38428. private _htmlAudioElement;
  38429. private _urlType;
  38430. private _length?;
  38431. private _offset?;
  38432. /** @hidden */
  38433. static _SceneComponentInitialization: (scene: Scene) => void;
  38434. /**
  38435. * Create a sound and attach it to a scene
  38436. * @param name Name of your sound
  38437. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38438. * @param scene defines the scene the sound belongs to
  38439. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38440. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38441. */
  38442. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38443. /**
  38444. * Release the sound and its associated resources
  38445. */
  38446. dispose(): void;
  38447. /**
  38448. * Gets if the sounds is ready to be played or not.
  38449. * @returns true if ready, otherwise false
  38450. */
  38451. isReady(): boolean;
  38452. private _soundLoaded;
  38453. /**
  38454. * Sets the data of the sound from an audiobuffer
  38455. * @param audioBuffer The audioBuffer containing the data
  38456. */
  38457. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38458. /**
  38459. * Updates the current sounds options such as maxdistance, loop...
  38460. * @param options A JSON object containing values named as the object properties
  38461. */
  38462. updateOptions(options: ISoundOptions): void;
  38463. private _createSpatialParameters;
  38464. private _updateSpatialParameters;
  38465. /**
  38466. * Switch the panning model to HRTF:
  38467. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38468. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38469. */
  38470. switchPanningModelToHRTF(): void;
  38471. /**
  38472. * Switch the panning model to Equal Power:
  38473. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38475. */
  38476. switchPanningModelToEqualPower(): void;
  38477. private _switchPanningModel;
  38478. /**
  38479. * Connect this sound to a sound track audio node like gain...
  38480. * @param soundTrackAudioNode the sound track audio node to connect to
  38481. */
  38482. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38483. /**
  38484. * Transform this sound into a directional source
  38485. * @param coneInnerAngle Size of the inner cone in degree
  38486. * @param coneOuterAngle Size of the outer cone in degree
  38487. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38488. */
  38489. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38490. /**
  38491. * Gets or sets the inner angle for the directional cone.
  38492. */
  38493. get directionalConeInnerAngle(): number;
  38494. /**
  38495. * Gets or sets the inner angle for the directional cone.
  38496. */
  38497. set directionalConeInnerAngle(value: number);
  38498. /**
  38499. * Gets or sets the outer angle for the directional cone.
  38500. */
  38501. get directionalConeOuterAngle(): number;
  38502. /**
  38503. * Gets or sets the outer angle for the directional cone.
  38504. */
  38505. set directionalConeOuterAngle(value: number);
  38506. /**
  38507. * Sets the position of the emitter if spatial sound is enabled
  38508. * @param newPosition Defines the new posisiton
  38509. */
  38510. setPosition(newPosition: Vector3): void;
  38511. /**
  38512. * Sets the local direction of the emitter if spatial sound is enabled
  38513. * @param newLocalDirection Defines the new local direction
  38514. */
  38515. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38516. private _updateDirection;
  38517. /** @hidden */
  38518. updateDistanceFromListener(): void;
  38519. /**
  38520. * Sets a new custom attenuation function for the sound.
  38521. * @param callback Defines the function used for the attenuation
  38522. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38523. */
  38524. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38525. /**
  38526. * Play the sound
  38527. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38528. * @param offset (optional) Start the sound at a specific time in seconds
  38529. * @param length (optional) Sound duration (in seconds)
  38530. */
  38531. play(time?: number, offset?: number, length?: number): void;
  38532. private _onended;
  38533. /**
  38534. * Stop the sound
  38535. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38536. */
  38537. stop(time?: number): void;
  38538. /**
  38539. * Put the sound in pause
  38540. */
  38541. pause(): void;
  38542. /**
  38543. * Sets a dedicated volume for this sounds
  38544. * @param newVolume Define the new volume of the sound
  38545. * @param time Define time for gradual change to new volume
  38546. */
  38547. setVolume(newVolume: number, time?: number): void;
  38548. /**
  38549. * Set the sound play back rate
  38550. * @param newPlaybackRate Define the playback rate the sound should be played at
  38551. */
  38552. setPlaybackRate(newPlaybackRate: number): void;
  38553. /**
  38554. * Gets the volume of the sound.
  38555. * @returns the volume of the sound
  38556. */
  38557. getVolume(): number;
  38558. /**
  38559. * Attach the sound to a dedicated mesh
  38560. * @param transformNode The transform node to connect the sound with
  38561. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38562. */
  38563. attachToMesh(transformNode: TransformNode): void;
  38564. /**
  38565. * Detach the sound from the previously attached mesh
  38566. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38567. */
  38568. detachFromMesh(): void;
  38569. private _onRegisterAfterWorldMatrixUpdate;
  38570. /**
  38571. * Clone the current sound in the scene.
  38572. * @returns the new sound clone
  38573. */
  38574. clone(): Nullable<Sound>;
  38575. /**
  38576. * Gets the current underlying audio buffer containing the data
  38577. * @returns the audio buffer
  38578. */
  38579. getAudioBuffer(): Nullable<AudioBuffer>;
  38580. /**
  38581. * Serializes the Sound in a JSON representation
  38582. * @returns the JSON representation of the sound
  38583. */
  38584. serialize(): any;
  38585. /**
  38586. * Parse a JSON representation of a sound to innstantiate in a given scene
  38587. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38588. * @param scene Define the scene the new parsed sound should be created in
  38589. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38590. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38591. * @returns the newly parsed sound
  38592. */
  38593. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38594. }
  38595. }
  38596. declare module "babylonjs/Actions/directAudioActions" {
  38597. import { Action } from "babylonjs/Actions/action";
  38598. import { Condition } from "babylonjs/Actions/condition";
  38599. import { Sound } from "babylonjs/Audio/sound";
  38600. /**
  38601. * This defines an action helpful to play a defined sound on a triggered action.
  38602. */
  38603. export class PlaySoundAction extends Action {
  38604. private _sound;
  38605. /**
  38606. * Instantiate the action
  38607. * @param triggerOptions defines the trigger options
  38608. * @param sound defines the sound to play
  38609. * @param condition defines the trigger related conditions
  38610. */
  38611. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38612. /** @hidden */
  38613. _prepare(): void;
  38614. /**
  38615. * Execute the action and play the sound.
  38616. */
  38617. execute(): void;
  38618. /**
  38619. * Serializes the actions and its related information.
  38620. * @param parent defines the object to serialize in
  38621. * @returns the serialized object
  38622. */
  38623. serialize(parent: any): any;
  38624. }
  38625. /**
  38626. * This defines an action helpful to stop a defined sound on a triggered action.
  38627. */
  38628. export class StopSoundAction extends Action {
  38629. private _sound;
  38630. /**
  38631. * Instantiate the action
  38632. * @param triggerOptions defines the trigger options
  38633. * @param sound defines the sound to stop
  38634. * @param condition defines the trigger related conditions
  38635. */
  38636. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38637. /** @hidden */
  38638. _prepare(): void;
  38639. /**
  38640. * Execute the action and stop the sound.
  38641. */
  38642. execute(): void;
  38643. /**
  38644. * Serializes the actions and its related information.
  38645. * @param parent defines the object to serialize in
  38646. * @returns the serialized object
  38647. */
  38648. serialize(parent: any): any;
  38649. }
  38650. }
  38651. declare module "babylonjs/Actions/interpolateValueAction" {
  38652. import { Action } from "babylonjs/Actions/action";
  38653. import { Condition } from "babylonjs/Actions/condition";
  38654. import { Observable } from "babylonjs/Misc/observable";
  38655. /**
  38656. * This defines an action responsible to change the value of a property
  38657. * by interpolating between its current value and the newly set one once triggered.
  38658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38659. */
  38660. export class InterpolateValueAction extends Action {
  38661. /**
  38662. * Defines the path of the property where the value should be interpolated
  38663. */
  38664. propertyPath: string;
  38665. /**
  38666. * Defines the target value at the end of the interpolation.
  38667. */
  38668. value: any;
  38669. /**
  38670. * Defines the time it will take for the property to interpolate to the value.
  38671. */
  38672. duration: number;
  38673. /**
  38674. * Defines if the other scene animations should be stopped when the action has been triggered
  38675. */
  38676. stopOtherAnimations?: boolean;
  38677. /**
  38678. * Defines a callback raised once the interpolation animation has been done.
  38679. */
  38680. onInterpolationDone?: () => void;
  38681. /**
  38682. * Observable triggered once the interpolation animation has been done.
  38683. */
  38684. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38685. private _target;
  38686. private _effectiveTarget;
  38687. private _property;
  38688. /**
  38689. * Instantiate the action
  38690. * @param triggerOptions defines the trigger options
  38691. * @param target defines the object containing the value to interpolate
  38692. * @param propertyPath defines the path to the property in the target object
  38693. * @param value defines the target value at the end of the interpolation
  38694. * @param duration deines the time it will take for the property to interpolate to the value.
  38695. * @param condition defines the trigger related conditions
  38696. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38697. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38698. */
  38699. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38700. /** @hidden */
  38701. _prepare(): void;
  38702. /**
  38703. * Execute the action starts the value interpolation.
  38704. */
  38705. execute(): void;
  38706. /**
  38707. * Serializes the actions and its related information.
  38708. * @param parent defines the object to serialize in
  38709. * @returns the serialized object
  38710. */
  38711. serialize(parent: any): any;
  38712. }
  38713. }
  38714. declare module "babylonjs/Actions/index" {
  38715. export * from "babylonjs/Actions/abstractActionManager";
  38716. export * from "babylonjs/Actions/action";
  38717. export * from "babylonjs/Actions/actionEvent";
  38718. export * from "babylonjs/Actions/actionManager";
  38719. export * from "babylonjs/Actions/condition";
  38720. export * from "babylonjs/Actions/directActions";
  38721. export * from "babylonjs/Actions/directAudioActions";
  38722. export * from "babylonjs/Actions/interpolateValueAction";
  38723. }
  38724. declare module "babylonjs/Animations/index" {
  38725. export * from "babylonjs/Animations/animatable";
  38726. export * from "babylonjs/Animations/animation";
  38727. export * from "babylonjs/Animations/animationGroup";
  38728. export * from "babylonjs/Animations/animationPropertiesOverride";
  38729. export * from "babylonjs/Animations/easing";
  38730. export * from "babylonjs/Animations/runtimeAnimation";
  38731. export * from "babylonjs/Animations/animationEvent";
  38732. export * from "babylonjs/Animations/animationGroup";
  38733. export * from "babylonjs/Animations/animationKey";
  38734. export * from "babylonjs/Animations/animationRange";
  38735. export * from "babylonjs/Animations/animatable.interface";
  38736. }
  38737. declare module "babylonjs/Audio/soundTrack" {
  38738. import { Sound } from "babylonjs/Audio/sound";
  38739. import { Analyser } from "babylonjs/Audio/analyser";
  38740. import { Scene } from "babylonjs/scene";
  38741. /**
  38742. * Options allowed during the creation of a sound track.
  38743. */
  38744. export interface ISoundTrackOptions {
  38745. /**
  38746. * The volume the sound track should take during creation
  38747. */
  38748. volume?: number;
  38749. /**
  38750. * Define if the sound track is the main sound track of the scene
  38751. */
  38752. mainTrack?: boolean;
  38753. }
  38754. /**
  38755. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38756. * It will be also used in a future release to apply effects on a specific track.
  38757. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38758. */
  38759. export class SoundTrack {
  38760. /**
  38761. * The unique identifier of the sound track in the scene.
  38762. */
  38763. id: number;
  38764. /**
  38765. * The list of sounds included in the sound track.
  38766. */
  38767. soundCollection: Array<Sound>;
  38768. private _outputAudioNode;
  38769. private _scene;
  38770. private _connectedAnalyser;
  38771. private _options;
  38772. private _isInitialized;
  38773. /**
  38774. * Creates a new sound track.
  38775. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38776. * @param scene Define the scene the sound track belongs to
  38777. * @param options
  38778. */
  38779. constructor(scene: Scene, options?: ISoundTrackOptions);
  38780. private _initializeSoundTrackAudioGraph;
  38781. /**
  38782. * Release the sound track and its associated resources
  38783. */
  38784. dispose(): void;
  38785. /**
  38786. * Adds a sound to this sound track
  38787. * @param sound define the cound to add
  38788. * @ignoreNaming
  38789. */
  38790. AddSound(sound: Sound): void;
  38791. /**
  38792. * Removes a sound to this sound track
  38793. * @param sound define the cound to remove
  38794. * @ignoreNaming
  38795. */
  38796. RemoveSound(sound: Sound): void;
  38797. /**
  38798. * Set a global volume for the full sound track.
  38799. * @param newVolume Define the new volume of the sound track
  38800. */
  38801. setVolume(newVolume: number): void;
  38802. /**
  38803. * Switch the panning model to HRTF:
  38804. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38805. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38806. */
  38807. switchPanningModelToHRTF(): void;
  38808. /**
  38809. * Switch the panning model to Equal Power:
  38810. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38811. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38812. */
  38813. switchPanningModelToEqualPower(): void;
  38814. /**
  38815. * Connect the sound track to an audio analyser allowing some amazing
  38816. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38817. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38818. * @param analyser The analyser to connect to the engine
  38819. */
  38820. connectToAnalyser(analyser: Analyser): void;
  38821. }
  38822. }
  38823. declare module "babylonjs/Audio/audioSceneComponent" {
  38824. import { Sound } from "babylonjs/Audio/sound";
  38825. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38826. import { Nullable } from "babylonjs/types";
  38827. import { Vector3 } from "babylonjs/Maths/math.vector";
  38828. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38829. import { Scene } from "babylonjs/scene";
  38830. import { AbstractScene } from "babylonjs/abstractScene";
  38831. import "babylonjs/Audio/audioEngine";
  38832. module "babylonjs/abstractScene" {
  38833. interface AbstractScene {
  38834. /**
  38835. * The list of sounds used in the scene.
  38836. */
  38837. sounds: Nullable<Array<Sound>>;
  38838. }
  38839. }
  38840. module "babylonjs/scene" {
  38841. interface Scene {
  38842. /**
  38843. * @hidden
  38844. * Backing field
  38845. */
  38846. _mainSoundTrack: SoundTrack;
  38847. /**
  38848. * The main sound track played by the scene.
  38849. * It cotains your primary collection of sounds.
  38850. */
  38851. mainSoundTrack: SoundTrack;
  38852. /**
  38853. * The list of sound tracks added to the scene
  38854. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38855. */
  38856. soundTracks: Nullable<Array<SoundTrack>>;
  38857. /**
  38858. * Gets a sound using a given name
  38859. * @param name defines the name to search for
  38860. * @return the found sound or null if not found at all.
  38861. */
  38862. getSoundByName(name: string): Nullable<Sound>;
  38863. /**
  38864. * Gets or sets if audio support is enabled
  38865. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38866. */
  38867. audioEnabled: boolean;
  38868. /**
  38869. * Gets or sets if audio will be output to headphones
  38870. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38871. */
  38872. headphone: boolean;
  38873. /**
  38874. * Gets or sets custom audio listener position provider
  38875. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38876. */
  38877. audioListenerPositionProvider: Nullable<() => Vector3>;
  38878. /**
  38879. * Gets or sets a refresh rate when using 3D audio positioning
  38880. */
  38881. audioPositioningRefreshRate: number;
  38882. }
  38883. }
  38884. /**
  38885. * Defines the sound scene component responsible to manage any sounds
  38886. * in a given scene.
  38887. */
  38888. export class AudioSceneComponent implements ISceneSerializableComponent {
  38889. /**
  38890. * The component name helpfull to identify the component in the list of scene components.
  38891. */
  38892. readonly name: string;
  38893. /**
  38894. * The scene the component belongs to.
  38895. */
  38896. scene: Scene;
  38897. private _audioEnabled;
  38898. /**
  38899. * Gets whether audio is enabled or not.
  38900. * Please use related enable/disable method to switch state.
  38901. */
  38902. get audioEnabled(): boolean;
  38903. private _headphone;
  38904. /**
  38905. * Gets whether audio is outputing to headphone or not.
  38906. * Please use the according Switch methods to change output.
  38907. */
  38908. get headphone(): boolean;
  38909. /**
  38910. * Gets or sets a refresh rate when using 3D audio positioning
  38911. */
  38912. audioPositioningRefreshRate: number;
  38913. private _audioListenerPositionProvider;
  38914. /**
  38915. * Gets the current audio listener position provider
  38916. */
  38917. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38918. /**
  38919. * Sets a custom listener position for all sounds in the scene
  38920. * By default, this is the position of the first active camera
  38921. */
  38922. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38923. /**
  38924. * Creates a new instance of the component for the given scene
  38925. * @param scene Defines the scene to register the component in
  38926. */
  38927. constructor(scene: Scene);
  38928. /**
  38929. * Registers the component in a given scene
  38930. */
  38931. register(): void;
  38932. /**
  38933. * Rebuilds the elements related to this component in case of
  38934. * context lost for instance.
  38935. */
  38936. rebuild(): void;
  38937. /**
  38938. * Serializes the component data to the specified json object
  38939. * @param serializationObject The object to serialize to
  38940. */
  38941. serialize(serializationObject: any): void;
  38942. /**
  38943. * Adds all the elements from the container to the scene
  38944. * @param container the container holding the elements
  38945. */
  38946. addFromContainer(container: AbstractScene): void;
  38947. /**
  38948. * Removes all the elements in the container from the scene
  38949. * @param container contains the elements to remove
  38950. * @param dispose if the removed element should be disposed (default: false)
  38951. */
  38952. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38953. /**
  38954. * Disposes the component and the associated ressources.
  38955. */
  38956. dispose(): void;
  38957. /**
  38958. * Disables audio in the associated scene.
  38959. */
  38960. disableAudio(): void;
  38961. /**
  38962. * Enables audio in the associated scene.
  38963. */
  38964. enableAudio(): void;
  38965. /**
  38966. * Switch audio to headphone output.
  38967. */
  38968. switchAudioModeForHeadphones(): void;
  38969. /**
  38970. * Switch audio to normal speakers.
  38971. */
  38972. switchAudioModeForNormalSpeakers(): void;
  38973. private _cachedCameraDirection;
  38974. private _cachedCameraPosition;
  38975. private _lastCheck;
  38976. private _afterRender;
  38977. }
  38978. }
  38979. declare module "babylonjs/Audio/weightedsound" {
  38980. import { Sound } from "babylonjs/Audio/sound";
  38981. /**
  38982. * Wraps one or more Sound objects and selects one with random weight for playback.
  38983. */
  38984. export class WeightedSound {
  38985. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38986. loop: boolean;
  38987. private _coneInnerAngle;
  38988. private _coneOuterAngle;
  38989. private _volume;
  38990. /** A Sound is currently playing. */
  38991. isPlaying: boolean;
  38992. /** A Sound is currently paused. */
  38993. isPaused: boolean;
  38994. private _sounds;
  38995. private _weights;
  38996. private _currentIndex?;
  38997. /**
  38998. * Creates a new WeightedSound from the list of sounds given.
  38999. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39000. * @param sounds Array of Sounds that will be selected from.
  39001. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39002. */
  39003. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39004. /**
  39005. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39006. */
  39007. get directionalConeInnerAngle(): number;
  39008. /**
  39009. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39010. */
  39011. set directionalConeInnerAngle(value: number);
  39012. /**
  39013. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39014. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39015. */
  39016. get directionalConeOuterAngle(): number;
  39017. /**
  39018. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39019. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39020. */
  39021. set directionalConeOuterAngle(value: number);
  39022. /**
  39023. * Playback volume.
  39024. */
  39025. get volume(): number;
  39026. /**
  39027. * Playback volume.
  39028. */
  39029. set volume(value: number);
  39030. private _onended;
  39031. /**
  39032. * Suspend playback
  39033. */
  39034. pause(): void;
  39035. /**
  39036. * Stop playback
  39037. */
  39038. stop(): void;
  39039. /**
  39040. * Start playback.
  39041. * @param startOffset Position the clip head at a specific time in seconds.
  39042. */
  39043. play(startOffset?: number): void;
  39044. }
  39045. }
  39046. declare module "babylonjs/Audio/index" {
  39047. export * from "babylonjs/Audio/analyser";
  39048. export * from "babylonjs/Audio/audioEngine";
  39049. export * from "babylonjs/Audio/audioSceneComponent";
  39050. export * from "babylonjs/Audio/sound";
  39051. export * from "babylonjs/Audio/soundTrack";
  39052. export * from "babylonjs/Audio/weightedsound";
  39053. }
  39054. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39055. import { Behavior } from "babylonjs/Behaviors/behavior";
  39056. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39057. import { BackEase } from "babylonjs/Animations/easing";
  39058. /**
  39059. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39060. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39061. */
  39062. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39063. /**
  39064. * Gets the name of the behavior.
  39065. */
  39066. get name(): string;
  39067. /**
  39068. * The easing function used by animations
  39069. */
  39070. static EasingFunction: BackEase;
  39071. /**
  39072. * The easing mode used by animations
  39073. */
  39074. static EasingMode: number;
  39075. /**
  39076. * The duration of the animation, in milliseconds
  39077. */
  39078. transitionDuration: number;
  39079. /**
  39080. * Length of the distance animated by the transition when lower radius is reached
  39081. */
  39082. lowerRadiusTransitionRange: number;
  39083. /**
  39084. * Length of the distance animated by the transition when upper radius is reached
  39085. */
  39086. upperRadiusTransitionRange: number;
  39087. private _autoTransitionRange;
  39088. /**
  39089. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39090. */
  39091. get autoTransitionRange(): boolean;
  39092. /**
  39093. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39094. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39095. */
  39096. set autoTransitionRange(value: boolean);
  39097. private _attachedCamera;
  39098. private _onAfterCheckInputsObserver;
  39099. private _onMeshTargetChangedObserver;
  39100. /**
  39101. * Initializes the behavior.
  39102. */
  39103. init(): void;
  39104. /**
  39105. * Attaches the behavior to its arc rotate camera.
  39106. * @param camera Defines the camera to attach the behavior to
  39107. */
  39108. attach(camera: ArcRotateCamera): void;
  39109. /**
  39110. * Detaches the behavior from its current arc rotate camera.
  39111. */
  39112. detach(): void;
  39113. private _radiusIsAnimating;
  39114. private _radiusBounceTransition;
  39115. private _animatables;
  39116. private _cachedWheelPrecision;
  39117. /**
  39118. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39119. * @param radiusLimit The limit to check against.
  39120. * @return Bool to indicate if at limit.
  39121. */
  39122. private _isRadiusAtLimit;
  39123. /**
  39124. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39125. * @param radiusDelta The delta by which to animate to. Can be negative.
  39126. */
  39127. private _applyBoundRadiusAnimation;
  39128. /**
  39129. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39130. */
  39131. protected _clearAnimationLocks(): void;
  39132. /**
  39133. * Stops and removes all animations that have been applied to the camera
  39134. */
  39135. stopAllAnimations(): void;
  39136. }
  39137. }
  39138. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39139. import { Behavior } from "babylonjs/Behaviors/behavior";
  39140. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39141. import { ExponentialEase } from "babylonjs/Animations/easing";
  39142. import { Nullable } from "babylonjs/types";
  39143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39144. import { Vector3 } from "babylonjs/Maths/math.vector";
  39145. /**
  39146. * 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.
  39147. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39148. */
  39149. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39150. /**
  39151. * Gets the name of the behavior.
  39152. */
  39153. get name(): string;
  39154. private _mode;
  39155. private _radiusScale;
  39156. private _positionScale;
  39157. private _defaultElevation;
  39158. private _elevationReturnTime;
  39159. private _elevationReturnWaitTime;
  39160. private _zoomStopsAnimation;
  39161. private _framingTime;
  39162. /**
  39163. * The easing function used by animations
  39164. */
  39165. static EasingFunction: ExponentialEase;
  39166. /**
  39167. * The easing mode used by animations
  39168. */
  39169. static EasingMode: number;
  39170. /**
  39171. * Sets the current mode used by the behavior
  39172. */
  39173. set mode(mode: number);
  39174. /**
  39175. * Gets current mode used by the behavior.
  39176. */
  39177. get mode(): number;
  39178. /**
  39179. * Sets the scale applied to the radius (1 by default)
  39180. */
  39181. set radiusScale(radius: number);
  39182. /**
  39183. * Gets the scale applied to the radius
  39184. */
  39185. get radiusScale(): number;
  39186. /**
  39187. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39188. */
  39189. set positionScale(scale: number);
  39190. /**
  39191. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39192. */
  39193. get positionScale(): number;
  39194. /**
  39195. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39196. * behaviour is triggered, in radians.
  39197. */
  39198. set defaultElevation(elevation: number);
  39199. /**
  39200. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39201. * behaviour is triggered, in radians.
  39202. */
  39203. get defaultElevation(): number;
  39204. /**
  39205. * Sets the time (in milliseconds) taken to return to the default beta position.
  39206. * Negative value indicates camera should not return to default.
  39207. */
  39208. set elevationReturnTime(speed: number);
  39209. /**
  39210. * Gets the time (in milliseconds) taken to return to the default beta position.
  39211. * Negative value indicates camera should not return to default.
  39212. */
  39213. get elevationReturnTime(): number;
  39214. /**
  39215. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39216. */
  39217. set elevationReturnWaitTime(time: number);
  39218. /**
  39219. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39220. */
  39221. get elevationReturnWaitTime(): number;
  39222. /**
  39223. * Sets the flag that indicates if user zooming should stop animation.
  39224. */
  39225. set zoomStopsAnimation(flag: boolean);
  39226. /**
  39227. * Gets the flag that indicates if user zooming should stop animation.
  39228. */
  39229. get zoomStopsAnimation(): boolean;
  39230. /**
  39231. * Sets the transition time when framing the mesh, in milliseconds
  39232. */
  39233. set framingTime(time: number);
  39234. /**
  39235. * Gets the transition time when framing the mesh, in milliseconds
  39236. */
  39237. get framingTime(): number;
  39238. /**
  39239. * Define if the behavior should automatically change the configured
  39240. * camera limits and sensibilities.
  39241. */
  39242. autoCorrectCameraLimitsAndSensibility: boolean;
  39243. private _onPrePointerObservableObserver;
  39244. private _onAfterCheckInputsObserver;
  39245. private _onMeshTargetChangedObserver;
  39246. private _attachedCamera;
  39247. private _isPointerDown;
  39248. private _lastInteractionTime;
  39249. /**
  39250. * Initializes the behavior.
  39251. */
  39252. init(): void;
  39253. /**
  39254. * Attaches the behavior to its arc rotate camera.
  39255. * @param camera Defines the camera to attach the behavior to
  39256. */
  39257. attach(camera: ArcRotateCamera): void;
  39258. /**
  39259. * Detaches the behavior from its current arc rotate camera.
  39260. */
  39261. detach(): void;
  39262. private _animatables;
  39263. private _betaIsAnimating;
  39264. private _betaTransition;
  39265. private _radiusTransition;
  39266. private _vectorTransition;
  39267. /**
  39268. * Targets the given mesh and updates zoom level accordingly.
  39269. * @param mesh The mesh to target.
  39270. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39271. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39272. */
  39273. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39274. /**
  39275. * Targets the given mesh with its children and updates zoom level accordingly.
  39276. * @param mesh The mesh to target.
  39277. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39278. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39279. */
  39280. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39281. /**
  39282. * Targets the given meshes with their children and updates zoom level accordingly.
  39283. * @param meshes The mesh to target.
  39284. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39285. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39286. */
  39287. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39288. /**
  39289. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39290. * @param minimumWorld Determines the smaller position of the bounding box extend
  39291. * @param maximumWorld Determines the bigger position of the bounding box extend
  39292. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39293. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39294. */
  39295. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39296. /**
  39297. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39298. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39299. * frustum width.
  39300. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39301. * to fully enclose the mesh in the viewing frustum.
  39302. */
  39303. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39304. /**
  39305. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39306. * is automatically returned to its default position (expected to be above ground plane).
  39307. */
  39308. private _maintainCameraAboveGround;
  39309. /**
  39310. * Returns the frustum slope based on the canvas ratio and camera FOV
  39311. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39312. */
  39313. private _getFrustumSlope;
  39314. /**
  39315. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39316. */
  39317. private _clearAnimationLocks;
  39318. /**
  39319. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39320. */
  39321. private _applyUserInteraction;
  39322. /**
  39323. * Stops and removes all animations that have been applied to the camera
  39324. */
  39325. stopAllAnimations(): void;
  39326. /**
  39327. * Gets a value indicating if the user is moving the camera
  39328. */
  39329. get isUserIsMoving(): boolean;
  39330. /**
  39331. * The camera can move all the way towards the mesh.
  39332. */
  39333. static IgnoreBoundsSizeMode: number;
  39334. /**
  39335. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39336. */
  39337. static FitFrustumSidesMode: number;
  39338. }
  39339. }
  39340. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39341. import { Nullable } from "babylonjs/types";
  39342. import { Camera } from "babylonjs/Cameras/camera";
  39343. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39344. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39345. /**
  39346. * Base class for Camera Pointer Inputs.
  39347. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39348. * for example usage.
  39349. */
  39350. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39351. /**
  39352. * Defines the camera the input is attached to.
  39353. */
  39354. abstract camera: Camera;
  39355. /**
  39356. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39357. */
  39358. protected _altKey: boolean;
  39359. protected _ctrlKey: boolean;
  39360. protected _metaKey: boolean;
  39361. protected _shiftKey: boolean;
  39362. /**
  39363. * Which mouse buttons were pressed at time of last mouse event.
  39364. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39365. */
  39366. protected _buttonsPressed: number;
  39367. /**
  39368. * Defines the buttons associated with the input to handle camera move.
  39369. */
  39370. buttons: number[];
  39371. /**
  39372. * Attach the input controls to a specific dom element to get the input from.
  39373. * @param element Defines the element the controls should be listened from
  39374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39375. */
  39376. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39377. /**
  39378. * Detach the current controls from the specified dom element.
  39379. * @param element Defines the element to stop listening the inputs from
  39380. */
  39381. detachControl(element: Nullable<HTMLElement>): void;
  39382. /**
  39383. * Gets the class name of the current input.
  39384. * @returns the class name
  39385. */
  39386. getClassName(): string;
  39387. /**
  39388. * Get the friendly name associated with the input class.
  39389. * @returns the input friendly name
  39390. */
  39391. getSimpleName(): string;
  39392. /**
  39393. * Called on pointer POINTERDOUBLETAP event.
  39394. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39395. */
  39396. protected onDoubleTap(type: string): void;
  39397. /**
  39398. * Called on pointer POINTERMOVE event if only a single touch is active.
  39399. * Override this method to provide functionality.
  39400. */
  39401. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39402. /**
  39403. * Called on pointer POINTERMOVE event if multiple touches are active.
  39404. * Override this method to provide functionality.
  39405. */
  39406. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39407. /**
  39408. * Called on JS contextmenu event.
  39409. * Override this method to provide functionality.
  39410. */
  39411. protected onContextMenu(evt: PointerEvent): void;
  39412. /**
  39413. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39414. * press.
  39415. * Override this method to provide functionality.
  39416. */
  39417. protected onButtonDown(evt: PointerEvent): void;
  39418. /**
  39419. * Called each time a new POINTERUP event occurs. Ie, for each button
  39420. * release.
  39421. * Override this method to provide functionality.
  39422. */
  39423. protected onButtonUp(evt: PointerEvent): void;
  39424. /**
  39425. * Called when window becomes inactive.
  39426. * Override this method to provide functionality.
  39427. */
  39428. protected onLostFocus(): void;
  39429. private _pointerInput;
  39430. private _observer;
  39431. private _onLostFocus;
  39432. private pointA;
  39433. private pointB;
  39434. }
  39435. }
  39436. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39437. import { Nullable } from "babylonjs/types";
  39438. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39439. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39440. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39441. /**
  39442. * Manage the pointers inputs to control an arc rotate camera.
  39443. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39444. */
  39445. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39446. /**
  39447. * Defines the camera the input is attached to.
  39448. */
  39449. camera: ArcRotateCamera;
  39450. /**
  39451. * Gets the class name of the current input.
  39452. * @returns the class name
  39453. */
  39454. getClassName(): string;
  39455. /**
  39456. * Defines the buttons associated with the input to handle camera move.
  39457. */
  39458. buttons: number[];
  39459. /**
  39460. * Defines the pointer angular sensibility along the X axis or how fast is
  39461. * the camera rotating.
  39462. */
  39463. angularSensibilityX: number;
  39464. /**
  39465. * Defines the pointer angular sensibility along the Y axis or how fast is
  39466. * the camera rotating.
  39467. */
  39468. angularSensibilityY: number;
  39469. /**
  39470. * Defines the pointer pinch precision or how fast is the camera zooming.
  39471. */
  39472. pinchPrecision: number;
  39473. /**
  39474. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39475. * from 0.
  39476. * It defines the percentage of current camera.radius to use as delta when
  39477. * pinch zoom is used.
  39478. */
  39479. pinchDeltaPercentage: number;
  39480. /**
  39481. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39482. * that any object in the plane at the camera's target point will scale
  39483. * perfectly with finger motion.
  39484. * Overrides pinchDeltaPercentage and pinchPrecision.
  39485. */
  39486. useNaturalPinchZoom: boolean;
  39487. /**
  39488. * Defines the pointer panning sensibility or how fast is the camera moving.
  39489. */
  39490. panningSensibility: number;
  39491. /**
  39492. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39493. */
  39494. multiTouchPanning: boolean;
  39495. /**
  39496. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39497. * zoom (pinch) through multitouch.
  39498. */
  39499. multiTouchPanAndZoom: boolean;
  39500. /**
  39501. * Revers pinch action direction.
  39502. */
  39503. pinchInwards: boolean;
  39504. private _isPanClick;
  39505. private _twoFingerActivityCount;
  39506. private _isPinching;
  39507. /**
  39508. * Called on pointer POINTERMOVE event if only a single touch is active.
  39509. */
  39510. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39511. /**
  39512. * Called on pointer POINTERDOUBLETAP event.
  39513. */
  39514. protected onDoubleTap(type: string): void;
  39515. /**
  39516. * Called on pointer POINTERMOVE event if multiple touches are active.
  39517. */
  39518. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39519. /**
  39520. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39521. * press.
  39522. */
  39523. protected onButtonDown(evt: PointerEvent): void;
  39524. /**
  39525. * Called each time a new POINTERUP event occurs. Ie, for each button
  39526. * release.
  39527. */
  39528. protected onButtonUp(evt: PointerEvent): void;
  39529. /**
  39530. * Called when window becomes inactive.
  39531. */
  39532. protected onLostFocus(): void;
  39533. }
  39534. }
  39535. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39536. import { Nullable } from "babylonjs/types";
  39537. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39538. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39539. /**
  39540. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39541. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39542. */
  39543. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39544. /**
  39545. * Defines the camera the input is attached to.
  39546. */
  39547. camera: ArcRotateCamera;
  39548. /**
  39549. * Defines the list of key codes associated with the up action (increase alpha)
  39550. */
  39551. keysUp: number[];
  39552. /**
  39553. * Defines the list of key codes associated with the down action (decrease alpha)
  39554. */
  39555. keysDown: number[];
  39556. /**
  39557. * Defines the list of key codes associated with the left action (increase beta)
  39558. */
  39559. keysLeft: number[];
  39560. /**
  39561. * Defines the list of key codes associated with the right action (decrease beta)
  39562. */
  39563. keysRight: number[];
  39564. /**
  39565. * Defines the list of key codes associated with the reset action.
  39566. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39567. */
  39568. keysReset: number[];
  39569. /**
  39570. * Defines the panning sensibility of the inputs.
  39571. * (How fast is the camera panning)
  39572. */
  39573. panningSensibility: number;
  39574. /**
  39575. * Defines the zooming sensibility of the inputs.
  39576. * (How fast is the camera zooming)
  39577. */
  39578. zoomingSensibility: number;
  39579. /**
  39580. * Defines whether maintaining the alt key down switch the movement mode from
  39581. * orientation to zoom.
  39582. */
  39583. useAltToZoom: boolean;
  39584. /**
  39585. * Rotation speed of the camera
  39586. */
  39587. angularSpeed: number;
  39588. private _keys;
  39589. private _ctrlPressed;
  39590. private _altPressed;
  39591. private _onCanvasBlurObserver;
  39592. private _onKeyboardObserver;
  39593. private _engine;
  39594. private _scene;
  39595. /**
  39596. * Attach the input controls to a specific dom element to get the input from.
  39597. * @param element Defines the element the controls should be listened from
  39598. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39599. */
  39600. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39601. /**
  39602. * Detach the current controls from the specified dom element.
  39603. * @param element Defines the element to stop listening the inputs from
  39604. */
  39605. detachControl(element: Nullable<HTMLElement>): void;
  39606. /**
  39607. * Update the current camera state depending on the inputs that have been used this frame.
  39608. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39609. */
  39610. checkInputs(): void;
  39611. /**
  39612. * Gets the class name of the current intput.
  39613. * @returns the class name
  39614. */
  39615. getClassName(): string;
  39616. /**
  39617. * Get the friendly name associated with the input class.
  39618. * @returns the input friendly name
  39619. */
  39620. getSimpleName(): string;
  39621. }
  39622. }
  39623. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39624. import { Nullable } from "babylonjs/types";
  39625. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39626. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39627. /**
  39628. * Manage the mouse wheel inputs to control an arc rotate camera.
  39629. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39630. */
  39631. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39632. /**
  39633. * Defines the camera the input is attached to.
  39634. */
  39635. camera: ArcRotateCamera;
  39636. /**
  39637. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39638. */
  39639. wheelPrecision: number;
  39640. /**
  39641. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39642. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39643. */
  39644. wheelDeltaPercentage: number;
  39645. private _wheel;
  39646. private _observer;
  39647. private computeDeltaFromMouseWheelLegacyEvent;
  39648. /**
  39649. * Attach the input controls to a specific dom element to get the input from.
  39650. * @param element Defines the element the controls should be listened from
  39651. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39652. */
  39653. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39654. /**
  39655. * Detach the current controls from the specified dom element.
  39656. * @param element Defines the element to stop listening the inputs from
  39657. */
  39658. detachControl(element: Nullable<HTMLElement>): void;
  39659. /**
  39660. * Gets the class name of the current intput.
  39661. * @returns the class name
  39662. */
  39663. getClassName(): string;
  39664. /**
  39665. * Get the friendly name associated with the input class.
  39666. * @returns the input friendly name
  39667. */
  39668. getSimpleName(): string;
  39669. }
  39670. }
  39671. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39672. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39673. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39674. /**
  39675. * Default Inputs manager for the ArcRotateCamera.
  39676. * It groups all the default supported inputs for ease of use.
  39677. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39678. */
  39679. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39680. /**
  39681. * Instantiates a new ArcRotateCameraInputsManager.
  39682. * @param camera Defines the camera the inputs belong to
  39683. */
  39684. constructor(camera: ArcRotateCamera);
  39685. /**
  39686. * Add mouse wheel input support to the input manager.
  39687. * @returns the current input manager
  39688. */
  39689. addMouseWheel(): ArcRotateCameraInputsManager;
  39690. /**
  39691. * Add pointers input support to the input manager.
  39692. * @returns the current input manager
  39693. */
  39694. addPointers(): ArcRotateCameraInputsManager;
  39695. /**
  39696. * Add keyboard input support to the input manager.
  39697. * @returns the current input manager
  39698. */
  39699. addKeyboard(): ArcRotateCameraInputsManager;
  39700. }
  39701. }
  39702. declare module "babylonjs/Cameras/arcRotateCamera" {
  39703. import { Observable } from "babylonjs/Misc/observable";
  39704. import { Nullable } from "babylonjs/types";
  39705. import { Scene } from "babylonjs/scene";
  39706. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39708. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39709. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39710. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39711. import { Camera } from "babylonjs/Cameras/camera";
  39712. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39713. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39714. import { Collider } from "babylonjs/Collisions/collider";
  39715. /**
  39716. * This represents an orbital type of camera.
  39717. *
  39718. * 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.
  39719. * 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.
  39720. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39721. */
  39722. export class ArcRotateCamera extends TargetCamera {
  39723. /**
  39724. * Defines the rotation angle of the camera along the longitudinal axis.
  39725. */
  39726. alpha: number;
  39727. /**
  39728. * Defines the rotation angle of the camera along the latitudinal axis.
  39729. */
  39730. beta: number;
  39731. /**
  39732. * Defines the radius of the camera from it s target point.
  39733. */
  39734. radius: number;
  39735. protected _target: Vector3;
  39736. protected _targetHost: Nullable<AbstractMesh>;
  39737. /**
  39738. * Defines the target point of the camera.
  39739. * The camera looks towards it form the radius distance.
  39740. */
  39741. get target(): Vector3;
  39742. set target(value: Vector3);
  39743. /**
  39744. * Define the current local position of the camera in the scene
  39745. */
  39746. get position(): Vector3;
  39747. set position(newPosition: Vector3);
  39748. protected _upVector: Vector3;
  39749. protected _upToYMatrix: Matrix;
  39750. protected _YToUpMatrix: Matrix;
  39751. /**
  39752. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39753. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39754. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39755. */
  39756. set upVector(vec: Vector3);
  39757. get upVector(): Vector3;
  39758. /**
  39759. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39760. */
  39761. setMatUp(): void;
  39762. /**
  39763. * Current inertia value on the longitudinal axis.
  39764. * The bigger this number the longer it will take for the camera to stop.
  39765. */
  39766. inertialAlphaOffset: number;
  39767. /**
  39768. * Current inertia value on the latitudinal axis.
  39769. * The bigger this number the longer it will take for the camera to stop.
  39770. */
  39771. inertialBetaOffset: number;
  39772. /**
  39773. * Current inertia value on the radius axis.
  39774. * The bigger this number the longer it will take for the camera to stop.
  39775. */
  39776. inertialRadiusOffset: number;
  39777. /**
  39778. * Minimum allowed angle on the longitudinal axis.
  39779. * This can help limiting how the Camera is able to move in the scene.
  39780. */
  39781. lowerAlphaLimit: Nullable<number>;
  39782. /**
  39783. * Maximum allowed angle on the longitudinal axis.
  39784. * This can help limiting how the Camera is able to move in the scene.
  39785. */
  39786. upperAlphaLimit: Nullable<number>;
  39787. /**
  39788. * Minimum allowed angle on the latitudinal axis.
  39789. * This can help limiting how the Camera is able to move in the scene.
  39790. */
  39791. lowerBetaLimit: number;
  39792. /**
  39793. * Maximum allowed angle on the latitudinal axis.
  39794. * This can help limiting how the Camera is able to move in the scene.
  39795. */
  39796. upperBetaLimit: number;
  39797. /**
  39798. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39799. * This can help limiting how the Camera is able to move in the scene.
  39800. */
  39801. lowerRadiusLimit: Nullable<number>;
  39802. /**
  39803. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39804. * This can help limiting how the Camera is able to move in the scene.
  39805. */
  39806. upperRadiusLimit: Nullable<number>;
  39807. /**
  39808. * Defines the current inertia value used during panning of the camera along the X axis.
  39809. */
  39810. inertialPanningX: number;
  39811. /**
  39812. * Defines the current inertia value used during panning of the camera along the Y axis.
  39813. */
  39814. inertialPanningY: number;
  39815. /**
  39816. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39817. * Basically if your fingers moves away from more than this distance you will be considered
  39818. * in pinch mode.
  39819. */
  39820. pinchToPanMaxDistance: number;
  39821. /**
  39822. * Defines the maximum distance the camera can pan.
  39823. * This could help keeping the cammera always in your scene.
  39824. */
  39825. panningDistanceLimit: Nullable<number>;
  39826. /**
  39827. * Defines the target of the camera before paning.
  39828. */
  39829. panningOriginTarget: Vector3;
  39830. /**
  39831. * Defines the value of the inertia used during panning.
  39832. * 0 would mean stop inertia and one would mean no decelleration at all.
  39833. */
  39834. panningInertia: number;
  39835. /**
  39836. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39837. */
  39838. get angularSensibilityX(): number;
  39839. set angularSensibilityX(value: number);
  39840. /**
  39841. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39842. */
  39843. get angularSensibilityY(): number;
  39844. set angularSensibilityY(value: number);
  39845. /**
  39846. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39847. */
  39848. get pinchPrecision(): number;
  39849. set pinchPrecision(value: number);
  39850. /**
  39851. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39852. * It will be used instead of pinchDeltaPrecision if different from 0.
  39853. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39854. */
  39855. get pinchDeltaPercentage(): number;
  39856. set pinchDeltaPercentage(value: number);
  39857. /**
  39858. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39859. * and pinch delta percentage.
  39860. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39861. * that any object in the plane at the camera's target point will scale
  39862. * perfectly with finger motion.
  39863. */
  39864. get useNaturalPinchZoom(): boolean;
  39865. set useNaturalPinchZoom(value: boolean);
  39866. /**
  39867. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39868. */
  39869. get panningSensibility(): number;
  39870. set panningSensibility(value: number);
  39871. /**
  39872. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39873. */
  39874. get keysUp(): number[];
  39875. set keysUp(value: number[]);
  39876. /**
  39877. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39878. */
  39879. get keysDown(): number[];
  39880. set keysDown(value: number[]);
  39881. /**
  39882. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39883. */
  39884. get keysLeft(): number[];
  39885. set keysLeft(value: number[]);
  39886. /**
  39887. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39888. */
  39889. get keysRight(): number[];
  39890. set keysRight(value: number[]);
  39891. /**
  39892. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39893. */
  39894. get wheelPrecision(): number;
  39895. set wheelPrecision(value: number);
  39896. /**
  39897. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39898. * It will be used instead of pinchDeltaPrecision if different from 0.
  39899. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39900. */
  39901. get wheelDeltaPercentage(): number;
  39902. set wheelDeltaPercentage(value: number);
  39903. /**
  39904. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39905. */
  39906. zoomOnFactor: number;
  39907. /**
  39908. * Defines a screen offset for the camera position.
  39909. */
  39910. targetScreenOffset: Vector2;
  39911. /**
  39912. * Allows the camera to be completely reversed.
  39913. * If false the camera can not arrive upside down.
  39914. */
  39915. allowUpsideDown: boolean;
  39916. /**
  39917. * Define if double tap/click is used to restore the previously saved state of the camera.
  39918. */
  39919. useInputToRestoreState: boolean;
  39920. /** @hidden */
  39921. _viewMatrix: Matrix;
  39922. /** @hidden */
  39923. _useCtrlForPanning: boolean;
  39924. /** @hidden */
  39925. _panningMouseButton: number;
  39926. /**
  39927. * Defines the input associated to the camera.
  39928. */
  39929. inputs: ArcRotateCameraInputsManager;
  39930. /** @hidden */
  39931. _reset: () => void;
  39932. /**
  39933. * Defines the allowed panning axis.
  39934. */
  39935. panningAxis: Vector3;
  39936. protected _localDirection: Vector3;
  39937. protected _transformedDirection: Vector3;
  39938. private _bouncingBehavior;
  39939. /**
  39940. * Gets the bouncing behavior of the camera if it has been enabled.
  39941. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39942. */
  39943. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39944. /**
  39945. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39946. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39947. */
  39948. get useBouncingBehavior(): boolean;
  39949. set useBouncingBehavior(value: boolean);
  39950. private _framingBehavior;
  39951. /**
  39952. * Gets the framing behavior of the camera if it has been enabled.
  39953. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39954. */
  39955. get framingBehavior(): Nullable<FramingBehavior>;
  39956. /**
  39957. * Defines if the framing behavior of the camera is enabled on the camera.
  39958. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39959. */
  39960. get useFramingBehavior(): boolean;
  39961. set useFramingBehavior(value: boolean);
  39962. private _autoRotationBehavior;
  39963. /**
  39964. * Gets the auto rotation behavior of the camera if it has been enabled.
  39965. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39966. */
  39967. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39968. /**
  39969. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39970. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39971. */
  39972. get useAutoRotationBehavior(): boolean;
  39973. set useAutoRotationBehavior(value: boolean);
  39974. /**
  39975. * Observable triggered when the mesh target has been changed on the camera.
  39976. */
  39977. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39978. /**
  39979. * Event raised when the camera is colliding with a mesh.
  39980. */
  39981. onCollide: (collidedMesh: AbstractMesh) => void;
  39982. /**
  39983. * Defines whether the camera should check collision with the objects oh the scene.
  39984. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39985. */
  39986. checkCollisions: boolean;
  39987. /**
  39988. * Defines the collision radius of the camera.
  39989. * This simulates a sphere around the camera.
  39990. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39991. */
  39992. collisionRadius: Vector3;
  39993. protected _collider: Collider;
  39994. protected _previousPosition: Vector3;
  39995. protected _collisionVelocity: Vector3;
  39996. protected _newPosition: Vector3;
  39997. protected _previousAlpha: number;
  39998. protected _previousBeta: number;
  39999. protected _previousRadius: number;
  40000. protected _collisionTriggered: boolean;
  40001. protected _targetBoundingCenter: Nullable<Vector3>;
  40002. private _computationVector;
  40003. /**
  40004. * Instantiates a new ArcRotateCamera in a given scene
  40005. * @param name Defines the name of the camera
  40006. * @param alpha Defines the camera rotation along the logitudinal axis
  40007. * @param beta Defines the camera rotation along the latitudinal axis
  40008. * @param radius Defines the camera distance from its target
  40009. * @param target Defines the camera target
  40010. * @param scene Defines the scene the camera belongs to
  40011. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40012. */
  40013. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40014. /** @hidden */
  40015. _initCache(): void;
  40016. /** @hidden */
  40017. _updateCache(ignoreParentClass?: boolean): void;
  40018. protected _getTargetPosition(): Vector3;
  40019. private _storedAlpha;
  40020. private _storedBeta;
  40021. private _storedRadius;
  40022. private _storedTarget;
  40023. private _storedTargetScreenOffset;
  40024. /**
  40025. * Stores the current state of the camera (alpha, beta, radius and target)
  40026. * @returns the camera itself
  40027. */
  40028. storeState(): Camera;
  40029. /**
  40030. * @hidden
  40031. * Restored camera state. You must call storeState() first
  40032. */
  40033. _restoreStateValues(): boolean;
  40034. /** @hidden */
  40035. _isSynchronizedViewMatrix(): boolean;
  40036. /**
  40037. * Attached controls to the current camera.
  40038. * @param element Defines the element the controls should be listened from
  40039. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40040. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40041. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40042. */
  40043. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40044. /**
  40045. * Detach the current controls from the camera.
  40046. * The camera will stop reacting to inputs.
  40047. * @param element Defines the element to stop listening the inputs from
  40048. */
  40049. detachControl(element: HTMLElement): void;
  40050. /** @hidden */
  40051. _checkInputs(): void;
  40052. protected _checkLimits(): void;
  40053. /**
  40054. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40055. */
  40056. rebuildAnglesAndRadius(): void;
  40057. /**
  40058. * Use a position to define the current camera related information like alpha, beta and radius
  40059. * @param position Defines the position to set the camera at
  40060. */
  40061. setPosition(position: Vector3): void;
  40062. /**
  40063. * Defines the target the camera should look at.
  40064. * This will automatically adapt alpha beta and radius to fit within the new target.
  40065. * @param target Defines the new target as a Vector or a mesh
  40066. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40067. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40068. */
  40069. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40070. /** @hidden */
  40071. _getViewMatrix(): Matrix;
  40072. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40073. /**
  40074. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40075. * @param meshes Defines the mesh to zoom on
  40076. * @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)
  40077. */
  40078. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40079. /**
  40080. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40081. * The target will be changed but the radius
  40082. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40083. * @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)
  40084. */
  40085. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40086. min: Vector3;
  40087. max: Vector3;
  40088. distance: number;
  40089. }, doNotUpdateMaxZ?: boolean): void;
  40090. /**
  40091. * @override
  40092. * Override Camera.createRigCamera
  40093. */
  40094. createRigCamera(name: string, cameraIndex: number): Camera;
  40095. /**
  40096. * @hidden
  40097. * @override
  40098. * Override Camera._updateRigCameras
  40099. */
  40100. _updateRigCameras(): void;
  40101. /**
  40102. * Destroy the camera and release the current resources hold by it.
  40103. */
  40104. dispose(): void;
  40105. /**
  40106. * Gets the current object class name.
  40107. * @return the class name
  40108. */
  40109. getClassName(): string;
  40110. }
  40111. }
  40112. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40113. import { Behavior } from "babylonjs/Behaviors/behavior";
  40114. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40115. /**
  40116. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40117. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40118. */
  40119. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40120. /**
  40121. * Gets the name of the behavior.
  40122. */
  40123. get name(): string;
  40124. private _zoomStopsAnimation;
  40125. private _idleRotationSpeed;
  40126. private _idleRotationWaitTime;
  40127. private _idleRotationSpinupTime;
  40128. /**
  40129. * Sets the flag that indicates if user zooming should stop animation.
  40130. */
  40131. set zoomStopsAnimation(flag: boolean);
  40132. /**
  40133. * Gets the flag that indicates if user zooming should stop animation.
  40134. */
  40135. get zoomStopsAnimation(): boolean;
  40136. /**
  40137. * Sets the default speed at which the camera rotates around the model.
  40138. */
  40139. set idleRotationSpeed(speed: number);
  40140. /**
  40141. * Gets the default speed at which the camera rotates around the model.
  40142. */
  40143. get idleRotationSpeed(): number;
  40144. /**
  40145. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40146. */
  40147. set idleRotationWaitTime(time: number);
  40148. /**
  40149. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40150. */
  40151. get idleRotationWaitTime(): number;
  40152. /**
  40153. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40154. */
  40155. set idleRotationSpinupTime(time: number);
  40156. /**
  40157. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40158. */
  40159. get idleRotationSpinupTime(): number;
  40160. /**
  40161. * Gets a value indicating if the camera is currently rotating because of this behavior
  40162. */
  40163. get rotationInProgress(): boolean;
  40164. private _onPrePointerObservableObserver;
  40165. private _onAfterCheckInputsObserver;
  40166. private _attachedCamera;
  40167. private _isPointerDown;
  40168. private _lastFrameTime;
  40169. private _lastInteractionTime;
  40170. private _cameraRotationSpeed;
  40171. /**
  40172. * Initializes the behavior.
  40173. */
  40174. init(): void;
  40175. /**
  40176. * Attaches the behavior to its arc rotate camera.
  40177. * @param camera Defines the camera to attach the behavior to
  40178. */
  40179. attach(camera: ArcRotateCamera): void;
  40180. /**
  40181. * Detaches the behavior from its current arc rotate camera.
  40182. */
  40183. detach(): void;
  40184. /**
  40185. * Returns true if user is scrolling.
  40186. * @return true if user is scrolling.
  40187. */
  40188. private _userIsZooming;
  40189. private _lastFrameRadius;
  40190. private _shouldAnimationStopForInteraction;
  40191. /**
  40192. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40193. */
  40194. private _applyUserInteraction;
  40195. private _userIsMoving;
  40196. }
  40197. }
  40198. declare module "babylonjs/Behaviors/Cameras/index" {
  40199. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40200. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40201. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40202. }
  40203. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40204. import { Mesh } from "babylonjs/Meshes/mesh";
  40205. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40206. import { Behavior } from "babylonjs/Behaviors/behavior";
  40207. /**
  40208. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40209. */
  40210. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40211. private ui;
  40212. /**
  40213. * The name of the behavior
  40214. */
  40215. name: string;
  40216. /**
  40217. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40218. */
  40219. distanceAwayFromFace: number;
  40220. /**
  40221. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40222. */
  40223. distanceAwayFromBottomOfFace: number;
  40224. private _faceVectors;
  40225. private _target;
  40226. private _scene;
  40227. private _onRenderObserver;
  40228. private _tmpMatrix;
  40229. private _tmpVector;
  40230. /**
  40231. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40232. * @param ui The transform node that should be attched to the mesh
  40233. */
  40234. constructor(ui: TransformNode);
  40235. /**
  40236. * Initializes the behavior
  40237. */
  40238. init(): void;
  40239. private _closestFace;
  40240. private _zeroVector;
  40241. private _lookAtTmpMatrix;
  40242. private _lookAtToRef;
  40243. /**
  40244. * Attaches the AttachToBoxBehavior to the passed in mesh
  40245. * @param target The mesh that the specified node will be attached to
  40246. */
  40247. attach(target: Mesh): void;
  40248. /**
  40249. * Detaches the behavior from the mesh
  40250. */
  40251. detach(): void;
  40252. }
  40253. }
  40254. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40255. import { Behavior } from "babylonjs/Behaviors/behavior";
  40256. import { Mesh } from "babylonjs/Meshes/mesh";
  40257. /**
  40258. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40259. */
  40260. export class FadeInOutBehavior implements Behavior<Mesh> {
  40261. /**
  40262. * Time in milliseconds to delay before fading in (Default: 0)
  40263. */
  40264. delay: number;
  40265. /**
  40266. * Time in milliseconds for the mesh to fade in (Default: 300)
  40267. */
  40268. fadeInTime: number;
  40269. private _millisecondsPerFrame;
  40270. private _hovered;
  40271. private _hoverValue;
  40272. private _ownerNode;
  40273. /**
  40274. * Instatiates the FadeInOutBehavior
  40275. */
  40276. constructor();
  40277. /**
  40278. * The name of the behavior
  40279. */
  40280. get name(): string;
  40281. /**
  40282. * Initializes the behavior
  40283. */
  40284. init(): void;
  40285. /**
  40286. * Attaches the fade behavior on the passed in mesh
  40287. * @param ownerNode The mesh that will be faded in/out once attached
  40288. */
  40289. attach(ownerNode: Mesh): void;
  40290. /**
  40291. * Detaches the behavior from the mesh
  40292. */
  40293. detach(): void;
  40294. /**
  40295. * Triggers the mesh to begin fading in or out
  40296. * @param value if the object should fade in or out (true to fade in)
  40297. */
  40298. fadeIn(value: boolean): void;
  40299. private _update;
  40300. private _setAllVisibility;
  40301. }
  40302. }
  40303. declare module "babylonjs/Misc/pivotTools" {
  40304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40305. /**
  40306. * Class containing a set of static utilities functions for managing Pivots
  40307. * @hidden
  40308. */
  40309. export class PivotTools {
  40310. private static _PivotCached;
  40311. private static _OldPivotPoint;
  40312. private static _PivotTranslation;
  40313. private static _PivotTmpVector;
  40314. /** @hidden */
  40315. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40316. /** @hidden */
  40317. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40318. }
  40319. }
  40320. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40321. import { Scene } from "babylonjs/scene";
  40322. import { Vector4 } from "babylonjs/Maths/math.vector";
  40323. import { Mesh } from "babylonjs/Meshes/mesh";
  40324. import { Nullable } from "babylonjs/types";
  40325. import { Plane } from "babylonjs/Maths/math.plane";
  40326. /**
  40327. * Class containing static functions to help procedurally build meshes
  40328. */
  40329. export class PlaneBuilder {
  40330. /**
  40331. * Creates a plane mesh
  40332. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40333. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40334. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40335. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40336. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40338. * @param name defines the name of the mesh
  40339. * @param options defines the options used to create the mesh
  40340. * @param scene defines the hosting scene
  40341. * @returns the plane mesh
  40342. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40343. */
  40344. static CreatePlane(name: string, options: {
  40345. size?: number;
  40346. width?: number;
  40347. height?: number;
  40348. sideOrientation?: number;
  40349. frontUVs?: Vector4;
  40350. backUVs?: Vector4;
  40351. updatable?: boolean;
  40352. sourcePlane?: Plane;
  40353. }, scene?: Nullable<Scene>): Mesh;
  40354. }
  40355. }
  40356. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40357. import { Behavior } from "babylonjs/Behaviors/behavior";
  40358. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40359. import { Observable } from "babylonjs/Misc/observable";
  40360. import { Vector3 } from "babylonjs/Maths/math.vector";
  40361. import { Ray } from "babylonjs/Culling/ray";
  40362. import "babylonjs/Meshes/Builders/planeBuilder";
  40363. /**
  40364. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40365. */
  40366. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40367. private static _AnyMouseID;
  40368. /**
  40369. * Abstract mesh the behavior is set on
  40370. */
  40371. attachedNode: AbstractMesh;
  40372. private _dragPlane;
  40373. private _scene;
  40374. private _pointerObserver;
  40375. private _beforeRenderObserver;
  40376. private static _planeScene;
  40377. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40378. /**
  40379. * 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)
  40380. */
  40381. maxDragAngle: number;
  40382. /**
  40383. * @hidden
  40384. */
  40385. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40386. /**
  40387. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40388. */
  40389. currentDraggingPointerID: number;
  40390. /**
  40391. * The last position where the pointer hit the drag plane in world space
  40392. */
  40393. lastDragPosition: Vector3;
  40394. /**
  40395. * If the behavior is currently in a dragging state
  40396. */
  40397. dragging: boolean;
  40398. /**
  40399. * 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)
  40400. */
  40401. dragDeltaRatio: number;
  40402. /**
  40403. * If the drag plane orientation should be updated during the dragging (Default: true)
  40404. */
  40405. updateDragPlane: boolean;
  40406. private _debugMode;
  40407. private _moving;
  40408. /**
  40409. * Fires each time the attached mesh is dragged with the pointer
  40410. * * delta between last drag position and current drag position in world space
  40411. * * dragDistance along the drag axis
  40412. * * dragPlaneNormal normal of the current drag plane used during the drag
  40413. * * dragPlanePoint in world space where the drag intersects the drag plane
  40414. */
  40415. onDragObservable: Observable<{
  40416. delta: Vector3;
  40417. dragPlanePoint: Vector3;
  40418. dragPlaneNormal: Vector3;
  40419. dragDistance: number;
  40420. pointerId: number;
  40421. }>;
  40422. /**
  40423. * Fires each time a drag begins (eg. mouse down on mesh)
  40424. */
  40425. onDragStartObservable: Observable<{
  40426. dragPlanePoint: Vector3;
  40427. pointerId: number;
  40428. }>;
  40429. /**
  40430. * Fires each time a drag ends (eg. mouse release after drag)
  40431. */
  40432. onDragEndObservable: Observable<{
  40433. dragPlanePoint: Vector3;
  40434. pointerId: number;
  40435. }>;
  40436. /**
  40437. * If the attached mesh should be moved when dragged
  40438. */
  40439. moveAttached: boolean;
  40440. /**
  40441. * If the drag behavior will react to drag events (Default: true)
  40442. */
  40443. enabled: boolean;
  40444. /**
  40445. * If pointer events should start and release the drag (Default: true)
  40446. */
  40447. startAndReleaseDragOnPointerEvents: boolean;
  40448. /**
  40449. * If camera controls should be detached during the drag
  40450. */
  40451. detachCameraControls: boolean;
  40452. /**
  40453. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40454. */
  40455. useObjectOrientationForDragging: boolean;
  40456. private _options;
  40457. /**
  40458. * Gets the options used by the behavior
  40459. */
  40460. get options(): {
  40461. dragAxis?: Vector3;
  40462. dragPlaneNormal?: Vector3;
  40463. };
  40464. /**
  40465. * Sets the options used by the behavior
  40466. */
  40467. set options(options: {
  40468. dragAxis?: Vector3;
  40469. dragPlaneNormal?: Vector3;
  40470. });
  40471. /**
  40472. * Creates a pointer drag behavior that can be attached to a mesh
  40473. * @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)
  40474. */
  40475. constructor(options?: {
  40476. dragAxis?: Vector3;
  40477. dragPlaneNormal?: Vector3;
  40478. });
  40479. /**
  40480. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40481. */
  40482. validateDrag: (targetPosition: Vector3) => boolean;
  40483. /**
  40484. * The name of the behavior
  40485. */
  40486. get name(): string;
  40487. /**
  40488. * Initializes the behavior
  40489. */
  40490. init(): void;
  40491. private _tmpVector;
  40492. private _alternatePickedPoint;
  40493. private _worldDragAxis;
  40494. private _targetPosition;
  40495. private _attachedElement;
  40496. /**
  40497. * Attaches the drag behavior the passed in mesh
  40498. * @param ownerNode The mesh that will be dragged around once attached
  40499. * @param predicate Predicate to use for pick filtering
  40500. */
  40501. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40502. /**
  40503. * Force relase the drag action by code.
  40504. */
  40505. releaseDrag(): void;
  40506. private _startDragRay;
  40507. private _lastPointerRay;
  40508. /**
  40509. * Simulates the start of a pointer drag event on the behavior
  40510. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40511. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40512. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40513. */
  40514. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40515. private _startDrag;
  40516. private _dragDelta;
  40517. private _moveDrag;
  40518. private _pickWithRayOnDragPlane;
  40519. private _pointA;
  40520. private _pointB;
  40521. private _pointC;
  40522. private _lineA;
  40523. private _lineB;
  40524. private _localAxis;
  40525. private _lookAt;
  40526. private _updateDragPlanePosition;
  40527. /**
  40528. * Detaches the behavior from the mesh
  40529. */
  40530. detach(): void;
  40531. }
  40532. }
  40533. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40534. import { Mesh } from "babylonjs/Meshes/mesh";
  40535. import { Behavior } from "babylonjs/Behaviors/behavior";
  40536. /**
  40537. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40538. */
  40539. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40540. private _dragBehaviorA;
  40541. private _dragBehaviorB;
  40542. private _startDistance;
  40543. private _initialScale;
  40544. private _targetScale;
  40545. private _ownerNode;
  40546. private _sceneRenderObserver;
  40547. /**
  40548. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40549. */
  40550. constructor();
  40551. /**
  40552. * The name of the behavior
  40553. */
  40554. get name(): string;
  40555. /**
  40556. * Initializes the behavior
  40557. */
  40558. init(): void;
  40559. private _getCurrentDistance;
  40560. /**
  40561. * Attaches the scale behavior the passed in mesh
  40562. * @param ownerNode The mesh that will be scaled around once attached
  40563. */
  40564. attach(ownerNode: Mesh): void;
  40565. /**
  40566. * Detaches the behavior from the mesh
  40567. */
  40568. detach(): void;
  40569. }
  40570. }
  40571. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40572. import { Behavior } from "babylonjs/Behaviors/behavior";
  40573. import { Mesh } from "babylonjs/Meshes/mesh";
  40574. import { Observable } from "babylonjs/Misc/observable";
  40575. /**
  40576. * 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
  40577. */
  40578. export class SixDofDragBehavior implements Behavior<Mesh> {
  40579. private static _virtualScene;
  40580. private _ownerNode;
  40581. private _sceneRenderObserver;
  40582. private _scene;
  40583. private _targetPosition;
  40584. private _virtualOriginMesh;
  40585. private _virtualDragMesh;
  40586. private _pointerObserver;
  40587. private _moving;
  40588. private _startingOrientation;
  40589. /**
  40590. * 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)
  40591. */
  40592. private zDragFactor;
  40593. /**
  40594. * If the object should rotate to face the drag origin
  40595. */
  40596. rotateDraggedObject: boolean;
  40597. /**
  40598. * If the behavior is currently in a dragging state
  40599. */
  40600. dragging: boolean;
  40601. /**
  40602. * 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)
  40603. */
  40604. dragDeltaRatio: number;
  40605. /**
  40606. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40607. */
  40608. currentDraggingPointerID: number;
  40609. /**
  40610. * If camera controls should be detached during the drag
  40611. */
  40612. detachCameraControls: boolean;
  40613. /**
  40614. * Fires each time a drag starts
  40615. */
  40616. onDragStartObservable: Observable<{}>;
  40617. /**
  40618. * Fires each time a drag ends (eg. mouse release after drag)
  40619. */
  40620. onDragEndObservable: Observable<{}>;
  40621. /**
  40622. * 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
  40623. */
  40624. constructor();
  40625. /**
  40626. * The name of the behavior
  40627. */
  40628. get name(): string;
  40629. /**
  40630. * Initializes the behavior
  40631. */
  40632. init(): void;
  40633. /**
  40634. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40635. */
  40636. private get _pointerCamera();
  40637. /**
  40638. * Attaches the scale behavior the passed in mesh
  40639. * @param ownerNode The mesh that will be scaled around once attached
  40640. */
  40641. attach(ownerNode: Mesh): void;
  40642. /**
  40643. * Detaches the behavior from the mesh
  40644. */
  40645. detach(): void;
  40646. }
  40647. }
  40648. declare module "babylonjs/Behaviors/Meshes/index" {
  40649. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40650. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40651. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40652. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40653. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40654. }
  40655. declare module "babylonjs/Behaviors/index" {
  40656. export * from "babylonjs/Behaviors/behavior";
  40657. export * from "babylonjs/Behaviors/Cameras/index";
  40658. export * from "babylonjs/Behaviors/Meshes/index";
  40659. }
  40660. declare module "babylonjs/Bones/boneIKController" {
  40661. import { Bone } from "babylonjs/Bones/bone";
  40662. import { Vector3 } from "babylonjs/Maths/math.vector";
  40663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40664. import { Nullable } from "babylonjs/types";
  40665. /**
  40666. * Class used to apply inverse kinematics to bones
  40667. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40668. */
  40669. export class BoneIKController {
  40670. private static _tmpVecs;
  40671. private static _tmpQuat;
  40672. private static _tmpMats;
  40673. /**
  40674. * Gets or sets the target mesh
  40675. */
  40676. targetMesh: AbstractMesh;
  40677. /** Gets or sets the mesh used as pole */
  40678. poleTargetMesh: AbstractMesh;
  40679. /**
  40680. * Gets or sets the bone used as pole
  40681. */
  40682. poleTargetBone: Nullable<Bone>;
  40683. /**
  40684. * Gets or sets the target position
  40685. */
  40686. targetPosition: Vector3;
  40687. /**
  40688. * Gets or sets the pole target position
  40689. */
  40690. poleTargetPosition: Vector3;
  40691. /**
  40692. * Gets or sets the pole target local offset
  40693. */
  40694. poleTargetLocalOffset: Vector3;
  40695. /**
  40696. * Gets or sets the pole angle
  40697. */
  40698. poleAngle: number;
  40699. /**
  40700. * Gets or sets the mesh associated with the controller
  40701. */
  40702. mesh: AbstractMesh;
  40703. /**
  40704. * 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)
  40705. */
  40706. slerpAmount: number;
  40707. private _bone1Quat;
  40708. private _bone1Mat;
  40709. private _bone2Ang;
  40710. private _bone1;
  40711. private _bone2;
  40712. private _bone1Length;
  40713. private _bone2Length;
  40714. private _maxAngle;
  40715. private _maxReach;
  40716. private _rightHandedSystem;
  40717. private _bendAxis;
  40718. private _slerping;
  40719. private _adjustRoll;
  40720. /**
  40721. * Gets or sets maximum allowed angle
  40722. */
  40723. get maxAngle(): number;
  40724. set maxAngle(value: number);
  40725. /**
  40726. * Creates a new BoneIKController
  40727. * @param mesh defines the mesh to control
  40728. * @param bone defines the bone to control
  40729. * @param options defines options to set up the controller
  40730. */
  40731. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40732. targetMesh?: AbstractMesh;
  40733. poleTargetMesh?: AbstractMesh;
  40734. poleTargetBone?: Bone;
  40735. poleTargetLocalOffset?: Vector3;
  40736. poleAngle?: number;
  40737. bendAxis?: Vector3;
  40738. maxAngle?: number;
  40739. slerpAmount?: number;
  40740. });
  40741. private _setMaxAngle;
  40742. /**
  40743. * Force the controller to update the bones
  40744. */
  40745. update(): void;
  40746. }
  40747. }
  40748. declare module "babylonjs/Bones/boneLookController" {
  40749. import { Vector3 } from "babylonjs/Maths/math.vector";
  40750. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40751. import { Bone } from "babylonjs/Bones/bone";
  40752. import { Space } from "babylonjs/Maths/math.axis";
  40753. /**
  40754. * Class used to make a bone look toward a point in space
  40755. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40756. */
  40757. export class BoneLookController {
  40758. private static _tmpVecs;
  40759. private static _tmpQuat;
  40760. private static _tmpMats;
  40761. /**
  40762. * The target Vector3 that the bone will look at
  40763. */
  40764. target: Vector3;
  40765. /**
  40766. * The mesh that the bone is attached to
  40767. */
  40768. mesh: AbstractMesh;
  40769. /**
  40770. * The bone that will be looking to the target
  40771. */
  40772. bone: Bone;
  40773. /**
  40774. * The up axis of the coordinate system that is used when the bone is rotated
  40775. */
  40776. upAxis: Vector3;
  40777. /**
  40778. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40779. */
  40780. upAxisSpace: Space;
  40781. /**
  40782. * Used to make an adjustment to the yaw of the bone
  40783. */
  40784. adjustYaw: number;
  40785. /**
  40786. * Used to make an adjustment to the pitch of the bone
  40787. */
  40788. adjustPitch: number;
  40789. /**
  40790. * Used to make an adjustment to the roll of the bone
  40791. */
  40792. adjustRoll: number;
  40793. /**
  40794. * 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)
  40795. */
  40796. slerpAmount: number;
  40797. private _minYaw;
  40798. private _maxYaw;
  40799. private _minPitch;
  40800. private _maxPitch;
  40801. private _minYawSin;
  40802. private _minYawCos;
  40803. private _maxYawSin;
  40804. private _maxYawCos;
  40805. private _midYawConstraint;
  40806. private _minPitchTan;
  40807. private _maxPitchTan;
  40808. private _boneQuat;
  40809. private _slerping;
  40810. private _transformYawPitch;
  40811. private _transformYawPitchInv;
  40812. private _firstFrameSkipped;
  40813. private _yawRange;
  40814. private _fowardAxis;
  40815. /**
  40816. * Gets or sets the minimum yaw angle that the bone can look to
  40817. */
  40818. get minYaw(): number;
  40819. set minYaw(value: number);
  40820. /**
  40821. * Gets or sets the maximum yaw angle that the bone can look to
  40822. */
  40823. get maxYaw(): number;
  40824. set maxYaw(value: number);
  40825. /**
  40826. * Gets or sets the minimum pitch angle that the bone can look to
  40827. */
  40828. get minPitch(): number;
  40829. set minPitch(value: number);
  40830. /**
  40831. * Gets or sets the maximum pitch angle that the bone can look to
  40832. */
  40833. get maxPitch(): number;
  40834. set maxPitch(value: number);
  40835. /**
  40836. * Create a BoneLookController
  40837. * @param mesh the mesh that the bone belongs to
  40838. * @param bone the bone that will be looking to the target
  40839. * @param target the target Vector3 to look at
  40840. * @param options optional settings:
  40841. * * maxYaw: the maximum angle the bone will yaw to
  40842. * * minYaw: the minimum angle the bone will yaw to
  40843. * * maxPitch: the maximum angle the bone will pitch to
  40844. * * minPitch: the minimum angle the bone will yaw to
  40845. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40846. * * upAxis: the up axis of the coordinate system
  40847. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40848. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40849. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40850. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40851. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40852. * * adjustRoll: used to make an adjustment to the roll of the bone
  40853. **/
  40854. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40855. maxYaw?: number;
  40856. minYaw?: number;
  40857. maxPitch?: number;
  40858. minPitch?: number;
  40859. slerpAmount?: number;
  40860. upAxis?: Vector3;
  40861. upAxisSpace?: Space;
  40862. yawAxis?: Vector3;
  40863. pitchAxis?: Vector3;
  40864. adjustYaw?: number;
  40865. adjustPitch?: number;
  40866. adjustRoll?: number;
  40867. });
  40868. /**
  40869. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40870. */
  40871. update(): void;
  40872. private _getAngleDiff;
  40873. private _getAngleBetween;
  40874. private _isAngleBetween;
  40875. }
  40876. }
  40877. declare module "babylonjs/Bones/index" {
  40878. export * from "babylonjs/Bones/bone";
  40879. export * from "babylonjs/Bones/boneIKController";
  40880. export * from "babylonjs/Bones/boneLookController";
  40881. export * from "babylonjs/Bones/skeleton";
  40882. }
  40883. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40884. import { Nullable } from "babylonjs/types";
  40885. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40886. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40887. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40888. /**
  40889. * Manage the gamepad inputs to control an arc rotate camera.
  40890. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40891. */
  40892. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40893. /**
  40894. * Defines the camera the input is attached to.
  40895. */
  40896. camera: ArcRotateCamera;
  40897. /**
  40898. * Defines the gamepad the input is gathering event from.
  40899. */
  40900. gamepad: Nullable<Gamepad>;
  40901. /**
  40902. * Defines the gamepad rotation sensiblity.
  40903. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40904. */
  40905. gamepadRotationSensibility: number;
  40906. /**
  40907. * Defines the gamepad move sensiblity.
  40908. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40909. */
  40910. gamepadMoveSensibility: number;
  40911. private _yAxisScale;
  40912. /**
  40913. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40914. */
  40915. get invertYAxis(): boolean;
  40916. set invertYAxis(value: boolean);
  40917. private _onGamepadConnectedObserver;
  40918. private _onGamepadDisconnectedObserver;
  40919. /**
  40920. * Attach the input controls to a specific dom element to get the input from.
  40921. * @param element Defines the element the controls should be listened from
  40922. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40923. */
  40924. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40925. /**
  40926. * Detach the current controls from the specified dom element.
  40927. * @param element Defines the element to stop listening the inputs from
  40928. */
  40929. detachControl(element: Nullable<HTMLElement>): void;
  40930. /**
  40931. * Update the current camera state depending on the inputs that have been used this frame.
  40932. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40933. */
  40934. checkInputs(): void;
  40935. /**
  40936. * Gets the class name of the current intput.
  40937. * @returns the class name
  40938. */
  40939. getClassName(): string;
  40940. /**
  40941. * Get the friendly name associated with the input class.
  40942. * @returns the input friendly name
  40943. */
  40944. getSimpleName(): string;
  40945. }
  40946. }
  40947. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40948. import { Nullable } from "babylonjs/types";
  40949. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40950. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40951. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40952. interface ArcRotateCameraInputsManager {
  40953. /**
  40954. * Add orientation input support to the input manager.
  40955. * @returns the current input manager
  40956. */
  40957. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40958. }
  40959. }
  40960. /**
  40961. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40962. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40963. */
  40964. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40965. /**
  40966. * Defines the camera the input is attached to.
  40967. */
  40968. camera: ArcRotateCamera;
  40969. /**
  40970. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40971. */
  40972. alphaCorrection: number;
  40973. /**
  40974. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40975. */
  40976. gammaCorrection: number;
  40977. private _alpha;
  40978. private _gamma;
  40979. private _dirty;
  40980. private _deviceOrientationHandler;
  40981. /**
  40982. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40983. */
  40984. constructor();
  40985. /**
  40986. * Attach the input controls to a specific dom element to get the input from.
  40987. * @param element Defines the element the controls should be listened from
  40988. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40989. */
  40990. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40991. /** @hidden */
  40992. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40993. /**
  40994. * Update the current camera state depending on the inputs that have been used this frame.
  40995. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40996. */
  40997. checkInputs(): void;
  40998. /**
  40999. * Detach the current controls from the specified dom element.
  41000. * @param element Defines the element to stop listening the inputs from
  41001. */
  41002. detachControl(element: Nullable<HTMLElement>): void;
  41003. /**
  41004. * Gets the class name of the current intput.
  41005. * @returns the class name
  41006. */
  41007. getClassName(): string;
  41008. /**
  41009. * Get the friendly name associated with the input class.
  41010. * @returns the input friendly name
  41011. */
  41012. getSimpleName(): string;
  41013. }
  41014. }
  41015. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41016. import { Nullable } from "babylonjs/types";
  41017. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41018. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41019. /**
  41020. * Listen to mouse events to control the camera.
  41021. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41022. */
  41023. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41024. /**
  41025. * Defines the camera the input is attached to.
  41026. */
  41027. camera: FlyCamera;
  41028. /**
  41029. * Defines if touch is enabled. (Default is true.)
  41030. */
  41031. touchEnabled: boolean;
  41032. /**
  41033. * Defines the buttons associated with the input to handle camera rotation.
  41034. */
  41035. buttons: number[];
  41036. /**
  41037. * Assign buttons for Yaw control.
  41038. */
  41039. buttonsYaw: number[];
  41040. /**
  41041. * Assign buttons for Pitch control.
  41042. */
  41043. buttonsPitch: number[];
  41044. /**
  41045. * Assign buttons for Roll control.
  41046. */
  41047. buttonsRoll: number[];
  41048. /**
  41049. * Detect if any button is being pressed while mouse is moved.
  41050. * -1 = Mouse locked.
  41051. * 0 = Left button.
  41052. * 1 = Middle Button.
  41053. * 2 = Right Button.
  41054. */
  41055. activeButton: number;
  41056. /**
  41057. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41058. * Higher values reduce its sensitivity.
  41059. */
  41060. angularSensibility: number;
  41061. private _mousemoveCallback;
  41062. private _observer;
  41063. private _rollObserver;
  41064. private previousPosition;
  41065. private noPreventDefault;
  41066. private element;
  41067. /**
  41068. * Listen to mouse events to control the camera.
  41069. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41070. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41071. */
  41072. constructor(touchEnabled?: boolean);
  41073. /**
  41074. * Attach the mouse control to the HTML DOM element.
  41075. * @param element Defines the element that listens to the input events.
  41076. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41077. */
  41078. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41079. /**
  41080. * Detach the current controls from the specified dom element.
  41081. * @param element Defines the element to stop listening the inputs from
  41082. */
  41083. detachControl(element: Nullable<HTMLElement>): void;
  41084. /**
  41085. * Gets the class name of the current input.
  41086. * @returns the class name.
  41087. */
  41088. getClassName(): string;
  41089. /**
  41090. * Get the friendly name associated with the input class.
  41091. * @returns the input's friendly name.
  41092. */
  41093. getSimpleName(): string;
  41094. private _pointerInput;
  41095. private _onMouseMove;
  41096. /**
  41097. * Rotate camera by mouse offset.
  41098. */
  41099. private rotateCamera;
  41100. }
  41101. }
  41102. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41103. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41104. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41105. /**
  41106. * Default Inputs manager for the FlyCamera.
  41107. * It groups all the default supported inputs for ease of use.
  41108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41109. */
  41110. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41111. /**
  41112. * Instantiates a new FlyCameraInputsManager.
  41113. * @param camera Defines the camera the inputs belong to.
  41114. */
  41115. constructor(camera: FlyCamera);
  41116. /**
  41117. * Add keyboard input support to the input manager.
  41118. * @returns the new FlyCameraKeyboardMoveInput().
  41119. */
  41120. addKeyboard(): FlyCameraInputsManager;
  41121. /**
  41122. * Add mouse input support to the input manager.
  41123. * @param touchEnabled Enable touch screen support.
  41124. * @returns the new FlyCameraMouseInput().
  41125. */
  41126. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41127. }
  41128. }
  41129. declare module "babylonjs/Cameras/flyCamera" {
  41130. import { Scene } from "babylonjs/scene";
  41131. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41133. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41134. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41135. /**
  41136. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41137. * such as in a 3D Space Shooter or a Flight Simulator.
  41138. */
  41139. export class FlyCamera extends TargetCamera {
  41140. /**
  41141. * Define the collision ellipsoid of the camera.
  41142. * This is helpful for simulating a camera body, like a player's body.
  41143. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41144. */
  41145. ellipsoid: Vector3;
  41146. /**
  41147. * Define an offset for the position of the ellipsoid around the camera.
  41148. * This can be helpful if the camera is attached away from the player's body center,
  41149. * such as at its head.
  41150. */
  41151. ellipsoidOffset: Vector3;
  41152. /**
  41153. * Enable or disable collisions of the camera with the rest of the scene objects.
  41154. */
  41155. checkCollisions: boolean;
  41156. /**
  41157. * Enable or disable gravity on the camera.
  41158. */
  41159. applyGravity: boolean;
  41160. /**
  41161. * Define the current direction the camera is moving to.
  41162. */
  41163. cameraDirection: Vector3;
  41164. /**
  41165. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41166. * This overrides and empties cameraRotation.
  41167. */
  41168. rotationQuaternion: Quaternion;
  41169. /**
  41170. * Track Roll to maintain the wanted Rolling when looking around.
  41171. */
  41172. _trackRoll: number;
  41173. /**
  41174. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41175. */
  41176. rollCorrect: number;
  41177. /**
  41178. * Mimic a banked turn, Rolling the camera when Yawing.
  41179. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41180. */
  41181. bankedTurn: boolean;
  41182. /**
  41183. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41184. */
  41185. bankedTurnLimit: number;
  41186. /**
  41187. * Value of 0 disables the banked Roll.
  41188. * Value of 1 is equal to the Yaw angle in radians.
  41189. */
  41190. bankedTurnMultiplier: number;
  41191. /**
  41192. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41193. */
  41194. inputs: FlyCameraInputsManager;
  41195. /**
  41196. * Gets the input sensibility for mouse input.
  41197. * Higher values reduce sensitivity.
  41198. */
  41199. get angularSensibility(): number;
  41200. /**
  41201. * Sets the input sensibility for a mouse input.
  41202. * Higher values reduce sensitivity.
  41203. */
  41204. set angularSensibility(value: number);
  41205. /**
  41206. * Get the keys for camera movement forward.
  41207. */
  41208. get keysForward(): number[];
  41209. /**
  41210. * Set the keys for camera movement forward.
  41211. */
  41212. set keysForward(value: number[]);
  41213. /**
  41214. * Get the keys for camera movement backward.
  41215. */
  41216. get keysBackward(): number[];
  41217. set keysBackward(value: number[]);
  41218. /**
  41219. * Get the keys for camera movement up.
  41220. */
  41221. get keysUp(): number[];
  41222. /**
  41223. * Set the keys for camera movement up.
  41224. */
  41225. set keysUp(value: number[]);
  41226. /**
  41227. * Get the keys for camera movement down.
  41228. */
  41229. get keysDown(): number[];
  41230. /**
  41231. * Set the keys for camera movement down.
  41232. */
  41233. set keysDown(value: number[]);
  41234. /**
  41235. * Get the keys for camera movement left.
  41236. */
  41237. get keysLeft(): number[];
  41238. /**
  41239. * Set the keys for camera movement left.
  41240. */
  41241. set keysLeft(value: number[]);
  41242. /**
  41243. * Set the keys for camera movement right.
  41244. */
  41245. get keysRight(): number[];
  41246. /**
  41247. * Set the keys for camera movement right.
  41248. */
  41249. set keysRight(value: number[]);
  41250. /**
  41251. * Event raised when the camera collides with a mesh in the scene.
  41252. */
  41253. onCollide: (collidedMesh: AbstractMesh) => void;
  41254. private _collider;
  41255. private _needMoveForGravity;
  41256. private _oldPosition;
  41257. private _diffPosition;
  41258. private _newPosition;
  41259. /** @hidden */
  41260. _localDirection: Vector3;
  41261. /** @hidden */
  41262. _transformedDirection: Vector3;
  41263. /**
  41264. * Instantiates a FlyCamera.
  41265. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41266. * such as in a 3D Space Shooter or a Flight Simulator.
  41267. * @param name Define the name of the camera in the scene.
  41268. * @param position Define the starting position of the camera in the scene.
  41269. * @param scene Define the scene the camera belongs to.
  41270. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41271. */
  41272. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41273. /**
  41274. * Attach a control to the HTML DOM element.
  41275. * @param element Defines the element that listens to the input events.
  41276. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41277. */
  41278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41279. /**
  41280. * Detach a control from the HTML DOM element.
  41281. * The camera will stop reacting to that input.
  41282. * @param element Defines the element that listens to the input events.
  41283. */
  41284. detachControl(element: HTMLElement): void;
  41285. private _collisionMask;
  41286. /**
  41287. * Get the mask that the camera ignores in collision events.
  41288. */
  41289. get collisionMask(): number;
  41290. /**
  41291. * Set the mask that the camera ignores in collision events.
  41292. */
  41293. set collisionMask(mask: number);
  41294. /** @hidden */
  41295. _collideWithWorld(displacement: Vector3): void;
  41296. /** @hidden */
  41297. private _onCollisionPositionChange;
  41298. /** @hidden */
  41299. _checkInputs(): void;
  41300. /** @hidden */
  41301. _decideIfNeedsToMove(): boolean;
  41302. /** @hidden */
  41303. _updatePosition(): void;
  41304. /**
  41305. * Restore the Roll to its target value at the rate specified.
  41306. * @param rate - Higher means slower restoring.
  41307. * @hidden
  41308. */
  41309. restoreRoll(rate: number): void;
  41310. /**
  41311. * Destroy the camera and release the current resources held by it.
  41312. */
  41313. dispose(): void;
  41314. /**
  41315. * Get the current object class name.
  41316. * @returns the class name.
  41317. */
  41318. getClassName(): string;
  41319. }
  41320. }
  41321. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41322. import { Nullable } from "babylonjs/types";
  41323. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41324. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41325. /**
  41326. * Listen to keyboard events to control the camera.
  41327. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41328. */
  41329. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41330. /**
  41331. * Defines the camera the input is attached to.
  41332. */
  41333. camera: FlyCamera;
  41334. /**
  41335. * The list of keyboard keys used to control the forward move of the camera.
  41336. */
  41337. keysForward: number[];
  41338. /**
  41339. * The list of keyboard keys used to control the backward move of the camera.
  41340. */
  41341. keysBackward: number[];
  41342. /**
  41343. * The list of keyboard keys used to control the forward move of the camera.
  41344. */
  41345. keysUp: number[];
  41346. /**
  41347. * The list of keyboard keys used to control the backward move of the camera.
  41348. */
  41349. keysDown: number[];
  41350. /**
  41351. * The list of keyboard keys used to control the right strafe move of the camera.
  41352. */
  41353. keysRight: number[];
  41354. /**
  41355. * The list of keyboard keys used to control the left strafe move of the camera.
  41356. */
  41357. keysLeft: number[];
  41358. private _keys;
  41359. private _onCanvasBlurObserver;
  41360. private _onKeyboardObserver;
  41361. private _engine;
  41362. private _scene;
  41363. /**
  41364. * Attach the input controls to a specific dom element to get the input from.
  41365. * @param element Defines the element the controls should be listened from
  41366. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41367. */
  41368. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41369. /**
  41370. * Detach the current controls from the specified dom element.
  41371. * @param element Defines the element to stop listening the inputs from
  41372. */
  41373. detachControl(element: Nullable<HTMLElement>): void;
  41374. /**
  41375. * Gets the class name of the current intput.
  41376. * @returns the class name
  41377. */
  41378. getClassName(): string;
  41379. /** @hidden */
  41380. _onLostFocus(e: FocusEvent): void;
  41381. /**
  41382. * Get the friendly name associated with the input class.
  41383. * @returns the input friendly name
  41384. */
  41385. getSimpleName(): string;
  41386. /**
  41387. * Update the current camera state depending on the inputs that have been used this frame.
  41388. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41389. */
  41390. checkInputs(): void;
  41391. }
  41392. }
  41393. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41394. import { Nullable } from "babylonjs/types";
  41395. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41396. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41397. /**
  41398. * Manage the mouse wheel inputs to control a follow camera.
  41399. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41400. */
  41401. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41402. /**
  41403. * Defines the camera the input is attached to.
  41404. */
  41405. camera: FollowCamera;
  41406. /**
  41407. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41408. */
  41409. axisControlRadius: boolean;
  41410. /**
  41411. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41412. */
  41413. axisControlHeight: boolean;
  41414. /**
  41415. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41416. */
  41417. axisControlRotation: boolean;
  41418. /**
  41419. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41420. * relation to mouseWheel events.
  41421. */
  41422. wheelPrecision: number;
  41423. /**
  41424. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41425. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41426. */
  41427. wheelDeltaPercentage: number;
  41428. private _wheel;
  41429. private _observer;
  41430. /**
  41431. * Attach the input controls to a specific dom element to get the input from.
  41432. * @param element Defines the element the controls should be listened from
  41433. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41434. */
  41435. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41436. /**
  41437. * Detach the current controls from the specified dom element.
  41438. * @param element Defines the element to stop listening the inputs from
  41439. */
  41440. detachControl(element: Nullable<HTMLElement>): void;
  41441. /**
  41442. * Gets the class name of the current intput.
  41443. * @returns the class name
  41444. */
  41445. getClassName(): string;
  41446. /**
  41447. * Get the friendly name associated with the input class.
  41448. * @returns the input friendly name
  41449. */
  41450. getSimpleName(): string;
  41451. }
  41452. }
  41453. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41454. import { Nullable } from "babylonjs/types";
  41455. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41456. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41457. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41458. /**
  41459. * Manage the pointers inputs to control an follow camera.
  41460. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41461. */
  41462. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41463. /**
  41464. * Defines the camera the input is attached to.
  41465. */
  41466. camera: FollowCamera;
  41467. /**
  41468. * Gets the class name of the current input.
  41469. * @returns the class name
  41470. */
  41471. getClassName(): string;
  41472. /**
  41473. * Defines the pointer angular sensibility along the X axis or how fast is
  41474. * the camera rotating.
  41475. * A negative number will reverse the axis direction.
  41476. */
  41477. angularSensibilityX: number;
  41478. /**
  41479. * Defines the pointer angular sensibility along the Y axis or how fast is
  41480. * the camera rotating.
  41481. * A negative number will reverse the axis direction.
  41482. */
  41483. angularSensibilityY: number;
  41484. /**
  41485. * Defines the pointer pinch precision or how fast is the camera zooming.
  41486. * A negative number will reverse the axis direction.
  41487. */
  41488. pinchPrecision: number;
  41489. /**
  41490. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41491. * from 0.
  41492. * It defines the percentage of current camera.radius to use as delta when
  41493. * pinch zoom is used.
  41494. */
  41495. pinchDeltaPercentage: number;
  41496. /**
  41497. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41498. */
  41499. axisXControlRadius: boolean;
  41500. /**
  41501. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41502. */
  41503. axisXControlHeight: boolean;
  41504. /**
  41505. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41506. */
  41507. axisXControlRotation: boolean;
  41508. /**
  41509. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41510. */
  41511. axisYControlRadius: boolean;
  41512. /**
  41513. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41514. */
  41515. axisYControlHeight: boolean;
  41516. /**
  41517. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41518. */
  41519. axisYControlRotation: boolean;
  41520. /**
  41521. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41522. */
  41523. axisPinchControlRadius: boolean;
  41524. /**
  41525. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41526. */
  41527. axisPinchControlHeight: boolean;
  41528. /**
  41529. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41530. */
  41531. axisPinchControlRotation: boolean;
  41532. /**
  41533. * Log error messages if basic misconfiguration has occurred.
  41534. */
  41535. warningEnable: boolean;
  41536. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41537. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41538. private _warningCounter;
  41539. private _warning;
  41540. }
  41541. }
  41542. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41543. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41544. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41545. /**
  41546. * Default Inputs manager for the FollowCamera.
  41547. * It groups all the default supported inputs for ease of use.
  41548. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41549. */
  41550. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41551. /**
  41552. * Instantiates a new FollowCameraInputsManager.
  41553. * @param camera Defines the camera the inputs belong to
  41554. */
  41555. constructor(camera: FollowCamera);
  41556. /**
  41557. * Add keyboard input support to the input manager.
  41558. * @returns the current input manager
  41559. */
  41560. addKeyboard(): FollowCameraInputsManager;
  41561. /**
  41562. * Add mouse wheel input support to the input manager.
  41563. * @returns the current input manager
  41564. */
  41565. addMouseWheel(): FollowCameraInputsManager;
  41566. /**
  41567. * Add pointers input support to the input manager.
  41568. * @returns the current input manager
  41569. */
  41570. addPointers(): FollowCameraInputsManager;
  41571. /**
  41572. * Add orientation input support to the input manager.
  41573. * @returns the current input manager
  41574. */
  41575. addVRDeviceOrientation(): FollowCameraInputsManager;
  41576. }
  41577. }
  41578. declare module "babylonjs/Cameras/followCamera" {
  41579. import { Nullable } from "babylonjs/types";
  41580. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41581. import { Scene } from "babylonjs/scene";
  41582. import { Vector3 } from "babylonjs/Maths/math.vector";
  41583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41584. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41585. /**
  41586. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41587. * an arc rotate version arcFollowCamera are available.
  41588. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41589. */
  41590. export class FollowCamera extends TargetCamera {
  41591. /**
  41592. * Distance the follow camera should follow an object at
  41593. */
  41594. radius: number;
  41595. /**
  41596. * Minimum allowed distance of the camera to the axis of rotation
  41597. * (The camera can not get closer).
  41598. * This can help limiting how the Camera is able to move in the scene.
  41599. */
  41600. lowerRadiusLimit: Nullable<number>;
  41601. /**
  41602. * Maximum allowed distance of the camera to the axis of rotation
  41603. * (The camera can not get further).
  41604. * This can help limiting how the Camera is able to move in the scene.
  41605. */
  41606. upperRadiusLimit: Nullable<number>;
  41607. /**
  41608. * Define a rotation offset between the camera and the object it follows
  41609. */
  41610. rotationOffset: number;
  41611. /**
  41612. * Minimum allowed angle to camera position relative to target object.
  41613. * This can help limiting how the Camera is able to move in the scene.
  41614. */
  41615. lowerRotationOffsetLimit: Nullable<number>;
  41616. /**
  41617. * Maximum allowed angle to camera position relative to target object.
  41618. * This can help limiting how the Camera is able to move in the scene.
  41619. */
  41620. upperRotationOffsetLimit: Nullable<number>;
  41621. /**
  41622. * Define a height offset between the camera and the object it follows.
  41623. * It can help following an object from the top (like a car chaing a plane)
  41624. */
  41625. heightOffset: number;
  41626. /**
  41627. * Minimum allowed height of camera position relative to target object.
  41628. * This can help limiting how the Camera is able to move in the scene.
  41629. */
  41630. lowerHeightOffsetLimit: Nullable<number>;
  41631. /**
  41632. * Maximum allowed height of camera position relative to target object.
  41633. * This can help limiting how the Camera is able to move in the scene.
  41634. */
  41635. upperHeightOffsetLimit: Nullable<number>;
  41636. /**
  41637. * Define how fast the camera can accelerate to follow it s target.
  41638. */
  41639. cameraAcceleration: number;
  41640. /**
  41641. * Define the speed limit of the camera following an object.
  41642. */
  41643. maxCameraSpeed: number;
  41644. /**
  41645. * Define the target of the camera.
  41646. */
  41647. lockedTarget: Nullable<AbstractMesh>;
  41648. /**
  41649. * Defines the input associated with the camera.
  41650. */
  41651. inputs: FollowCameraInputsManager;
  41652. /**
  41653. * Instantiates the follow camera.
  41654. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41655. * @param name Define the name of the camera in the scene
  41656. * @param position Define the position of the camera
  41657. * @param scene Define the scene the camera belong to
  41658. * @param lockedTarget Define the target of the camera
  41659. */
  41660. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41661. private _follow;
  41662. /**
  41663. * Attached controls to the current camera.
  41664. * @param element Defines the element the controls should be listened from
  41665. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41666. */
  41667. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41668. /**
  41669. * Detach the current controls from the camera.
  41670. * The camera will stop reacting to inputs.
  41671. * @param element Defines the element to stop listening the inputs from
  41672. */
  41673. detachControl(element: HTMLElement): void;
  41674. /** @hidden */
  41675. _checkInputs(): void;
  41676. private _checkLimits;
  41677. /**
  41678. * Gets the camera class name.
  41679. * @returns the class name
  41680. */
  41681. getClassName(): string;
  41682. }
  41683. /**
  41684. * Arc Rotate version of the follow camera.
  41685. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41686. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41687. */
  41688. export class ArcFollowCamera extends TargetCamera {
  41689. /** The longitudinal angle of the camera */
  41690. alpha: number;
  41691. /** The latitudinal angle of the camera */
  41692. beta: number;
  41693. /** The radius of the camera from its target */
  41694. radius: number;
  41695. /** Define the camera target (the messh it should follow) */
  41696. target: Nullable<AbstractMesh>;
  41697. private _cartesianCoordinates;
  41698. /**
  41699. * Instantiates a new ArcFollowCamera
  41700. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41701. * @param name Define the name of the camera
  41702. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41703. * @param beta Define the rotation angle of the camera around the elevation axis
  41704. * @param radius Define the radius of the camera from its target point
  41705. * @param target Define the target of the camera
  41706. * @param scene Define the scene the camera belongs to
  41707. */
  41708. constructor(name: string,
  41709. /** The longitudinal angle of the camera */
  41710. alpha: number,
  41711. /** The latitudinal angle of the camera */
  41712. beta: number,
  41713. /** The radius of the camera from its target */
  41714. radius: number,
  41715. /** Define the camera target (the messh it should follow) */
  41716. target: Nullable<AbstractMesh>, scene: Scene);
  41717. private _follow;
  41718. /** @hidden */
  41719. _checkInputs(): void;
  41720. /**
  41721. * Returns the class name of the object.
  41722. * It is mostly used internally for serialization purposes.
  41723. */
  41724. getClassName(): string;
  41725. }
  41726. }
  41727. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41728. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41729. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41730. import { Nullable } from "babylonjs/types";
  41731. /**
  41732. * Manage the keyboard inputs to control the movement of a follow camera.
  41733. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41734. */
  41735. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41736. /**
  41737. * Defines the camera the input is attached to.
  41738. */
  41739. camera: FollowCamera;
  41740. /**
  41741. * Defines the list of key codes associated with the up action (increase heightOffset)
  41742. */
  41743. keysHeightOffsetIncr: number[];
  41744. /**
  41745. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41746. */
  41747. keysHeightOffsetDecr: number[];
  41748. /**
  41749. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41750. */
  41751. keysHeightOffsetModifierAlt: boolean;
  41752. /**
  41753. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41754. */
  41755. keysHeightOffsetModifierCtrl: boolean;
  41756. /**
  41757. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41758. */
  41759. keysHeightOffsetModifierShift: boolean;
  41760. /**
  41761. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41762. */
  41763. keysRotationOffsetIncr: number[];
  41764. /**
  41765. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41766. */
  41767. keysRotationOffsetDecr: number[];
  41768. /**
  41769. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41770. */
  41771. keysRotationOffsetModifierAlt: boolean;
  41772. /**
  41773. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41774. */
  41775. keysRotationOffsetModifierCtrl: boolean;
  41776. /**
  41777. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41778. */
  41779. keysRotationOffsetModifierShift: boolean;
  41780. /**
  41781. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41782. */
  41783. keysRadiusIncr: number[];
  41784. /**
  41785. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41786. */
  41787. keysRadiusDecr: number[];
  41788. /**
  41789. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41790. */
  41791. keysRadiusModifierAlt: boolean;
  41792. /**
  41793. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41794. */
  41795. keysRadiusModifierCtrl: boolean;
  41796. /**
  41797. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41798. */
  41799. keysRadiusModifierShift: boolean;
  41800. /**
  41801. * Defines the rate of change of heightOffset.
  41802. */
  41803. heightSensibility: number;
  41804. /**
  41805. * Defines the rate of change of rotationOffset.
  41806. */
  41807. rotationSensibility: number;
  41808. /**
  41809. * Defines the rate of change of radius.
  41810. */
  41811. radiusSensibility: number;
  41812. private _keys;
  41813. private _ctrlPressed;
  41814. private _altPressed;
  41815. private _shiftPressed;
  41816. private _onCanvasBlurObserver;
  41817. private _onKeyboardObserver;
  41818. private _engine;
  41819. private _scene;
  41820. /**
  41821. * Attach the input controls to a specific dom element to get the input from.
  41822. * @param element Defines the element the controls should be listened from
  41823. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41824. */
  41825. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41826. /**
  41827. * Detach the current controls from the specified dom element.
  41828. * @param element Defines the element to stop listening the inputs from
  41829. */
  41830. detachControl(element: Nullable<HTMLElement>): void;
  41831. /**
  41832. * Update the current camera state depending on the inputs that have been used this frame.
  41833. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41834. */
  41835. checkInputs(): void;
  41836. /**
  41837. * Gets the class name of the current input.
  41838. * @returns the class name
  41839. */
  41840. getClassName(): string;
  41841. /**
  41842. * Get the friendly name associated with the input class.
  41843. * @returns the input friendly name
  41844. */
  41845. getSimpleName(): string;
  41846. /**
  41847. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41848. * allow modification of the heightOffset value.
  41849. */
  41850. private _modifierHeightOffset;
  41851. /**
  41852. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41853. * allow modification of the rotationOffset value.
  41854. */
  41855. private _modifierRotationOffset;
  41856. /**
  41857. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41858. * allow modification of the radius value.
  41859. */
  41860. private _modifierRadius;
  41861. }
  41862. }
  41863. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41864. import { Nullable } from "babylonjs/types";
  41865. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41866. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41867. import { Observable } from "babylonjs/Misc/observable";
  41868. module "babylonjs/Cameras/freeCameraInputsManager" {
  41869. interface FreeCameraInputsManager {
  41870. /**
  41871. * @hidden
  41872. */
  41873. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41874. /**
  41875. * Add orientation input support to the input manager.
  41876. * @returns the current input manager
  41877. */
  41878. addDeviceOrientation(): FreeCameraInputsManager;
  41879. }
  41880. }
  41881. /**
  41882. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41883. * Screen rotation is taken into account.
  41884. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41885. */
  41886. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41887. private _camera;
  41888. private _screenOrientationAngle;
  41889. private _constantTranform;
  41890. private _screenQuaternion;
  41891. private _alpha;
  41892. private _beta;
  41893. private _gamma;
  41894. /**
  41895. * Can be used to detect if a device orientation sensor is available on a device
  41896. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41897. * @returns a promise that will resolve on orientation change
  41898. */
  41899. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41900. /**
  41901. * @hidden
  41902. */
  41903. _onDeviceOrientationChangedObservable: Observable<void>;
  41904. /**
  41905. * Instantiates a new input
  41906. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41907. */
  41908. constructor();
  41909. /**
  41910. * Define the camera controlled by the input.
  41911. */
  41912. get camera(): FreeCamera;
  41913. set camera(camera: FreeCamera);
  41914. /**
  41915. * Attach the input controls to a specific dom element to get the input from.
  41916. * @param element Defines the element the controls should be listened from
  41917. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41918. */
  41919. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41920. private _orientationChanged;
  41921. private _deviceOrientation;
  41922. /**
  41923. * Detach the current controls from the specified dom element.
  41924. * @param element Defines the element to stop listening the inputs from
  41925. */
  41926. detachControl(element: Nullable<HTMLElement>): void;
  41927. /**
  41928. * Update the current camera state depending on the inputs that have been used this frame.
  41929. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41930. */
  41931. checkInputs(): void;
  41932. /**
  41933. * Gets the class name of the current intput.
  41934. * @returns the class name
  41935. */
  41936. getClassName(): string;
  41937. /**
  41938. * Get the friendly name associated with the input class.
  41939. * @returns the input friendly name
  41940. */
  41941. getSimpleName(): string;
  41942. }
  41943. }
  41944. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41945. import { Nullable } from "babylonjs/types";
  41946. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41947. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41948. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41949. /**
  41950. * Manage the gamepad inputs to control a free camera.
  41951. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41952. */
  41953. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41954. /**
  41955. * Define the camera the input is attached to.
  41956. */
  41957. camera: FreeCamera;
  41958. /**
  41959. * Define the Gamepad controlling the input
  41960. */
  41961. gamepad: Nullable<Gamepad>;
  41962. /**
  41963. * Defines the gamepad rotation sensiblity.
  41964. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41965. */
  41966. gamepadAngularSensibility: number;
  41967. /**
  41968. * Defines the gamepad move sensiblity.
  41969. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41970. */
  41971. gamepadMoveSensibility: number;
  41972. private _yAxisScale;
  41973. /**
  41974. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41975. */
  41976. get invertYAxis(): boolean;
  41977. set invertYAxis(value: boolean);
  41978. private _onGamepadConnectedObserver;
  41979. private _onGamepadDisconnectedObserver;
  41980. private _cameraTransform;
  41981. private _deltaTransform;
  41982. private _vector3;
  41983. private _vector2;
  41984. /**
  41985. * Attach the input controls to a specific dom element to get the input from.
  41986. * @param element Defines the element the controls should be listened from
  41987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41988. */
  41989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41990. /**
  41991. * Detach the current controls from the specified dom element.
  41992. * @param element Defines the element to stop listening the inputs from
  41993. */
  41994. detachControl(element: Nullable<HTMLElement>): void;
  41995. /**
  41996. * Update the current camera state depending on the inputs that have been used this frame.
  41997. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41998. */
  41999. checkInputs(): void;
  42000. /**
  42001. * Gets the class name of the current intput.
  42002. * @returns the class name
  42003. */
  42004. getClassName(): string;
  42005. /**
  42006. * Get the friendly name associated with the input class.
  42007. * @returns the input friendly name
  42008. */
  42009. getSimpleName(): string;
  42010. }
  42011. }
  42012. declare module "babylonjs/Misc/virtualJoystick" {
  42013. import { Nullable } from "babylonjs/types";
  42014. import { Vector3 } from "babylonjs/Maths/math.vector";
  42015. /**
  42016. * Defines the potential axis of a Joystick
  42017. */
  42018. export enum JoystickAxis {
  42019. /** X axis */
  42020. X = 0,
  42021. /** Y axis */
  42022. Y = 1,
  42023. /** Z axis */
  42024. Z = 2
  42025. }
  42026. /**
  42027. * Class used to define virtual joystick (used in touch mode)
  42028. */
  42029. export class VirtualJoystick {
  42030. /**
  42031. * Gets or sets a boolean indicating that left and right values must be inverted
  42032. */
  42033. reverseLeftRight: boolean;
  42034. /**
  42035. * Gets or sets a boolean indicating that up and down values must be inverted
  42036. */
  42037. reverseUpDown: boolean;
  42038. /**
  42039. * Gets the offset value for the position (ie. the change of the position value)
  42040. */
  42041. deltaPosition: Vector3;
  42042. /**
  42043. * Gets a boolean indicating if the virtual joystick was pressed
  42044. */
  42045. pressed: boolean;
  42046. /**
  42047. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42048. */
  42049. static Canvas: Nullable<HTMLCanvasElement>;
  42050. private static _globalJoystickIndex;
  42051. private static vjCanvasContext;
  42052. private static vjCanvasWidth;
  42053. private static vjCanvasHeight;
  42054. private static halfWidth;
  42055. private _action;
  42056. private _axisTargetedByLeftAndRight;
  42057. private _axisTargetedByUpAndDown;
  42058. private _joystickSensibility;
  42059. private _inversedSensibility;
  42060. private _joystickPointerID;
  42061. private _joystickColor;
  42062. private _joystickPointerPos;
  42063. private _joystickPreviousPointerPos;
  42064. private _joystickPointerStartPos;
  42065. private _deltaJoystickVector;
  42066. private _leftJoystick;
  42067. private _touches;
  42068. private _onPointerDownHandlerRef;
  42069. private _onPointerMoveHandlerRef;
  42070. private _onPointerUpHandlerRef;
  42071. private _onResize;
  42072. /**
  42073. * Creates a new virtual joystick
  42074. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42075. */
  42076. constructor(leftJoystick?: boolean);
  42077. /**
  42078. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42079. * @param newJoystickSensibility defines the new sensibility
  42080. */
  42081. setJoystickSensibility(newJoystickSensibility: number): void;
  42082. private _onPointerDown;
  42083. private _onPointerMove;
  42084. private _onPointerUp;
  42085. /**
  42086. * Change the color of the virtual joystick
  42087. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42088. */
  42089. setJoystickColor(newColor: string): void;
  42090. /**
  42091. * Defines a callback to call when the joystick is touched
  42092. * @param action defines the callback
  42093. */
  42094. setActionOnTouch(action: () => any): void;
  42095. /**
  42096. * Defines which axis you'd like to control for left & right
  42097. * @param axis defines the axis to use
  42098. */
  42099. setAxisForLeftRight(axis: JoystickAxis): void;
  42100. /**
  42101. * Defines which axis you'd like to control for up & down
  42102. * @param axis defines the axis to use
  42103. */
  42104. setAxisForUpDown(axis: JoystickAxis): void;
  42105. private _drawVirtualJoystick;
  42106. /**
  42107. * Release internal HTML canvas
  42108. */
  42109. releaseCanvas(): void;
  42110. }
  42111. }
  42112. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42113. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42114. import { Nullable } from "babylonjs/types";
  42115. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42116. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42117. module "babylonjs/Cameras/freeCameraInputsManager" {
  42118. interface FreeCameraInputsManager {
  42119. /**
  42120. * Add virtual joystick input support to the input manager.
  42121. * @returns the current input manager
  42122. */
  42123. addVirtualJoystick(): FreeCameraInputsManager;
  42124. }
  42125. }
  42126. /**
  42127. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42128. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42129. */
  42130. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42131. /**
  42132. * Defines the camera the input is attached to.
  42133. */
  42134. camera: FreeCamera;
  42135. private _leftjoystick;
  42136. private _rightjoystick;
  42137. /**
  42138. * Gets the left stick of the virtual joystick.
  42139. * @returns The virtual Joystick
  42140. */
  42141. getLeftJoystick(): VirtualJoystick;
  42142. /**
  42143. * Gets the right stick of the virtual joystick.
  42144. * @returns The virtual Joystick
  42145. */
  42146. getRightJoystick(): VirtualJoystick;
  42147. /**
  42148. * Update the current camera state depending on the inputs that have been used this frame.
  42149. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42150. */
  42151. checkInputs(): void;
  42152. /**
  42153. * Attach the input controls to a specific dom element to get the input from.
  42154. * @param element Defines the element the controls should be listened from
  42155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42156. */
  42157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42158. /**
  42159. * Detach the current controls from the specified dom element.
  42160. * @param element Defines the element to stop listening the inputs from
  42161. */
  42162. detachControl(element: Nullable<HTMLElement>): void;
  42163. /**
  42164. * Gets the class name of the current intput.
  42165. * @returns the class name
  42166. */
  42167. getClassName(): string;
  42168. /**
  42169. * Get the friendly name associated with the input class.
  42170. * @returns the input friendly name
  42171. */
  42172. getSimpleName(): string;
  42173. }
  42174. }
  42175. declare module "babylonjs/Cameras/Inputs/index" {
  42176. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42177. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42178. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42179. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42180. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42181. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42182. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42183. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42184. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42185. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42186. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42187. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42188. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42189. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42190. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42191. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42192. }
  42193. declare module "babylonjs/Cameras/touchCamera" {
  42194. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42195. import { Scene } from "babylonjs/scene";
  42196. import { Vector3 } from "babylonjs/Maths/math.vector";
  42197. /**
  42198. * This represents a FPS type of camera controlled by touch.
  42199. * This is like a universal camera minus the Gamepad controls.
  42200. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42201. */
  42202. export class TouchCamera extends FreeCamera {
  42203. /**
  42204. * Defines the touch sensibility for rotation.
  42205. * The higher the faster.
  42206. */
  42207. get touchAngularSensibility(): number;
  42208. set touchAngularSensibility(value: number);
  42209. /**
  42210. * Defines the touch sensibility for move.
  42211. * The higher the faster.
  42212. */
  42213. get touchMoveSensibility(): number;
  42214. set touchMoveSensibility(value: number);
  42215. /**
  42216. * Instantiates a new touch camera.
  42217. * This represents a FPS type of camera controlled by touch.
  42218. * This is like a universal camera minus the Gamepad controls.
  42219. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42220. * @param name Define the name of the camera in the scene
  42221. * @param position Define the start position of the camera in the scene
  42222. * @param scene Define the scene the camera belongs to
  42223. */
  42224. constructor(name: string, position: Vector3, scene: Scene);
  42225. /**
  42226. * Gets the current object class name.
  42227. * @return the class name
  42228. */
  42229. getClassName(): string;
  42230. /** @hidden */
  42231. _setupInputs(): void;
  42232. }
  42233. }
  42234. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42235. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42236. import { Scene } from "babylonjs/scene";
  42237. import { Vector3 } from "babylonjs/Maths/math.vector";
  42238. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42239. import { Axis } from "babylonjs/Maths/math.axis";
  42240. /**
  42241. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42242. * being tilted forward or back and left or right.
  42243. */
  42244. export class DeviceOrientationCamera extends FreeCamera {
  42245. private _initialQuaternion;
  42246. private _quaternionCache;
  42247. private _tmpDragQuaternion;
  42248. private _disablePointerInputWhenUsingDeviceOrientation;
  42249. /**
  42250. * Creates a new device orientation camera
  42251. * @param name The name of the camera
  42252. * @param position The start position camera
  42253. * @param scene The scene the camera belongs to
  42254. */
  42255. constructor(name: string, position: Vector3, scene: Scene);
  42256. /**
  42257. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42258. */
  42259. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42260. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42261. private _dragFactor;
  42262. /**
  42263. * Enabled turning on the y axis when the orientation sensor is active
  42264. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42265. */
  42266. enableHorizontalDragging(dragFactor?: number): void;
  42267. /**
  42268. * Gets the current instance class name ("DeviceOrientationCamera").
  42269. * This helps avoiding instanceof at run time.
  42270. * @returns the class name
  42271. */
  42272. getClassName(): string;
  42273. /**
  42274. * @hidden
  42275. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42276. */
  42277. _checkInputs(): void;
  42278. /**
  42279. * Reset the camera to its default orientation on the specified axis only.
  42280. * @param axis The axis to reset
  42281. */
  42282. resetToCurrentRotation(axis?: Axis): void;
  42283. }
  42284. }
  42285. declare module "babylonjs/Gamepads/xboxGamepad" {
  42286. import { Observable } from "babylonjs/Misc/observable";
  42287. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42288. /**
  42289. * Defines supported buttons for XBox360 compatible gamepads
  42290. */
  42291. export enum Xbox360Button {
  42292. /** A */
  42293. A = 0,
  42294. /** B */
  42295. B = 1,
  42296. /** X */
  42297. X = 2,
  42298. /** Y */
  42299. Y = 3,
  42300. /** Left button */
  42301. LB = 4,
  42302. /** Right button */
  42303. RB = 5,
  42304. /** Back */
  42305. Back = 8,
  42306. /** Start */
  42307. Start = 9,
  42308. /** Left stick */
  42309. LeftStick = 10,
  42310. /** Right stick */
  42311. RightStick = 11
  42312. }
  42313. /** Defines values for XBox360 DPad */
  42314. export enum Xbox360Dpad {
  42315. /** Up */
  42316. Up = 12,
  42317. /** Down */
  42318. Down = 13,
  42319. /** Left */
  42320. Left = 14,
  42321. /** Right */
  42322. Right = 15
  42323. }
  42324. /**
  42325. * Defines a XBox360 gamepad
  42326. */
  42327. export class Xbox360Pad extends Gamepad {
  42328. private _leftTrigger;
  42329. private _rightTrigger;
  42330. private _onlefttriggerchanged;
  42331. private _onrighttriggerchanged;
  42332. private _onbuttondown;
  42333. private _onbuttonup;
  42334. private _ondpaddown;
  42335. private _ondpadup;
  42336. /** Observable raised when a button is pressed */
  42337. onButtonDownObservable: Observable<Xbox360Button>;
  42338. /** Observable raised when a button is released */
  42339. onButtonUpObservable: Observable<Xbox360Button>;
  42340. /** Observable raised when a pad is pressed */
  42341. onPadDownObservable: Observable<Xbox360Dpad>;
  42342. /** Observable raised when a pad is released */
  42343. onPadUpObservable: Observable<Xbox360Dpad>;
  42344. private _buttonA;
  42345. private _buttonB;
  42346. private _buttonX;
  42347. private _buttonY;
  42348. private _buttonBack;
  42349. private _buttonStart;
  42350. private _buttonLB;
  42351. private _buttonRB;
  42352. private _buttonLeftStick;
  42353. private _buttonRightStick;
  42354. private _dPadUp;
  42355. private _dPadDown;
  42356. private _dPadLeft;
  42357. private _dPadRight;
  42358. private _isXboxOnePad;
  42359. /**
  42360. * Creates a new XBox360 gamepad object
  42361. * @param id defines the id of this gamepad
  42362. * @param index defines its index
  42363. * @param gamepad defines the internal HTML gamepad object
  42364. * @param xboxOne defines if it is a XBox One gamepad
  42365. */
  42366. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42367. /**
  42368. * Defines the callback to call when left trigger is pressed
  42369. * @param callback defines the callback to use
  42370. */
  42371. onlefttriggerchanged(callback: (value: number) => void): void;
  42372. /**
  42373. * Defines the callback to call when right trigger is pressed
  42374. * @param callback defines the callback to use
  42375. */
  42376. onrighttriggerchanged(callback: (value: number) => void): void;
  42377. /**
  42378. * Gets the left trigger value
  42379. */
  42380. get leftTrigger(): number;
  42381. /**
  42382. * Sets the left trigger value
  42383. */
  42384. set leftTrigger(newValue: number);
  42385. /**
  42386. * Gets the right trigger value
  42387. */
  42388. get rightTrigger(): number;
  42389. /**
  42390. * Sets the right trigger value
  42391. */
  42392. set rightTrigger(newValue: number);
  42393. /**
  42394. * Defines the callback to call when a button is pressed
  42395. * @param callback defines the callback to use
  42396. */
  42397. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42398. /**
  42399. * Defines the callback to call when a button is released
  42400. * @param callback defines the callback to use
  42401. */
  42402. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42403. /**
  42404. * Defines the callback to call when a pad is pressed
  42405. * @param callback defines the callback to use
  42406. */
  42407. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42408. /**
  42409. * Defines the callback to call when a pad is released
  42410. * @param callback defines the callback to use
  42411. */
  42412. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42413. private _setButtonValue;
  42414. private _setDPadValue;
  42415. /**
  42416. * Gets the value of the `A` button
  42417. */
  42418. get buttonA(): number;
  42419. /**
  42420. * Sets the value of the `A` button
  42421. */
  42422. set buttonA(value: number);
  42423. /**
  42424. * Gets the value of the `B` button
  42425. */
  42426. get buttonB(): number;
  42427. /**
  42428. * Sets the value of the `B` button
  42429. */
  42430. set buttonB(value: number);
  42431. /**
  42432. * Gets the value of the `X` button
  42433. */
  42434. get buttonX(): number;
  42435. /**
  42436. * Sets the value of the `X` button
  42437. */
  42438. set buttonX(value: number);
  42439. /**
  42440. * Gets the value of the `Y` button
  42441. */
  42442. get buttonY(): number;
  42443. /**
  42444. * Sets the value of the `Y` button
  42445. */
  42446. set buttonY(value: number);
  42447. /**
  42448. * Gets the value of the `Start` button
  42449. */
  42450. get buttonStart(): number;
  42451. /**
  42452. * Sets the value of the `Start` button
  42453. */
  42454. set buttonStart(value: number);
  42455. /**
  42456. * Gets the value of the `Back` button
  42457. */
  42458. get buttonBack(): number;
  42459. /**
  42460. * Sets the value of the `Back` button
  42461. */
  42462. set buttonBack(value: number);
  42463. /**
  42464. * Gets the value of the `Left` button
  42465. */
  42466. get buttonLB(): number;
  42467. /**
  42468. * Sets the value of the `Left` button
  42469. */
  42470. set buttonLB(value: number);
  42471. /**
  42472. * Gets the value of the `Right` button
  42473. */
  42474. get buttonRB(): number;
  42475. /**
  42476. * Sets the value of the `Right` button
  42477. */
  42478. set buttonRB(value: number);
  42479. /**
  42480. * Gets the value of the Left joystick
  42481. */
  42482. get buttonLeftStick(): number;
  42483. /**
  42484. * Sets the value of the Left joystick
  42485. */
  42486. set buttonLeftStick(value: number);
  42487. /**
  42488. * Gets the value of the Right joystick
  42489. */
  42490. get buttonRightStick(): number;
  42491. /**
  42492. * Sets the value of the Right joystick
  42493. */
  42494. set buttonRightStick(value: number);
  42495. /**
  42496. * Gets the value of D-pad up
  42497. */
  42498. get dPadUp(): number;
  42499. /**
  42500. * Sets the value of D-pad up
  42501. */
  42502. set dPadUp(value: number);
  42503. /**
  42504. * Gets the value of D-pad down
  42505. */
  42506. get dPadDown(): number;
  42507. /**
  42508. * Sets the value of D-pad down
  42509. */
  42510. set dPadDown(value: number);
  42511. /**
  42512. * Gets the value of D-pad left
  42513. */
  42514. get dPadLeft(): number;
  42515. /**
  42516. * Sets the value of D-pad left
  42517. */
  42518. set dPadLeft(value: number);
  42519. /**
  42520. * Gets the value of D-pad right
  42521. */
  42522. get dPadRight(): number;
  42523. /**
  42524. * Sets the value of D-pad right
  42525. */
  42526. set dPadRight(value: number);
  42527. /**
  42528. * Force the gamepad to synchronize with device values
  42529. */
  42530. update(): void;
  42531. /**
  42532. * Disposes the gamepad
  42533. */
  42534. dispose(): void;
  42535. }
  42536. }
  42537. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42538. import { Observable } from "babylonjs/Misc/observable";
  42539. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42540. /**
  42541. * Defines supported buttons for DualShock compatible gamepads
  42542. */
  42543. export enum DualShockButton {
  42544. /** Cross */
  42545. Cross = 0,
  42546. /** Circle */
  42547. Circle = 1,
  42548. /** Square */
  42549. Square = 2,
  42550. /** Triangle */
  42551. Triangle = 3,
  42552. /** L1 */
  42553. L1 = 4,
  42554. /** R1 */
  42555. R1 = 5,
  42556. /** Share */
  42557. Share = 8,
  42558. /** Options */
  42559. Options = 9,
  42560. /** Left stick */
  42561. LeftStick = 10,
  42562. /** Right stick */
  42563. RightStick = 11
  42564. }
  42565. /** Defines values for DualShock DPad */
  42566. export enum DualShockDpad {
  42567. /** Up */
  42568. Up = 12,
  42569. /** Down */
  42570. Down = 13,
  42571. /** Left */
  42572. Left = 14,
  42573. /** Right */
  42574. Right = 15
  42575. }
  42576. /**
  42577. * Defines a DualShock gamepad
  42578. */
  42579. export class DualShockPad extends Gamepad {
  42580. private _leftTrigger;
  42581. private _rightTrigger;
  42582. private _onlefttriggerchanged;
  42583. private _onrighttriggerchanged;
  42584. private _onbuttondown;
  42585. private _onbuttonup;
  42586. private _ondpaddown;
  42587. private _ondpadup;
  42588. /** Observable raised when a button is pressed */
  42589. onButtonDownObservable: Observable<DualShockButton>;
  42590. /** Observable raised when a button is released */
  42591. onButtonUpObservable: Observable<DualShockButton>;
  42592. /** Observable raised when a pad is pressed */
  42593. onPadDownObservable: Observable<DualShockDpad>;
  42594. /** Observable raised when a pad is released */
  42595. onPadUpObservable: Observable<DualShockDpad>;
  42596. private _buttonCross;
  42597. private _buttonCircle;
  42598. private _buttonSquare;
  42599. private _buttonTriangle;
  42600. private _buttonShare;
  42601. private _buttonOptions;
  42602. private _buttonL1;
  42603. private _buttonR1;
  42604. private _buttonLeftStick;
  42605. private _buttonRightStick;
  42606. private _dPadUp;
  42607. private _dPadDown;
  42608. private _dPadLeft;
  42609. private _dPadRight;
  42610. /**
  42611. * Creates a new DualShock gamepad object
  42612. * @param id defines the id of this gamepad
  42613. * @param index defines its index
  42614. * @param gamepad defines the internal HTML gamepad object
  42615. */
  42616. constructor(id: string, index: number, gamepad: any);
  42617. /**
  42618. * Defines the callback to call when left trigger is pressed
  42619. * @param callback defines the callback to use
  42620. */
  42621. onlefttriggerchanged(callback: (value: number) => void): void;
  42622. /**
  42623. * Defines the callback to call when right trigger is pressed
  42624. * @param callback defines the callback to use
  42625. */
  42626. onrighttriggerchanged(callback: (value: number) => void): void;
  42627. /**
  42628. * Gets the left trigger value
  42629. */
  42630. get leftTrigger(): number;
  42631. /**
  42632. * Sets the left trigger value
  42633. */
  42634. set leftTrigger(newValue: number);
  42635. /**
  42636. * Gets the right trigger value
  42637. */
  42638. get rightTrigger(): number;
  42639. /**
  42640. * Sets the right trigger value
  42641. */
  42642. set rightTrigger(newValue: number);
  42643. /**
  42644. * Defines the callback to call when a button is pressed
  42645. * @param callback defines the callback to use
  42646. */
  42647. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42648. /**
  42649. * Defines the callback to call when a button is released
  42650. * @param callback defines the callback to use
  42651. */
  42652. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42653. /**
  42654. * Defines the callback to call when a pad is pressed
  42655. * @param callback defines the callback to use
  42656. */
  42657. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42658. /**
  42659. * Defines the callback to call when a pad is released
  42660. * @param callback defines the callback to use
  42661. */
  42662. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42663. private _setButtonValue;
  42664. private _setDPadValue;
  42665. /**
  42666. * Gets the value of the `Cross` button
  42667. */
  42668. get buttonCross(): number;
  42669. /**
  42670. * Sets the value of the `Cross` button
  42671. */
  42672. set buttonCross(value: number);
  42673. /**
  42674. * Gets the value of the `Circle` button
  42675. */
  42676. get buttonCircle(): number;
  42677. /**
  42678. * Sets the value of the `Circle` button
  42679. */
  42680. set buttonCircle(value: number);
  42681. /**
  42682. * Gets the value of the `Square` button
  42683. */
  42684. get buttonSquare(): number;
  42685. /**
  42686. * Sets the value of the `Square` button
  42687. */
  42688. set buttonSquare(value: number);
  42689. /**
  42690. * Gets the value of the `Triangle` button
  42691. */
  42692. get buttonTriangle(): number;
  42693. /**
  42694. * Sets the value of the `Triangle` button
  42695. */
  42696. set buttonTriangle(value: number);
  42697. /**
  42698. * Gets the value of the `Options` button
  42699. */
  42700. get buttonOptions(): number;
  42701. /**
  42702. * Sets the value of the `Options` button
  42703. */
  42704. set buttonOptions(value: number);
  42705. /**
  42706. * Gets the value of the `Share` button
  42707. */
  42708. get buttonShare(): number;
  42709. /**
  42710. * Sets the value of the `Share` button
  42711. */
  42712. set buttonShare(value: number);
  42713. /**
  42714. * Gets the value of the `L1` button
  42715. */
  42716. get buttonL1(): number;
  42717. /**
  42718. * Sets the value of the `L1` button
  42719. */
  42720. set buttonL1(value: number);
  42721. /**
  42722. * Gets the value of the `R1` button
  42723. */
  42724. get buttonR1(): number;
  42725. /**
  42726. * Sets the value of the `R1` button
  42727. */
  42728. set buttonR1(value: number);
  42729. /**
  42730. * Gets the value of the Left joystick
  42731. */
  42732. get buttonLeftStick(): number;
  42733. /**
  42734. * Sets the value of the Left joystick
  42735. */
  42736. set buttonLeftStick(value: number);
  42737. /**
  42738. * Gets the value of the Right joystick
  42739. */
  42740. get buttonRightStick(): number;
  42741. /**
  42742. * Sets the value of the Right joystick
  42743. */
  42744. set buttonRightStick(value: number);
  42745. /**
  42746. * Gets the value of D-pad up
  42747. */
  42748. get dPadUp(): number;
  42749. /**
  42750. * Sets the value of D-pad up
  42751. */
  42752. set dPadUp(value: number);
  42753. /**
  42754. * Gets the value of D-pad down
  42755. */
  42756. get dPadDown(): number;
  42757. /**
  42758. * Sets the value of D-pad down
  42759. */
  42760. set dPadDown(value: number);
  42761. /**
  42762. * Gets the value of D-pad left
  42763. */
  42764. get dPadLeft(): number;
  42765. /**
  42766. * Sets the value of D-pad left
  42767. */
  42768. set dPadLeft(value: number);
  42769. /**
  42770. * Gets the value of D-pad right
  42771. */
  42772. get dPadRight(): number;
  42773. /**
  42774. * Sets the value of D-pad right
  42775. */
  42776. set dPadRight(value: number);
  42777. /**
  42778. * Force the gamepad to synchronize with device values
  42779. */
  42780. update(): void;
  42781. /**
  42782. * Disposes the gamepad
  42783. */
  42784. dispose(): void;
  42785. }
  42786. }
  42787. declare module "babylonjs/Gamepads/gamepadManager" {
  42788. import { Observable } from "babylonjs/Misc/observable";
  42789. import { Nullable } from "babylonjs/types";
  42790. import { Scene } from "babylonjs/scene";
  42791. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42792. /**
  42793. * Manager for handling gamepads
  42794. */
  42795. export class GamepadManager {
  42796. private _scene?;
  42797. private _babylonGamepads;
  42798. private _oneGamepadConnected;
  42799. /** @hidden */
  42800. _isMonitoring: boolean;
  42801. private _gamepadEventSupported;
  42802. private _gamepadSupport?;
  42803. /**
  42804. * observable to be triggered when the gamepad controller has been connected
  42805. */
  42806. onGamepadConnectedObservable: Observable<Gamepad>;
  42807. /**
  42808. * observable to be triggered when the gamepad controller has been disconnected
  42809. */
  42810. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42811. private _onGamepadConnectedEvent;
  42812. private _onGamepadDisconnectedEvent;
  42813. /**
  42814. * Initializes the gamepad manager
  42815. * @param _scene BabylonJS scene
  42816. */
  42817. constructor(_scene?: Scene | undefined);
  42818. /**
  42819. * The gamepads in the game pad manager
  42820. */
  42821. get gamepads(): Gamepad[];
  42822. /**
  42823. * Get the gamepad controllers based on type
  42824. * @param type The type of gamepad controller
  42825. * @returns Nullable gamepad
  42826. */
  42827. getGamepadByType(type?: number): Nullable<Gamepad>;
  42828. /**
  42829. * Disposes the gamepad manager
  42830. */
  42831. dispose(): void;
  42832. private _addNewGamepad;
  42833. private _startMonitoringGamepads;
  42834. private _stopMonitoringGamepads;
  42835. /** @hidden */
  42836. _checkGamepadsStatus(): void;
  42837. private _updateGamepadObjects;
  42838. }
  42839. }
  42840. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42841. import { Nullable } from "babylonjs/types";
  42842. import { Scene } from "babylonjs/scene";
  42843. import { ISceneComponent } from "babylonjs/sceneComponent";
  42844. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42845. module "babylonjs/scene" {
  42846. interface Scene {
  42847. /** @hidden */
  42848. _gamepadManager: Nullable<GamepadManager>;
  42849. /**
  42850. * Gets the gamepad manager associated with the scene
  42851. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42852. */
  42853. gamepadManager: GamepadManager;
  42854. }
  42855. }
  42856. module "babylonjs/Cameras/freeCameraInputsManager" {
  42857. /**
  42858. * Interface representing a free camera inputs manager
  42859. */
  42860. interface FreeCameraInputsManager {
  42861. /**
  42862. * Adds gamepad input support to the FreeCameraInputsManager.
  42863. * @returns the FreeCameraInputsManager
  42864. */
  42865. addGamepad(): FreeCameraInputsManager;
  42866. }
  42867. }
  42868. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42869. /**
  42870. * Interface representing an arc rotate camera inputs manager
  42871. */
  42872. interface ArcRotateCameraInputsManager {
  42873. /**
  42874. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42875. * @returns the camera inputs manager
  42876. */
  42877. addGamepad(): ArcRotateCameraInputsManager;
  42878. }
  42879. }
  42880. /**
  42881. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42882. */
  42883. export class GamepadSystemSceneComponent implements ISceneComponent {
  42884. /**
  42885. * The component name helpfull to identify the component in the list of scene components.
  42886. */
  42887. readonly name: string;
  42888. /**
  42889. * The scene the component belongs to.
  42890. */
  42891. scene: Scene;
  42892. /**
  42893. * Creates a new instance of the component for the given scene
  42894. * @param scene Defines the scene to register the component in
  42895. */
  42896. constructor(scene: Scene);
  42897. /**
  42898. * Registers the component in a given scene
  42899. */
  42900. register(): void;
  42901. /**
  42902. * Rebuilds the elements related to this component in case of
  42903. * context lost for instance.
  42904. */
  42905. rebuild(): void;
  42906. /**
  42907. * Disposes the component and the associated ressources
  42908. */
  42909. dispose(): void;
  42910. private _beforeCameraUpdate;
  42911. }
  42912. }
  42913. declare module "babylonjs/Cameras/universalCamera" {
  42914. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42915. import { Scene } from "babylonjs/scene";
  42916. import { Vector3 } from "babylonjs/Maths/math.vector";
  42917. import "babylonjs/Gamepads/gamepadSceneComponent";
  42918. /**
  42919. * 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,
  42920. * which still works and will still be found in many Playgrounds.
  42921. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42922. */
  42923. export class UniversalCamera extends TouchCamera {
  42924. /**
  42925. * Defines the gamepad rotation sensiblity.
  42926. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42927. */
  42928. get gamepadAngularSensibility(): number;
  42929. set gamepadAngularSensibility(value: number);
  42930. /**
  42931. * Defines the gamepad move sensiblity.
  42932. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42933. */
  42934. get gamepadMoveSensibility(): number;
  42935. set gamepadMoveSensibility(value: number);
  42936. /**
  42937. * 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,
  42938. * which still works and will still be found in many Playgrounds.
  42939. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42940. * @param name Define the name of the camera in the scene
  42941. * @param position Define the start position of the camera in the scene
  42942. * @param scene Define the scene the camera belongs to
  42943. */
  42944. constructor(name: string, position: Vector3, scene: Scene);
  42945. /**
  42946. * Gets the current object class name.
  42947. * @return the class name
  42948. */
  42949. getClassName(): string;
  42950. }
  42951. }
  42952. declare module "babylonjs/Cameras/gamepadCamera" {
  42953. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42954. import { Scene } from "babylonjs/scene";
  42955. import { Vector3 } from "babylonjs/Maths/math.vector";
  42956. /**
  42957. * This represents a FPS type of camera. This is only here for back compat purpose.
  42958. * Please use the UniversalCamera instead as both are identical.
  42959. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42960. */
  42961. export class GamepadCamera extends UniversalCamera {
  42962. /**
  42963. * Instantiates a new Gamepad Camera
  42964. * This represents a FPS type of camera. This is only here for back compat purpose.
  42965. * Please use the UniversalCamera instead as both are identical.
  42966. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42967. * @param name Define the name of the camera in the scene
  42968. * @param position Define the start position of the camera in the scene
  42969. * @param scene Define the scene the camera belongs to
  42970. */
  42971. constructor(name: string, position: Vector3, scene: Scene);
  42972. /**
  42973. * Gets the current object class name.
  42974. * @return the class name
  42975. */
  42976. getClassName(): string;
  42977. }
  42978. }
  42979. declare module "babylonjs/Shaders/pass.fragment" {
  42980. /** @hidden */
  42981. export var passPixelShader: {
  42982. name: string;
  42983. shader: string;
  42984. };
  42985. }
  42986. declare module "babylonjs/Shaders/passCube.fragment" {
  42987. /** @hidden */
  42988. export var passCubePixelShader: {
  42989. name: string;
  42990. shader: string;
  42991. };
  42992. }
  42993. declare module "babylonjs/PostProcesses/passPostProcess" {
  42994. import { Nullable } from "babylonjs/types";
  42995. import { Camera } from "babylonjs/Cameras/camera";
  42996. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42997. import { Engine } from "babylonjs/Engines/engine";
  42998. import "babylonjs/Shaders/pass.fragment";
  42999. import "babylonjs/Shaders/passCube.fragment";
  43000. /**
  43001. * PassPostProcess which produces an output the same as it's input
  43002. */
  43003. export class PassPostProcess extends PostProcess {
  43004. /**
  43005. * Creates the PassPostProcess
  43006. * @param name The name of the effect.
  43007. * @param options The required width/height ratio to downsize to before computing the render pass.
  43008. * @param camera The camera to apply the render pass to.
  43009. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43010. * @param engine The engine which the post process will be applied. (default: current engine)
  43011. * @param reusable If the post process can be reused on the same frame. (default: false)
  43012. * @param textureType The type of texture to be used when performing the post processing.
  43013. * @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)
  43014. */
  43015. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43016. }
  43017. /**
  43018. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43019. */
  43020. export class PassCubePostProcess extends PostProcess {
  43021. private _face;
  43022. /**
  43023. * Gets or sets the cube face to display.
  43024. * * 0 is +X
  43025. * * 1 is -X
  43026. * * 2 is +Y
  43027. * * 3 is -Y
  43028. * * 4 is +Z
  43029. * * 5 is -Z
  43030. */
  43031. get face(): number;
  43032. set face(value: number);
  43033. /**
  43034. * Creates the PassCubePostProcess
  43035. * @param name The name of the effect.
  43036. * @param options The required width/height ratio to downsize to before computing the render pass.
  43037. * @param camera The camera to apply the render pass to.
  43038. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43039. * @param engine The engine which the post process will be applied. (default: current engine)
  43040. * @param reusable If the post process can be reused on the same frame. (default: false)
  43041. * @param textureType The type of texture to be used when performing the post processing.
  43042. * @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)
  43043. */
  43044. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43045. }
  43046. }
  43047. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43048. /** @hidden */
  43049. export var anaglyphPixelShader: {
  43050. name: string;
  43051. shader: string;
  43052. };
  43053. }
  43054. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43055. import { Engine } from "babylonjs/Engines/engine";
  43056. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43057. import { Camera } from "babylonjs/Cameras/camera";
  43058. import "babylonjs/Shaders/anaglyph.fragment";
  43059. /**
  43060. * Postprocess used to generate anaglyphic rendering
  43061. */
  43062. export class AnaglyphPostProcess extends PostProcess {
  43063. private _passedProcess;
  43064. /**
  43065. * Creates a new AnaglyphPostProcess
  43066. * @param name defines postprocess name
  43067. * @param options defines creation options or target ratio scale
  43068. * @param rigCameras defines cameras using this postprocess
  43069. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43070. * @param engine defines hosting engine
  43071. * @param reusable defines if the postprocess will be reused multiple times per frame
  43072. */
  43073. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43074. }
  43075. }
  43076. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43077. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43078. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43079. import { Scene } from "babylonjs/scene";
  43080. import { Vector3 } from "babylonjs/Maths/math.vector";
  43081. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43082. /**
  43083. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43084. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43085. */
  43086. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43087. /**
  43088. * Creates a new AnaglyphArcRotateCamera
  43089. * @param name defines camera name
  43090. * @param alpha defines alpha angle (in radians)
  43091. * @param beta defines beta angle (in radians)
  43092. * @param radius defines radius
  43093. * @param target defines camera target
  43094. * @param interaxialDistance defines distance between each color axis
  43095. * @param scene defines the hosting scene
  43096. */
  43097. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43098. /**
  43099. * Gets camera class name
  43100. * @returns AnaglyphArcRotateCamera
  43101. */
  43102. getClassName(): string;
  43103. }
  43104. }
  43105. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43106. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43107. import { Scene } from "babylonjs/scene";
  43108. import { Vector3 } from "babylonjs/Maths/math.vector";
  43109. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43110. /**
  43111. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43112. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43113. */
  43114. export class AnaglyphFreeCamera extends FreeCamera {
  43115. /**
  43116. * Creates a new AnaglyphFreeCamera
  43117. * @param name defines camera name
  43118. * @param position defines initial position
  43119. * @param interaxialDistance defines distance between each color axis
  43120. * @param scene defines the hosting scene
  43121. */
  43122. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43123. /**
  43124. * Gets camera class name
  43125. * @returns AnaglyphFreeCamera
  43126. */
  43127. getClassName(): string;
  43128. }
  43129. }
  43130. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43131. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43132. import { Scene } from "babylonjs/scene";
  43133. import { Vector3 } from "babylonjs/Maths/math.vector";
  43134. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43135. /**
  43136. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43137. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43138. */
  43139. export class AnaglyphGamepadCamera extends GamepadCamera {
  43140. /**
  43141. * Creates a new AnaglyphGamepadCamera
  43142. * @param name defines camera name
  43143. * @param position defines initial position
  43144. * @param interaxialDistance defines distance between each color axis
  43145. * @param scene defines the hosting scene
  43146. */
  43147. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43148. /**
  43149. * Gets camera class name
  43150. * @returns AnaglyphGamepadCamera
  43151. */
  43152. getClassName(): string;
  43153. }
  43154. }
  43155. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43156. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43157. import { Scene } from "babylonjs/scene";
  43158. import { Vector3 } from "babylonjs/Maths/math.vector";
  43159. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43160. /**
  43161. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43162. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43163. */
  43164. export class AnaglyphUniversalCamera extends UniversalCamera {
  43165. /**
  43166. * Creates a new AnaglyphUniversalCamera
  43167. * @param name defines camera name
  43168. * @param position defines initial position
  43169. * @param interaxialDistance defines distance between each color axis
  43170. * @param scene defines the hosting scene
  43171. */
  43172. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43173. /**
  43174. * Gets camera class name
  43175. * @returns AnaglyphUniversalCamera
  43176. */
  43177. getClassName(): string;
  43178. }
  43179. }
  43180. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43181. /** @hidden */
  43182. export var stereoscopicInterlacePixelShader: {
  43183. name: string;
  43184. shader: string;
  43185. };
  43186. }
  43187. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43188. import { Camera } from "babylonjs/Cameras/camera";
  43189. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43190. import { Engine } from "babylonjs/Engines/engine";
  43191. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43192. /**
  43193. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43194. */
  43195. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43196. private _stepSize;
  43197. private _passedProcess;
  43198. /**
  43199. * Initializes a StereoscopicInterlacePostProcessI
  43200. * @param name The name of the effect.
  43201. * @param rigCameras The rig cameras to be appled to the post process
  43202. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43203. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43204. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43205. * @param engine The engine which the post process will be applied. (default: current engine)
  43206. * @param reusable If the post process can be reused on the same frame. (default: false)
  43207. */
  43208. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43209. }
  43210. /**
  43211. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43212. */
  43213. export class StereoscopicInterlacePostProcess extends PostProcess {
  43214. private _stepSize;
  43215. private _passedProcess;
  43216. /**
  43217. * Initializes a StereoscopicInterlacePostProcess
  43218. * @param name The name of the effect.
  43219. * @param rigCameras The rig cameras to be appled to the post process
  43220. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43221. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43222. * @param engine The engine which the post process will be applied. (default: current engine)
  43223. * @param reusable If the post process can be reused on the same frame. (default: false)
  43224. */
  43225. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43226. }
  43227. }
  43228. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43229. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43230. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43231. import { Scene } from "babylonjs/scene";
  43232. import { Vector3 } from "babylonjs/Maths/math.vector";
  43233. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43234. /**
  43235. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43236. * @see http://doc.babylonjs.com/features/cameras
  43237. */
  43238. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43239. /**
  43240. * Creates a new StereoscopicArcRotateCamera
  43241. * @param name defines camera name
  43242. * @param alpha defines alpha angle (in radians)
  43243. * @param beta defines beta angle (in radians)
  43244. * @param radius defines radius
  43245. * @param target defines camera target
  43246. * @param interaxialDistance defines distance between each color axis
  43247. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43248. * @param scene defines the hosting scene
  43249. */
  43250. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43251. /**
  43252. * Gets camera class name
  43253. * @returns StereoscopicArcRotateCamera
  43254. */
  43255. getClassName(): string;
  43256. }
  43257. }
  43258. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43259. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43260. import { Scene } from "babylonjs/scene";
  43261. import { Vector3 } from "babylonjs/Maths/math.vector";
  43262. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43263. /**
  43264. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43265. * @see http://doc.babylonjs.com/features/cameras
  43266. */
  43267. export class StereoscopicFreeCamera extends FreeCamera {
  43268. /**
  43269. * Creates a new StereoscopicFreeCamera
  43270. * @param name defines camera name
  43271. * @param position defines initial position
  43272. * @param interaxialDistance defines distance between each color axis
  43273. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43274. * @param scene defines the hosting scene
  43275. */
  43276. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43277. /**
  43278. * Gets camera class name
  43279. * @returns StereoscopicFreeCamera
  43280. */
  43281. getClassName(): string;
  43282. }
  43283. }
  43284. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43285. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43286. import { Scene } from "babylonjs/scene";
  43287. import { Vector3 } from "babylonjs/Maths/math.vector";
  43288. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43289. /**
  43290. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43291. * @see http://doc.babylonjs.com/features/cameras
  43292. */
  43293. export class StereoscopicGamepadCamera extends GamepadCamera {
  43294. /**
  43295. * Creates a new StereoscopicGamepadCamera
  43296. * @param name defines camera name
  43297. * @param position defines initial position
  43298. * @param interaxialDistance defines distance between each color axis
  43299. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43300. * @param scene defines the hosting scene
  43301. */
  43302. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43303. /**
  43304. * Gets camera class name
  43305. * @returns StereoscopicGamepadCamera
  43306. */
  43307. getClassName(): string;
  43308. }
  43309. }
  43310. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43311. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43312. import { Scene } from "babylonjs/scene";
  43313. import { Vector3 } from "babylonjs/Maths/math.vector";
  43314. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43315. /**
  43316. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43317. * @see http://doc.babylonjs.com/features/cameras
  43318. */
  43319. export class StereoscopicUniversalCamera extends UniversalCamera {
  43320. /**
  43321. * Creates a new StereoscopicUniversalCamera
  43322. * @param name defines camera name
  43323. * @param position defines initial position
  43324. * @param interaxialDistance defines distance between each color axis
  43325. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43326. * @param scene defines the hosting scene
  43327. */
  43328. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43329. /**
  43330. * Gets camera class name
  43331. * @returns StereoscopicUniversalCamera
  43332. */
  43333. getClassName(): string;
  43334. }
  43335. }
  43336. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43337. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43338. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43339. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43340. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43341. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43342. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43343. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43344. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43345. }
  43346. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43347. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43348. import { Scene } from "babylonjs/scene";
  43349. import { Vector3 } from "babylonjs/Maths/math.vector";
  43350. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43351. /**
  43352. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43353. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43354. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43355. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43356. */
  43357. export class VirtualJoysticksCamera extends FreeCamera {
  43358. /**
  43359. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43360. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43361. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43362. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43363. * @param name Define the name of the camera in the scene
  43364. * @param position Define the start position of the camera in the scene
  43365. * @param scene Define the scene the camera belongs to
  43366. */
  43367. constructor(name: string, position: Vector3, scene: Scene);
  43368. /**
  43369. * Gets the current object class name.
  43370. * @return the class name
  43371. */
  43372. getClassName(): string;
  43373. }
  43374. }
  43375. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43376. import { Matrix } from "babylonjs/Maths/math.vector";
  43377. /**
  43378. * This represents all the required metrics to create a VR camera.
  43379. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43380. */
  43381. export class VRCameraMetrics {
  43382. /**
  43383. * Define the horizontal resolution off the screen.
  43384. */
  43385. hResolution: number;
  43386. /**
  43387. * Define the vertical resolution off the screen.
  43388. */
  43389. vResolution: number;
  43390. /**
  43391. * Define the horizontal screen size.
  43392. */
  43393. hScreenSize: number;
  43394. /**
  43395. * Define the vertical screen size.
  43396. */
  43397. vScreenSize: number;
  43398. /**
  43399. * Define the vertical screen center position.
  43400. */
  43401. vScreenCenter: number;
  43402. /**
  43403. * Define the distance of the eyes to the screen.
  43404. */
  43405. eyeToScreenDistance: number;
  43406. /**
  43407. * Define the distance between both lenses
  43408. */
  43409. lensSeparationDistance: number;
  43410. /**
  43411. * Define the distance between both viewer's eyes.
  43412. */
  43413. interpupillaryDistance: number;
  43414. /**
  43415. * Define the distortion factor of the VR postprocess.
  43416. * Please, touch with care.
  43417. */
  43418. distortionK: number[];
  43419. /**
  43420. * Define the chromatic aberration correction factors for the VR post process.
  43421. */
  43422. chromaAbCorrection: number[];
  43423. /**
  43424. * Define the scale factor of the post process.
  43425. * The smaller the better but the slower.
  43426. */
  43427. postProcessScaleFactor: number;
  43428. /**
  43429. * Define an offset for the lens center.
  43430. */
  43431. lensCenterOffset: number;
  43432. /**
  43433. * Define if the current vr camera should compensate the distortion of the lense or not.
  43434. */
  43435. compensateDistortion: boolean;
  43436. /**
  43437. * Defines if multiview should be enabled when rendering (Default: false)
  43438. */
  43439. multiviewEnabled: boolean;
  43440. /**
  43441. * Gets the rendering aspect ratio based on the provided resolutions.
  43442. */
  43443. get aspectRatio(): number;
  43444. /**
  43445. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43446. */
  43447. get aspectRatioFov(): number;
  43448. /**
  43449. * @hidden
  43450. */
  43451. get leftHMatrix(): Matrix;
  43452. /**
  43453. * @hidden
  43454. */
  43455. get rightHMatrix(): Matrix;
  43456. /**
  43457. * @hidden
  43458. */
  43459. get leftPreViewMatrix(): Matrix;
  43460. /**
  43461. * @hidden
  43462. */
  43463. get rightPreViewMatrix(): Matrix;
  43464. /**
  43465. * Get the default VRMetrics based on the most generic setup.
  43466. * @returns the default vr metrics
  43467. */
  43468. static GetDefault(): VRCameraMetrics;
  43469. }
  43470. }
  43471. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43472. /** @hidden */
  43473. export var vrDistortionCorrectionPixelShader: {
  43474. name: string;
  43475. shader: string;
  43476. };
  43477. }
  43478. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43479. import { Camera } from "babylonjs/Cameras/camera";
  43480. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43481. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43482. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43483. /**
  43484. * VRDistortionCorrectionPostProcess used for mobile VR
  43485. */
  43486. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43487. private _isRightEye;
  43488. private _distortionFactors;
  43489. private _postProcessScaleFactor;
  43490. private _lensCenterOffset;
  43491. private _scaleIn;
  43492. private _scaleFactor;
  43493. private _lensCenter;
  43494. /**
  43495. * Initializes the VRDistortionCorrectionPostProcess
  43496. * @param name The name of the effect.
  43497. * @param camera The camera to apply the render pass to.
  43498. * @param isRightEye If this is for the right eye distortion
  43499. * @param vrMetrics All the required metrics for the VR camera
  43500. */
  43501. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43502. }
  43503. }
  43504. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43505. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43506. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43507. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43508. import { Scene } from "babylonjs/scene";
  43509. import { Vector3 } from "babylonjs/Maths/math.vector";
  43510. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43511. import "babylonjs/Cameras/RigModes/vrRigMode";
  43512. /**
  43513. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43514. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43515. */
  43516. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43517. /**
  43518. * Creates a new VRDeviceOrientationArcRotateCamera
  43519. * @param name defines camera name
  43520. * @param alpha defines the camera rotation along the logitudinal axis
  43521. * @param beta defines the camera rotation along the latitudinal axis
  43522. * @param radius defines the camera distance from its target
  43523. * @param target defines the camera target
  43524. * @param scene defines the scene the camera belongs to
  43525. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43526. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43527. */
  43528. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43529. /**
  43530. * Gets camera class name
  43531. * @returns VRDeviceOrientationArcRotateCamera
  43532. */
  43533. getClassName(): string;
  43534. }
  43535. }
  43536. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43537. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43538. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43539. import { Scene } from "babylonjs/scene";
  43540. import { Vector3 } from "babylonjs/Maths/math.vector";
  43541. import "babylonjs/Cameras/RigModes/vrRigMode";
  43542. /**
  43543. * Camera used to simulate VR rendering (based on FreeCamera)
  43544. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43545. */
  43546. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43547. /**
  43548. * Creates a new VRDeviceOrientationFreeCamera
  43549. * @param name defines camera name
  43550. * @param position defines the start position of the camera
  43551. * @param scene defines the scene the camera belongs to
  43552. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43553. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43554. */
  43555. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43556. /**
  43557. * Gets camera class name
  43558. * @returns VRDeviceOrientationFreeCamera
  43559. */
  43560. getClassName(): string;
  43561. }
  43562. }
  43563. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43564. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43565. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43566. import { Scene } from "babylonjs/scene";
  43567. import { Vector3 } from "babylonjs/Maths/math.vector";
  43568. import "babylonjs/Gamepads/gamepadSceneComponent";
  43569. /**
  43570. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43571. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43572. */
  43573. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43574. /**
  43575. * Creates a new VRDeviceOrientationGamepadCamera
  43576. * @param name defines camera name
  43577. * @param position defines the start position of the camera
  43578. * @param scene defines the scene the camera belongs to
  43579. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43580. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43581. */
  43582. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43583. /**
  43584. * Gets camera class name
  43585. * @returns VRDeviceOrientationGamepadCamera
  43586. */
  43587. getClassName(): string;
  43588. }
  43589. }
  43590. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43591. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43592. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43593. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43594. /** @hidden */
  43595. export var imageProcessingPixelShader: {
  43596. name: string;
  43597. shader: string;
  43598. };
  43599. }
  43600. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43601. import { Nullable } from "babylonjs/types";
  43602. import { Color4 } from "babylonjs/Maths/math.color";
  43603. import { Camera } from "babylonjs/Cameras/camera";
  43604. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43605. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43606. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43607. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43608. import { Engine } from "babylonjs/Engines/engine";
  43609. import "babylonjs/Shaders/imageProcessing.fragment";
  43610. import "babylonjs/Shaders/postprocess.vertex";
  43611. /**
  43612. * ImageProcessingPostProcess
  43613. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43614. */
  43615. export class ImageProcessingPostProcess extends PostProcess {
  43616. /**
  43617. * Default configuration related to image processing available in the PBR Material.
  43618. */
  43619. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43620. /**
  43621. * Gets the image processing configuration used either in this material.
  43622. */
  43623. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43624. /**
  43625. * Sets the Default image processing configuration used either in the this material.
  43626. *
  43627. * If sets to null, the scene one is in use.
  43628. */
  43629. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43630. /**
  43631. * Keep track of the image processing observer to allow dispose and replace.
  43632. */
  43633. private _imageProcessingObserver;
  43634. /**
  43635. * Attaches a new image processing configuration to the PBR Material.
  43636. * @param configuration
  43637. */
  43638. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43639. /**
  43640. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43641. */
  43642. get colorCurves(): Nullable<ColorCurves>;
  43643. /**
  43644. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43645. */
  43646. set colorCurves(value: Nullable<ColorCurves>);
  43647. /**
  43648. * Gets wether the color curves effect is enabled.
  43649. */
  43650. get colorCurvesEnabled(): boolean;
  43651. /**
  43652. * Sets wether the color curves effect is enabled.
  43653. */
  43654. set colorCurvesEnabled(value: boolean);
  43655. /**
  43656. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43657. */
  43658. get colorGradingTexture(): Nullable<BaseTexture>;
  43659. /**
  43660. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43661. */
  43662. set colorGradingTexture(value: Nullable<BaseTexture>);
  43663. /**
  43664. * Gets wether the color grading effect is enabled.
  43665. */
  43666. get colorGradingEnabled(): boolean;
  43667. /**
  43668. * Gets wether the color grading effect is enabled.
  43669. */
  43670. set colorGradingEnabled(value: boolean);
  43671. /**
  43672. * Gets exposure used in the effect.
  43673. */
  43674. get exposure(): number;
  43675. /**
  43676. * Sets exposure used in the effect.
  43677. */
  43678. set exposure(value: number);
  43679. /**
  43680. * Gets wether tonemapping is enabled or not.
  43681. */
  43682. get toneMappingEnabled(): boolean;
  43683. /**
  43684. * Sets wether tonemapping is enabled or not
  43685. */
  43686. set toneMappingEnabled(value: boolean);
  43687. /**
  43688. * Gets the type of tone mapping effect.
  43689. */
  43690. get toneMappingType(): number;
  43691. /**
  43692. * Sets the type of tone mapping effect.
  43693. */
  43694. set toneMappingType(value: number);
  43695. /**
  43696. * Gets contrast used in the effect.
  43697. */
  43698. get contrast(): number;
  43699. /**
  43700. * Sets contrast used in the effect.
  43701. */
  43702. set contrast(value: number);
  43703. /**
  43704. * Gets Vignette stretch size.
  43705. */
  43706. get vignetteStretch(): number;
  43707. /**
  43708. * Sets Vignette stretch size.
  43709. */
  43710. set vignetteStretch(value: number);
  43711. /**
  43712. * Gets Vignette centre X Offset.
  43713. */
  43714. get vignetteCentreX(): number;
  43715. /**
  43716. * Sets Vignette centre X Offset.
  43717. */
  43718. set vignetteCentreX(value: number);
  43719. /**
  43720. * Gets Vignette centre Y Offset.
  43721. */
  43722. get vignetteCentreY(): number;
  43723. /**
  43724. * Sets Vignette centre Y Offset.
  43725. */
  43726. set vignetteCentreY(value: number);
  43727. /**
  43728. * Gets Vignette weight or intensity of the vignette effect.
  43729. */
  43730. get vignetteWeight(): number;
  43731. /**
  43732. * Sets Vignette weight or intensity of the vignette effect.
  43733. */
  43734. set vignetteWeight(value: number);
  43735. /**
  43736. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43737. * if vignetteEnabled is set to true.
  43738. */
  43739. get vignetteColor(): Color4;
  43740. /**
  43741. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43742. * if vignetteEnabled is set to true.
  43743. */
  43744. set vignetteColor(value: Color4);
  43745. /**
  43746. * Gets Camera field of view used by the Vignette effect.
  43747. */
  43748. get vignetteCameraFov(): number;
  43749. /**
  43750. * Sets Camera field of view used by the Vignette effect.
  43751. */
  43752. set vignetteCameraFov(value: number);
  43753. /**
  43754. * Gets the vignette blend mode allowing different kind of effect.
  43755. */
  43756. get vignetteBlendMode(): number;
  43757. /**
  43758. * Sets the vignette blend mode allowing different kind of effect.
  43759. */
  43760. set vignetteBlendMode(value: number);
  43761. /**
  43762. * Gets wether the vignette effect is enabled.
  43763. */
  43764. get vignetteEnabled(): boolean;
  43765. /**
  43766. * Sets wether the vignette effect is enabled.
  43767. */
  43768. set vignetteEnabled(value: boolean);
  43769. private _fromLinearSpace;
  43770. /**
  43771. * Gets wether the input of the processing is in Gamma or Linear Space.
  43772. */
  43773. get fromLinearSpace(): boolean;
  43774. /**
  43775. * Sets wether the input of the processing is in Gamma or Linear Space.
  43776. */
  43777. set fromLinearSpace(value: boolean);
  43778. /**
  43779. * Defines cache preventing GC.
  43780. */
  43781. private _defines;
  43782. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43783. /**
  43784. * "ImageProcessingPostProcess"
  43785. * @returns "ImageProcessingPostProcess"
  43786. */
  43787. getClassName(): string;
  43788. protected _updateParameters(): void;
  43789. dispose(camera?: Camera): void;
  43790. }
  43791. }
  43792. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43793. import { Scene } from "babylonjs/scene";
  43794. import { Color3 } from "babylonjs/Maths/math.color";
  43795. import { Mesh } from "babylonjs/Meshes/mesh";
  43796. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43797. import { Nullable } from "babylonjs/types";
  43798. /**
  43799. * Class containing static functions to help procedurally build meshes
  43800. */
  43801. export class GroundBuilder {
  43802. /**
  43803. * Creates a ground mesh
  43804. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43805. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43807. * @param name defines the name of the mesh
  43808. * @param options defines the options used to create the mesh
  43809. * @param scene defines the hosting scene
  43810. * @returns the ground mesh
  43811. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43812. */
  43813. static CreateGround(name: string, options: {
  43814. width?: number;
  43815. height?: number;
  43816. subdivisions?: number;
  43817. subdivisionsX?: number;
  43818. subdivisionsY?: number;
  43819. updatable?: boolean;
  43820. }, scene: any): Mesh;
  43821. /**
  43822. * Creates a tiled ground mesh
  43823. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43824. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43825. * * 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
  43826. * * 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
  43827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43828. * @param name defines the name of the mesh
  43829. * @param options defines the options used to create the mesh
  43830. * @param scene defines the hosting scene
  43831. * @returns the tiled ground mesh
  43832. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43833. */
  43834. static CreateTiledGround(name: string, options: {
  43835. xmin: number;
  43836. zmin: number;
  43837. xmax: number;
  43838. zmax: number;
  43839. subdivisions?: {
  43840. w: number;
  43841. h: number;
  43842. };
  43843. precision?: {
  43844. w: number;
  43845. h: number;
  43846. };
  43847. updatable?: boolean;
  43848. }, scene?: Nullable<Scene>): Mesh;
  43849. /**
  43850. * Creates a ground mesh from a height map
  43851. * * The parameter `url` sets the URL of the height map image resource.
  43852. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43853. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43854. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43855. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43856. * * 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.
  43857. * * 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).
  43858. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43860. * @param name defines the name of the mesh
  43861. * @param url defines the url to the height map
  43862. * @param options defines the options used to create the mesh
  43863. * @param scene defines the hosting scene
  43864. * @returns the ground mesh
  43865. * @see https://doc.babylonjs.com/babylon101/height_map
  43866. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43867. */
  43868. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43869. width?: number;
  43870. height?: number;
  43871. subdivisions?: number;
  43872. minHeight?: number;
  43873. maxHeight?: number;
  43874. colorFilter?: Color3;
  43875. alphaFilter?: number;
  43876. updatable?: boolean;
  43877. onReady?: (mesh: GroundMesh) => void;
  43878. }, scene?: Nullable<Scene>): GroundMesh;
  43879. }
  43880. }
  43881. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43882. import { Vector4 } from "babylonjs/Maths/math.vector";
  43883. import { Mesh } from "babylonjs/Meshes/mesh";
  43884. /**
  43885. * Class containing static functions to help procedurally build meshes
  43886. */
  43887. export class TorusBuilder {
  43888. /**
  43889. * Creates a torus mesh
  43890. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43891. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43892. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43894. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43896. * @param name defines the name of the mesh
  43897. * @param options defines the options used to create the mesh
  43898. * @param scene defines the hosting scene
  43899. * @returns the torus mesh
  43900. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43901. */
  43902. static CreateTorus(name: string, options: {
  43903. diameter?: number;
  43904. thickness?: number;
  43905. tessellation?: number;
  43906. updatable?: boolean;
  43907. sideOrientation?: number;
  43908. frontUVs?: Vector4;
  43909. backUVs?: Vector4;
  43910. }, scene: any): Mesh;
  43911. }
  43912. }
  43913. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43914. import { Vector4 } from "babylonjs/Maths/math.vector";
  43915. import { Color4 } from "babylonjs/Maths/math.color";
  43916. import { Mesh } from "babylonjs/Meshes/mesh";
  43917. /**
  43918. * Class containing static functions to help procedurally build meshes
  43919. */
  43920. export class CylinderBuilder {
  43921. /**
  43922. * Creates a cylinder or a cone mesh
  43923. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43924. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43925. * * 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.
  43926. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43927. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43928. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43929. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43930. * * 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).
  43931. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43932. * * 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).
  43933. * * 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
  43934. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43935. * * 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
  43936. * * 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.
  43937. * * If `enclose` is false, a ring surface is one element.
  43938. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43939. * * 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
  43940. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43941. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43943. * @param name defines the name of the mesh
  43944. * @param options defines the options used to create the mesh
  43945. * @param scene defines the hosting scene
  43946. * @returns the cylinder mesh
  43947. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43948. */
  43949. static CreateCylinder(name: string, options: {
  43950. height?: number;
  43951. diameterTop?: number;
  43952. diameterBottom?: number;
  43953. diameter?: number;
  43954. tessellation?: number;
  43955. subdivisions?: number;
  43956. arc?: number;
  43957. faceColors?: Color4[];
  43958. faceUV?: Vector4[];
  43959. updatable?: boolean;
  43960. hasRings?: boolean;
  43961. enclose?: boolean;
  43962. cap?: number;
  43963. sideOrientation?: number;
  43964. frontUVs?: Vector4;
  43965. backUVs?: Vector4;
  43966. }, scene: any): Mesh;
  43967. }
  43968. }
  43969. declare module "babylonjs/XR/webXRTypes" {
  43970. import { Nullable } from "babylonjs/types";
  43971. import { IDisposable } from "babylonjs/scene";
  43972. /**
  43973. * States of the webXR experience
  43974. */
  43975. export enum WebXRState {
  43976. /**
  43977. * Transitioning to being in XR mode
  43978. */
  43979. ENTERING_XR = 0,
  43980. /**
  43981. * Transitioning to non XR mode
  43982. */
  43983. EXITING_XR = 1,
  43984. /**
  43985. * In XR mode and presenting
  43986. */
  43987. IN_XR = 2,
  43988. /**
  43989. * Not entered XR mode
  43990. */
  43991. NOT_IN_XR = 3
  43992. }
  43993. /**
  43994. * Abstraction of the XR render target
  43995. */
  43996. export interface WebXRRenderTarget extends IDisposable {
  43997. /**
  43998. * xrpresent context of the canvas which can be used to display/mirror xr content
  43999. */
  44000. canvasContext: WebGLRenderingContext;
  44001. /**
  44002. * xr layer for the canvas
  44003. */
  44004. xrLayer: Nullable<XRWebGLLayer>;
  44005. /**
  44006. * Initializes the xr layer for the session
  44007. * @param xrSession xr session
  44008. * @returns a promise that will resolve once the XR Layer has been created
  44009. */
  44010. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44011. }
  44012. }
  44013. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44014. import { Nullable } from "babylonjs/types";
  44015. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44016. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44017. /**
  44018. * COnfiguration object for WebXR output canvas
  44019. */
  44020. export class WebXRManagedOutputCanvasOptions {
  44021. /**
  44022. * An optional canvas in case you wish to create it yourself and provide it here.
  44023. * If not provided, a new canvas will be created
  44024. */
  44025. canvasElement?: HTMLCanvasElement;
  44026. /**
  44027. * Options for this XR Layer output
  44028. */
  44029. canvasOptions?: XRWebGLLayerOptions;
  44030. /**
  44031. * CSS styling for a newly created canvas (if not provided)
  44032. */
  44033. newCanvasCssStyle?: string;
  44034. /**
  44035. * Get the default values of the configuration object
  44036. * @returns default values of this configuration object
  44037. */
  44038. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44039. }
  44040. /**
  44041. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44042. */
  44043. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44044. private _options;
  44045. private _canvas;
  44046. private _engine;
  44047. /**
  44048. * Rendering context of the canvas which can be used to display/mirror xr content
  44049. */
  44050. canvasContext: WebGLRenderingContext;
  44051. /**
  44052. * xr layer for the canvas
  44053. */
  44054. xrLayer: Nullable<XRWebGLLayer>;
  44055. /**
  44056. * Initializes the canvas to be added/removed upon entering/exiting xr
  44057. * @param _xrSessionManager The XR Session manager
  44058. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44059. */
  44060. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44061. /**
  44062. * Disposes of the object
  44063. */
  44064. dispose(): void;
  44065. /**
  44066. * Initializes the xr layer for the session
  44067. * @param xrSession xr session
  44068. * @returns a promise that will resolve once the XR Layer has been created
  44069. */
  44070. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44071. private _addCanvas;
  44072. private _removeCanvas;
  44073. private _setManagedOutputCanvas;
  44074. }
  44075. }
  44076. declare module "babylonjs/XR/webXRSessionManager" {
  44077. import { Observable } from "babylonjs/Misc/observable";
  44078. import { Nullable } from "babylonjs/types";
  44079. import { IDisposable, Scene } from "babylonjs/scene";
  44080. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44081. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44082. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44083. /**
  44084. * Manages an XRSession to work with Babylon's engine
  44085. * @see https://doc.babylonjs.com/how_to/webxr
  44086. */
  44087. export class WebXRSessionManager implements IDisposable {
  44088. /** The scene which the session should be created for */
  44089. scene: Scene;
  44090. private _referenceSpace;
  44091. private _rttProvider;
  44092. private _sessionEnded;
  44093. private _xrNavigator;
  44094. private baseLayer;
  44095. /**
  44096. * The base reference space from which the session started. good if you want to reset your
  44097. * reference space
  44098. */
  44099. baseReferenceSpace: XRReferenceSpace;
  44100. /**
  44101. * Current XR frame
  44102. */
  44103. currentFrame: Nullable<XRFrame>;
  44104. /** WebXR timestamp updated every frame */
  44105. currentTimestamp: number;
  44106. /**
  44107. * Used just in case of a failure to initialize an immersive session.
  44108. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44109. */
  44110. defaultHeightCompensation: number;
  44111. /**
  44112. * Fires every time a new xrFrame arrives which can be used to update the camera
  44113. */
  44114. onXRFrameObservable: Observable<XRFrame>;
  44115. /**
  44116. * Fires when the reference space changed
  44117. */
  44118. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44119. /**
  44120. * Fires when the xr session is ended either by the device or manually done
  44121. */
  44122. onXRSessionEnded: Observable<any>;
  44123. /**
  44124. * Fires when the xr session is ended either by the device or manually done
  44125. */
  44126. onXRSessionInit: Observable<XRSession>;
  44127. /**
  44128. * Underlying xr session
  44129. */
  44130. session: XRSession;
  44131. /**
  44132. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44133. * or get the offset the player is currently at.
  44134. */
  44135. viewerReferenceSpace: XRReferenceSpace;
  44136. /**
  44137. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44138. * @param scene The scene which the session should be created for
  44139. */
  44140. constructor(
  44141. /** The scene which the session should be created for */
  44142. scene: Scene);
  44143. /**
  44144. * The current reference space used in this session. This reference space can constantly change!
  44145. * It is mainly used to offset the camera's position.
  44146. */
  44147. get referenceSpace(): XRReferenceSpace;
  44148. /**
  44149. * Set a new reference space and triggers the observable
  44150. */
  44151. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44152. /**
  44153. * Disposes of the session manager
  44154. */
  44155. dispose(): void;
  44156. /**
  44157. * Stops the xrSession and restores the render loop
  44158. * @returns Promise which resolves after it exits XR
  44159. */
  44160. exitXRAsync(): Promise<void>;
  44161. /**
  44162. * Gets the correct render target texture to be rendered this frame for this eye
  44163. * @param eye the eye for which to get the render target
  44164. * @returns the render target for the specified eye
  44165. */
  44166. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44167. /**
  44168. * Creates a WebXRRenderTarget object for the XR session
  44169. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44170. * @param options optional options to provide when creating a new render target
  44171. * @returns a WebXR render target to which the session can render
  44172. */
  44173. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44174. /**
  44175. * Initializes the manager
  44176. * After initialization enterXR can be called to start an XR session
  44177. * @returns Promise which resolves after it is initialized
  44178. */
  44179. initializeAsync(): Promise<void>;
  44180. /**
  44181. * Initializes an xr session
  44182. * @param xrSessionMode mode to initialize
  44183. * @param xrSessionInit defines optional and required values to pass to the session builder
  44184. * @returns a promise which will resolve once the session has been initialized
  44185. */
  44186. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44187. /**
  44188. * Checks if a session would be supported for the creation options specified
  44189. * @param sessionMode session mode to check if supported eg. immersive-vr
  44190. * @returns A Promise that resolves to true if supported and false if not
  44191. */
  44192. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44193. /**
  44194. * Resets the reference space to the one started the session
  44195. */
  44196. resetReferenceSpace(): void;
  44197. /**
  44198. * Starts rendering to the xr layer
  44199. */
  44200. runXRRenderLoop(): void;
  44201. /**
  44202. * Sets the reference space on the xr session
  44203. * @param referenceSpaceType space to set
  44204. * @returns a promise that will resolve once the reference space has been set
  44205. */
  44206. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44207. /**
  44208. * Updates the render state of the session
  44209. * @param state state to set
  44210. * @returns a promise that resolves once the render state has been updated
  44211. */
  44212. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44213. /**
  44214. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44215. * @param sessionMode defines the session to test
  44216. * @returns a promise with boolean as final value
  44217. */
  44218. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44219. private _createRenderTargetTexture;
  44220. }
  44221. }
  44222. declare module "babylonjs/XR/webXRCamera" {
  44223. import { Scene } from "babylonjs/scene";
  44224. import { Camera } from "babylonjs/Cameras/camera";
  44225. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44226. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44227. /**
  44228. * WebXR Camera which holds the views for the xrSession
  44229. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44230. */
  44231. export class WebXRCamera extends FreeCamera {
  44232. private _xrSessionManager;
  44233. private _firstFrame;
  44234. private _referenceQuaternion;
  44235. private _referencedPosition;
  44236. private _xrInvPositionCache;
  44237. private _xrInvQuaternionCache;
  44238. /**
  44239. * Should position compensation execute on first frame.
  44240. * This is used when copying the position from a native (non XR) camera
  44241. */
  44242. compensateOnFirstFrame: boolean;
  44243. /**
  44244. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44245. * @param name the name of the camera
  44246. * @param scene the scene to add the camera to
  44247. * @param _xrSessionManager a constructed xr session manager
  44248. */
  44249. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44250. /**
  44251. * Return the user's height, unrelated to the current ground.
  44252. * This will be the y position of this camera, when ground level is 0.
  44253. */
  44254. get realWorldHeight(): number;
  44255. /** @hidden */
  44256. _updateForDualEyeDebugging(): void;
  44257. /**
  44258. * Sets this camera's transformation based on a non-vr camera
  44259. * @param otherCamera the non-vr camera to copy the transformation from
  44260. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44261. */
  44262. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44263. /**
  44264. * Gets the current instance class name ("WebXRCamera").
  44265. * @returns the class name
  44266. */
  44267. getClassName(): string;
  44268. private _updateFromXRSession;
  44269. private _updateNumberOfRigCameras;
  44270. private _updateReferenceSpace;
  44271. private _updateReferenceSpaceOffset;
  44272. }
  44273. }
  44274. declare module "babylonjs/XR/webXRFeaturesManager" {
  44275. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44276. import { IDisposable } from "babylonjs/scene";
  44277. /**
  44278. * Defining the interface required for a (webxr) feature
  44279. */
  44280. export interface IWebXRFeature extends IDisposable {
  44281. /**
  44282. * Is this feature attached
  44283. */
  44284. attached: boolean;
  44285. /**
  44286. * Should auto-attach be disabled?
  44287. */
  44288. disableAutoAttach: boolean;
  44289. /**
  44290. * Attach the feature to the session
  44291. * Will usually be called by the features manager
  44292. *
  44293. * @param force should attachment be forced (even when already attached)
  44294. * @returns true if successful.
  44295. */
  44296. attach(force?: boolean): boolean;
  44297. /**
  44298. * Detach the feature from the session
  44299. * Will usually be called by the features manager
  44300. *
  44301. * @returns true if successful.
  44302. */
  44303. detach(): boolean;
  44304. }
  44305. /**
  44306. * A list of the currently available features without referencing them
  44307. */
  44308. export class WebXRFeatureName {
  44309. /**
  44310. * The name of the anchor system feature
  44311. */
  44312. static ANCHOR_SYSTEM: string;
  44313. /**
  44314. * The name of the background remover feature
  44315. */
  44316. static BACKGROUND_REMOVER: string;
  44317. /**
  44318. * The name of the hit test feature
  44319. */
  44320. static HIT_TEST: string;
  44321. /**
  44322. * physics impostors for xr controllers feature
  44323. */
  44324. static PHYSICS_CONTROLLERS: string;
  44325. /**
  44326. * The name of the plane detection feature
  44327. */
  44328. static PLANE_DETECTION: string;
  44329. /**
  44330. * The name of the pointer selection feature
  44331. */
  44332. static POINTER_SELECTION: string;
  44333. /**
  44334. * The name of the teleportation feature
  44335. */
  44336. static TELEPORTATION: string;
  44337. }
  44338. /**
  44339. * Defining the constructor of a feature. Used to register the modules.
  44340. */
  44341. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44342. /**
  44343. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44344. * It is mainly used in AR sessions.
  44345. *
  44346. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44347. */
  44348. export class WebXRFeaturesManager implements IDisposable {
  44349. private _xrSessionManager;
  44350. private static readonly _AvailableFeatures;
  44351. private _features;
  44352. /**
  44353. * constructs a new features manages.
  44354. *
  44355. * @param _xrSessionManager an instance of WebXRSessionManager
  44356. */
  44357. constructor(_xrSessionManager: WebXRSessionManager);
  44358. /**
  44359. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44360. * Mainly used internally.
  44361. *
  44362. * @param featureName the name of the feature to register
  44363. * @param constructorFunction the function used to construct the module
  44364. * @param version the (babylon) version of the module
  44365. * @param stable is that a stable version of this module
  44366. */
  44367. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44368. /**
  44369. * Returns a constructor of a specific feature.
  44370. *
  44371. * @param featureName the name of the feature to construct
  44372. * @param version the version of the feature to load
  44373. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44374. * @param options optional options provided to the module.
  44375. * @returns a function that, when called, will return a new instance of this feature
  44376. */
  44377. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44378. /**
  44379. * Can be used to return the list of features currently registered
  44380. *
  44381. * @returns an Array of available features
  44382. */
  44383. static GetAvailableFeatures(): string[];
  44384. /**
  44385. * Gets the versions available for a specific feature
  44386. * @param featureName the name of the feature
  44387. * @returns an array with the available versions
  44388. */
  44389. static GetAvailableVersions(featureName: string): string[];
  44390. /**
  44391. * Return the latest unstable version of this feature
  44392. * @param featureName the name of the feature to search
  44393. * @returns the version number. if not found will return -1
  44394. */
  44395. static GetLatestVersionOfFeature(featureName: string): number;
  44396. /**
  44397. * Return the latest stable version of this feature
  44398. * @param featureName the name of the feature to search
  44399. * @returns the version number. if not found will return -1
  44400. */
  44401. static GetStableVersionOfFeature(featureName: string): number;
  44402. /**
  44403. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44404. * Can be used during a session to start a feature
  44405. * @param featureName the name of feature to attach
  44406. */
  44407. attachFeature(featureName: string): void;
  44408. /**
  44409. * Can be used inside a session or when the session ends to detach a specific feature
  44410. * @param featureName the name of the feature to detach
  44411. */
  44412. detachFeature(featureName: string): void;
  44413. /**
  44414. * Used to disable an already-enabled feature
  44415. * The feature will be disposed and will be recreated once enabled.
  44416. * @param featureName the feature to disable
  44417. * @returns true if disable was successful
  44418. */
  44419. disableFeature(featureName: string | {
  44420. Name: string;
  44421. }): boolean;
  44422. /**
  44423. * dispose this features manager
  44424. */
  44425. dispose(): void;
  44426. /**
  44427. * 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.
  44428. * 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.
  44429. *
  44430. * @param featureName the name of the feature to load or the class of the feature
  44431. * @param version optional version to load. if not provided the latest version will be enabled
  44432. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44433. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44434. * @returns a new constructed feature or throws an error if feature not found.
  44435. */
  44436. enableFeature(featureName: string | {
  44437. Name: string;
  44438. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44439. /**
  44440. * get the implementation of an enabled feature.
  44441. * @param featureName the name of the feature to load
  44442. * @returns the feature class, if found
  44443. */
  44444. getEnabledFeature(featureName: string): IWebXRFeature;
  44445. /**
  44446. * Get the list of enabled features
  44447. * @returns an array of enabled features
  44448. */
  44449. getEnabledFeatures(): string[];
  44450. }
  44451. }
  44452. declare module "babylonjs/XR/webXRExperienceHelper" {
  44453. import { Observable } from "babylonjs/Misc/observable";
  44454. import { IDisposable, Scene } from "babylonjs/scene";
  44455. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44456. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44457. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44458. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44459. /**
  44460. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  44461. * @see https://doc.babylonjs.com/how_to/webxr
  44462. */
  44463. export class WebXRExperienceHelper implements IDisposable {
  44464. private scene;
  44465. private _nonVRCamera;
  44466. private _originalSceneAutoClear;
  44467. private _supported;
  44468. /**
  44469. * Camera used to render xr content
  44470. */
  44471. camera: WebXRCamera;
  44472. /** A features manager for this xr session */
  44473. featuresManager: WebXRFeaturesManager;
  44474. /**
  44475. * Observers registered here will be triggered after the camera's initial transformation is set
  44476. * This can be used to set a different ground level or an extra rotation.
  44477. *
  44478. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44479. * to the position set after this observable is done executing.
  44480. */
  44481. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44482. /**
  44483. * Fires when the state of the experience helper has changed
  44484. */
  44485. onStateChangedObservable: Observable<WebXRState>;
  44486. /** Session manager used to keep track of xr session */
  44487. sessionManager: WebXRSessionManager;
  44488. /**
  44489. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44490. */
  44491. state: WebXRState;
  44492. /**
  44493. * Creates a WebXRExperienceHelper
  44494. * @param scene The scene the helper should be created in
  44495. */
  44496. private constructor();
  44497. /**
  44498. * Creates the experience helper
  44499. * @param scene the scene to attach the experience helper to
  44500. * @returns a promise for the experience helper
  44501. */
  44502. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44503. /**
  44504. * Disposes of the experience helper
  44505. */
  44506. dispose(): void;
  44507. /**
  44508. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44509. * @param sessionMode options for the XR session
  44510. * @param referenceSpaceType frame of reference of the XR session
  44511. * @param renderTarget the output canvas that will be used to enter XR mode
  44512. * @returns promise that resolves after xr mode has entered
  44513. */
  44514. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44515. /**
  44516. * Exits XR mode and returns the scene to its original state
  44517. * @returns promise that resolves after xr mode has exited
  44518. */
  44519. exitXRAsync(): Promise<void>;
  44520. private _nonXRToXRCamera;
  44521. private _setState;
  44522. }
  44523. }
  44524. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44525. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44526. import { Observable } from "babylonjs/Misc/observable";
  44527. import { IDisposable } from "babylonjs/scene";
  44528. /**
  44529. * X-Y values for axes in WebXR
  44530. */
  44531. export interface IWebXRMotionControllerAxesValue {
  44532. /**
  44533. * The value of the x axis
  44534. */
  44535. x: number;
  44536. /**
  44537. * The value of the y-axis
  44538. */
  44539. y: number;
  44540. }
  44541. /**
  44542. * changed / previous values for the values of this component
  44543. */
  44544. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44545. /**
  44546. * current (this frame) value
  44547. */
  44548. current: T;
  44549. /**
  44550. * previous (last change) value
  44551. */
  44552. previous: T;
  44553. }
  44554. /**
  44555. * Represents changes in the component between current frame and last values recorded
  44556. */
  44557. export interface IWebXRMotionControllerComponentChanges {
  44558. /**
  44559. * will be populated with previous and current values if axes changed
  44560. */
  44561. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44562. /**
  44563. * will be populated with previous and current values if pressed changed
  44564. */
  44565. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44566. /**
  44567. * will be populated with previous and current values if touched changed
  44568. */
  44569. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44570. /**
  44571. * will be populated with previous and current values if value changed
  44572. */
  44573. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44574. }
  44575. /**
  44576. * This class represents a single component (for example button or thumbstick) of a motion controller
  44577. */
  44578. export class WebXRControllerComponent implements IDisposable {
  44579. /**
  44580. * the id of this component
  44581. */
  44582. id: string;
  44583. /**
  44584. * the type of the component
  44585. */
  44586. type: MotionControllerComponentType;
  44587. private _buttonIndex;
  44588. private _axesIndices;
  44589. private _axes;
  44590. private _changes;
  44591. private _currentValue;
  44592. private _hasChanges;
  44593. private _pressed;
  44594. private _touched;
  44595. /**
  44596. * button component type
  44597. */
  44598. static BUTTON_TYPE: MotionControllerComponentType;
  44599. /**
  44600. * squeeze component type
  44601. */
  44602. static SQUEEZE_TYPE: MotionControllerComponentType;
  44603. /**
  44604. * Thumbstick component type
  44605. */
  44606. static THUMBSTICK_TYPE: MotionControllerComponentType;
  44607. /**
  44608. * Touchpad component type
  44609. */
  44610. static TOUCHPAD_TYPE: MotionControllerComponentType;
  44611. /**
  44612. * trigger component type
  44613. */
  44614. static TRIGGER_TYPE: MotionControllerComponentType;
  44615. /**
  44616. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44617. * the axes data changes
  44618. */
  44619. onAxisValueChangedObservable: Observable<{
  44620. x: number;
  44621. y: number;
  44622. }>;
  44623. /**
  44624. * Observers registered here will be triggered when the state of a button changes
  44625. * State change is either pressed / touched / value
  44626. */
  44627. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  44628. /**
  44629. * Creates a new component for a motion controller.
  44630. * It is created by the motion controller itself
  44631. *
  44632. * @param id the id of this component
  44633. * @param type the type of the component
  44634. * @param _buttonIndex index in the buttons array of the gamepad
  44635. * @param _axesIndices indices of the values in the axes array of the gamepad
  44636. */
  44637. constructor(
  44638. /**
  44639. * the id of this component
  44640. */
  44641. id: string,
  44642. /**
  44643. * the type of the component
  44644. */
  44645. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44646. /**
  44647. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44648. */
  44649. get axes(): IWebXRMotionControllerAxesValue;
  44650. /**
  44651. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44652. */
  44653. get changes(): IWebXRMotionControllerComponentChanges;
  44654. /**
  44655. * Return whether or not the component changed the last frame
  44656. */
  44657. get hasChanges(): boolean;
  44658. /**
  44659. * is the button currently pressed
  44660. */
  44661. get pressed(): boolean;
  44662. /**
  44663. * is the button currently touched
  44664. */
  44665. get touched(): boolean;
  44666. /**
  44667. * Get the current value of this component
  44668. */
  44669. get value(): number;
  44670. /**
  44671. * Dispose this component
  44672. */
  44673. dispose(): void;
  44674. /**
  44675. * Are there axes correlating to this component
  44676. * @return true is axes data is available
  44677. */
  44678. isAxes(): boolean;
  44679. /**
  44680. * Is this component a button (hence - pressable)
  44681. * @returns true if can be pressed
  44682. */
  44683. isButton(): boolean;
  44684. /**
  44685. * update this component using the gamepad object it is in. Called on every frame
  44686. * @param nativeController the native gamepad controller object
  44687. */
  44688. update(nativeController: IMinimalMotionControllerObject): void;
  44689. }
  44690. }
  44691. declare module "babylonjs/Loading/sceneLoader" {
  44692. import { Observable } from "babylonjs/Misc/observable";
  44693. import { Nullable } from "babylonjs/types";
  44694. import { Scene } from "babylonjs/scene";
  44695. import { Engine } from "babylonjs/Engines/engine";
  44696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44697. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44698. import { AssetContainer } from "babylonjs/assetContainer";
  44699. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44700. import { Skeleton } from "babylonjs/Bones/skeleton";
  44701. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44702. import { WebRequest } from "babylonjs/Misc/webRequest";
  44703. /**
  44704. * Class used to represent data loading progression
  44705. */
  44706. export class SceneLoaderProgressEvent {
  44707. /** defines if data length to load can be evaluated */
  44708. readonly lengthComputable: boolean;
  44709. /** defines the loaded data length */
  44710. readonly loaded: number;
  44711. /** defines the data length to load */
  44712. readonly total: number;
  44713. /**
  44714. * Create a new progress event
  44715. * @param lengthComputable defines if data length to load can be evaluated
  44716. * @param loaded defines the loaded data length
  44717. * @param total defines the data length to load
  44718. */
  44719. constructor(
  44720. /** defines if data length to load can be evaluated */
  44721. lengthComputable: boolean,
  44722. /** defines the loaded data length */
  44723. loaded: number,
  44724. /** defines the data length to load */
  44725. total: number);
  44726. /**
  44727. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44728. * @param event defines the source event
  44729. * @returns a new SceneLoaderProgressEvent
  44730. */
  44731. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44732. }
  44733. /**
  44734. * Interface used by SceneLoader plugins to define supported file extensions
  44735. */
  44736. export interface ISceneLoaderPluginExtensions {
  44737. /**
  44738. * Defines the list of supported extensions
  44739. */
  44740. [extension: string]: {
  44741. isBinary: boolean;
  44742. };
  44743. }
  44744. /**
  44745. * Interface used by SceneLoader plugin factory
  44746. */
  44747. export interface ISceneLoaderPluginFactory {
  44748. /**
  44749. * Defines the name of the factory
  44750. */
  44751. name: string;
  44752. /**
  44753. * Function called to create a new plugin
  44754. * @return the new plugin
  44755. */
  44756. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44757. /**
  44758. * The callback that returns true if the data can be directly loaded.
  44759. * @param data string containing the file data
  44760. * @returns if the data can be loaded directly
  44761. */
  44762. canDirectLoad?(data: string): boolean;
  44763. }
  44764. /**
  44765. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44766. */
  44767. export interface ISceneLoaderPluginBase {
  44768. /**
  44769. * The friendly name of this plugin.
  44770. */
  44771. name: string;
  44772. /**
  44773. * The file extensions supported by this plugin.
  44774. */
  44775. extensions: string | ISceneLoaderPluginExtensions;
  44776. /**
  44777. * The callback called when loading from a url.
  44778. * @param scene scene loading this url
  44779. * @param url url to load
  44780. * @param onSuccess callback called when the file successfully loads
  44781. * @param onProgress callback called while file is loading (if the server supports this mode)
  44782. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44783. * @param onError callback called when the file fails to load
  44784. * @returns a file request object
  44785. */
  44786. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44787. /**
  44788. * The callback called when loading from a file object.
  44789. * @param scene scene loading this file
  44790. * @param file defines the file to load
  44791. * @param onSuccess defines the callback to call when data is loaded
  44792. * @param onProgress defines the callback to call during loading process
  44793. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44794. * @param onError defines the callback to call when an error occurs
  44795. * @returns a file request object
  44796. */
  44797. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44798. /**
  44799. * The callback that returns true if the data can be directly loaded.
  44800. * @param data string containing the file data
  44801. * @returns if the data can be loaded directly
  44802. */
  44803. canDirectLoad?(data: string): boolean;
  44804. /**
  44805. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44806. * @param scene scene loading this data
  44807. * @param data string containing the data
  44808. * @returns data to pass to the plugin
  44809. */
  44810. directLoad?(scene: Scene, data: string): any;
  44811. /**
  44812. * The callback that allows custom handling of the root url based on the response url.
  44813. * @param rootUrl the original root url
  44814. * @param responseURL the response url if available
  44815. * @returns the new root url
  44816. */
  44817. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44818. }
  44819. /**
  44820. * Interface used to define a SceneLoader plugin
  44821. */
  44822. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44823. /**
  44824. * Import meshes into a scene.
  44825. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44826. * @param scene The scene to import into
  44827. * @param data The data to import
  44828. * @param rootUrl The root url for scene and resources
  44829. * @param meshes The meshes array to import into
  44830. * @param particleSystems The particle systems array to import into
  44831. * @param skeletons The skeletons array to import into
  44832. * @param onError The callback when import fails
  44833. * @returns True if successful or false otherwise
  44834. */
  44835. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44836. /**
  44837. * Load into a scene.
  44838. * @param scene The scene to load into
  44839. * @param data The data to import
  44840. * @param rootUrl The root url for scene and resources
  44841. * @param onError The callback when import fails
  44842. * @returns True if successful or false otherwise
  44843. */
  44844. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44845. /**
  44846. * Load into an asset container.
  44847. * @param scene The scene to load into
  44848. * @param data The data to import
  44849. * @param rootUrl The root url for scene and resources
  44850. * @param onError The callback when import fails
  44851. * @returns The loaded asset container
  44852. */
  44853. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44854. }
  44855. /**
  44856. * Interface used to define an async SceneLoader plugin
  44857. */
  44858. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44859. /**
  44860. * Import meshes into a scene.
  44861. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44862. * @param scene The scene to import into
  44863. * @param data The data to import
  44864. * @param rootUrl The root url for scene and resources
  44865. * @param onProgress The callback when the load progresses
  44866. * @param fileName Defines the name of the file to load
  44867. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44868. */
  44869. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44870. meshes: AbstractMesh[];
  44871. particleSystems: IParticleSystem[];
  44872. skeletons: Skeleton[];
  44873. animationGroups: AnimationGroup[];
  44874. }>;
  44875. /**
  44876. * Load into a scene.
  44877. * @param scene The scene to load into
  44878. * @param data The data to import
  44879. * @param rootUrl The root url for scene and resources
  44880. * @param onProgress The callback when the load progresses
  44881. * @param fileName Defines the name of the file to load
  44882. * @returns Nothing
  44883. */
  44884. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44885. /**
  44886. * Load into an asset container.
  44887. * @param scene The scene to load into
  44888. * @param data The data to import
  44889. * @param rootUrl The root url for scene and resources
  44890. * @param onProgress The callback when the load progresses
  44891. * @param fileName Defines the name of the file to load
  44892. * @returns The loaded asset container
  44893. */
  44894. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44895. }
  44896. /**
  44897. * Mode that determines how to handle old animation groups before loading new ones.
  44898. */
  44899. export enum SceneLoaderAnimationGroupLoadingMode {
  44900. /**
  44901. * Reset all old animations to initial state then dispose them.
  44902. */
  44903. Clean = 0,
  44904. /**
  44905. * Stop all old animations.
  44906. */
  44907. Stop = 1,
  44908. /**
  44909. * Restart old animations from first frame.
  44910. */
  44911. Sync = 2,
  44912. /**
  44913. * Old animations remains untouched.
  44914. */
  44915. NoSync = 3
  44916. }
  44917. /**
  44918. * Class used to load scene from various file formats using registered plugins
  44919. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44920. */
  44921. export class SceneLoader {
  44922. /**
  44923. * No logging while loading
  44924. */
  44925. static readonly NO_LOGGING: number;
  44926. /**
  44927. * Minimal logging while loading
  44928. */
  44929. static readonly MINIMAL_LOGGING: number;
  44930. /**
  44931. * Summary logging while loading
  44932. */
  44933. static readonly SUMMARY_LOGGING: number;
  44934. /**
  44935. * Detailled logging while loading
  44936. */
  44937. static readonly DETAILED_LOGGING: number;
  44938. /**
  44939. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44940. */
  44941. static get ForceFullSceneLoadingForIncremental(): boolean;
  44942. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44943. /**
  44944. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44945. */
  44946. static get ShowLoadingScreen(): boolean;
  44947. static set ShowLoadingScreen(value: boolean);
  44948. /**
  44949. * Defines the current logging level (while loading the scene)
  44950. * @ignorenaming
  44951. */
  44952. static get loggingLevel(): number;
  44953. static set loggingLevel(value: number);
  44954. /**
  44955. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44956. */
  44957. static get CleanBoneMatrixWeights(): boolean;
  44958. static set CleanBoneMatrixWeights(value: boolean);
  44959. /**
  44960. * Event raised when a plugin is used to load a scene
  44961. */
  44962. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44963. private static _registeredPlugins;
  44964. private static _getDefaultPlugin;
  44965. private static _getPluginForExtension;
  44966. private static _getPluginForDirectLoad;
  44967. private static _getPluginForFilename;
  44968. private static _getDirectLoad;
  44969. private static _loadData;
  44970. private static _getFileInfo;
  44971. /**
  44972. * Gets a plugin that can load the given extension
  44973. * @param extension defines the extension to load
  44974. * @returns a plugin or null if none works
  44975. */
  44976. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44977. /**
  44978. * Gets a boolean indicating that the given extension can be loaded
  44979. * @param extension defines the extension to load
  44980. * @returns true if the extension is supported
  44981. */
  44982. static IsPluginForExtensionAvailable(extension: string): boolean;
  44983. /**
  44984. * Adds a new plugin to the list of registered plugins
  44985. * @param plugin defines the plugin to add
  44986. */
  44987. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44988. /**
  44989. * Import meshes into a scene
  44990. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44991. * @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)
  44992. * @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)
  44993. * @param scene the instance of BABYLON.Scene to append to
  44994. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44995. * @param onProgress a callback with a progress event for each file being loaded
  44996. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44997. * @param pluginExtension the extension used to determine the plugin
  44998. * @returns The loaded plugin
  44999. */
  45000. 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>;
  45001. /**
  45002. * Import meshes into a scene
  45003. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45004. * @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)
  45005. * @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)
  45006. * @param scene the instance of BABYLON.Scene to append to
  45007. * @param onProgress a callback with a progress event for each file being loaded
  45008. * @param pluginExtension the extension used to determine the plugin
  45009. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45010. */
  45011. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45012. meshes: AbstractMesh[];
  45013. particleSystems: IParticleSystem[];
  45014. skeletons: Skeleton[];
  45015. animationGroups: AnimationGroup[];
  45016. }>;
  45017. /**
  45018. * Load a scene
  45019. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  45020. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  45021. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45022. * @param onSuccess a callback with the scene when import succeeds
  45023. * @param onProgress a callback with a progress event for each file being loaded
  45024. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45025. * @param pluginExtension the extension used to determine the plugin
  45026. * @returns The loaded plugin
  45027. */
  45028. static 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>;
  45029. /**
  45030. * Load a scene
  45031. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  45032. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  45033. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45034. * @param onProgress a callback with a progress event for each file being loaded
  45035. * @param pluginExtension the extension used to determine the plugin
  45036. * @returns The loaded scene
  45037. */
  45038. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45039. /**
  45040. * Append a scene
  45041. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  45042. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  45043. * @param scene is the instance of BABYLON.Scene to append to
  45044. * @param onSuccess a callback with the scene when import succeeds
  45045. * @param onProgress a callback with a progress event for each file being loaded
  45046. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45047. * @param pluginExtension the extension used to determine the plugin
  45048. * @returns The loaded plugin
  45049. */
  45050. 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>;
  45051. /**
  45052. * Append a scene
  45053. * @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)
  45054. * @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)
  45055. * @param scene is the instance of BABYLON.Scene to append to
  45056. * @param onProgress a callback with a progress event for each file being loaded
  45057. * @param pluginExtension the extension used to determine the plugin
  45058. * @returns The given scene
  45059. */
  45060. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45061. /**
  45062. * Load a scene into an asset container
  45063. * @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)
  45064. * @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)
  45065. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45066. * @param onSuccess a callback with the scene when import succeeds
  45067. * @param onProgress a callback with a progress event for each file being loaded
  45068. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45069. * @param pluginExtension the extension used to determine the plugin
  45070. * @returns The loaded plugin
  45071. */
  45072. 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>;
  45073. /**
  45074. * Load a scene into an asset container
  45075. * @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)
  45076. * @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)
  45077. * @param scene is the instance of Scene to append to
  45078. * @param onProgress a callback with a progress event for each file being loaded
  45079. * @param pluginExtension the extension used to determine the plugin
  45080. * @returns The loaded asset container
  45081. */
  45082. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45083. /**
  45084. * Import animations from a file into a scene
  45085. * @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)
  45086. * @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)
  45087. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45088. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45089. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45090. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45091. * @param onSuccess a callback with the scene when import succeeds
  45092. * @param onProgress a callback with a progress event for each file being loaded
  45093. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45094. */
  45095. 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;
  45096. /**
  45097. * Import animations from a file into a scene
  45098. * @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)
  45099. * @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)
  45100. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45101. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45102. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45103. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45104. * @param onSuccess a callback with the scene when import succeeds
  45105. * @param onProgress a callback with a progress event for each file being loaded
  45106. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45107. * @returns the updated scene with imported animations
  45108. */
  45109. 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>;
  45110. }
  45111. }
  45112. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45113. import { IDisposable, Scene } from "babylonjs/scene";
  45114. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45115. import { Observable } from "babylonjs/Misc/observable";
  45116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45117. import { Nullable } from "babylonjs/types";
  45118. /**
  45119. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45120. */
  45121. export type MotionControllerHandness = "none" | "left" | "right";
  45122. /**
  45123. * The type of components available in motion controllers.
  45124. * This is not the name of the component.
  45125. */
  45126. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45127. /**
  45128. * The state of a controller component
  45129. */
  45130. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45131. /**
  45132. * The schema of motion controller layout.
  45133. * No object will be initialized using this interface
  45134. * This is used just to define the profile.
  45135. */
  45136. export interface IMotionControllerLayout {
  45137. /**
  45138. * Path to load the assets. Usually relative to the base path
  45139. */
  45140. assetPath: string;
  45141. /**
  45142. * Available components (unsorted)
  45143. */
  45144. components: {
  45145. /**
  45146. * A map of component Ids
  45147. */
  45148. [componentId: string]: {
  45149. /**
  45150. * The type of input the component outputs
  45151. */
  45152. type: MotionControllerComponentType;
  45153. /**
  45154. * The indices of this component in the gamepad object
  45155. */
  45156. gamepadIndices: {
  45157. /**
  45158. * Index of button
  45159. */
  45160. button?: number;
  45161. /**
  45162. * If available, index of x-axis
  45163. */
  45164. xAxis?: number;
  45165. /**
  45166. * If available, index of y-axis
  45167. */
  45168. yAxis?: number;
  45169. };
  45170. /**
  45171. * The mesh's root node name
  45172. */
  45173. rootNodeName: string;
  45174. /**
  45175. * Animation definitions for this model
  45176. */
  45177. visualResponses: {
  45178. [stateKey: string]: {
  45179. /**
  45180. * What property will be animated
  45181. */
  45182. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45183. /**
  45184. * What states influence this visual response
  45185. */
  45186. states: MotionControllerComponentStateType[];
  45187. /**
  45188. * Type of animation - movement or visibility
  45189. */
  45190. valueNodeProperty: "transform" | "visibility";
  45191. /**
  45192. * Base node name to move. Its position will be calculated according to the min and max nodes
  45193. */
  45194. valueNodeName?: string;
  45195. /**
  45196. * Minimum movement node
  45197. */
  45198. minNodeName?: string;
  45199. /**
  45200. * Max movement node
  45201. */
  45202. maxNodeName?: string;
  45203. };
  45204. };
  45205. /**
  45206. * If touch enabled, what is the name of node to display user feedback
  45207. */
  45208. touchPointNodeName?: string;
  45209. };
  45210. };
  45211. /**
  45212. * Is it xr standard mapping or not
  45213. */
  45214. gamepadMapping: "" | "xr-standard";
  45215. /**
  45216. * Base root node of this entire model
  45217. */
  45218. rootNodeName: string;
  45219. /**
  45220. * Defines the main button component id
  45221. */
  45222. selectComponentId: string;
  45223. }
  45224. /**
  45225. * A definition for the layout map in the input profile
  45226. */
  45227. export interface IMotionControllerLayoutMap {
  45228. /**
  45229. * Layouts with handness type as a key
  45230. */
  45231. [handness: string]: IMotionControllerLayout;
  45232. }
  45233. /**
  45234. * The XR Input profile schema
  45235. * Profiles can be found here:
  45236. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45237. */
  45238. export interface IMotionControllerProfile {
  45239. /**
  45240. * fallback profiles for this profileId
  45241. */
  45242. fallbackProfileIds: string[];
  45243. /**
  45244. * The layout map, with handness as key
  45245. */
  45246. layouts: IMotionControllerLayoutMap;
  45247. /**
  45248. * The id of this profile
  45249. * correlates to the profile(s) in the xrInput.profiles array
  45250. */
  45251. profileId: string;
  45252. }
  45253. /**
  45254. * A helper-interface for the 3 meshes needed for controller button animation
  45255. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45256. */
  45257. export interface IMotionControllerButtonMeshMap {
  45258. /**
  45259. * the mesh that defines the pressed value mesh position.
  45260. * This is used to find the max-position of this button
  45261. */
  45262. pressedMesh: AbstractMesh;
  45263. /**
  45264. * the mesh that defines the unpressed value mesh position.
  45265. * This is used to find the min (or initial) position of this button
  45266. */
  45267. unpressedMesh: AbstractMesh;
  45268. /**
  45269. * The mesh that will be changed when value changes
  45270. */
  45271. valueMesh: AbstractMesh;
  45272. }
  45273. /**
  45274. * A helper-interface for the 3 meshes needed for controller axis animation.
  45275. * This will be expanded when touchpad animations are fully supported
  45276. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45277. */
  45278. export interface IMotionControllerMeshMap {
  45279. /**
  45280. * the mesh that defines the maximum value mesh position.
  45281. */
  45282. maxMesh?: AbstractMesh;
  45283. /**
  45284. * the mesh that defines the minimum value mesh position.
  45285. */
  45286. minMesh?: AbstractMesh;
  45287. /**
  45288. * The mesh that will be changed when axis value changes
  45289. */
  45290. valueMesh: AbstractMesh;
  45291. }
  45292. /**
  45293. * The elements needed for change-detection of the gamepad objects in motion controllers
  45294. */
  45295. export interface IMinimalMotionControllerObject {
  45296. /**
  45297. * Available axes of this controller
  45298. */
  45299. axes: number[];
  45300. /**
  45301. * An array of available buttons
  45302. */
  45303. buttons: Array<{
  45304. /**
  45305. * Value of the button/trigger
  45306. */
  45307. value: number;
  45308. /**
  45309. * If the button/trigger is currently touched
  45310. */
  45311. touched: boolean;
  45312. /**
  45313. * If the button/trigger is currently pressed
  45314. */
  45315. pressed: boolean;
  45316. }>;
  45317. }
  45318. /**
  45319. * An Abstract Motion controller
  45320. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45321. * Each component has an observable to check for changes in value and state
  45322. */
  45323. export abstract class WebXRAbstractMotionController implements IDisposable {
  45324. protected scene: Scene;
  45325. protected layout: IMotionControllerLayout;
  45326. /**
  45327. * The gamepad object correlating to this controller
  45328. */
  45329. gamepadObject: IMinimalMotionControllerObject;
  45330. /**
  45331. * handness (left/right/none) of this controller
  45332. */
  45333. handness: MotionControllerHandness;
  45334. private _initComponent;
  45335. private _modelReady;
  45336. /**
  45337. * A map of components (WebXRControllerComponent) in this motion controller
  45338. * Components have a ComponentType and can also have both button and axis definitions
  45339. */
  45340. readonly components: {
  45341. [id: string]: WebXRControllerComponent;
  45342. };
  45343. /**
  45344. * Disable the model's animation. Can be set at any time.
  45345. */
  45346. disableAnimation: boolean;
  45347. /**
  45348. * Observers registered here will be triggered when the model of this controller is done loading
  45349. */
  45350. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45351. /**
  45352. * The profile id of this motion controller
  45353. */
  45354. abstract profileId: string;
  45355. /**
  45356. * The root mesh of the model. It is null if the model was not yet initialized
  45357. */
  45358. rootMesh: Nullable<AbstractMesh>;
  45359. /**
  45360. * constructs a new abstract motion controller
  45361. * @param scene the scene to which the model of the controller will be added
  45362. * @param layout The profile layout to load
  45363. * @param gamepadObject The gamepad object correlating to this controller
  45364. * @param handness handness (left/right/none) of this controller
  45365. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45366. */
  45367. constructor(scene: Scene, layout: IMotionControllerLayout,
  45368. /**
  45369. * The gamepad object correlating to this controller
  45370. */
  45371. gamepadObject: IMinimalMotionControllerObject,
  45372. /**
  45373. * handness (left/right/none) of this controller
  45374. */
  45375. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45376. /**
  45377. * Dispose this controller, the model mesh and all its components
  45378. */
  45379. dispose(): void;
  45380. /**
  45381. * Returns all components of specific type
  45382. * @param type the type to search for
  45383. * @return an array of components with this type
  45384. */
  45385. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45386. /**
  45387. * get a component based an its component id as defined in layout.components
  45388. * @param id the id of the component
  45389. * @returns the component correlates to the id or undefined if not found
  45390. */
  45391. getComponent(id: string): WebXRControllerComponent;
  45392. /**
  45393. * Get the list of components available in this motion controller
  45394. * @returns an array of strings correlating to available components
  45395. */
  45396. getComponentIds(): string[];
  45397. /**
  45398. * Get the first component of specific type
  45399. * @param type type of component to find
  45400. * @return a controller component or null if not found
  45401. */
  45402. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45403. /**
  45404. * Get the main (Select) component of this controller as defined in the layout
  45405. * @returns the main component of this controller
  45406. */
  45407. getMainComponent(): WebXRControllerComponent;
  45408. /**
  45409. * Loads the model correlating to this controller
  45410. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45411. * @returns A promise fulfilled with the result of the model loading
  45412. */
  45413. loadModel(): Promise<boolean>;
  45414. /**
  45415. * Update this model using the current XRFrame
  45416. * @param xrFrame the current xr frame to use and update the model
  45417. */
  45418. updateFromXRFrame(xrFrame: XRFrame): void;
  45419. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45420. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45421. /**
  45422. * Moves the axis on the controller mesh based on its current state
  45423. * @param axis the index of the axis
  45424. * @param axisValue the value of the axis which determines the meshes new position
  45425. * @hidden
  45426. */
  45427. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45428. /**
  45429. * Update the model itself with the current frame data
  45430. * @param xrFrame the frame to use for updating the model mesh
  45431. */
  45432. protected updateModel(xrFrame: XRFrame): void;
  45433. /**
  45434. * Get the filename and path for this controller's model
  45435. * @returns a map of filename and path
  45436. */
  45437. protected abstract _getFilenameAndPath(): {
  45438. filename: string;
  45439. path: string;
  45440. };
  45441. /**
  45442. * This function is called before the mesh is loaded. It checks for loading constraints.
  45443. * For example, this function can check if the GLB loader is available
  45444. * If this function returns false, the generic controller will be loaded instead
  45445. * @returns Is the client ready to load the mesh
  45446. */
  45447. protected abstract _getModelLoadingConstraints(): boolean;
  45448. /**
  45449. * This function will be called after the model was successfully loaded and can be used
  45450. * for mesh transformations before it is available for the user
  45451. * @param meshes the loaded meshes
  45452. */
  45453. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45454. /**
  45455. * Set the root mesh for this controller. Important for the WebXR controller class
  45456. * @param meshes the loaded meshes
  45457. */
  45458. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45459. /**
  45460. * A function executed each frame that updates the mesh (if needed)
  45461. * @param xrFrame the current xrFrame
  45462. */
  45463. protected abstract _updateModel(xrFrame: XRFrame): void;
  45464. private _getGenericFilenameAndPath;
  45465. private _getGenericParentMesh;
  45466. }
  45467. }
  45468. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45469. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45470. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45471. import { Scene } from "babylonjs/scene";
  45472. /**
  45473. * A generic trigger-only motion controller for WebXR
  45474. */
  45475. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45476. /**
  45477. * Static version of the profile id of this controller
  45478. */
  45479. static ProfileId: string;
  45480. profileId: string;
  45481. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45482. protected _getFilenameAndPath(): {
  45483. filename: string;
  45484. path: string;
  45485. };
  45486. protected _getModelLoadingConstraints(): boolean;
  45487. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45488. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45489. protected _updateModel(): void;
  45490. }
  45491. }
  45492. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45493. import { Vector4 } from "babylonjs/Maths/math.vector";
  45494. import { Mesh } from "babylonjs/Meshes/mesh";
  45495. import { Scene } from "babylonjs/scene";
  45496. import { Nullable } from "babylonjs/types";
  45497. /**
  45498. * Class containing static functions to help procedurally build meshes
  45499. */
  45500. export class SphereBuilder {
  45501. /**
  45502. * Creates a sphere mesh
  45503. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45504. * * 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`)
  45505. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45506. * * 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
  45507. * * 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)
  45508. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45509. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45511. * @param name defines the name of the mesh
  45512. * @param options defines the options used to create the mesh
  45513. * @param scene defines the hosting scene
  45514. * @returns the sphere mesh
  45515. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45516. */
  45517. static CreateSphere(name: string, options: {
  45518. segments?: number;
  45519. diameter?: number;
  45520. diameterX?: number;
  45521. diameterY?: number;
  45522. diameterZ?: number;
  45523. arc?: number;
  45524. slice?: number;
  45525. sideOrientation?: number;
  45526. frontUVs?: Vector4;
  45527. backUVs?: Vector4;
  45528. updatable?: boolean;
  45529. }, scene?: Nullable<Scene>): Mesh;
  45530. }
  45531. }
  45532. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45534. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45535. import { Scene } from "babylonjs/scene";
  45536. /**
  45537. * A profiled motion controller has its profile loaded from an online repository.
  45538. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45539. */
  45540. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45541. private _repositoryUrl;
  45542. private _buttonMeshMapping;
  45543. private _touchDots;
  45544. /**
  45545. * The profile ID of this controller. Will be populated when the controller initializes.
  45546. */
  45547. profileId: string;
  45548. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45549. dispose(): void;
  45550. protected _getFilenameAndPath(): {
  45551. filename: string;
  45552. path: string;
  45553. };
  45554. protected _getModelLoadingConstraints(): boolean;
  45555. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45556. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45557. protected _updateModel(_xrFrame: XRFrame): void;
  45558. }
  45559. }
  45560. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45561. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45562. import { Scene } from "babylonjs/scene";
  45563. /**
  45564. * A construction function type to create a new controller based on an xrInput object
  45565. */
  45566. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45567. /**
  45568. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45569. *
  45570. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45571. * it should be replaced with auto-loaded controllers.
  45572. *
  45573. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45574. */
  45575. export class WebXRMotionControllerManager {
  45576. private static _AvailableControllers;
  45577. private static _Fallbacks;
  45578. private static _ProfileLoadingPromises;
  45579. private static _ProfilesList;
  45580. /**
  45581. * The base URL of the online controller repository. Can be changed at any time.
  45582. */
  45583. static BaseRepositoryUrl: string;
  45584. /**
  45585. * Which repository gets priority - local or online
  45586. */
  45587. static PrioritizeOnlineRepository: boolean;
  45588. /**
  45589. * Use the online repository, or use only locally-defined controllers
  45590. */
  45591. static UseOnlineRepository: boolean;
  45592. /**
  45593. * Clear the cache used for profile loading and reload when requested again
  45594. */
  45595. static ClearProfilesCache(): void;
  45596. /**
  45597. * Register the default fallbacks.
  45598. * This function is called automatically when this file is imported.
  45599. */
  45600. static DefaultFallbacks(): void;
  45601. /**
  45602. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45603. * @param profileId the profile to which a fallback needs to be found
  45604. * @return an array with corresponding fallback profiles
  45605. */
  45606. static FindFallbackWithProfileId(profileId: string): string[];
  45607. /**
  45608. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45609. * The order of search:
  45610. *
  45611. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45612. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45613. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45614. * 4) return the generic trigger controller if none were found
  45615. *
  45616. * @param xrInput the xrInput to which a new controller is initialized
  45617. * @param scene the scene to which the model will be added
  45618. * @param forceProfile force a certain profile for this controller
  45619. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45620. */
  45621. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45622. /**
  45623. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45624. *
  45625. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45626. *
  45627. * @param type the profile type to register
  45628. * @param constructFunction the function to be called when loading this profile
  45629. */
  45630. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45631. /**
  45632. * Register a fallback to a specific profile.
  45633. * @param profileId the profileId that will receive the fallbacks
  45634. * @param fallbacks A list of fallback profiles
  45635. */
  45636. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45637. /**
  45638. * Will update the list of profiles available in the repository
  45639. * @return a promise that resolves to a map of profiles available online
  45640. */
  45641. static UpdateProfilesList(): Promise<{
  45642. [profile: string]: string;
  45643. }>;
  45644. private static _LoadProfileFromRepository;
  45645. private static _LoadProfilesFromAvailableControllers;
  45646. }
  45647. }
  45648. declare module "babylonjs/XR/webXRInputSource" {
  45649. import { Observable } from "babylonjs/Misc/observable";
  45650. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45651. import { Ray } from "babylonjs/Culling/ray";
  45652. import { Scene } from "babylonjs/scene";
  45653. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45654. /**
  45655. * Configuration options for the WebXR controller creation
  45656. */
  45657. export interface IWebXRControllerOptions {
  45658. /**
  45659. * Should the controller mesh be animated when a user interacts with it
  45660. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45661. */
  45662. disableMotionControllerAnimation?: boolean;
  45663. /**
  45664. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45665. */
  45666. doNotLoadControllerMesh?: boolean;
  45667. /**
  45668. * Force a specific controller type for this controller.
  45669. * This can be used when creating your own profile or when testing different controllers
  45670. */
  45671. forceControllerProfile?: string;
  45672. }
  45673. /**
  45674. * Represents an XR controller
  45675. */
  45676. export class WebXRInputSource {
  45677. private _scene;
  45678. /** The underlying input source for the controller */
  45679. inputSource: XRInputSource;
  45680. private _options;
  45681. private _tmpQuaternion;
  45682. private _tmpVector;
  45683. private _uniqueId;
  45684. /**
  45685. * 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
  45686. */
  45687. grip?: AbstractMesh;
  45688. /**
  45689. * If available, this is the gamepad object related to this controller.
  45690. * Using this object it is possible to get click events and trackpad changes of the
  45691. * webxr controller that is currently being used.
  45692. */
  45693. motionController?: WebXRAbstractMotionController;
  45694. /**
  45695. * Event that fires when the controller is removed/disposed.
  45696. * The object provided as event data is this controller, after associated assets were disposed.
  45697. * uniqueId is still available.
  45698. */
  45699. onDisposeObservable: Observable<WebXRInputSource>;
  45700. /**
  45701. * Will be triggered when the mesh associated with the motion controller is done loading.
  45702. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45703. * A shortened version of controller -> motion controller -> on mesh loaded.
  45704. */
  45705. onMeshLoadedObservable: Observable<AbstractMesh>;
  45706. /**
  45707. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45708. */
  45709. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45710. /**
  45711. * Pointer which can be used to select objects or attach a visible laser to
  45712. */
  45713. pointer: AbstractMesh;
  45714. /**
  45715. * Creates the controller
  45716. * @see https://doc.babylonjs.com/how_to/webxr
  45717. * @param _scene the scene which the controller should be associated to
  45718. * @param inputSource the underlying input source for the controller
  45719. * @param _options options for this controller creation
  45720. */
  45721. constructor(_scene: Scene,
  45722. /** The underlying input source for the controller */
  45723. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45724. /**
  45725. * Get this controllers unique id
  45726. */
  45727. get uniqueId(): string;
  45728. /**
  45729. * Disposes of the object
  45730. */
  45731. dispose(): void;
  45732. /**
  45733. * Gets a world space ray coming from the pointer or grip
  45734. * @param result the resulting ray
  45735. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  45736. */
  45737. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  45738. /**
  45739. * Updates the controller pose based on the given XRFrame
  45740. * @param xrFrame xr frame to update the pose with
  45741. * @param referenceSpace reference space to use
  45742. */
  45743. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45744. }
  45745. }
  45746. declare module "babylonjs/XR/webXRInput" {
  45747. import { Observable } from "babylonjs/Misc/observable";
  45748. import { IDisposable } from "babylonjs/scene";
  45749. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45750. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45751. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45752. /**
  45753. * The schema for initialization options of the XR Input class
  45754. */
  45755. export interface IWebXRInputOptions {
  45756. /**
  45757. * If set to true no model will be automatically loaded
  45758. */
  45759. doNotLoadControllerMeshes?: boolean;
  45760. /**
  45761. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45762. * If not found, the xr input profile data will be used.
  45763. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45764. */
  45765. forceInputProfile?: string;
  45766. /**
  45767. * Do not send a request to the controller repository to load the profile.
  45768. *
  45769. * Instead, use the controllers available in babylon itself.
  45770. */
  45771. disableOnlineControllerRepository?: boolean;
  45772. /**
  45773. * A custom URL for the controllers repository
  45774. */
  45775. customControllersRepositoryURL?: string;
  45776. /**
  45777. * Should the controller model's components not move according to the user input
  45778. */
  45779. disableControllerAnimation?: boolean;
  45780. }
  45781. /**
  45782. * XR input used to track XR inputs such as controllers/rays
  45783. */
  45784. export class WebXRInput implements IDisposable {
  45785. /**
  45786. * the xr session manager for this session
  45787. */
  45788. xrSessionManager: WebXRSessionManager;
  45789. /**
  45790. * the WebXR camera for this session. Mainly used for teleportation
  45791. */
  45792. xrCamera: WebXRCamera;
  45793. private readonly options;
  45794. /**
  45795. * XR controllers being tracked
  45796. */
  45797. controllers: Array<WebXRInputSource>;
  45798. private _frameObserver;
  45799. private _sessionEndedObserver;
  45800. private _sessionInitObserver;
  45801. /**
  45802. * Event when a controller has been connected/added
  45803. */
  45804. onControllerAddedObservable: Observable<WebXRInputSource>;
  45805. /**
  45806. * Event when a controller has been removed/disconnected
  45807. */
  45808. onControllerRemovedObservable: Observable<WebXRInputSource>;
  45809. /**
  45810. * Initializes the WebXRInput
  45811. * @param xrSessionManager the xr session manager for this session
  45812. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45813. * @param options = initialization options for this xr input
  45814. */
  45815. constructor(
  45816. /**
  45817. * the xr session manager for this session
  45818. */
  45819. xrSessionManager: WebXRSessionManager,
  45820. /**
  45821. * the WebXR camera for this session. Mainly used for teleportation
  45822. */
  45823. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45824. private _onInputSourcesChange;
  45825. private _addAndRemoveControllers;
  45826. /**
  45827. * Disposes of the object
  45828. */
  45829. dispose(): void;
  45830. }
  45831. }
  45832. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45833. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45834. import { Observable, EventState } from "babylonjs/Misc/observable";
  45835. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45836. /**
  45837. * This is the base class for all WebXR features.
  45838. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45839. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45840. */
  45841. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45842. protected _xrSessionManager: WebXRSessionManager;
  45843. private _attached;
  45844. private _removeOnDetach;
  45845. /**
  45846. * Should auto-attach be disabled?
  45847. */
  45848. disableAutoAttach: boolean;
  45849. /**
  45850. * Construct a new (abstract) WebXR feature
  45851. * @param _xrSessionManager the xr session manager for this feature
  45852. */
  45853. constructor(_xrSessionManager: WebXRSessionManager);
  45854. /**
  45855. * Is this feature attached
  45856. */
  45857. get attached(): boolean;
  45858. /**
  45859. * attach this feature
  45860. *
  45861. * @param force should attachment be forced (even when already attached)
  45862. * @returns true if successful, false is failed or already attached
  45863. */
  45864. attach(force?: boolean): boolean;
  45865. /**
  45866. * detach this feature.
  45867. *
  45868. * @returns true if successful, false if failed or already detached
  45869. */
  45870. detach(): boolean;
  45871. /**
  45872. * Dispose this feature and all of the resources attached
  45873. */
  45874. dispose(): void;
  45875. /**
  45876. * This is used to register callbacks that will automatically be removed when detach is called.
  45877. * @param observable the observable to which the observer will be attached
  45878. * @param callback the callback to register
  45879. */
  45880. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45881. /**
  45882. * Code in this function will be executed on each xrFrame received from the browser.
  45883. * This function will not execute after the feature is detached.
  45884. * @param _xrFrame the current frame
  45885. */
  45886. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  45887. }
  45888. }
  45889. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45890. import { IDisposable, Scene } from "babylonjs/scene";
  45891. import { Nullable } from "babylonjs/types";
  45892. import { Observable } from "babylonjs/Misc/observable";
  45893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45894. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45895. import { Camera } from "babylonjs/Cameras/camera";
  45896. /**
  45897. * Renders a layer on top of an existing scene
  45898. */
  45899. export class UtilityLayerRenderer implements IDisposable {
  45900. /** the original scene that will be rendered on top of */
  45901. originalScene: Scene;
  45902. private _pointerCaptures;
  45903. private _lastPointerEvents;
  45904. private static _DefaultUtilityLayer;
  45905. private static _DefaultKeepDepthUtilityLayer;
  45906. private _sharedGizmoLight;
  45907. private _renderCamera;
  45908. /**
  45909. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45910. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  45911. * @returns the camera that is used when rendering the utility layer
  45912. */
  45913. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  45914. /**
  45915. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45916. * @param cam the camera that should be used when rendering the utility layer
  45917. */
  45918. setRenderCamera(cam: Nullable<Camera>): void;
  45919. /**
  45920. * @hidden
  45921. * Light which used by gizmos to get light shading
  45922. */
  45923. _getSharedGizmoLight(): HemisphericLight;
  45924. /**
  45925. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45926. */
  45927. pickUtilitySceneFirst: boolean;
  45928. /**
  45929. * 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)
  45930. */
  45931. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45932. /**
  45933. * 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)
  45934. */
  45935. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45936. /**
  45937. * The scene that is rendered on top of the original scene
  45938. */
  45939. utilityLayerScene: Scene;
  45940. /**
  45941. * If the utility layer should automatically be rendered on top of existing scene
  45942. */
  45943. shouldRender: boolean;
  45944. /**
  45945. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45946. */
  45947. onlyCheckPointerDownEvents: boolean;
  45948. /**
  45949. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45950. */
  45951. processAllEvents: boolean;
  45952. /**
  45953. * Observable raised when the pointer move from the utility layer scene to the main scene
  45954. */
  45955. onPointerOutObservable: Observable<number>;
  45956. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45957. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45958. private _afterRenderObserver;
  45959. private _sceneDisposeObserver;
  45960. private _originalPointerObserver;
  45961. /**
  45962. * Instantiates a UtilityLayerRenderer
  45963. * @param originalScene the original scene that will be rendered on top of
  45964. * @param handleEvents boolean indicating if the utility layer should handle events
  45965. */
  45966. constructor(
  45967. /** the original scene that will be rendered on top of */
  45968. originalScene: Scene, handleEvents?: boolean);
  45969. private _notifyObservers;
  45970. /**
  45971. * Renders the utility layers scene on top of the original scene
  45972. */
  45973. render(): void;
  45974. /**
  45975. * Disposes of the renderer
  45976. */
  45977. dispose(): void;
  45978. private _updateCamera;
  45979. }
  45980. }
  45981. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  45982. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45984. import { WebXRInput } from "babylonjs/XR/webXRInput";
  45985. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45986. import { Scene } from "babylonjs/scene";
  45987. import { Nullable } from "babylonjs/types";
  45988. import { Color3 } from "babylonjs/Maths/math.color";
  45989. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  45990. /**
  45991. * Options interface for the pointer selection module
  45992. */
  45993. export interface IWebXRControllerPointerSelectionOptions {
  45994. /**
  45995. * if provided, this scene will be used to render meshes.
  45996. */
  45997. customUtilityLayerScene?: Scene;
  45998. /**
  45999. * 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)
  46000. * If not disabled, the last picked point will be used to execute a pointer up event
  46001. * If disabled, pointer up event will be triggered right after the pointer down event.
  46002. * Used in screen and gaze target ray mode only
  46003. */
  46004. disablePointerUpOnTouchOut: boolean;
  46005. /**
  46006. * For gaze mode (time to select instead of press)
  46007. */
  46008. forceGazeMode: boolean;
  46009. /**
  46010. * 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
  46011. * to start a new countdown to the pointer down event.
  46012. * Defaults to 1.
  46013. */
  46014. gazeModePointerMovedFactor?: number;
  46015. /**
  46016. * Different button type to use instead of the main component
  46017. */
  46018. overrideButtonId?: string;
  46019. /**
  46020. * use this rendering group id for the meshes (optional)
  46021. */
  46022. renderingGroupId?: number;
  46023. /**
  46024. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46025. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46026. * 3000 means 3 seconds between pointing at something and selecting it
  46027. */
  46028. timeToSelect?: number;
  46029. /**
  46030. * Should meshes created here be added to a utility layer or the main scene
  46031. */
  46032. useUtilityLayer?: boolean;
  46033. /**
  46034. * the xr input to use with this pointer selection
  46035. */
  46036. xrInput: WebXRInput;
  46037. }
  46038. /**
  46039. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46040. */
  46041. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46042. private readonly _options;
  46043. private static _idCounter;
  46044. private _attachController;
  46045. private _controllers;
  46046. private _scene;
  46047. private _tmpVectorForPickCompare;
  46048. /**
  46049. * The module's name
  46050. */
  46051. static readonly Name: string;
  46052. /**
  46053. * The (Babylon) version of this module.
  46054. * This is an integer representing the implementation version.
  46055. * This number does not correspond to the WebXR specs version
  46056. */
  46057. static readonly Version: number;
  46058. /**
  46059. * Disable lighting on the laser pointer (so it will always be visible)
  46060. */
  46061. disablePointerLighting: boolean;
  46062. /**
  46063. * Disable lighting on the selection mesh (so it will always be visible)
  46064. */
  46065. disableSelectionMeshLighting: boolean;
  46066. /**
  46067. * Should the laser pointer be displayed
  46068. */
  46069. displayLaserPointer: boolean;
  46070. /**
  46071. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46072. */
  46073. displaySelectionMesh: boolean;
  46074. /**
  46075. * This color will be set to the laser pointer when selection is triggered
  46076. */
  46077. laserPointerPickedColor: Color3;
  46078. /**
  46079. * Default color of the laser pointer
  46080. */
  46081. lasterPointerDefaultColor: Color3;
  46082. /**
  46083. * default color of the selection ring
  46084. */
  46085. selectionMeshDefaultColor: Color3;
  46086. /**
  46087. * This color will be applied to the selection ring when selection is triggered
  46088. */
  46089. selectionMeshPickedColor: Color3;
  46090. /**
  46091. * constructs a new background remover module
  46092. * @param _xrSessionManager the session manager for this module
  46093. * @param _options read-only options to be used in this module
  46094. */
  46095. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46096. /**
  46097. * attach this feature
  46098. * Will usually be called by the features manager
  46099. *
  46100. * @returns true if successful.
  46101. */
  46102. attach(): boolean;
  46103. /**
  46104. * detach this feature.
  46105. * Will usually be called by the features manager
  46106. *
  46107. * @returns true if successful.
  46108. */
  46109. detach(): boolean;
  46110. /**
  46111. * Will get the mesh under a specific pointer.
  46112. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46113. * @param controllerId the controllerId to check
  46114. * @returns The mesh under pointer or null if no mesh is under the pointer
  46115. */
  46116. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46117. /**
  46118. * Get the xr controller that correlates to the pointer id in the pointer event
  46119. *
  46120. * @param id the pointer id to search for
  46121. * @returns the controller that correlates to this id or null if not found
  46122. */
  46123. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46124. protected _onXRFrame(_xrFrame: XRFrame): void;
  46125. private _attachGazeMode;
  46126. private _attachScreenRayMode;
  46127. private _attachTrackedPointerRayMode;
  46128. private _convertNormalToDirectionOfRay;
  46129. private _detachController;
  46130. private _generateNewMeshPair;
  46131. private _pickingMoved;
  46132. private _updatePointerDistance;
  46133. }
  46134. }
  46135. declare module "babylonjs/XR/webXREnterExitUI" {
  46136. import { Nullable } from "babylonjs/types";
  46137. import { Observable } from "babylonjs/Misc/observable";
  46138. import { IDisposable, Scene } from "babylonjs/scene";
  46139. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46140. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46141. /**
  46142. * Button which can be used to enter a different mode of XR
  46143. */
  46144. export class WebXREnterExitUIButton {
  46145. /** button element */
  46146. element: HTMLElement;
  46147. /** XR initialization options for the button */
  46148. sessionMode: XRSessionMode;
  46149. /** Reference space type */
  46150. referenceSpaceType: XRReferenceSpaceType;
  46151. /**
  46152. * Creates a WebXREnterExitUIButton
  46153. * @param element button element
  46154. * @param sessionMode XR initialization session mode
  46155. * @param referenceSpaceType the type of reference space to be used
  46156. */
  46157. constructor(
  46158. /** button element */
  46159. element: HTMLElement,
  46160. /** XR initialization options for the button */
  46161. sessionMode: XRSessionMode,
  46162. /** Reference space type */
  46163. referenceSpaceType: XRReferenceSpaceType);
  46164. /**
  46165. * Extendable function which can be used to update the button's visuals when the state changes
  46166. * @param activeButton the current active button in the UI
  46167. */
  46168. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46169. }
  46170. /**
  46171. * Options to create the webXR UI
  46172. */
  46173. export class WebXREnterExitUIOptions {
  46174. /**
  46175. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46176. */
  46177. customButtons?: Array<WebXREnterExitUIButton>;
  46178. /**
  46179. * A reference space type to use when creating the default button.
  46180. * Default is local-floor
  46181. */
  46182. referenceSpaceType?: XRReferenceSpaceType;
  46183. /**
  46184. * Context to enter xr with
  46185. */
  46186. renderTarget?: Nullable<WebXRRenderTarget>;
  46187. /**
  46188. * A session mode to use when creating the default button.
  46189. * Default is immersive-vr
  46190. */
  46191. sessionMode?: XRSessionMode;
  46192. }
  46193. /**
  46194. * UI to allow the user to enter/exit XR mode
  46195. */
  46196. export class WebXREnterExitUI implements IDisposable {
  46197. private scene;
  46198. /** version of the options passed to this UI */
  46199. options: WebXREnterExitUIOptions;
  46200. private _activeButton;
  46201. private _buttons;
  46202. private _overlay;
  46203. /**
  46204. * Fired every time the active button is changed.
  46205. *
  46206. * When xr is entered via a button that launches xr that button will be the callback parameter
  46207. *
  46208. * When exiting xr the callback parameter will be null)
  46209. */
  46210. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46211. /**
  46212. *
  46213. * @param scene babylon scene object to use
  46214. * @param options (read-only) version of the options passed to this UI
  46215. */
  46216. private constructor();
  46217. /**
  46218. * Creates UI to allow the user to enter/exit XR mode
  46219. * @param scene the scene to add the ui to
  46220. * @param helper the xr experience helper to enter/exit xr with
  46221. * @param options options to configure the UI
  46222. * @returns the created ui
  46223. */
  46224. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46225. /**
  46226. * Disposes of the XR UI component
  46227. */
  46228. dispose(): void;
  46229. private _updateButtons;
  46230. }
  46231. }
  46232. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46233. import { Vector3 } from "babylonjs/Maths/math.vector";
  46234. import { Color4 } from "babylonjs/Maths/math.color";
  46235. import { Nullable } from "babylonjs/types";
  46236. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46237. import { Scene } from "babylonjs/scene";
  46238. /**
  46239. * Class containing static functions to help procedurally build meshes
  46240. */
  46241. export class LinesBuilder {
  46242. /**
  46243. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46244. * * 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
  46245. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46246. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46247. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46248. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46249. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46250. * * 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
  46251. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46253. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46254. * @param name defines the name of the new line system
  46255. * @param options defines the options used to create the line system
  46256. * @param scene defines the hosting scene
  46257. * @returns a new line system mesh
  46258. */
  46259. static CreateLineSystem(name: string, options: {
  46260. lines: Vector3[][];
  46261. updatable?: boolean;
  46262. instance?: Nullable<LinesMesh>;
  46263. colors?: Nullable<Color4[][]>;
  46264. useVertexAlpha?: boolean;
  46265. }, scene: Nullable<Scene>): LinesMesh;
  46266. /**
  46267. * Creates a line mesh
  46268. * 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
  46269. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46270. * * The parameter `points` is an array successive Vector3
  46271. * * 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
  46272. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46273. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46274. * * When updating an instance, remember that only point positions can change, not the number of points
  46275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46276. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46277. * @param name defines the name of the new line system
  46278. * @param options defines the options used to create the line system
  46279. * @param scene defines the hosting scene
  46280. * @returns a new line mesh
  46281. */
  46282. static CreateLines(name: string, options: {
  46283. points: Vector3[];
  46284. updatable?: boolean;
  46285. instance?: Nullable<LinesMesh>;
  46286. colors?: Color4[];
  46287. useVertexAlpha?: boolean;
  46288. }, scene?: Nullable<Scene>): LinesMesh;
  46289. /**
  46290. * Creates a dashed line mesh
  46291. * * 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
  46292. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46293. * * The parameter `points` is an array successive Vector3
  46294. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46295. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46296. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46297. * * 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
  46298. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46299. * * When updating an instance, remember that only point positions can change, not the number of points
  46300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46301. * @param name defines the name of the mesh
  46302. * @param options defines the options used to create the mesh
  46303. * @param scene defines the hosting scene
  46304. * @returns the dashed line mesh
  46305. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46306. */
  46307. static CreateDashedLines(name: string, options: {
  46308. points: Vector3[];
  46309. dashSize?: number;
  46310. gapSize?: number;
  46311. dashNb?: number;
  46312. updatable?: boolean;
  46313. instance?: LinesMesh;
  46314. useVertexAlpha?: boolean;
  46315. }, scene?: Nullable<Scene>): LinesMesh;
  46316. }
  46317. }
  46318. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46319. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46320. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46321. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46323. import { Vector3 } from "babylonjs/Maths/math.vector";
  46324. import { Material } from "babylonjs/Materials/material";
  46325. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46326. import { Scene } from "babylonjs/scene";
  46327. /**
  46328. * The options container for the teleportation module
  46329. */
  46330. export interface IWebXRTeleportationOptions {
  46331. /**
  46332. * if provided, this scene will be used to render meshes.
  46333. */
  46334. customUtilityLayerScene?: Scene;
  46335. /**
  46336. * Values to configure the default target mesh
  46337. */
  46338. defaultTargetMeshOptions?: {
  46339. /**
  46340. * Fill color of the teleportation area
  46341. */
  46342. teleportationFillColor?: string;
  46343. /**
  46344. * Border color for the teleportation area
  46345. */
  46346. teleportationBorderColor?: string;
  46347. /**
  46348. * Disable the mesh's animation sequence
  46349. */
  46350. disableAnimation?: boolean;
  46351. /**
  46352. * Disable lighting on the material or the ring and arrow
  46353. */
  46354. disableLighting?: boolean;
  46355. /**
  46356. * Override the default material of the torus and arrow
  46357. */
  46358. torusArrowMaterial?: Material;
  46359. };
  46360. /**
  46361. * A list of meshes to use as floor meshes.
  46362. * Meshes can be added and removed after initializing the feature using the
  46363. * addFloorMesh and removeFloorMesh functions
  46364. * If empty, rotation will still work
  46365. */
  46366. floorMeshes?: AbstractMesh[];
  46367. /**
  46368. * use this rendering group id for the meshes (optional)
  46369. */
  46370. renderingGroupId?: number;
  46371. /**
  46372. * Should teleportation move only to snap points
  46373. */
  46374. snapPointsOnly?: boolean;
  46375. /**
  46376. * An array of points to which the teleportation will snap to.
  46377. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46378. */
  46379. snapPositions?: Vector3[];
  46380. /**
  46381. * How close should the teleportation ray be in order to snap to position.
  46382. * Default to 0.8 units (meters)
  46383. */
  46384. snapToPositionRadius?: number;
  46385. /**
  46386. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46387. * If you want to support rotation, make sure your mesh has a direction indicator.
  46388. *
  46389. * When left untouched, the default mesh will be initialized.
  46390. */
  46391. teleportationTargetMesh?: AbstractMesh;
  46392. /**
  46393. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46394. */
  46395. timeToTeleport?: number;
  46396. /**
  46397. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46398. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46399. */
  46400. useMainComponentOnly?: boolean;
  46401. /**
  46402. * Should meshes created here be added to a utility layer or the main scene
  46403. */
  46404. useUtilityLayer?: boolean;
  46405. /**
  46406. * Babylon XR Input class for controller
  46407. */
  46408. xrInput: WebXRInput;
  46409. }
  46410. /**
  46411. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  46412. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46413. * the input of the attached controllers.
  46414. */
  46415. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46416. private _options;
  46417. private _controllers;
  46418. private _currentTeleportationControllerId;
  46419. private _floorMeshes;
  46420. private _quadraticBezierCurve;
  46421. private _selectionFeature;
  46422. private _snapToPositions;
  46423. private _snappedToPoint;
  46424. private _teleportationRingMaterial?;
  46425. private _tmpRay;
  46426. private _tmpVector;
  46427. /**
  46428. * The module's name
  46429. */
  46430. static readonly Name: string;
  46431. /**
  46432. * The (Babylon) version of this module.
  46433. * This is an integer representing the implementation version.
  46434. * This number does not correspond to the webxr specs version
  46435. */
  46436. static readonly Version: number;
  46437. /**
  46438. * Is movement backwards enabled
  46439. */
  46440. backwardsMovementEnabled: boolean;
  46441. /**
  46442. * Distance to travel when moving backwards
  46443. */
  46444. backwardsTeleportationDistance: number;
  46445. /**
  46446. * The distance from the user to the inspection point in the direction of the controller
  46447. * A higher number will allow the user to move further
  46448. * defaults to 5 (meters, in xr units)
  46449. */
  46450. parabolicCheckRadius: number;
  46451. /**
  46452. * Should the module support parabolic ray on top of direct ray
  46453. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46454. * Very helpful when moving between floors / different heights
  46455. */
  46456. parabolicRayEnabled: boolean;
  46457. /**
  46458. * How much rotation should be applied when rotating right and left
  46459. */
  46460. rotationAngle: number;
  46461. /**
  46462. * Is rotation enabled when moving forward?
  46463. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46464. */
  46465. rotationEnabled: boolean;
  46466. /**
  46467. * constructs a new anchor system
  46468. * @param _xrSessionManager an instance of WebXRSessionManager
  46469. * @param _options configuration object for this feature
  46470. */
  46471. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46472. /**
  46473. * Get the snapPointsOnly flag
  46474. */
  46475. get snapPointsOnly(): boolean;
  46476. /**
  46477. * Sets the snapPointsOnly flag
  46478. * @param snapToPoints should teleportation be exclusively to snap points
  46479. */
  46480. set snapPointsOnly(snapToPoints: boolean);
  46481. /**
  46482. * Add a new mesh to the floor meshes array
  46483. * @param mesh the mesh to use as floor mesh
  46484. */
  46485. addFloorMesh(mesh: AbstractMesh): void;
  46486. /**
  46487. * Add a new snap-to point to fix teleportation to this position
  46488. * @param newSnapPoint The new Snap-To point
  46489. */
  46490. addSnapPoint(newSnapPoint: Vector3): void;
  46491. attach(): boolean;
  46492. detach(): boolean;
  46493. dispose(): void;
  46494. /**
  46495. * Remove a mesh from the floor meshes array
  46496. * @param mesh the mesh to remove
  46497. */
  46498. removeFloorMesh(mesh: AbstractMesh): void;
  46499. /**
  46500. * Remove a mesh from the floor meshes array using its name
  46501. * @param name the mesh name to remove
  46502. */
  46503. removeFloorMeshByName(name: string): void;
  46504. /**
  46505. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  46506. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46507. * @returns was the point found and removed or not
  46508. */
  46509. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46510. /**
  46511. * This function sets a selection feature that will be disabled when
  46512. * the forward ray is shown and will be reattached when hidden.
  46513. * This is used to remove the selection rays when moving.
  46514. * @param selectionFeature the feature to disable when forward movement is enabled
  46515. */
  46516. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46517. protected _onXRFrame(_xrFrame: XRFrame): void;
  46518. private _attachController;
  46519. private _createDefaultTargetMesh;
  46520. private _detachController;
  46521. private _findClosestSnapPointWithRadius;
  46522. private _setTargetMeshPosition;
  46523. private _setTargetMeshVisibility;
  46524. private _showParabolicPath;
  46525. private _teleportForward;
  46526. }
  46527. }
  46528. declare module "babylonjs/XR/webXRDefaultExperience" {
  46529. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46530. import { Scene } from "babylonjs/scene";
  46531. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46532. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46533. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46534. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46536. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46537. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46538. /**
  46539. * Options for the default xr helper
  46540. */
  46541. export class WebXRDefaultExperienceOptions {
  46542. /**
  46543. * Enable or disable default UI to enter XR
  46544. */
  46545. disableDefaultUI?: boolean;
  46546. /**
  46547. * Should teleportation not initialize. defaults to false.
  46548. */
  46549. disableTeleportation?: boolean;
  46550. /**
  46551. * Floor meshes that will be used for teleport
  46552. */
  46553. floorMeshes?: Array<AbstractMesh>;
  46554. /**
  46555. * If set to true, the first frame will not be used to reset position
  46556. * The first frame is mainly used when copying transformation from the old camera
  46557. * Mainly used in AR
  46558. */
  46559. ignoreNativeCameraTransformation?: boolean;
  46560. /**
  46561. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46562. */
  46563. inputOptions?: IWebXRInputOptions;
  46564. /**
  46565. * optional configuration for the output canvas
  46566. */
  46567. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46568. /**
  46569. * optional UI options. This can be used among other to change session mode and reference space type
  46570. */
  46571. uiOptions?: WebXREnterExitUIOptions;
  46572. /**
  46573. * When loading teleportation and pointer select, use stable versions instead of latest.
  46574. */
  46575. useStablePlugins?: boolean;
  46576. }
  46577. /**
  46578. * Default experience which provides a similar setup to the previous webVRExperience
  46579. */
  46580. export class WebXRDefaultExperience {
  46581. /**
  46582. * Base experience
  46583. */
  46584. baseExperience: WebXRExperienceHelper;
  46585. /**
  46586. * Enables ui for entering/exiting xr
  46587. */
  46588. enterExitUI: WebXREnterExitUI;
  46589. /**
  46590. * Input experience extension
  46591. */
  46592. input: WebXRInput;
  46593. /**
  46594. * Enables laser pointer and selection
  46595. */
  46596. pointerSelection: WebXRControllerPointerSelection;
  46597. /**
  46598. * Default target xr should render to
  46599. */
  46600. renderTarget: WebXRRenderTarget;
  46601. /**
  46602. * Enables teleportation
  46603. */
  46604. teleportation: WebXRMotionControllerTeleportation;
  46605. private constructor();
  46606. /**
  46607. * Creates the default xr experience
  46608. * @param scene scene
  46609. * @param options options for basic configuration
  46610. * @returns resulting WebXRDefaultExperience
  46611. */
  46612. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46613. /**
  46614. * DIsposes of the experience helper
  46615. */
  46616. dispose(): void;
  46617. }
  46618. }
  46619. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46620. import { Observable } from "babylonjs/Misc/observable";
  46621. import { Nullable } from "babylonjs/types";
  46622. import { Camera } from "babylonjs/Cameras/camera";
  46623. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46624. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46625. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46626. import { Scene } from "babylonjs/scene";
  46627. import { Vector3 } from "babylonjs/Maths/math.vector";
  46628. import { Color3 } from "babylonjs/Maths/math.color";
  46629. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46631. import { Mesh } from "babylonjs/Meshes/mesh";
  46632. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46633. import { EasingFunction } from "babylonjs/Animations/easing";
  46634. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46635. import "babylonjs/Meshes/Builders/groundBuilder";
  46636. import "babylonjs/Meshes/Builders/torusBuilder";
  46637. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46638. import "babylonjs/Gamepads/gamepadSceneComponent";
  46639. import "babylonjs/Animations/animatable";
  46640. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46641. /**
  46642. * Options to modify the vr teleportation behavior.
  46643. */
  46644. export interface VRTeleportationOptions {
  46645. /**
  46646. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46647. */
  46648. floorMeshName?: string;
  46649. /**
  46650. * A list of meshes to be used as the teleportation floor. (default: empty)
  46651. */
  46652. floorMeshes?: Mesh[];
  46653. /**
  46654. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46655. */
  46656. teleportationMode?: number;
  46657. /**
  46658. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46659. */
  46660. teleportationTime?: number;
  46661. /**
  46662. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46663. */
  46664. teleportationSpeed?: number;
  46665. /**
  46666. * The easing function used in the animation or null for Linear. (default CircleEase)
  46667. */
  46668. easingFunction?: EasingFunction;
  46669. }
  46670. /**
  46671. * Options to modify the vr experience helper's behavior.
  46672. */
  46673. export interface VRExperienceHelperOptions extends WebVROptions {
  46674. /**
  46675. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46676. */
  46677. createDeviceOrientationCamera?: boolean;
  46678. /**
  46679. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46680. */
  46681. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46682. /**
  46683. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46684. */
  46685. laserToggle?: boolean;
  46686. /**
  46687. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46688. */
  46689. floorMeshes?: Mesh[];
  46690. /**
  46691. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46692. */
  46693. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46694. /**
  46695. * Defines if WebXR should be used instead of WebVR (if available)
  46696. */
  46697. useXR?: boolean;
  46698. }
  46699. /**
  46700. * Event containing information after VR has been entered
  46701. */
  46702. export class OnAfterEnteringVRObservableEvent {
  46703. /**
  46704. * If entering vr was successful
  46705. */
  46706. success: boolean;
  46707. }
  46708. /**
  46709. * Helps to quickly add VR support to an existing scene.
  46710. * See http://doc.babylonjs.com/how_to/webvr_helper
  46711. */
  46712. export class VRExperienceHelper {
  46713. /** Options to modify the vr experience helper's behavior. */
  46714. webVROptions: VRExperienceHelperOptions;
  46715. private _scene;
  46716. private _position;
  46717. private _btnVR;
  46718. private _btnVRDisplayed;
  46719. private _webVRsupported;
  46720. private _webVRready;
  46721. private _webVRrequesting;
  46722. private _webVRpresenting;
  46723. private _hasEnteredVR;
  46724. private _fullscreenVRpresenting;
  46725. private _inputElement;
  46726. private _webVRCamera;
  46727. private _vrDeviceOrientationCamera;
  46728. private _deviceOrientationCamera;
  46729. private _existingCamera;
  46730. private _onKeyDown;
  46731. private _onVrDisplayPresentChange;
  46732. private _onVRDisplayChanged;
  46733. private _onVRRequestPresentStart;
  46734. private _onVRRequestPresentComplete;
  46735. /**
  46736. * 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)
  46737. */
  46738. enableGazeEvenWhenNoPointerLock: boolean;
  46739. /**
  46740. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46741. */
  46742. exitVROnDoubleTap: boolean;
  46743. /**
  46744. * Observable raised right before entering VR.
  46745. */
  46746. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46747. /**
  46748. * Observable raised when entering VR has completed.
  46749. */
  46750. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46751. /**
  46752. * Observable raised when exiting VR.
  46753. */
  46754. onExitingVRObservable: Observable<VRExperienceHelper>;
  46755. /**
  46756. * Observable raised when controller mesh is loaded.
  46757. */
  46758. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46759. /** Return this.onEnteringVRObservable
  46760. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46761. */
  46762. get onEnteringVR(): Observable<VRExperienceHelper>;
  46763. /** Return this.onExitingVRObservable
  46764. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46765. */
  46766. get onExitingVR(): Observable<VRExperienceHelper>;
  46767. /** Return this.onControllerMeshLoadedObservable
  46768. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46769. */
  46770. get onControllerMeshLoaded(): Observable<WebVRController>;
  46771. private _rayLength;
  46772. private _useCustomVRButton;
  46773. private _teleportationRequested;
  46774. private _teleportActive;
  46775. private _floorMeshName;
  46776. private _floorMeshesCollection;
  46777. private _teleportationMode;
  46778. private _teleportationTime;
  46779. private _teleportationSpeed;
  46780. private _teleportationEasing;
  46781. private _rotationAllowed;
  46782. private _teleportBackwardsVector;
  46783. private _teleportationTarget;
  46784. private _isDefaultTeleportationTarget;
  46785. private _postProcessMove;
  46786. private _teleportationFillColor;
  46787. private _teleportationBorderColor;
  46788. private _rotationAngle;
  46789. private _haloCenter;
  46790. private _cameraGazer;
  46791. private _padSensibilityUp;
  46792. private _padSensibilityDown;
  46793. private _leftController;
  46794. private _rightController;
  46795. private _gazeColor;
  46796. private _laserColor;
  46797. private _pickedLaserColor;
  46798. private _pickedGazeColor;
  46799. /**
  46800. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46801. */
  46802. onNewMeshSelected: Observable<AbstractMesh>;
  46803. /**
  46804. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46805. * This observable will provide the mesh and the controller used to select the mesh
  46806. */
  46807. onMeshSelectedWithController: Observable<{
  46808. mesh: AbstractMesh;
  46809. controller: WebVRController;
  46810. }>;
  46811. /**
  46812. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46813. */
  46814. onNewMeshPicked: Observable<PickingInfo>;
  46815. private _circleEase;
  46816. /**
  46817. * Observable raised before camera teleportation
  46818. */
  46819. onBeforeCameraTeleport: Observable<Vector3>;
  46820. /**
  46821. * Observable raised after camera teleportation
  46822. */
  46823. onAfterCameraTeleport: Observable<Vector3>;
  46824. /**
  46825. * Observable raised when current selected mesh gets unselected
  46826. */
  46827. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46828. private _raySelectionPredicate;
  46829. /**
  46830. * To be optionaly changed by user to define custom ray selection
  46831. */
  46832. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46833. /**
  46834. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46835. */
  46836. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46837. /**
  46838. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46839. */
  46840. teleportationEnabled: boolean;
  46841. private _defaultHeight;
  46842. private _teleportationInitialized;
  46843. private _interactionsEnabled;
  46844. private _interactionsRequested;
  46845. private _displayGaze;
  46846. private _displayLaserPointer;
  46847. /**
  46848. * The mesh used to display where the user is going to teleport.
  46849. */
  46850. get teleportationTarget(): Mesh;
  46851. /**
  46852. * Sets the mesh to be used to display where the user is going to teleport.
  46853. */
  46854. set teleportationTarget(value: Mesh);
  46855. /**
  46856. * 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
  46857. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46858. * See http://doc.babylonjs.com/resources/baking_transformations
  46859. */
  46860. get gazeTrackerMesh(): Mesh;
  46861. set gazeTrackerMesh(value: Mesh);
  46862. /**
  46863. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46864. */
  46865. updateGazeTrackerScale: boolean;
  46866. /**
  46867. * If the gaze trackers color should be updated when selecting meshes
  46868. */
  46869. updateGazeTrackerColor: boolean;
  46870. /**
  46871. * If the controller laser color should be updated when selecting meshes
  46872. */
  46873. updateControllerLaserColor: boolean;
  46874. /**
  46875. * The gaze tracking mesh corresponding to the left controller
  46876. */
  46877. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46878. /**
  46879. * The gaze tracking mesh corresponding to the right controller
  46880. */
  46881. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46882. /**
  46883. * If the ray of the gaze should be displayed.
  46884. */
  46885. get displayGaze(): boolean;
  46886. /**
  46887. * Sets if the ray of the gaze should be displayed.
  46888. */
  46889. set displayGaze(value: boolean);
  46890. /**
  46891. * If the ray of the LaserPointer should be displayed.
  46892. */
  46893. get displayLaserPointer(): boolean;
  46894. /**
  46895. * Sets if the ray of the LaserPointer should be displayed.
  46896. */
  46897. set displayLaserPointer(value: boolean);
  46898. /**
  46899. * The deviceOrientationCamera used as the camera when not in VR.
  46900. */
  46901. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46902. /**
  46903. * Based on the current WebVR support, returns the current VR camera used.
  46904. */
  46905. get currentVRCamera(): Nullable<Camera>;
  46906. /**
  46907. * The webVRCamera which is used when in VR.
  46908. */
  46909. get webVRCamera(): WebVRFreeCamera;
  46910. /**
  46911. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46912. */
  46913. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46914. /**
  46915. * The html button that is used to trigger entering into VR.
  46916. */
  46917. get vrButton(): Nullable<HTMLButtonElement>;
  46918. private get _teleportationRequestInitiated();
  46919. /**
  46920. * Defines whether or not Pointer lock should be requested when switching to
  46921. * full screen.
  46922. */
  46923. requestPointerLockOnFullScreen: boolean;
  46924. /**
  46925. * If asking to force XR, this will be populated with the default xr experience
  46926. */
  46927. xr: WebXRDefaultExperience;
  46928. /**
  46929. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46930. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46931. */
  46932. xrTestDone: boolean;
  46933. /**
  46934. * Instantiates a VRExperienceHelper.
  46935. * Helps to quickly add VR support to an existing scene.
  46936. * @param scene The scene the VRExperienceHelper belongs to.
  46937. * @param webVROptions Options to modify the vr experience helper's behavior.
  46938. */
  46939. constructor(scene: Scene,
  46940. /** Options to modify the vr experience helper's behavior. */
  46941. webVROptions?: VRExperienceHelperOptions);
  46942. private completeVRInit;
  46943. private _onDefaultMeshLoaded;
  46944. private _onResize;
  46945. private _onFullscreenChange;
  46946. /**
  46947. * Gets a value indicating if we are currently in VR mode.
  46948. */
  46949. get isInVRMode(): boolean;
  46950. private onVrDisplayPresentChange;
  46951. private onVRDisplayChanged;
  46952. private moveButtonToBottomRight;
  46953. private displayVRButton;
  46954. private updateButtonVisibility;
  46955. private _cachedAngularSensibility;
  46956. /**
  46957. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46958. * Otherwise, will use the fullscreen API.
  46959. */
  46960. enterVR(): void;
  46961. /**
  46962. * Attempt to exit VR, or fullscreen.
  46963. */
  46964. exitVR(): void;
  46965. /**
  46966. * The position of the vr experience helper.
  46967. */
  46968. get position(): Vector3;
  46969. /**
  46970. * Sets the position of the vr experience helper.
  46971. */
  46972. set position(value: Vector3);
  46973. /**
  46974. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  46975. */
  46976. enableInteractions(): void;
  46977. private get _noControllerIsActive();
  46978. private beforeRender;
  46979. private _isTeleportationFloor;
  46980. /**
  46981. * Adds a floor mesh to be used for teleportation.
  46982. * @param floorMesh the mesh to be used for teleportation.
  46983. */
  46984. addFloorMesh(floorMesh: Mesh): void;
  46985. /**
  46986. * Removes a floor mesh from being used for teleportation.
  46987. * @param floorMesh the mesh to be removed.
  46988. */
  46989. removeFloorMesh(floorMesh: Mesh): void;
  46990. /**
  46991. * Enables interactions and teleportation using the VR controllers and gaze.
  46992. * @param vrTeleportationOptions options to modify teleportation behavior.
  46993. */
  46994. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  46995. private _onNewGamepadConnected;
  46996. private _tryEnableInteractionOnController;
  46997. private _onNewGamepadDisconnected;
  46998. private _enableInteractionOnController;
  46999. private _checkTeleportWithRay;
  47000. private _checkRotate;
  47001. private _checkTeleportBackwards;
  47002. private _enableTeleportationOnController;
  47003. private _createTeleportationCircles;
  47004. private _displayTeleportationTarget;
  47005. private _hideTeleportationTarget;
  47006. private _rotateCamera;
  47007. private _moveTeleportationSelectorTo;
  47008. private _workingVector;
  47009. private _workingQuaternion;
  47010. private _workingMatrix;
  47011. /**
  47012. * Time Constant Teleportation Mode
  47013. */
  47014. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47015. /**
  47016. * Speed Constant Teleportation Mode
  47017. */
  47018. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47019. /**
  47020. * Teleports the users feet to the desired location
  47021. * @param location The location where the user's feet should be placed
  47022. */
  47023. teleportCamera(location: Vector3): void;
  47024. private _convertNormalToDirectionOfRay;
  47025. private _castRayAndSelectObject;
  47026. private _notifySelectedMeshUnselected;
  47027. /**
  47028. * Permanently set new colors for the laser pointer
  47029. * @param color the new laser color
  47030. * @param pickedColor the new laser color when picked mesh detected
  47031. */
  47032. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47033. /**
  47034. * Set lighting enabled / disabled on the laser pointer of both controllers
  47035. * @param enabled should the lighting be enabled on the laser pointer
  47036. */
  47037. setLaserLightingState(enabled?: boolean): void;
  47038. /**
  47039. * Permanently set new colors for the gaze pointer
  47040. * @param color the new gaze color
  47041. * @param pickedColor the new gaze color when picked mesh detected
  47042. */
  47043. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47044. /**
  47045. * Sets the color of the laser ray from the vr controllers.
  47046. * @param color new color for the ray.
  47047. */
  47048. changeLaserColor(color: Color3): void;
  47049. /**
  47050. * Sets the color of the ray from the vr headsets gaze.
  47051. * @param color new color for the ray.
  47052. */
  47053. changeGazeColor(color: Color3): void;
  47054. /**
  47055. * Exits VR and disposes of the vr experience helper
  47056. */
  47057. dispose(): void;
  47058. /**
  47059. * Gets the name of the VRExperienceHelper class
  47060. * @returns "VRExperienceHelper"
  47061. */
  47062. getClassName(): string;
  47063. }
  47064. }
  47065. declare module "babylonjs/Cameras/VR/index" {
  47066. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47067. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47068. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47069. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47070. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47071. export * from "babylonjs/Cameras/VR/webVRCamera";
  47072. }
  47073. declare module "babylonjs/Cameras/RigModes/index" {
  47074. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47075. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47076. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47077. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47078. }
  47079. declare module "babylonjs/Cameras/index" {
  47080. export * from "babylonjs/Cameras/Inputs/index";
  47081. export * from "babylonjs/Cameras/cameraInputsManager";
  47082. export * from "babylonjs/Cameras/camera";
  47083. export * from "babylonjs/Cameras/targetCamera";
  47084. export * from "babylonjs/Cameras/freeCamera";
  47085. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47086. export * from "babylonjs/Cameras/touchCamera";
  47087. export * from "babylonjs/Cameras/arcRotateCamera";
  47088. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47089. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47090. export * from "babylonjs/Cameras/flyCamera";
  47091. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47092. export * from "babylonjs/Cameras/followCamera";
  47093. export * from "babylonjs/Cameras/followCameraInputsManager";
  47094. export * from "babylonjs/Cameras/gamepadCamera";
  47095. export * from "babylonjs/Cameras/Stereoscopic/index";
  47096. export * from "babylonjs/Cameras/universalCamera";
  47097. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47098. export * from "babylonjs/Cameras/VR/index";
  47099. export * from "babylonjs/Cameras/RigModes/index";
  47100. }
  47101. declare module "babylonjs/Collisions/index" {
  47102. export * from "babylonjs/Collisions/collider";
  47103. export * from "babylonjs/Collisions/collisionCoordinator";
  47104. export * from "babylonjs/Collisions/pickingInfo";
  47105. export * from "babylonjs/Collisions/intersectionInfo";
  47106. export * from "babylonjs/Collisions/meshCollisionData";
  47107. }
  47108. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47109. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47110. import { Vector3 } from "babylonjs/Maths/math.vector";
  47111. import { Ray } from "babylonjs/Culling/ray";
  47112. import { Plane } from "babylonjs/Maths/math.plane";
  47113. /**
  47114. * Contains an array of blocks representing the octree
  47115. */
  47116. export interface IOctreeContainer<T> {
  47117. /**
  47118. * Blocks within the octree
  47119. */
  47120. blocks: Array<OctreeBlock<T>>;
  47121. }
  47122. /**
  47123. * Class used to store a cell in an octree
  47124. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47125. */
  47126. export class OctreeBlock<T> {
  47127. /**
  47128. * Gets the content of the current block
  47129. */
  47130. entries: T[];
  47131. /**
  47132. * Gets the list of block children
  47133. */
  47134. blocks: Array<OctreeBlock<T>>;
  47135. private _depth;
  47136. private _maxDepth;
  47137. private _capacity;
  47138. private _minPoint;
  47139. private _maxPoint;
  47140. private _boundingVectors;
  47141. private _creationFunc;
  47142. /**
  47143. * Creates a new block
  47144. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47145. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47146. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47147. * @param depth defines the current depth of this block in the octree
  47148. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47149. * @param creationFunc defines a callback to call when an element is added to the block
  47150. */
  47151. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47152. /**
  47153. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47154. */
  47155. get capacity(): number;
  47156. /**
  47157. * Gets the minimum vector (in world space) of the block's bounding box
  47158. */
  47159. get minPoint(): Vector3;
  47160. /**
  47161. * Gets the maximum vector (in world space) of the block's bounding box
  47162. */
  47163. get maxPoint(): Vector3;
  47164. /**
  47165. * Add a new element to this block
  47166. * @param entry defines the element to add
  47167. */
  47168. addEntry(entry: T): void;
  47169. /**
  47170. * Remove an element from this block
  47171. * @param entry defines the element to remove
  47172. */
  47173. removeEntry(entry: T): void;
  47174. /**
  47175. * Add an array of elements to this block
  47176. * @param entries defines the array of elements to add
  47177. */
  47178. addEntries(entries: T[]): void;
  47179. /**
  47180. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47181. * @param frustumPlanes defines the frustum planes to test
  47182. * @param selection defines the array to store current content if selection is positive
  47183. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47184. */
  47185. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47186. /**
  47187. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47188. * @param sphereCenter defines the bounding sphere center
  47189. * @param sphereRadius defines the bounding sphere radius
  47190. * @param selection defines the array to store current content if selection is positive
  47191. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47192. */
  47193. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47194. /**
  47195. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47196. * @param ray defines the ray to test with
  47197. * @param selection defines the array to store current content if selection is positive
  47198. */
  47199. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47200. /**
  47201. * Subdivide the content into child blocks (this block will then be empty)
  47202. */
  47203. createInnerBlocks(): void;
  47204. /**
  47205. * @hidden
  47206. */
  47207. 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;
  47208. }
  47209. }
  47210. declare module "babylonjs/Culling/Octrees/octree" {
  47211. import { SmartArray } from "babylonjs/Misc/smartArray";
  47212. import { Vector3 } from "babylonjs/Maths/math.vector";
  47213. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47215. import { Ray } from "babylonjs/Culling/ray";
  47216. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47217. import { Plane } from "babylonjs/Maths/math.plane";
  47218. /**
  47219. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47220. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47221. */
  47222. export class Octree<T> {
  47223. /** 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.) */
  47224. maxDepth: number;
  47225. /**
  47226. * Blocks within the octree containing objects
  47227. */
  47228. blocks: Array<OctreeBlock<T>>;
  47229. /**
  47230. * Content stored in the octree
  47231. */
  47232. dynamicContent: T[];
  47233. private _maxBlockCapacity;
  47234. private _selectionContent;
  47235. private _creationFunc;
  47236. /**
  47237. * Creates a octree
  47238. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47239. * @param creationFunc function to be used to instatiate the octree
  47240. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47241. * @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.)
  47242. */
  47243. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47244. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  47245. maxDepth?: number);
  47246. /**
  47247. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47248. * @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);
  47249. * @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);
  47250. * @param entries meshes to be added to the octree blocks
  47251. */
  47252. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47253. /**
  47254. * Adds a mesh to the octree
  47255. * @param entry Mesh to add to the octree
  47256. */
  47257. addMesh(entry: T): void;
  47258. /**
  47259. * Remove an element from the octree
  47260. * @param entry defines the element to remove
  47261. */
  47262. removeMesh(entry: T): void;
  47263. /**
  47264. * Selects an array of meshes within the frustum
  47265. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47266. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47267. * @returns array of meshes within the frustum
  47268. */
  47269. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47270. /**
  47271. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47272. * @param sphereCenter defines the bounding sphere center
  47273. * @param sphereRadius defines the bounding sphere radius
  47274. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47275. * @returns an array of objects that intersect the sphere
  47276. */
  47277. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47278. /**
  47279. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47280. * @param ray defines the ray to test with
  47281. * @returns array of intersected objects
  47282. */
  47283. intersectsRay(ray: Ray): SmartArray<T>;
  47284. /**
  47285. * Adds a mesh into the octree block if it intersects the block
  47286. */
  47287. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47288. /**
  47289. * Adds a submesh into the octree block if it intersects the block
  47290. */
  47291. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47292. }
  47293. }
  47294. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47295. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47296. import { Scene } from "babylonjs/scene";
  47297. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47298. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47299. import { Ray } from "babylonjs/Culling/ray";
  47300. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47301. import { Collider } from "babylonjs/Collisions/collider";
  47302. module "babylonjs/scene" {
  47303. interface Scene {
  47304. /**
  47305. * @hidden
  47306. * Backing Filed
  47307. */
  47308. _selectionOctree: Octree<AbstractMesh>;
  47309. /**
  47310. * Gets the octree used to boost mesh selection (picking)
  47311. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47312. */
  47313. selectionOctree: Octree<AbstractMesh>;
  47314. /**
  47315. * Creates or updates the octree used to boost selection (picking)
  47316. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47317. * @param maxCapacity defines the maximum capacity per leaf
  47318. * @param maxDepth defines the maximum depth of the octree
  47319. * @returns an octree of AbstractMesh
  47320. */
  47321. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47322. }
  47323. }
  47324. module "babylonjs/Meshes/abstractMesh" {
  47325. interface AbstractMesh {
  47326. /**
  47327. * @hidden
  47328. * Backing Field
  47329. */
  47330. _submeshesOctree: Octree<SubMesh>;
  47331. /**
  47332. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47333. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47334. * @param maxCapacity defines the maximum size of each block (64 by default)
  47335. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47336. * @returns the new octree
  47337. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47338. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47339. */
  47340. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47341. }
  47342. }
  47343. /**
  47344. * Defines the octree scene component responsible to manage any octrees
  47345. * in a given scene.
  47346. */
  47347. export class OctreeSceneComponent {
  47348. /**
  47349. * The component name help to identify the component in the list of scene components.
  47350. */
  47351. readonly name: string;
  47352. /**
  47353. * The scene the component belongs to.
  47354. */
  47355. scene: Scene;
  47356. /**
  47357. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47358. */
  47359. readonly checksIsEnabled: boolean;
  47360. /**
  47361. * Creates a new instance of the component for the given scene
  47362. * @param scene Defines the scene to register the component in
  47363. */
  47364. constructor(scene: Scene);
  47365. /**
  47366. * Registers the component in a given scene
  47367. */
  47368. register(): void;
  47369. /**
  47370. * Return the list of active meshes
  47371. * @returns the list of active meshes
  47372. */
  47373. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47374. /**
  47375. * Return the list of active sub meshes
  47376. * @param mesh The mesh to get the candidates sub meshes from
  47377. * @returns the list of active sub meshes
  47378. */
  47379. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47380. private _tempRay;
  47381. /**
  47382. * Return the list of sub meshes intersecting with a given local ray
  47383. * @param mesh defines the mesh to find the submesh for
  47384. * @param localRay defines the ray in local space
  47385. * @returns the list of intersecting sub meshes
  47386. */
  47387. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47388. /**
  47389. * Return the list of sub meshes colliding with a collider
  47390. * @param mesh defines the mesh to find the submesh for
  47391. * @param collider defines the collider to evaluate the collision against
  47392. * @returns the list of colliding sub meshes
  47393. */
  47394. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47395. /**
  47396. * Rebuilds the elements related to this component in case of
  47397. * context lost for instance.
  47398. */
  47399. rebuild(): void;
  47400. /**
  47401. * Disposes the component and the associated ressources.
  47402. */
  47403. dispose(): void;
  47404. }
  47405. }
  47406. declare module "babylonjs/Culling/Octrees/index" {
  47407. export * from "babylonjs/Culling/Octrees/octree";
  47408. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47409. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47410. }
  47411. declare module "babylonjs/Culling/index" {
  47412. export * from "babylonjs/Culling/boundingBox";
  47413. export * from "babylonjs/Culling/boundingInfo";
  47414. export * from "babylonjs/Culling/boundingSphere";
  47415. export * from "babylonjs/Culling/Octrees/index";
  47416. export * from "babylonjs/Culling/ray";
  47417. }
  47418. declare module "babylonjs/Gizmos/gizmo" {
  47419. import { Nullable } from "babylonjs/types";
  47420. import { IDisposable } from "babylonjs/scene";
  47421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47422. import { Mesh } from "babylonjs/Meshes/mesh";
  47423. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47424. /**
  47425. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47426. */
  47427. export class Gizmo implements IDisposable {
  47428. /** The utility layer the gizmo will be added to */
  47429. gizmoLayer: UtilityLayerRenderer;
  47430. /**
  47431. * The root mesh of the gizmo
  47432. */
  47433. _rootMesh: Mesh;
  47434. private _attachedMesh;
  47435. /**
  47436. * Ratio for the scale of the gizmo (Default: 1)
  47437. */
  47438. scaleRatio: number;
  47439. /**
  47440. * If a custom mesh has been set (Default: false)
  47441. */
  47442. protected _customMeshSet: boolean;
  47443. /**
  47444. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47445. * * When set, interactions will be enabled
  47446. */
  47447. get attachedMesh(): Nullable<AbstractMesh>;
  47448. set attachedMesh(value: Nullable<AbstractMesh>);
  47449. /**
  47450. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47451. * @param mesh The mesh to replace the default mesh of the gizmo
  47452. */
  47453. setCustomMesh(mesh: Mesh): void;
  47454. /**
  47455. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47456. */
  47457. updateGizmoRotationToMatchAttachedMesh: boolean;
  47458. /**
  47459. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47460. */
  47461. updateGizmoPositionToMatchAttachedMesh: boolean;
  47462. /**
  47463. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47464. */
  47465. updateScale: boolean;
  47466. protected _interactionsEnabled: boolean;
  47467. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47468. private _beforeRenderObserver;
  47469. private _tempVector;
  47470. /**
  47471. * Creates a gizmo
  47472. * @param gizmoLayer The utility layer the gizmo will be added to
  47473. */
  47474. constructor(
  47475. /** The utility layer the gizmo will be added to */
  47476. gizmoLayer?: UtilityLayerRenderer);
  47477. /**
  47478. * Updates the gizmo to match the attached mesh's position/rotation
  47479. */
  47480. protected _update(): void;
  47481. /**
  47482. * Disposes of the gizmo
  47483. */
  47484. dispose(): void;
  47485. }
  47486. }
  47487. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47488. import { Observable } from "babylonjs/Misc/observable";
  47489. import { Nullable } from "babylonjs/types";
  47490. import { Vector3 } from "babylonjs/Maths/math.vector";
  47491. import { Color3 } from "babylonjs/Maths/math.color";
  47492. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47494. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47495. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47496. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47497. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47498. import { Scene } from "babylonjs/scene";
  47499. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47500. /**
  47501. * Single plane drag gizmo
  47502. */
  47503. export class PlaneDragGizmo extends Gizmo {
  47504. /**
  47505. * Drag behavior responsible for the gizmos dragging interactions
  47506. */
  47507. dragBehavior: PointerDragBehavior;
  47508. private _pointerObserver;
  47509. /**
  47510. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47511. */
  47512. snapDistance: number;
  47513. /**
  47514. * Event that fires each time the gizmo snaps to a new location.
  47515. * * snapDistance is the the change in distance
  47516. */
  47517. onSnapObservable: Observable<{
  47518. snapDistance: number;
  47519. }>;
  47520. private _plane;
  47521. private _coloredMaterial;
  47522. private _hoverMaterial;
  47523. private _isEnabled;
  47524. private _parent;
  47525. /** @hidden */
  47526. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47527. /** @hidden */
  47528. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47529. /**
  47530. * Creates a PlaneDragGizmo
  47531. * @param gizmoLayer The utility layer the gizmo will be added to
  47532. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47533. * @param color The color of the gizmo
  47534. */
  47535. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47536. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47537. /**
  47538. * If the gizmo is enabled
  47539. */
  47540. set isEnabled(value: boolean);
  47541. get isEnabled(): boolean;
  47542. /**
  47543. * Disposes of the gizmo
  47544. */
  47545. dispose(): void;
  47546. }
  47547. }
  47548. declare module "babylonjs/Gizmos/positionGizmo" {
  47549. import { Observable } from "babylonjs/Misc/observable";
  47550. import { Nullable } from "babylonjs/types";
  47551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47552. import { Mesh } from "babylonjs/Meshes/mesh";
  47553. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47554. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47555. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47556. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47557. /**
  47558. * Gizmo that enables dragging a mesh along 3 axis
  47559. */
  47560. export class PositionGizmo extends Gizmo {
  47561. /**
  47562. * Internal gizmo used for interactions on the x axis
  47563. */
  47564. xGizmo: AxisDragGizmo;
  47565. /**
  47566. * Internal gizmo used for interactions on the y axis
  47567. */
  47568. yGizmo: AxisDragGizmo;
  47569. /**
  47570. * Internal gizmo used for interactions on the z axis
  47571. */
  47572. zGizmo: AxisDragGizmo;
  47573. /**
  47574. * Internal gizmo used for interactions on the yz plane
  47575. */
  47576. xPlaneGizmo: PlaneDragGizmo;
  47577. /**
  47578. * Internal gizmo used for interactions on the xz plane
  47579. */
  47580. yPlaneGizmo: PlaneDragGizmo;
  47581. /**
  47582. * Internal gizmo used for interactions on the xy plane
  47583. */
  47584. zPlaneGizmo: PlaneDragGizmo;
  47585. /**
  47586. * private variables
  47587. */
  47588. private _meshAttached;
  47589. private _updateGizmoRotationToMatchAttachedMesh;
  47590. private _snapDistance;
  47591. private _scaleRatio;
  47592. /** Fires an event when any of it's sub gizmos are dragged */
  47593. onDragStartObservable: Observable<unknown>;
  47594. /** Fires an event when any of it's sub gizmos are released from dragging */
  47595. onDragEndObservable: Observable<unknown>;
  47596. /**
  47597. * If set to true, planar drag is enabled
  47598. */
  47599. private _planarGizmoEnabled;
  47600. get attachedMesh(): Nullable<AbstractMesh>;
  47601. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47602. /**
  47603. * Creates a PositionGizmo
  47604. * @param gizmoLayer The utility layer the gizmo will be added to
  47605. */
  47606. constructor(gizmoLayer?: UtilityLayerRenderer);
  47607. /**
  47608. * If the planar drag gizmo is enabled
  47609. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47610. */
  47611. set planarGizmoEnabled(value: boolean);
  47612. get planarGizmoEnabled(): boolean;
  47613. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47614. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47615. /**
  47616. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47617. */
  47618. set snapDistance(value: number);
  47619. get snapDistance(): number;
  47620. /**
  47621. * Ratio for the scale of the gizmo (Default: 1)
  47622. */
  47623. set scaleRatio(value: number);
  47624. get scaleRatio(): number;
  47625. /**
  47626. * Disposes of the gizmo
  47627. */
  47628. dispose(): void;
  47629. /**
  47630. * CustomMeshes are not supported by this gizmo
  47631. * @param mesh The mesh to replace the default mesh of the gizmo
  47632. */
  47633. setCustomMesh(mesh: Mesh): void;
  47634. }
  47635. }
  47636. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47637. import { Observable } from "babylonjs/Misc/observable";
  47638. import { Nullable } from "babylonjs/types";
  47639. import { Vector3 } from "babylonjs/Maths/math.vector";
  47640. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47642. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47643. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47644. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47645. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47646. import { Scene } from "babylonjs/scene";
  47647. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47648. import { Color3 } from "babylonjs/Maths/math.color";
  47649. /**
  47650. * Single axis drag gizmo
  47651. */
  47652. export class AxisDragGizmo extends Gizmo {
  47653. /**
  47654. * Drag behavior responsible for the gizmos dragging interactions
  47655. */
  47656. dragBehavior: PointerDragBehavior;
  47657. private _pointerObserver;
  47658. /**
  47659. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47660. */
  47661. snapDistance: number;
  47662. /**
  47663. * Event that fires each time the gizmo snaps to a new location.
  47664. * * snapDistance is the the change in distance
  47665. */
  47666. onSnapObservable: Observable<{
  47667. snapDistance: number;
  47668. }>;
  47669. private _isEnabled;
  47670. private _parent;
  47671. private _arrow;
  47672. private _coloredMaterial;
  47673. private _hoverMaterial;
  47674. /** @hidden */
  47675. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47676. /** @hidden */
  47677. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47678. /**
  47679. * Creates an AxisDragGizmo
  47680. * @param gizmoLayer The utility layer the gizmo will be added to
  47681. * @param dragAxis The axis which the gizmo will be able to drag on
  47682. * @param color The color of the gizmo
  47683. */
  47684. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47685. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47686. /**
  47687. * If the gizmo is enabled
  47688. */
  47689. set isEnabled(value: boolean);
  47690. get isEnabled(): boolean;
  47691. /**
  47692. * Disposes of the gizmo
  47693. */
  47694. dispose(): void;
  47695. }
  47696. }
  47697. declare module "babylonjs/Debug/axesViewer" {
  47698. import { Vector3 } from "babylonjs/Maths/math.vector";
  47699. import { Nullable } from "babylonjs/types";
  47700. import { Scene } from "babylonjs/scene";
  47701. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47702. /**
  47703. * The Axes viewer will show 3 axes in a specific point in space
  47704. */
  47705. export class AxesViewer {
  47706. private _xAxis;
  47707. private _yAxis;
  47708. private _zAxis;
  47709. private _scaleLinesFactor;
  47710. private _instanced;
  47711. /**
  47712. * Gets the hosting scene
  47713. */
  47714. scene: Scene;
  47715. /**
  47716. * Gets or sets a number used to scale line length
  47717. */
  47718. scaleLines: number;
  47719. /** Gets the node hierarchy used to render x-axis */
  47720. get xAxis(): TransformNode;
  47721. /** Gets the node hierarchy used to render y-axis */
  47722. get yAxis(): TransformNode;
  47723. /** Gets the node hierarchy used to render z-axis */
  47724. get zAxis(): TransformNode;
  47725. /**
  47726. * Creates a new AxesViewer
  47727. * @param scene defines the hosting scene
  47728. * @param scaleLines defines a number used to scale line length (1 by default)
  47729. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47730. * @param xAxis defines the node hierarchy used to render the x-axis
  47731. * @param yAxis defines the node hierarchy used to render the y-axis
  47732. * @param zAxis defines the node hierarchy used to render the z-axis
  47733. */
  47734. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47735. /**
  47736. * Force the viewer to update
  47737. * @param position defines the position of the viewer
  47738. * @param xaxis defines the x axis of the viewer
  47739. * @param yaxis defines the y axis of the viewer
  47740. * @param zaxis defines the z axis of the viewer
  47741. */
  47742. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47743. /**
  47744. * Creates an instance of this axes viewer.
  47745. * @returns a new axes viewer with instanced meshes
  47746. */
  47747. createInstance(): AxesViewer;
  47748. /** Releases resources */
  47749. dispose(): void;
  47750. private static _SetRenderingGroupId;
  47751. }
  47752. }
  47753. declare module "babylonjs/Debug/boneAxesViewer" {
  47754. import { Nullable } from "babylonjs/types";
  47755. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47756. import { Vector3 } from "babylonjs/Maths/math.vector";
  47757. import { Mesh } from "babylonjs/Meshes/mesh";
  47758. import { Bone } from "babylonjs/Bones/bone";
  47759. import { Scene } from "babylonjs/scene";
  47760. /**
  47761. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47762. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47763. */
  47764. export class BoneAxesViewer extends AxesViewer {
  47765. /**
  47766. * Gets or sets the target mesh where to display the axes viewer
  47767. */
  47768. mesh: Nullable<Mesh>;
  47769. /**
  47770. * Gets or sets the target bone where to display the axes viewer
  47771. */
  47772. bone: Nullable<Bone>;
  47773. /** Gets current position */
  47774. pos: Vector3;
  47775. /** Gets direction of X axis */
  47776. xaxis: Vector3;
  47777. /** Gets direction of Y axis */
  47778. yaxis: Vector3;
  47779. /** Gets direction of Z axis */
  47780. zaxis: Vector3;
  47781. /**
  47782. * Creates a new BoneAxesViewer
  47783. * @param scene defines the hosting scene
  47784. * @param bone defines the target bone
  47785. * @param mesh defines the target mesh
  47786. * @param scaleLines defines a scaling factor for line length (1 by default)
  47787. */
  47788. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47789. /**
  47790. * Force the viewer to update
  47791. */
  47792. update(): void;
  47793. /** Releases resources */
  47794. dispose(): void;
  47795. }
  47796. }
  47797. declare module "babylonjs/Debug/debugLayer" {
  47798. import { Scene } from "babylonjs/scene";
  47799. /**
  47800. * Interface used to define scene explorer extensibility option
  47801. */
  47802. export interface IExplorerExtensibilityOption {
  47803. /**
  47804. * Define the option label
  47805. */
  47806. label: string;
  47807. /**
  47808. * Defines the action to execute on click
  47809. */
  47810. action: (entity: any) => void;
  47811. }
  47812. /**
  47813. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47814. */
  47815. export interface IExplorerExtensibilityGroup {
  47816. /**
  47817. * Defines a predicate to test if a given type mut be extended
  47818. */
  47819. predicate: (entity: any) => boolean;
  47820. /**
  47821. * Gets the list of options added to a type
  47822. */
  47823. entries: IExplorerExtensibilityOption[];
  47824. }
  47825. /**
  47826. * Interface used to define the options to use to create the Inspector
  47827. */
  47828. export interface IInspectorOptions {
  47829. /**
  47830. * Display in overlay mode (default: false)
  47831. */
  47832. overlay?: boolean;
  47833. /**
  47834. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47835. */
  47836. globalRoot?: HTMLElement;
  47837. /**
  47838. * Display the Scene explorer
  47839. */
  47840. showExplorer?: boolean;
  47841. /**
  47842. * Display the property inspector
  47843. */
  47844. showInspector?: boolean;
  47845. /**
  47846. * Display in embed mode (both panes on the right)
  47847. */
  47848. embedMode?: boolean;
  47849. /**
  47850. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47851. */
  47852. handleResize?: boolean;
  47853. /**
  47854. * Allow the panes to popup (default: true)
  47855. */
  47856. enablePopup?: boolean;
  47857. /**
  47858. * Allow the panes to be closed by users (default: true)
  47859. */
  47860. enableClose?: boolean;
  47861. /**
  47862. * Optional list of extensibility entries
  47863. */
  47864. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47865. /**
  47866. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47867. */
  47868. inspectorURL?: string;
  47869. /**
  47870. * Optional initial tab (default to DebugLayerTab.Properties)
  47871. */
  47872. initialTab?: DebugLayerTab;
  47873. }
  47874. module "babylonjs/scene" {
  47875. interface Scene {
  47876. /**
  47877. * @hidden
  47878. * Backing field
  47879. */
  47880. _debugLayer: DebugLayer;
  47881. /**
  47882. * Gets the debug layer (aka Inspector) associated with the scene
  47883. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47884. */
  47885. debugLayer: DebugLayer;
  47886. }
  47887. }
  47888. /**
  47889. * Enum of inspector action tab
  47890. */
  47891. export enum DebugLayerTab {
  47892. /**
  47893. * Properties tag (default)
  47894. */
  47895. Properties = 0,
  47896. /**
  47897. * Debug tab
  47898. */
  47899. Debug = 1,
  47900. /**
  47901. * Statistics tab
  47902. */
  47903. Statistics = 2,
  47904. /**
  47905. * Tools tab
  47906. */
  47907. Tools = 3,
  47908. /**
  47909. * Settings tab
  47910. */
  47911. Settings = 4
  47912. }
  47913. /**
  47914. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47915. * what is happening in your scene
  47916. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47917. */
  47918. export class DebugLayer {
  47919. /**
  47920. * Define the url to get the inspector script from.
  47921. * By default it uses the babylonjs CDN.
  47922. * @ignoreNaming
  47923. */
  47924. static InspectorURL: string;
  47925. private _scene;
  47926. private BJSINSPECTOR;
  47927. private _onPropertyChangedObservable?;
  47928. /**
  47929. * Observable triggered when a property is changed through the inspector.
  47930. */
  47931. get onPropertyChangedObservable(): any;
  47932. /**
  47933. * Instantiates a new debug layer.
  47934. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47935. * what is happening in your scene
  47936. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47937. * @param scene Defines the scene to inspect
  47938. */
  47939. constructor(scene: Scene);
  47940. /** Creates the inspector window. */
  47941. private _createInspector;
  47942. /**
  47943. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47944. * @param entity defines the entity to select
  47945. * @param lineContainerTitle defines the specific block to highlight
  47946. */
  47947. select(entity: any, lineContainerTitle?: string): void;
  47948. /** Get the inspector from bundle or global */
  47949. private _getGlobalInspector;
  47950. /**
  47951. * Get if the inspector is visible or not.
  47952. * @returns true if visible otherwise, false
  47953. */
  47954. isVisible(): boolean;
  47955. /**
  47956. * Hide the inspector and close its window.
  47957. */
  47958. hide(): void;
  47959. /**
  47960. * Launch the debugLayer.
  47961. * @param config Define the configuration of the inspector
  47962. * @return a promise fulfilled when the debug layer is visible
  47963. */
  47964. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47965. }
  47966. }
  47967. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47968. import { Nullable } from "babylonjs/types";
  47969. import { Scene } from "babylonjs/scene";
  47970. import { Vector4 } from "babylonjs/Maths/math.vector";
  47971. import { Color4 } from "babylonjs/Maths/math.color";
  47972. import { Mesh } from "babylonjs/Meshes/mesh";
  47973. /**
  47974. * Class containing static functions to help procedurally build meshes
  47975. */
  47976. export class BoxBuilder {
  47977. /**
  47978. * Creates a box mesh
  47979. * * The parameter `size` sets the size (float) of each box side (default 1)
  47980. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47981. * * 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)
  47982. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47983. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47984. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47986. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47987. * @param name defines the name of the mesh
  47988. * @param options defines the options used to create the mesh
  47989. * @param scene defines the hosting scene
  47990. * @returns the box mesh
  47991. */
  47992. static CreateBox(name: string, options: {
  47993. size?: number;
  47994. width?: number;
  47995. height?: number;
  47996. depth?: number;
  47997. faceUV?: Vector4[];
  47998. faceColors?: Color4[];
  47999. sideOrientation?: number;
  48000. frontUVs?: Vector4;
  48001. backUVs?: Vector4;
  48002. wrap?: boolean;
  48003. topBaseAt?: number;
  48004. bottomBaseAt?: number;
  48005. updatable?: boolean;
  48006. }, scene?: Nullable<Scene>): Mesh;
  48007. }
  48008. }
  48009. declare module "babylonjs/Debug/physicsViewer" {
  48010. import { Nullable } from "babylonjs/types";
  48011. import { Scene } from "babylonjs/scene";
  48012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48013. import { Mesh } from "babylonjs/Meshes/mesh";
  48014. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48015. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48016. /**
  48017. * Used to show the physics impostor around the specific mesh
  48018. */
  48019. export class PhysicsViewer {
  48020. /** @hidden */
  48021. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48022. /** @hidden */
  48023. protected _meshes: Array<Nullable<AbstractMesh>>;
  48024. /** @hidden */
  48025. protected _scene: Nullable<Scene>;
  48026. /** @hidden */
  48027. protected _numMeshes: number;
  48028. /** @hidden */
  48029. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48030. private _renderFunction;
  48031. private _utilityLayer;
  48032. private _debugBoxMesh;
  48033. private _debugSphereMesh;
  48034. private _debugCylinderMesh;
  48035. private _debugMaterial;
  48036. private _debugMeshMeshes;
  48037. /**
  48038. * Creates a new PhysicsViewer
  48039. * @param scene defines the hosting scene
  48040. */
  48041. constructor(scene: Scene);
  48042. /** @hidden */
  48043. protected _updateDebugMeshes(): void;
  48044. /**
  48045. * Renders a specified physic impostor
  48046. * @param impostor defines the impostor to render
  48047. * @param targetMesh defines the mesh represented by the impostor
  48048. * @returns the new debug mesh used to render the impostor
  48049. */
  48050. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48051. /**
  48052. * Hides a specified physic impostor
  48053. * @param impostor defines the impostor to hide
  48054. */
  48055. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48056. private _getDebugMaterial;
  48057. private _getDebugBoxMesh;
  48058. private _getDebugSphereMesh;
  48059. private _getDebugCylinderMesh;
  48060. private _getDebugMeshMesh;
  48061. private _getDebugMesh;
  48062. /** Releases all resources */
  48063. dispose(): void;
  48064. }
  48065. }
  48066. declare module "babylonjs/Debug/rayHelper" {
  48067. import { Nullable } from "babylonjs/types";
  48068. import { Ray } from "babylonjs/Culling/ray";
  48069. import { Vector3 } from "babylonjs/Maths/math.vector";
  48070. import { Color3 } from "babylonjs/Maths/math.color";
  48071. import { Scene } from "babylonjs/scene";
  48072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48073. import "babylonjs/Meshes/Builders/linesBuilder";
  48074. /**
  48075. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48076. * in order to better appreciate the issue one might have.
  48077. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48078. */
  48079. export class RayHelper {
  48080. /**
  48081. * Defines the ray we are currently tryin to visualize.
  48082. */
  48083. ray: Nullable<Ray>;
  48084. private _renderPoints;
  48085. private _renderLine;
  48086. private _renderFunction;
  48087. private _scene;
  48088. private _updateToMeshFunction;
  48089. private _attachedToMesh;
  48090. private _meshSpaceDirection;
  48091. private _meshSpaceOrigin;
  48092. /**
  48093. * Helper function to create a colored helper in a scene in one line.
  48094. * @param ray Defines the ray we are currently tryin to visualize
  48095. * @param scene Defines the scene the ray is used in
  48096. * @param color Defines the color we want to see the ray in
  48097. * @returns The newly created ray helper.
  48098. */
  48099. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48100. /**
  48101. * Instantiate a new ray helper.
  48102. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48103. * in order to better appreciate the issue one might have.
  48104. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48105. * @param ray Defines the ray we are currently tryin to visualize
  48106. */
  48107. constructor(ray: Ray);
  48108. /**
  48109. * Shows the ray we are willing to debug.
  48110. * @param scene Defines the scene the ray needs to be rendered in
  48111. * @param color Defines the color the ray needs to be rendered in
  48112. */
  48113. show(scene: Scene, color?: Color3): void;
  48114. /**
  48115. * Hides the ray we are debugging.
  48116. */
  48117. hide(): void;
  48118. private _render;
  48119. /**
  48120. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48121. * @param mesh Defines the mesh we want the helper attached to
  48122. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48123. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48124. * @param length Defines the length of the ray
  48125. */
  48126. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48127. /**
  48128. * Detach the ray helper from the mesh it has previously been attached to.
  48129. */
  48130. detachFromMesh(): void;
  48131. private _updateToMesh;
  48132. /**
  48133. * Dispose the helper and release its associated resources.
  48134. */
  48135. dispose(): void;
  48136. }
  48137. }
  48138. declare module "babylonjs/Debug/skeletonViewer" {
  48139. import { Color3 } from "babylonjs/Maths/math.color";
  48140. import { Scene } from "babylonjs/scene";
  48141. import { Nullable } from "babylonjs/types";
  48142. import { Skeleton } from "babylonjs/Bones/skeleton";
  48143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48144. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48145. /**
  48146. * Class used to render a debug view of a given skeleton
  48147. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48148. */
  48149. export class SkeletonViewer {
  48150. /** defines the skeleton to render */
  48151. skeleton: Skeleton;
  48152. /** defines the mesh attached to the skeleton */
  48153. mesh: AbstractMesh;
  48154. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48155. autoUpdateBonesMatrices: boolean;
  48156. /** defines the rendering group id to use with the viewer */
  48157. renderingGroupId: number;
  48158. /** Gets or sets the color used to render the skeleton */
  48159. color: Color3;
  48160. private _scene;
  48161. private _debugLines;
  48162. private _debugMesh;
  48163. private _isEnabled;
  48164. private _renderFunction;
  48165. private _utilityLayer;
  48166. /**
  48167. * Returns the mesh used to render the bones
  48168. */
  48169. get debugMesh(): Nullable<LinesMesh>;
  48170. /**
  48171. * Creates a new SkeletonViewer
  48172. * @param skeleton defines the skeleton to render
  48173. * @param mesh defines the mesh attached to the skeleton
  48174. * @param scene defines the hosting scene
  48175. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48176. * @param renderingGroupId defines the rendering group id to use with the viewer
  48177. */
  48178. constructor(
  48179. /** defines the skeleton to render */
  48180. skeleton: Skeleton,
  48181. /** defines the mesh attached to the skeleton */
  48182. mesh: AbstractMesh, scene: Scene,
  48183. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48184. autoUpdateBonesMatrices?: boolean,
  48185. /** defines the rendering group id to use with the viewer */
  48186. renderingGroupId?: number);
  48187. /** Gets or sets a boolean indicating if the viewer is enabled */
  48188. set isEnabled(value: boolean);
  48189. get isEnabled(): boolean;
  48190. private _getBonePosition;
  48191. private _getLinesForBonesWithLength;
  48192. private _getLinesForBonesNoLength;
  48193. /** Update the viewer to sync with current skeleton state */
  48194. update(): void;
  48195. /** Release associated resources */
  48196. dispose(): void;
  48197. }
  48198. }
  48199. declare module "babylonjs/Debug/index" {
  48200. export * from "babylonjs/Debug/axesViewer";
  48201. export * from "babylonjs/Debug/boneAxesViewer";
  48202. export * from "babylonjs/Debug/debugLayer";
  48203. export * from "babylonjs/Debug/physicsViewer";
  48204. export * from "babylonjs/Debug/rayHelper";
  48205. export * from "babylonjs/Debug/skeletonViewer";
  48206. }
  48207. declare module "babylonjs/Engines/nullEngine" {
  48208. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48209. import { Engine } from "babylonjs/Engines/engine";
  48210. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48211. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48212. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48213. import { Effect } from "babylonjs/Materials/effect";
  48214. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48215. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48216. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48217. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48218. /**
  48219. * Options to create the null engine
  48220. */
  48221. export class NullEngineOptions {
  48222. /**
  48223. * Render width (Default: 512)
  48224. */
  48225. renderWidth: number;
  48226. /**
  48227. * Render height (Default: 256)
  48228. */
  48229. renderHeight: number;
  48230. /**
  48231. * Texture size (Default: 512)
  48232. */
  48233. textureSize: number;
  48234. /**
  48235. * If delta time between frames should be constant
  48236. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48237. */
  48238. deterministicLockstep: boolean;
  48239. /**
  48240. * Maximum about of steps between frames (Default: 4)
  48241. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48242. */
  48243. lockstepMaxSteps: number;
  48244. }
  48245. /**
  48246. * The null engine class provides support for headless version of babylon.js.
  48247. * This can be used in server side scenario or for testing purposes
  48248. */
  48249. export class NullEngine extends Engine {
  48250. private _options;
  48251. /**
  48252. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48253. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48254. * @returns true if engine is in deterministic lock step mode
  48255. */
  48256. isDeterministicLockStep(): boolean;
  48257. /**
  48258. * Gets the max steps when engine is running in deterministic lock step
  48259. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48260. * @returns the max steps
  48261. */
  48262. getLockstepMaxSteps(): number;
  48263. /**
  48264. * Gets the current hardware scaling level.
  48265. * By default the hardware scaling level is computed from the window device ratio.
  48266. * 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.
  48267. * @returns a number indicating the current hardware scaling level
  48268. */
  48269. getHardwareScalingLevel(): number;
  48270. constructor(options?: NullEngineOptions);
  48271. /**
  48272. * Creates a vertex buffer
  48273. * @param vertices the data for the vertex buffer
  48274. * @returns the new WebGL static buffer
  48275. */
  48276. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48277. /**
  48278. * Creates a new index buffer
  48279. * @param indices defines the content of the index buffer
  48280. * @param updatable defines if the index buffer must be updatable
  48281. * @returns a new webGL buffer
  48282. */
  48283. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48284. /**
  48285. * Clear the current render buffer or the current render target (if any is set up)
  48286. * @param color defines the color to use
  48287. * @param backBuffer defines if the back buffer must be cleared
  48288. * @param depth defines if the depth buffer must be cleared
  48289. * @param stencil defines if the stencil buffer must be cleared
  48290. */
  48291. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48292. /**
  48293. * Gets the current render width
  48294. * @param useScreen defines if screen size must be used (or the current render target if any)
  48295. * @returns a number defining the current render width
  48296. */
  48297. getRenderWidth(useScreen?: boolean): number;
  48298. /**
  48299. * Gets the current render height
  48300. * @param useScreen defines if screen size must be used (or the current render target if any)
  48301. * @returns a number defining the current render height
  48302. */
  48303. getRenderHeight(useScreen?: boolean): number;
  48304. /**
  48305. * Set the WebGL's viewport
  48306. * @param viewport defines the viewport element to be used
  48307. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48308. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48309. */
  48310. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48311. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48312. /**
  48313. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48314. * @param pipelineContext defines the pipeline context to use
  48315. * @param uniformsNames defines the list of uniform names
  48316. * @returns an array of webGL uniform locations
  48317. */
  48318. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48319. /**
  48320. * Gets the lsit of active attributes for a given webGL program
  48321. * @param pipelineContext defines the pipeline context to use
  48322. * @param attributesNames defines the list of attribute names to get
  48323. * @returns an array of indices indicating the offset of each attribute
  48324. */
  48325. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48326. /**
  48327. * Binds an effect to the webGL context
  48328. * @param effect defines the effect to bind
  48329. */
  48330. bindSamplers(effect: Effect): void;
  48331. /**
  48332. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48333. * @param effect defines the effect to activate
  48334. */
  48335. enableEffect(effect: Effect): void;
  48336. /**
  48337. * Set various states to the webGL context
  48338. * @param culling defines backface culling state
  48339. * @param zOffset defines the value to apply to zOffset (0 by default)
  48340. * @param force defines if states must be applied even if cache is up to date
  48341. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48342. */
  48343. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48344. /**
  48345. * Set the value of an uniform to an array of int32
  48346. * @param uniform defines the webGL uniform location where to store the value
  48347. * @param array defines the array of int32 to store
  48348. */
  48349. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48350. /**
  48351. * Set the value of an uniform to an array of int32 (stored as vec2)
  48352. * @param uniform defines the webGL uniform location where to store the value
  48353. * @param array defines the array of int32 to store
  48354. */
  48355. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48356. /**
  48357. * Set the value of an uniform to an array of int32 (stored as vec3)
  48358. * @param uniform defines the webGL uniform location where to store the value
  48359. * @param array defines the array of int32 to store
  48360. */
  48361. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48362. /**
  48363. * Set the value of an uniform to an array of int32 (stored as vec4)
  48364. * @param uniform defines the webGL uniform location where to store the value
  48365. * @param array defines the array of int32 to store
  48366. */
  48367. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48368. /**
  48369. * Set the value of an uniform to an array of float32
  48370. * @param uniform defines the webGL uniform location where to store the value
  48371. * @param array defines the array of float32 to store
  48372. */
  48373. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48374. /**
  48375. * Set the value of an uniform to an array of float32 (stored as vec2)
  48376. * @param uniform defines the webGL uniform location where to store the value
  48377. * @param array defines the array of float32 to store
  48378. */
  48379. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48380. /**
  48381. * Set the value of an uniform to an array of float32 (stored as vec3)
  48382. * @param uniform defines the webGL uniform location where to store the value
  48383. * @param array defines the array of float32 to store
  48384. */
  48385. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48386. /**
  48387. * Set the value of an uniform to an array of float32 (stored as vec4)
  48388. * @param uniform defines the webGL uniform location where to store the value
  48389. * @param array defines the array of float32 to store
  48390. */
  48391. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48392. /**
  48393. * Set the value of an uniform to an array of number
  48394. * @param uniform defines the webGL uniform location where to store the value
  48395. * @param array defines the array of number to store
  48396. */
  48397. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48398. /**
  48399. * Set the value of an uniform to an array of number (stored as vec2)
  48400. * @param uniform defines the webGL uniform location where to store the value
  48401. * @param array defines the array of number to store
  48402. */
  48403. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48404. /**
  48405. * Set the value of an uniform to an array of number (stored as vec3)
  48406. * @param uniform defines the webGL uniform location where to store the value
  48407. * @param array defines the array of number to store
  48408. */
  48409. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48410. /**
  48411. * Set the value of an uniform to an array of number (stored as vec4)
  48412. * @param uniform defines the webGL uniform location where to store the value
  48413. * @param array defines the array of number to store
  48414. */
  48415. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48416. /**
  48417. * Set the value of an uniform to an array of float32 (stored as matrices)
  48418. * @param uniform defines the webGL uniform location where to store the value
  48419. * @param matrices defines the array of float32 to store
  48420. */
  48421. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48422. /**
  48423. * Set the value of an uniform to a matrix (3x3)
  48424. * @param uniform defines the webGL uniform location where to store the value
  48425. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48426. */
  48427. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48428. /**
  48429. * Set the value of an uniform to a matrix (2x2)
  48430. * @param uniform defines the webGL uniform location where to store the value
  48431. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48432. */
  48433. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48434. /**
  48435. * Set the value of an uniform to a number (float)
  48436. * @param uniform defines the webGL uniform location where to store the value
  48437. * @param value defines the float number to store
  48438. */
  48439. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48440. /**
  48441. * Set the value of an uniform to a vec2
  48442. * @param uniform defines the webGL uniform location where to store the value
  48443. * @param x defines the 1st component of the value
  48444. * @param y defines the 2nd component of the value
  48445. */
  48446. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48447. /**
  48448. * Set the value of an uniform to a vec3
  48449. * @param uniform defines the webGL uniform location where to store the value
  48450. * @param x defines the 1st component of the value
  48451. * @param y defines the 2nd component of the value
  48452. * @param z defines the 3rd component of the value
  48453. */
  48454. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48455. /**
  48456. * Set the value of an uniform to a boolean
  48457. * @param uniform defines the webGL uniform location where to store the value
  48458. * @param bool defines the boolean to store
  48459. */
  48460. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48461. /**
  48462. * Set the value of an uniform to a vec4
  48463. * @param uniform defines the webGL uniform location where to store the value
  48464. * @param x defines the 1st component of the value
  48465. * @param y defines the 2nd component of the value
  48466. * @param z defines the 3rd component of the value
  48467. * @param w defines the 4th component of the value
  48468. */
  48469. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48470. /**
  48471. * Sets the current alpha mode
  48472. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48473. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48474. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48475. */
  48476. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48477. /**
  48478. * Bind webGl buffers directly to the webGL context
  48479. * @param vertexBuffers defines the vertex buffer to bind
  48480. * @param indexBuffer defines the index buffer to bind
  48481. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48482. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48483. * @param effect defines the effect associated with the vertex buffer
  48484. */
  48485. bindBuffers(vertexBuffers: {
  48486. [key: string]: VertexBuffer;
  48487. }, indexBuffer: DataBuffer, effect: Effect): void;
  48488. /**
  48489. * Force the entire cache to be cleared
  48490. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48491. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48492. */
  48493. wipeCaches(bruteForce?: boolean): void;
  48494. /**
  48495. * Send a draw order
  48496. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48497. * @param indexStart defines the starting index
  48498. * @param indexCount defines the number of index to draw
  48499. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48500. */
  48501. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48502. /**
  48503. * Draw a list of indexed primitives
  48504. * @param fillMode defines the primitive to use
  48505. * @param indexStart defines the starting index
  48506. * @param indexCount defines the number of index to draw
  48507. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48508. */
  48509. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48510. /**
  48511. * Draw a list of unindexed primitives
  48512. * @param fillMode defines the primitive to use
  48513. * @param verticesStart defines the index of first vertex to draw
  48514. * @param verticesCount defines the count of vertices to draw
  48515. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48516. */
  48517. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48518. /** @hidden */
  48519. _createTexture(): WebGLTexture;
  48520. /** @hidden */
  48521. _releaseTexture(texture: InternalTexture): void;
  48522. /**
  48523. * Usually called from Texture.ts.
  48524. * Passed information to create a WebGLTexture
  48525. * @param urlArg defines a value which contains one of the following:
  48526. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48527. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48528. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48529. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48530. * @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)
  48531. * @param scene needed for loading to the correct scene
  48532. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48533. * @param onLoad optional callback to be called upon successful completion
  48534. * @param onError optional callback to be called upon failure
  48535. * @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
  48536. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48537. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48538. * @param forcedExtension defines the extension to use to pick the right loader
  48539. * @param mimeType defines an optional mime type
  48540. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48541. */
  48542. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  48543. /**
  48544. * Creates a new render target texture
  48545. * @param size defines the size of the texture
  48546. * @param options defines the options used to create the texture
  48547. * @returns a new render target texture stored in an InternalTexture
  48548. */
  48549. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48550. /**
  48551. * Update the sampling mode of a given texture
  48552. * @param samplingMode defines the required sampling mode
  48553. * @param texture defines the texture to update
  48554. */
  48555. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48556. /**
  48557. * Binds the frame buffer to the specified texture.
  48558. * @param texture The texture to render to or null for the default canvas
  48559. * @param faceIndex The face of the texture to render to in case of cube texture
  48560. * @param requiredWidth The width of the target to render to
  48561. * @param requiredHeight The height of the target to render to
  48562. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48563. * @param lodLevel defines le lod level to bind to the frame buffer
  48564. */
  48565. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48566. /**
  48567. * Unbind the current render target texture from the webGL context
  48568. * @param texture defines the render target texture to unbind
  48569. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48570. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48571. */
  48572. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48573. /**
  48574. * Creates a dynamic vertex buffer
  48575. * @param vertices the data for the dynamic vertex buffer
  48576. * @returns the new WebGL dynamic buffer
  48577. */
  48578. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48579. /**
  48580. * Update the content of a dynamic texture
  48581. * @param texture defines the texture to update
  48582. * @param canvas defines the canvas containing the source
  48583. * @param invertY defines if data must be stored with Y axis inverted
  48584. * @param premulAlpha defines if alpha is stored as premultiplied
  48585. * @param format defines the format of the data
  48586. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48587. */
  48588. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48589. /**
  48590. * Gets a boolean indicating if all created effects are ready
  48591. * @returns true if all effects are ready
  48592. */
  48593. areAllEffectsReady(): boolean;
  48594. /**
  48595. * @hidden
  48596. * Get the current error code of the webGL context
  48597. * @returns the error code
  48598. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48599. */
  48600. getError(): number;
  48601. /** @hidden */
  48602. _getUnpackAlignement(): number;
  48603. /** @hidden */
  48604. _unpackFlipY(value: boolean): void;
  48605. /**
  48606. * Update a dynamic index buffer
  48607. * @param indexBuffer defines the target index buffer
  48608. * @param indices defines the data to update
  48609. * @param offset defines the offset in the target index buffer where update should start
  48610. */
  48611. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48612. /**
  48613. * Updates a dynamic vertex buffer.
  48614. * @param vertexBuffer the vertex buffer to update
  48615. * @param vertices the data used to update the vertex buffer
  48616. * @param byteOffset the byte offset of the data (optional)
  48617. * @param byteLength the byte length of the data (optional)
  48618. */
  48619. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48620. /** @hidden */
  48621. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48622. /** @hidden */
  48623. _bindTexture(channel: number, texture: InternalTexture): void;
  48624. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48625. /**
  48626. * 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
  48627. */
  48628. releaseEffects(): void;
  48629. displayLoadingUI(): void;
  48630. hideLoadingUI(): void;
  48631. /** @hidden */
  48632. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48633. /** @hidden */
  48634. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48635. /** @hidden */
  48636. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48637. /** @hidden */
  48638. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48639. }
  48640. }
  48641. declare module "babylonjs/Instrumentation/timeToken" {
  48642. import { Nullable } from "babylonjs/types";
  48643. /**
  48644. * @hidden
  48645. **/
  48646. export class _TimeToken {
  48647. _startTimeQuery: Nullable<WebGLQuery>;
  48648. _endTimeQuery: Nullable<WebGLQuery>;
  48649. _timeElapsedQuery: Nullable<WebGLQuery>;
  48650. _timeElapsedQueryEnded: boolean;
  48651. }
  48652. }
  48653. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48654. import { Nullable, int } from "babylonjs/types";
  48655. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48656. /** @hidden */
  48657. export class _OcclusionDataStorage {
  48658. /** @hidden */
  48659. occlusionInternalRetryCounter: number;
  48660. /** @hidden */
  48661. isOcclusionQueryInProgress: boolean;
  48662. /** @hidden */
  48663. isOccluded: boolean;
  48664. /** @hidden */
  48665. occlusionRetryCount: number;
  48666. /** @hidden */
  48667. occlusionType: number;
  48668. /** @hidden */
  48669. occlusionQueryAlgorithmType: number;
  48670. }
  48671. module "babylonjs/Engines/engine" {
  48672. interface Engine {
  48673. /**
  48674. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48675. * @return the new query
  48676. */
  48677. createQuery(): WebGLQuery;
  48678. /**
  48679. * Delete and release a webGL query
  48680. * @param query defines the query to delete
  48681. * @return the current engine
  48682. */
  48683. deleteQuery(query: WebGLQuery): Engine;
  48684. /**
  48685. * Check if a given query has resolved and got its value
  48686. * @param query defines the query to check
  48687. * @returns true if the query got its value
  48688. */
  48689. isQueryResultAvailable(query: WebGLQuery): boolean;
  48690. /**
  48691. * Gets the value of a given query
  48692. * @param query defines the query to check
  48693. * @returns the value of the query
  48694. */
  48695. getQueryResult(query: WebGLQuery): number;
  48696. /**
  48697. * Initiates an occlusion query
  48698. * @param algorithmType defines the algorithm to use
  48699. * @param query defines the query to use
  48700. * @returns the current engine
  48701. * @see http://doc.babylonjs.com/features/occlusionquery
  48702. */
  48703. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48704. /**
  48705. * Ends an occlusion query
  48706. * @see http://doc.babylonjs.com/features/occlusionquery
  48707. * @param algorithmType defines the algorithm to use
  48708. * @returns the current engine
  48709. */
  48710. endOcclusionQuery(algorithmType: number): Engine;
  48711. /**
  48712. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48713. * Please note that only one query can be issued at a time
  48714. * @returns a time token used to track the time span
  48715. */
  48716. startTimeQuery(): Nullable<_TimeToken>;
  48717. /**
  48718. * Ends a time query
  48719. * @param token defines the token used to measure the time span
  48720. * @returns the time spent (in ns)
  48721. */
  48722. endTimeQuery(token: _TimeToken): int;
  48723. /** @hidden */
  48724. _currentNonTimestampToken: Nullable<_TimeToken>;
  48725. /** @hidden */
  48726. _createTimeQuery(): WebGLQuery;
  48727. /** @hidden */
  48728. _deleteTimeQuery(query: WebGLQuery): void;
  48729. /** @hidden */
  48730. _getGlAlgorithmType(algorithmType: number): number;
  48731. /** @hidden */
  48732. _getTimeQueryResult(query: WebGLQuery): any;
  48733. /** @hidden */
  48734. _getTimeQueryAvailability(query: WebGLQuery): any;
  48735. }
  48736. }
  48737. module "babylonjs/Meshes/abstractMesh" {
  48738. interface AbstractMesh {
  48739. /**
  48740. * Backing filed
  48741. * @hidden
  48742. */
  48743. __occlusionDataStorage: _OcclusionDataStorage;
  48744. /**
  48745. * Access property
  48746. * @hidden
  48747. */
  48748. _occlusionDataStorage: _OcclusionDataStorage;
  48749. /**
  48750. * 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.
  48751. * The default value is -1 which means don't break the query and wait till the result
  48752. * @see http://doc.babylonjs.com/features/occlusionquery
  48753. */
  48754. occlusionRetryCount: number;
  48755. /**
  48756. * 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:
  48757. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48758. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48759. * * 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.
  48760. * @see http://doc.babylonjs.com/features/occlusionquery
  48761. */
  48762. occlusionType: number;
  48763. /**
  48764. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48765. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48766. * * 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.
  48767. * @see http://doc.babylonjs.com/features/occlusionquery
  48768. */
  48769. occlusionQueryAlgorithmType: number;
  48770. /**
  48771. * 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
  48772. * @see http://doc.babylonjs.com/features/occlusionquery
  48773. */
  48774. isOccluded: boolean;
  48775. /**
  48776. * Flag to check the progress status of the query
  48777. * @see http://doc.babylonjs.com/features/occlusionquery
  48778. */
  48779. isOcclusionQueryInProgress: boolean;
  48780. }
  48781. }
  48782. }
  48783. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48784. import { Nullable } from "babylonjs/types";
  48785. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48786. /** @hidden */
  48787. export var _forceTransformFeedbackToBundle: boolean;
  48788. module "babylonjs/Engines/engine" {
  48789. interface Engine {
  48790. /**
  48791. * Creates a webGL transform feedback object
  48792. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48793. * @returns the webGL transform feedback object
  48794. */
  48795. createTransformFeedback(): WebGLTransformFeedback;
  48796. /**
  48797. * Delete a webGL transform feedback object
  48798. * @param value defines the webGL transform feedback object to delete
  48799. */
  48800. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48801. /**
  48802. * Bind a webGL transform feedback object to the webgl context
  48803. * @param value defines the webGL transform feedback object to bind
  48804. */
  48805. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48806. /**
  48807. * Begins a transform feedback operation
  48808. * @param usePoints defines if points or triangles must be used
  48809. */
  48810. beginTransformFeedback(usePoints: boolean): void;
  48811. /**
  48812. * Ends a transform feedback operation
  48813. */
  48814. endTransformFeedback(): void;
  48815. /**
  48816. * Specify the varyings to use with transform feedback
  48817. * @param program defines the associated webGL program
  48818. * @param value defines the list of strings representing the varying names
  48819. */
  48820. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48821. /**
  48822. * Bind a webGL buffer for a transform feedback operation
  48823. * @param value defines the webGL buffer to bind
  48824. */
  48825. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48826. }
  48827. }
  48828. }
  48829. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48830. import { Scene } from "babylonjs/scene";
  48831. import { Engine } from "babylonjs/Engines/engine";
  48832. import { Texture } from "babylonjs/Materials/Textures/texture";
  48833. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48834. import "babylonjs/Engines/Extensions/engine.multiRender";
  48835. /**
  48836. * Creation options of the multi render target texture.
  48837. */
  48838. export interface IMultiRenderTargetOptions {
  48839. /**
  48840. * Define if the texture needs to create mip maps after render.
  48841. */
  48842. generateMipMaps?: boolean;
  48843. /**
  48844. * Define the types of all the draw buffers we want to create
  48845. */
  48846. types?: number[];
  48847. /**
  48848. * Define the sampling modes of all the draw buffers we want to create
  48849. */
  48850. samplingModes?: number[];
  48851. /**
  48852. * Define if a depth buffer is required
  48853. */
  48854. generateDepthBuffer?: boolean;
  48855. /**
  48856. * Define if a stencil buffer is required
  48857. */
  48858. generateStencilBuffer?: boolean;
  48859. /**
  48860. * Define if a depth texture is required instead of a depth buffer
  48861. */
  48862. generateDepthTexture?: boolean;
  48863. /**
  48864. * Define the number of desired draw buffers
  48865. */
  48866. textureCount?: number;
  48867. /**
  48868. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48869. */
  48870. doNotChangeAspectRatio?: boolean;
  48871. /**
  48872. * Define the default type of the buffers we are creating
  48873. */
  48874. defaultType?: number;
  48875. }
  48876. /**
  48877. * A multi render target, like a render target provides the ability to render to a texture.
  48878. * Unlike the render target, it can render to several draw buffers in one draw.
  48879. * This is specially interesting in deferred rendering or for any effects requiring more than
  48880. * just one color from a single pass.
  48881. */
  48882. export class MultiRenderTarget extends RenderTargetTexture {
  48883. private _internalTextures;
  48884. private _textures;
  48885. private _multiRenderTargetOptions;
  48886. /**
  48887. * Get if draw buffers are currently supported by the used hardware and browser.
  48888. */
  48889. get isSupported(): boolean;
  48890. /**
  48891. * Get the list of textures generated by the multi render target.
  48892. */
  48893. get textures(): Texture[];
  48894. /**
  48895. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48896. */
  48897. get depthTexture(): Texture;
  48898. /**
  48899. * Set the wrapping mode on U of all the textures we are rendering to.
  48900. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48901. */
  48902. set wrapU(wrap: number);
  48903. /**
  48904. * Set the wrapping mode on V of all the textures we are rendering to.
  48905. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48906. */
  48907. set wrapV(wrap: number);
  48908. /**
  48909. * Instantiate a new multi render target texture.
  48910. * A multi render target, like a render target provides the ability to render to a texture.
  48911. * Unlike the render target, it can render to several draw buffers in one draw.
  48912. * This is specially interesting in deferred rendering or for any effects requiring more than
  48913. * just one color from a single pass.
  48914. * @param name Define the name of the texture
  48915. * @param size Define the size of the buffers to render to
  48916. * @param count Define the number of target we are rendering into
  48917. * @param scene Define the scene the texture belongs to
  48918. * @param options Define the options used to create the multi render target
  48919. */
  48920. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48921. /** @hidden */
  48922. _rebuild(): void;
  48923. private _createInternalTextures;
  48924. private _createTextures;
  48925. /**
  48926. * Define the number of samples used if MSAA is enabled.
  48927. */
  48928. get samples(): number;
  48929. set samples(value: number);
  48930. /**
  48931. * Resize all the textures in the multi render target.
  48932. * Be carrefull as it will recreate all the data in the new texture.
  48933. * @param size Define the new size
  48934. */
  48935. resize(size: any): void;
  48936. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48937. /**
  48938. * Dispose the render targets and their associated resources
  48939. */
  48940. dispose(): void;
  48941. /**
  48942. * Release all the underlying texture used as draw buffers.
  48943. */
  48944. releaseInternalTextures(): void;
  48945. }
  48946. }
  48947. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48948. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48949. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48950. import { Nullable } from "babylonjs/types";
  48951. module "babylonjs/Engines/thinEngine" {
  48952. interface ThinEngine {
  48953. /**
  48954. * Unbind a list of render target textures from the webGL context
  48955. * This is used only when drawBuffer extension or webGL2 are active
  48956. * @param textures defines the render target textures to unbind
  48957. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48958. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48959. */
  48960. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48961. /**
  48962. * Create a multi render target texture
  48963. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48964. * @param size defines the size of the texture
  48965. * @param options defines the creation options
  48966. * @returns the cube texture as an InternalTexture
  48967. */
  48968. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48969. /**
  48970. * Update the sample count for a given multiple render target texture
  48971. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48972. * @param textures defines the textures to update
  48973. * @param samples defines the sample count to set
  48974. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48975. */
  48976. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48977. }
  48978. }
  48979. }
  48980. declare module "babylonjs/Engines/Extensions/engine.views" {
  48981. import { Camera } from "babylonjs/Cameras/camera";
  48982. import { Nullable } from "babylonjs/types";
  48983. /**
  48984. * Class used to define an additional view for the engine
  48985. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48986. */
  48987. export class EngineView {
  48988. /** Defines the canvas where to render the view */
  48989. target: HTMLCanvasElement;
  48990. /** Defines an optional camera used to render the view (will use active camera else) */
  48991. camera?: Camera;
  48992. }
  48993. module "babylonjs/Engines/engine" {
  48994. interface Engine {
  48995. /**
  48996. * Gets or sets the HTML element to use for attaching events
  48997. */
  48998. inputElement: Nullable<HTMLElement>;
  48999. /**
  49000. * Gets the current engine view
  49001. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49002. */
  49003. activeView: Nullable<EngineView>;
  49004. /** Gets or sets the list of views */
  49005. views: EngineView[];
  49006. /**
  49007. * Register a new child canvas
  49008. * @param canvas defines the canvas to register
  49009. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49010. * @returns the associated view
  49011. */
  49012. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49013. /**
  49014. * Remove a registered child canvas
  49015. * @param canvas defines the canvas to remove
  49016. * @returns the current engine
  49017. */
  49018. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49019. }
  49020. }
  49021. }
  49022. declare module "babylonjs/Engines/Extensions/index" {
  49023. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49024. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49025. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49026. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49027. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49028. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49029. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49030. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49031. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49032. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49033. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49034. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49035. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49036. export * from "babylonjs/Engines/Extensions/engine.views";
  49037. }
  49038. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49039. import { Nullable } from "babylonjs/types";
  49040. /**
  49041. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49042. */
  49043. export interface CubeMapInfo {
  49044. /**
  49045. * The pixel array for the front face.
  49046. * This is stored in format, left to right, up to down format.
  49047. */
  49048. front: Nullable<ArrayBufferView>;
  49049. /**
  49050. * The pixel array for the back face.
  49051. * This is stored in format, left to right, up to down format.
  49052. */
  49053. back: Nullable<ArrayBufferView>;
  49054. /**
  49055. * The pixel array for the left face.
  49056. * This is stored in format, left to right, up to down format.
  49057. */
  49058. left: Nullable<ArrayBufferView>;
  49059. /**
  49060. * The pixel array for the right face.
  49061. * This is stored in format, left to right, up to down format.
  49062. */
  49063. right: Nullable<ArrayBufferView>;
  49064. /**
  49065. * The pixel array for the up face.
  49066. * This is stored in format, left to right, up to down format.
  49067. */
  49068. up: Nullable<ArrayBufferView>;
  49069. /**
  49070. * The pixel array for the down face.
  49071. * This is stored in format, left to right, up to down format.
  49072. */
  49073. down: Nullable<ArrayBufferView>;
  49074. /**
  49075. * The size of the cubemap stored.
  49076. *
  49077. * Each faces will be size * size pixels.
  49078. */
  49079. size: number;
  49080. /**
  49081. * The format of the texture.
  49082. *
  49083. * RGBA, RGB.
  49084. */
  49085. format: number;
  49086. /**
  49087. * The type of the texture data.
  49088. *
  49089. * UNSIGNED_INT, FLOAT.
  49090. */
  49091. type: number;
  49092. /**
  49093. * Specifies whether the texture is in gamma space.
  49094. */
  49095. gammaSpace: boolean;
  49096. }
  49097. /**
  49098. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49099. */
  49100. export class PanoramaToCubeMapTools {
  49101. private static FACE_FRONT;
  49102. private static FACE_BACK;
  49103. private static FACE_RIGHT;
  49104. private static FACE_LEFT;
  49105. private static FACE_DOWN;
  49106. private static FACE_UP;
  49107. /**
  49108. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49109. *
  49110. * @param float32Array The source data.
  49111. * @param inputWidth The width of the input panorama.
  49112. * @param inputHeight The height of the input panorama.
  49113. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49114. * @return The cubemap data
  49115. */
  49116. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49117. private static CreateCubemapTexture;
  49118. private static CalcProjectionSpherical;
  49119. }
  49120. }
  49121. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49122. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49123. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49124. import { Nullable } from "babylonjs/types";
  49125. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49126. /**
  49127. * Helper class dealing with the extraction of spherical polynomial dataArray
  49128. * from a cube map.
  49129. */
  49130. export class CubeMapToSphericalPolynomialTools {
  49131. private static FileFaces;
  49132. /**
  49133. * Converts a texture to the according Spherical Polynomial data.
  49134. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49135. *
  49136. * @param texture The texture to extract the information from.
  49137. * @return The Spherical Polynomial data.
  49138. */
  49139. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49140. /**
  49141. * Converts a cubemap to the according Spherical Polynomial data.
  49142. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49143. *
  49144. * @param cubeInfo The Cube map to extract the information from.
  49145. * @return The Spherical Polynomial data.
  49146. */
  49147. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49148. }
  49149. }
  49150. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49151. import { Nullable } from "babylonjs/types";
  49152. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49153. module "babylonjs/Materials/Textures/baseTexture" {
  49154. interface BaseTexture {
  49155. /**
  49156. * Get the polynomial representation of the texture data.
  49157. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49158. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49159. */
  49160. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49161. }
  49162. }
  49163. }
  49164. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49165. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49166. /** @hidden */
  49167. export var rgbdEncodePixelShader: {
  49168. name: string;
  49169. shader: string;
  49170. };
  49171. }
  49172. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49173. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49174. /** @hidden */
  49175. export var rgbdDecodePixelShader: {
  49176. name: string;
  49177. shader: string;
  49178. };
  49179. }
  49180. declare module "babylonjs/Misc/environmentTextureTools" {
  49181. import { Nullable } from "babylonjs/types";
  49182. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49183. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49184. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49185. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49186. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49187. import "babylonjs/Shaders/rgbdEncode.fragment";
  49188. import "babylonjs/Shaders/rgbdDecode.fragment";
  49189. /**
  49190. * Raw texture data and descriptor sufficient for WebGL texture upload
  49191. */
  49192. export interface EnvironmentTextureInfo {
  49193. /**
  49194. * Version of the environment map
  49195. */
  49196. version: number;
  49197. /**
  49198. * Width of image
  49199. */
  49200. width: number;
  49201. /**
  49202. * Irradiance information stored in the file.
  49203. */
  49204. irradiance: any;
  49205. /**
  49206. * Specular information stored in the file.
  49207. */
  49208. specular: any;
  49209. }
  49210. /**
  49211. * Defines One Image in the file. It requires only the position in the file
  49212. * as well as the length.
  49213. */
  49214. interface BufferImageData {
  49215. /**
  49216. * Length of the image data.
  49217. */
  49218. length: number;
  49219. /**
  49220. * Position of the data from the null terminator delimiting the end of the JSON.
  49221. */
  49222. position: number;
  49223. }
  49224. /**
  49225. * Defines the specular data enclosed in the file.
  49226. * This corresponds to the version 1 of the data.
  49227. */
  49228. export interface EnvironmentTextureSpecularInfoV1 {
  49229. /**
  49230. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49231. */
  49232. specularDataPosition?: number;
  49233. /**
  49234. * This contains all the images data needed to reconstruct the cubemap.
  49235. */
  49236. mipmaps: Array<BufferImageData>;
  49237. /**
  49238. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49239. */
  49240. lodGenerationScale: number;
  49241. }
  49242. /**
  49243. * Sets of helpers addressing the serialization and deserialization of environment texture
  49244. * stored in a BabylonJS env file.
  49245. * Those files are usually stored as .env files.
  49246. */
  49247. export class EnvironmentTextureTools {
  49248. /**
  49249. * Magic number identifying the env file.
  49250. */
  49251. private static _MagicBytes;
  49252. /**
  49253. * Gets the environment info from an env file.
  49254. * @param data The array buffer containing the .env bytes.
  49255. * @returns the environment file info (the json header) if successfully parsed.
  49256. */
  49257. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49258. /**
  49259. * Creates an environment texture from a loaded cube texture.
  49260. * @param texture defines the cube texture to convert in env file
  49261. * @return a promise containing the environment data if succesfull.
  49262. */
  49263. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49264. /**
  49265. * Creates a JSON representation of the spherical data.
  49266. * @param texture defines the texture containing the polynomials
  49267. * @return the JSON representation of the spherical info
  49268. */
  49269. private static _CreateEnvTextureIrradiance;
  49270. /**
  49271. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49272. * @param data the image data
  49273. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49274. * @return the views described by info providing access to the underlying buffer
  49275. */
  49276. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49277. /**
  49278. * Uploads the texture info contained in the env file to the GPU.
  49279. * @param texture defines the internal texture to upload to
  49280. * @param data defines the data to load
  49281. * @param info defines the texture info retrieved through the GetEnvInfo method
  49282. * @returns a promise
  49283. */
  49284. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49285. private static _OnImageReadyAsync;
  49286. /**
  49287. * Uploads the levels of image data to the GPU.
  49288. * @param texture defines the internal texture to upload to
  49289. * @param imageData defines the array buffer views of image data [mipmap][face]
  49290. * @returns a promise
  49291. */
  49292. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49293. /**
  49294. * Uploads spherical polynomials information to the texture.
  49295. * @param texture defines the texture we are trying to upload the information to
  49296. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49297. */
  49298. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49299. /** @hidden */
  49300. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49301. }
  49302. }
  49303. declare module "babylonjs/Maths/math.vertexFormat" {
  49304. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49305. /**
  49306. * Contains position and normal vectors for a vertex
  49307. */
  49308. export class PositionNormalVertex {
  49309. /** the position of the vertex (defaut: 0,0,0) */
  49310. position: Vector3;
  49311. /** the normal of the vertex (defaut: 0,1,0) */
  49312. normal: Vector3;
  49313. /**
  49314. * Creates a PositionNormalVertex
  49315. * @param position the position of the vertex (defaut: 0,0,0)
  49316. * @param normal the normal of the vertex (defaut: 0,1,0)
  49317. */
  49318. constructor(
  49319. /** the position of the vertex (defaut: 0,0,0) */
  49320. position?: Vector3,
  49321. /** the normal of the vertex (defaut: 0,1,0) */
  49322. normal?: Vector3);
  49323. /**
  49324. * Clones the PositionNormalVertex
  49325. * @returns the cloned PositionNormalVertex
  49326. */
  49327. clone(): PositionNormalVertex;
  49328. }
  49329. /**
  49330. * Contains position, normal and uv vectors for a vertex
  49331. */
  49332. export class PositionNormalTextureVertex {
  49333. /** the position of the vertex (defaut: 0,0,0) */
  49334. position: Vector3;
  49335. /** the normal of the vertex (defaut: 0,1,0) */
  49336. normal: Vector3;
  49337. /** the uv of the vertex (default: 0,0) */
  49338. uv: Vector2;
  49339. /**
  49340. * Creates a PositionNormalTextureVertex
  49341. * @param position the position of the vertex (defaut: 0,0,0)
  49342. * @param normal the normal of the vertex (defaut: 0,1,0)
  49343. * @param uv the uv of the vertex (default: 0,0)
  49344. */
  49345. constructor(
  49346. /** the position of the vertex (defaut: 0,0,0) */
  49347. position?: Vector3,
  49348. /** the normal of the vertex (defaut: 0,1,0) */
  49349. normal?: Vector3,
  49350. /** the uv of the vertex (default: 0,0) */
  49351. uv?: Vector2);
  49352. /**
  49353. * Clones the PositionNormalTextureVertex
  49354. * @returns the cloned PositionNormalTextureVertex
  49355. */
  49356. clone(): PositionNormalTextureVertex;
  49357. }
  49358. }
  49359. declare module "babylonjs/Maths/math" {
  49360. export * from "babylonjs/Maths/math.axis";
  49361. export * from "babylonjs/Maths/math.color";
  49362. export * from "babylonjs/Maths/math.constants";
  49363. export * from "babylonjs/Maths/math.frustum";
  49364. export * from "babylonjs/Maths/math.path";
  49365. export * from "babylonjs/Maths/math.plane";
  49366. export * from "babylonjs/Maths/math.size";
  49367. export * from "babylonjs/Maths/math.vector";
  49368. export * from "babylonjs/Maths/math.vertexFormat";
  49369. export * from "babylonjs/Maths/math.viewport";
  49370. }
  49371. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49372. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49373. /** @hidden */
  49374. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49375. private _genericAttributeLocation;
  49376. private _varyingLocationCount;
  49377. private _varyingLocationMap;
  49378. private _replacements;
  49379. private _textureCount;
  49380. private _uniforms;
  49381. lineProcessor(line: string): string;
  49382. attributeProcessor(attribute: string): string;
  49383. varyingProcessor(varying: string, isFragment: boolean): string;
  49384. uniformProcessor(uniform: string): string;
  49385. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49386. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49387. }
  49388. }
  49389. declare module "babylonjs/Engines/nativeEngine" {
  49390. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49391. import { Engine } from "babylonjs/Engines/engine";
  49392. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49393. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49394. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49395. import { Effect } from "babylonjs/Materials/effect";
  49396. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49397. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49398. import { IColor4Like } from "babylonjs/Maths/math.like";
  49399. import { Scene } from "babylonjs/scene";
  49400. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49401. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49402. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  49403. /**
  49404. * Container for accessors for natively-stored mesh data buffers.
  49405. */
  49406. class NativeDataBuffer extends DataBuffer {
  49407. /**
  49408. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49409. */
  49410. nativeIndexBuffer?: any;
  49411. /**
  49412. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49413. */
  49414. nativeVertexBuffer?: any;
  49415. }
  49416. /** @hidden */
  49417. class NativeTexture extends InternalTexture {
  49418. getInternalTexture(): InternalTexture;
  49419. getViewCount(): number;
  49420. }
  49421. /** @hidden */
  49422. export class NativeEngine extends Engine {
  49423. private readonly _native;
  49424. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49425. private readonly INVALID_HANDLE;
  49426. getHardwareScalingLevel(): number;
  49427. constructor();
  49428. /**
  49429. * Can be used to override the current requestAnimationFrame requester.
  49430. * @hidden
  49431. */
  49432. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49433. /**
  49434. * Override default engine behavior.
  49435. * @param color
  49436. * @param backBuffer
  49437. * @param depth
  49438. * @param stencil
  49439. */
  49440. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49441. /**
  49442. * Gets host document
  49443. * @returns the host document object
  49444. */
  49445. getHostDocument(): Nullable<Document>;
  49446. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49447. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49448. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49449. recordVertexArrayObject(vertexBuffers: {
  49450. [key: string]: VertexBuffer;
  49451. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49452. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49453. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49454. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49455. /**
  49456. * Draw a list of indexed primitives
  49457. * @param fillMode defines the primitive to use
  49458. * @param indexStart defines the starting index
  49459. * @param indexCount defines the number of index to draw
  49460. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49461. */
  49462. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49463. /**
  49464. * Draw a list of unindexed primitives
  49465. * @param fillMode defines the primitive to use
  49466. * @param verticesStart defines the index of first vertex to draw
  49467. * @param verticesCount defines the count of vertices to draw
  49468. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49469. */
  49470. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49471. createPipelineContext(): IPipelineContext;
  49472. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49473. /** @hidden */
  49474. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49475. /** @hidden */
  49476. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49477. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49478. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49479. protected _setProgram(program: WebGLProgram): void;
  49480. _releaseEffect(effect: Effect): void;
  49481. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49482. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49483. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49484. bindSamplers(effect: Effect): void;
  49485. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49486. getRenderWidth(useScreen?: boolean): number;
  49487. getRenderHeight(useScreen?: boolean): number;
  49488. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49489. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49490. /**
  49491. * Set the z offset to apply to current rendering
  49492. * @param value defines the offset to apply
  49493. */
  49494. setZOffset(value: number): void;
  49495. /**
  49496. * Gets the current value of the zOffset
  49497. * @returns the current zOffset state
  49498. */
  49499. getZOffset(): number;
  49500. /**
  49501. * Enable or disable depth buffering
  49502. * @param enable defines the state to set
  49503. */
  49504. setDepthBuffer(enable: boolean): void;
  49505. /**
  49506. * Gets a boolean indicating if depth writing is enabled
  49507. * @returns the current depth writing state
  49508. */
  49509. getDepthWrite(): boolean;
  49510. /**
  49511. * Enable or disable depth writing
  49512. * @param enable defines the state to set
  49513. */
  49514. setDepthWrite(enable: boolean): void;
  49515. /**
  49516. * Enable or disable color writing
  49517. * @param enable defines the state to set
  49518. */
  49519. setColorWrite(enable: boolean): void;
  49520. /**
  49521. * Gets a boolean indicating if color writing is enabled
  49522. * @returns the current color writing state
  49523. */
  49524. getColorWrite(): boolean;
  49525. /**
  49526. * Sets alpha constants used by some alpha blending modes
  49527. * @param r defines the red component
  49528. * @param g defines the green component
  49529. * @param b defines the blue component
  49530. * @param a defines the alpha component
  49531. */
  49532. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49533. /**
  49534. * Sets the current alpha mode
  49535. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49536. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49537. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49538. */
  49539. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49540. /**
  49541. * Gets the current alpha mode
  49542. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49543. * @returns the current alpha mode
  49544. */
  49545. getAlphaMode(): number;
  49546. setInt(uniform: WebGLUniformLocation, int: number): void;
  49547. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49548. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49549. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49550. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49551. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49552. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49553. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49554. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49555. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49556. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49557. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49558. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49559. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49560. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49561. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49562. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49563. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49564. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49565. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49566. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49567. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49568. wipeCaches(bruteForce?: boolean): void;
  49569. _createTexture(): WebGLTexture;
  49570. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49571. /**
  49572. * Usually called from Texture.ts.
  49573. * Passed information to create a WebGLTexture
  49574. * @param urlArg defines a value which contains one of the following:
  49575. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49576. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49577. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49578. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49579. * @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)
  49580. * @param scene needed for loading to the correct scene
  49581. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49582. * @param onLoad optional callback to be called upon successful completion
  49583. * @param onError optional callback to be called upon failure
  49584. * @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
  49585. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49586. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49587. * @param forcedExtension defines the extension to use to pick the right loader
  49588. * @param mimeType defines an optional mime type
  49589. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49590. */
  49591. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  49592. /**
  49593. * Creates a cube texture
  49594. * @param rootUrl defines the url where the files to load is located
  49595. * @param scene defines the current scene
  49596. * @param files defines the list of files to load (1 per face)
  49597. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49598. * @param onLoad defines an optional callback raised when the texture is loaded
  49599. * @param onError defines an optional callback raised if there is an issue to load the texture
  49600. * @param format defines the format of the data
  49601. * @param forcedExtension defines the extension to use to pick the right loader
  49602. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49603. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49604. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49605. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49606. * @returns the cube texture as an InternalTexture
  49607. */
  49608. 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;
  49609. private _getSamplingFilter;
  49610. private static _GetNativeTextureFormat;
  49611. createRenderTargetTexture(size: number | {
  49612. width: number;
  49613. height: number;
  49614. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49615. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49616. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49617. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49618. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49619. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49620. /**
  49621. * Updates a dynamic vertex buffer.
  49622. * @param vertexBuffer the vertex buffer to update
  49623. * @param data the data used to update the vertex buffer
  49624. * @param byteOffset the byte offset of the data (optional)
  49625. * @param byteLength the byte length of the data (optional)
  49626. */
  49627. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49628. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49629. private _updateAnisotropicLevel;
  49630. private _getAddressMode;
  49631. /** @hidden */
  49632. _bindTexture(channel: number, texture: InternalTexture): void;
  49633. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49634. releaseEffects(): void;
  49635. /** @hidden */
  49636. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49637. /** @hidden */
  49638. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49639. /** @hidden */
  49640. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49641. /** @hidden */
  49642. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49643. }
  49644. }
  49645. declare module "babylonjs/Engines/index" {
  49646. export * from "babylonjs/Engines/constants";
  49647. export * from "babylonjs/Engines/engineCapabilities";
  49648. export * from "babylonjs/Engines/instancingAttributeInfo";
  49649. export * from "babylonjs/Engines/thinEngine";
  49650. export * from "babylonjs/Engines/engine";
  49651. export * from "babylonjs/Engines/engineStore";
  49652. export * from "babylonjs/Engines/nullEngine";
  49653. export * from "babylonjs/Engines/Extensions/index";
  49654. export * from "babylonjs/Engines/IPipelineContext";
  49655. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49656. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49657. export * from "babylonjs/Engines/nativeEngine";
  49658. }
  49659. declare module "babylonjs/Events/clipboardEvents" {
  49660. /**
  49661. * Gather the list of clipboard event types as constants.
  49662. */
  49663. export class ClipboardEventTypes {
  49664. /**
  49665. * The clipboard event is fired when a copy command is active (pressed).
  49666. */
  49667. static readonly COPY: number;
  49668. /**
  49669. * The clipboard event is fired when a cut command is active (pressed).
  49670. */
  49671. static readonly CUT: number;
  49672. /**
  49673. * The clipboard event is fired when a paste command is active (pressed).
  49674. */
  49675. static readonly PASTE: number;
  49676. }
  49677. /**
  49678. * This class is used to store clipboard related info for the onClipboardObservable event.
  49679. */
  49680. export class ClipboardInfo {
  49681. /**
  49682. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49683. */
  49684. type: number;
  49685. /**
  49686. * Defines the related dom event
  49687. */
  49688. event: ClipboardEvent;
  49689. /**
  49690. *Creates an instance of ClipboardInfo.
  49691. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49692. * @param event Defines the related dom event
  49693. */
  49694. constructor(
  49695. /**
  49696. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49697. */
  49698. type: number,
  49699. /**
  49700. * Defines the related dom event
  49701. */
  49702. event: ClipboardEvent);
  49703. /**
  49704. * Get the clipboard event's type from the keycode.
  49705. * @param keyCode Defines the keyCode for the current keyboard event.
  49706. * @return {number}
  49707. */
  49708. static GetTypeFromCharacter(keyCode: number): number;
  49709. }
  49710. }
  49711. declare module "babylonjs/Events/index" {
  49712. export * from "babylonjs/Events/keyboardEvents";
  49713. export * from "babylonjs/Events/pointerEvents";
  49714. export * from "babylonjs/Events/clipboardEvents";
  49715. }
  49716. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49717. import { Scene } from "babylonjs/scene";
  49718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49719. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49720. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49721. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49722. /**
  49723. * Google Daydream controller
  49724. */
  49725. export class DaydreamController extends WebVRController {
  49726. /**
  49727. * Base Url for the controller model.
  49728. */
  49729. static MODEL_BASE_URL: string;
  49730. /**
  49731. * File name for the controller model.
  49732. */
  49733. static MODEL_FILENAME: string;
  49734. /**
  49735. * Gamepad Id prefix used to identify Daydream Controller.
  49736. */
  49737. static readonly GAMEPAD_ID_PREFIX: string;
  49738. /**
  49739. * Creates a new DaydreamController from a gamepad
  49740. * @param vrGamepad the gamepad that the controller should be created from
  49741. */
  49742. constructor(vrGamepad: any);
  49743. /**
  49744. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49745. * @param scene scene in which to add meshes
  49746. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49747. */
  49748. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49749. /**
  49750. * Called once for each button that changed state since the last frame
  49751. * @param buttonIdx Which button index changed
  49752. * @param state New state of the button
  49753. * @param changes Which properties on the state changed since last frame
  49754. */
  49755. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49756. }
  49757. }
  49758. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49759. import { Scene } from "babylonjs/scene";
  49760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49761. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49762. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49763. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49764. /**
  49765. * Gear VR Controller
  49766. */
  49767. export class GearVRController extends WebVRController {
  49768. /**
  49769. * Base Url for the controller model.
  49770. */
  49771. static MODEL_BASE_URL: string;
  49772. /**
  49773. * File name for the controller model.
  49774. */
  49775. static MODEL_FILENAME: string;
  49776. /**
  49777. * Gamepad Id prefix used to identify this controller.
  49778. */
  49779. static readonly GAMEPAD_ID_PREFIX: string;
  49780. private readonly _buttonIndexToObservableNameMap;
  49781. /**
  49782. * Creates a new GearVRController from a gamepad
  49783. * @param vrGamepad the gamepad that the controller should be created from
  49784. */
  49785. constructor(vrGamepad: any);
  49786. /**
  49787. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49788. * @param scene scene in which to add meshes
  49789. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49790. */
  49791. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49792. /**
  49793. * Called once for each button that changed state since the last frame
  49794. * @param buttonIdx Which button index changed
  49795. * @param state New state of the button
  49796. * @param changes Which properties on the state changed since last frame
  49797. */
  49798. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49799. }
  49800. }
  49801. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49802. import { Scene } from "babylonjs/scene";
  49803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49804. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49805. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49806. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49807. /**
  49808. * Generic Controller
  49809. */
  49810. export class GenericController extends WebVRController {
  49811. /**
  49812. * Base Url for the controller model.
  49813. */
  49814. static readonly MODEL_BASE_URL: string;
  49815. /**
  49816. * File name for the controller model.
  49817. */
  49818. static readonly MODEL_FILENAME: string;
  49819. /**
  49820. * Creates a new GenericController from a gamepad
  49821. * @param vrGamepad the gamepad that the controller should be created from
  49822. */
  49823. constructor(vrGamepad: any);
  49824. /**
  49825. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49826. * @param scene scene in which to add meshes
  49827. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49828. */
  49829. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49830. /**
  49831. * Called once for each button that changed state since the last frame
  49832. * @param buttonIdx Which button index changed
  49833. * @param state New state of the button
  49834. * @param changes Which properties on the state changed since last frame
  49835. */
  49836. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49837. }
  49838. }
  49839. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49840. import { Observable } from "babylonjs/Misc/observable";
  49841. import { Scene } from "babylonjs/scene";
  49842. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49843. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49844. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49845. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49846. /**
  49847. * Oculus Touch Controller
  49848. */
  49849. export class OculusTouchController extends WebVRController {
  49850. /**
  49851. * Base Url for the controller model.
  49852. */
  49853. static MODEL_BASE_URL: string;
  49854. /**
  49855. * File name for the left controller model.
  49856. */
  49857. static MODEL_LEFT_FILENAME: string;
  49858. /**
  49859. * File name for the right controller model.
  49860. */
  49861. static MODEL_RIGHT_FILENAME: string;
  49862. /**
  49863. * Base Url for the Quest controller model.
  49864. */
  49865. static QUEST_MODEL_BASE_URL: string;
  49866. /**
  49867. * @hidden
  49868. * If the controllers are running on a device that needs the updated Quest controller models
  49869. */
  49870. static _IsQuest: boolean;
  49871. /**
  49872. * Fired when the secondary trigger on this controller is modified
  49873. */
  49874. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49875. /**
  49876. * Fired when the thumb rest on this controller is modified
  49877. */
  49878. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49879. /**
  49880. * Creates a new OculusTouchController from a gamepad
  49881. * @param vrGamepad the gamepad that the controller should be created from
  49882. */
  49883. constructor(vrGamepad: any);
  49884. /**
  49885. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49886. * @param scene scene in which to add meshes
  49887. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49888. */
  49889. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49890. /**
  49891. * Fired when the A button on this controller is modified
  49892. */
  49893. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49894. /**
  49895. * Fired when the B button on this controller is modified
  49896. */
  49897. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49898. /**
  49899. * Fired when the X button on this controller is modified
  49900. */
  49901. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49902. /**
  49903. * Fired when the Y button on this controller is modified
  49904. */
  49905. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49906. /**
  49907. * Called once for each button that changed state since the last frame
  49908. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49909. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49910. * 2) secondary trigger (same)
  49911. * 3) A (right) X (left), touch, pressed = value
  49912. * 4) B / Y
  49913. * 5) thumb rest
  49914. * @param buttonIdx Which button index changed
  49915. * @param state New state of the button
  49916. * @param changes Which properties on the state changed since last frame
  49917. */
  49918. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49919. }
  49920. }
  49921. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49922. import { Scene } from "babylonjs/scene";
  49923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49924. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49925. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49926. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49927. import { Observable } from "babylonjs/Misc/observable";
  49928. /**
  49929. * Vive Controller
  49930. */
  49931. export class ViveController extends WebVRController {
  49932. /**
  49933. * Base Url for the controller model.
  49934. */
  49935. static MODEL_BASE_URL: string;
  49936. /**
  49937. * File name for the controller model.
  49938. */
  49939. static MODEL_FILENAME: string;
  49940. /**
  49941. * Creates a new ViveController from a gamepad
  49942. * @param vrGamepad the gamepad that the controller should be created from
  49943. */
  49944. constructor(vrGamepad: any);
  49945. /**
  49946. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49947. * @param scene scene in which to add meshes
  49948. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49949. */
  49950. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49951. /**
  49952. * Fired when the left button on this controller is modified
  49953. */
  49954. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49955. /**
  49956. * Fired when the right button on this controller is modified
  49957. */
  49958. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49959. /**
  49960. * Fired when the menu button on this controller is modified
  49961. */
  49962. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49963. /**
  49964. * Called once for each button that changed state since the last frame
  49965. * Vive mapping:
  49966. * 0: touchpad
  49967. * 1: trigger
  49968. * 2: left AND right buttons
  49969. * 3: menu button
  49970. * @param buttonIdx Which button index changed
  49971. * @param state New state of the button
  49972. * @param changes Which properties on the state changed since last frame
  49973. */
  49974. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49975. }
  49976. }
  49977. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  49978. import { Observable } from "babylonjs/Misc/observable";
  49979. import { Scene } from "babylonjs/scene";
  49980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49981. import { Ray } from "babylonjs/Culling/ray";
  49982. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49983. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49984. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49985. /**
  49986. * Defines the WindowsMotionController object that the state of the windows motion controller
  49987. */
  49988. export class WindowsMotionController extends WebVRController {
  49989. /**
  49990. * The base url used to load the left and right controller models
  49991. */
  49992. static MODEL_BASE_URL: string;
  49993. /**
  49994. * The name of the left controller model file
  49995. */
  49996. static MODEL_LEFT_FILENAME: string;
  49997. /**
  49998. * The name of the right controller model file
  49999. */
  50000. static MODEL_RIGHT_FILENAME: string;
  50001. /**
  50002. * The controller name prefix for this controller type
  50003. */
  50004. static readonly GAMEPAD_ID_PREFIX: string;
  50005. /**
  50006. * The controller id pattern for this controller type
  50007. */
  50008. private static readonly GAMEPAD_ID_PATTERN;
  50009. private _loadedMeshInfo;
  50010. protected readonly _mapping: {
  50011. buttons: string[];
  50012. buttonMeshNames: {
  50013. 'trigger': string;
  50014. 'menu': string;
  50015. 'grip': string;
  50016. 'thumbstick': string;
  50017. 'trackpad': string;
  50018. };
  50019. buttonObservableNames: {
  50020. 'trigger': string;
  50021. 'menu': string;
  50022. 'grip': string;
  50023. 'thumbstick': string;
  50024. 'trackpad': string;
  50025. };
  50026. axisMeshNames: string[];
  50027. pointingPoseMeshName: string;
  50028. };
  50029. /**
  50030. * Fired when the trackpad on this controller is clicked
  50031. */
  50032. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50033. /**
  50034. * Fired when the trackpad on this controller is modified
  50035. */
  50036. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50037. /**
  50038. * The current x and y values of this controller's trackpad
  50039. */
  50040. trackpad: StickValues;
  50041. /**
  50042. * Creates a new WindowsMotionController from a gamepad
  50043. * @param vrGamepad the gamepad that the controller should be created from
  50044. */
  50045. constructor(vrGamepad: any);
  50046. /**
  50047. * Fired when the trigger on this controller is modified
  50048. */
  50049. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50050. /**
  50051. * Fired when the menu button on this controller is modified
  50052. */
  50053. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50054. /**
  50055. * Fired when the grip button on this controller is modified
  50056. */
  50057. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50058. /**
  50059. * Fired when the thumbstick button on this controller is modified
  50060. */
  50061. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50062. /**
  50063. * Fired when the touchpad button on this controller is modified
  50064. */
  50065. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50066. /**
  50067. * Fired when the touchpad values on this controller are modified
  50068. */
  50069. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50070. protected _updateTrackpad(): void;
  50071. /**
  50072. * Called once per frame by the engine.
  50073. */
  50074. update(): void;
  50075. /**
  50076. * Called once for each button that changed state since the last frame
  50077. * @param buttonIdx Which button index changed
  50078. * @param state New state of the button
  50079. * @param changes Which properties on the state changed since last frame
  50080. */
  50081. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50082. /**
  50083. * Moves the buttons on the controller mesh based on their current state
  50084. * @param buttonName the name of the button to move
  50085. * @param buttonValue the value of the button which determines the buttons new position
  50086. */
  50087. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50088. /**
  50089. * Moves the axis on the controller mesh based on its current state
  50090. * @param axis the index of the axis
  50091. * @param axisValue the value of the axis which determines the meshes new position
  50092. * @hidden
  50093. */
  50094. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50095. /**
  50096. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50097. * @param scene scene in which to add meshes
  50098. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50099. */
  50100. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50101. /**
  50102. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50103. * can be transformed by button presses and axes values, based on this._mapping.
  50104. *
  50105. * @param scene scene in which the meshes exist
  50106. * @param meshes list of meshes that make up the controller model to process
  50107. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50108. */
  50109. private processModel;
  50110. private createMeshInfo;
  50111. /**
  50112. * Gets the ray of the controller in the direction the controller is pointing
  50113. * @param length the length the resulting ray should be
  50114. * @returns a ray in the direction the controller is pointing
  50115. */
  50116. getForwardRay(length?: number): Ray;
  50117. /**
  50118. * Disposes of the controller
  50119. */
  50120. dispose(): void;
  50121. }
  50122. /**
  50123. * This class represents a new windows motion controller in XR.
  50124. */
  50125. export class XRWindowsMotionController extends WindowsMotionController {
  50126. /**
  50127. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50128. */
  50129. protected readonly _mapping: {
  50130. buttons: string[];
  50131. buttonMeshNames: {
  50132. 'trigger': string;
  50133. 'menu': string;
  50134. 'grip': string;
  50135. 'thumbstick': string;
  50136. 'trackpad': string;
  50137. };
  50138. buttonObservableNames: {
  50139. 'trigger': string;
  50140. 'menu': string;
  50141. 'grip': string;
  50142. 'thumbstick': string;
  50143. 'trackpad': string;
  50144. };
  50145. axisMeshNames: string[];
  50146. pointingPoseMeshName: string;
  50147. };
  50148. /**
  50149. * Construct a new XR-Based windows motion controller
  50150. *
  50151. * @param gamepadInfo the gamepad object from the browser
  50152. */
  50153. constructor(gamepadInfo: any);
  50154. /**
  50155. * holds the thumbstick values (X,Y)
  50156. */
  50157. thumbstickValues: StickValues;
  50158. /**
  50159. * Fired when the thumbstick on this controller is clicked
  50160. */
  50161. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50162. /**
  50163. * Fired when the thumbstick on this controller is modified
  50164. */
  50165. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50166. /**
  50167. * Fired when the touchpad button on this controller is modified
  50168. */
  50169. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50170. /**
  50171. * Fired when the touchpad values on this controller are modified
  50172. */
  50173. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50174. /**
  50175. * Fired when the thumbstick button on this controller is modified
  50176. * here to prevent breaking changes
  50177. */
  50178. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50179. /**
  50180. * updating the thumbstick(!) and not the trackpad.
  50181. * This is named this way due to the difference between WebVR and XR and to avoid
  50182. * changing the parent class.
  50183. */
  50184. protected _updateTrackpad(): void;
  50185. /**
  50186. * Disposes the class with joy
  50187. */
  50188. dispose(): void;
  50189. }
  50190. }
  50191. declare module "babylonjs/Gamepads/Controllers/index" {
  50192. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50193. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50194. export * from "babylonjs/Gamepads/Controllers/genericController";
  50195. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50196. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50197. export * from "babylonjs/Gamepads/Controllers/viveController";
  50198. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50199. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50200. }
  50201. declare module "babylonjs/Gamepads/index" {
  50202. export * from "babylonjs/Gamepads/Controllers/index";
  50203. export * from "babylonjs/Gamepads/gamepad";
  50204. export * from "babylonjs/Gamepads/gamepadManager";
  50205. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50206. export * from "babylonjs/Gamepads/xboxGamepad";
  50207. export * from "babylonjs/Gamepads/dualShockGamepad";
  50208. }
  50209. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50210. import { Scene } from "babylonjs/scene";
  50211. import { Vector4 } from "babylonjs/Maths/math.vector";
  50212. import { Color4 } from "babylonjs/Maths/math.color";
  50213. import { Mesh } from "babylonjs/Meshes/mesh";
  50214. import { Nullable } from "babylonjs/types";
  50215. /**
  50216. * Class containing static functions to help procedurally build meshes
  50217. */
  50218. export class PolyhedronBuilder {
  50219. /**
  50220. * Creates a polyhedron mesh
  50221. * * 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
  50222. * * The parameter `size` (positive float, default 1) sets the polygon size
  50223. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50224. * * 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`
  50225. * * 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
  50226. * * 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)`)
  50227. * * 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
  50228. * * 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
  50229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50232. * @param name defines the name of the mesh
  50233. * @param options defines the options used to create the mesh
  50234. * @param scene defines the hosting scene
  50235. * @returns the polyhedron mesh
  50236. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50237. */
  50238. static CreatePolyhedron(name: string, options: {
  50239. type?: number;
  50240. size?: number;
  50241. sizeX?: number;
  50242. sizeY?: number;
  50243. sizeZ?: number;
  50244. custom?: any;
  50245. faceUV?: Vector4[];
  50246. faceColors?: Color4[];
  50247. flat?: boolean;
  50248. updatable?: boolean;
  50249. sideOrientation?: number;
  50250. frontUVs?: Vector4;
  50251. backUVs?: Vector4;
  50252. }, scene?: Nullable<Scene>): Mesh;
  50253. }
  50254. }
  50255. declare module "babylonjs/Gizmos/scaleGizmo" {
  50256. import { Observable } from "babylonjs/Misc/observable";
  50257. import { Nullable } from "babylonjs/types";
  50258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50259. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50260. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50261. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50262. /**
  50263. * Gizmo that enables scaling a mesh along 3 axis
  50264. */
  50265. export class ScaleGizmo extends Gizmo {
  50266. /**
  50267. * Internal gizmo used for interactions on the x axis
  50268. */
  50269. xGizmo: AxisScaleGizmo;
  50270. /**
  50271. * Internal gizmo used for interactions on the y axis
  50272. */
  50273. yGizmo: AxisScaleGizmo;
  50274. /**
  50275. * Internal gizmo used for interactions on the z axis
  50276. */
  50277. zGizmo: AxisScaleGizmo;
  50278. /**
  50279. * Internal gizmo used to scale all axis equally
  50280. */
  50281. uniformScaleGizmo: AxisScaleGizmo;
  50282. private _meshAttached;
  50283. private _updateGizmoRotationToMatchAttachedMesh;
  50284. private _snapDistance;
  50285. private _scaleRatio;
  50286. private _uniformScalingMesh;
  50287. private _octahedron;
  50288. private _sensitivity;
  50289. /** Fires an event when any of it's sub gizmos are dragged */
  50290. onDragStartObservable: Observable<unknown>;
  50291. /** Fires an event when any of it's sub gizmos are released from dragging */
  50292. onDragEndObservable: Observable<unknown>;
  50293. get attachedMesh(): Nullable<AbstractMesh>;
  50294. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50295. /**
  50296. * Creates a ScaleGizmo
  50297. * @param gizmoLayer The utility layer the gizmo will be added to
  50298. */
  50299. constructor(gizmoLayer?: UtilityLayerRenderer);
  50300. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50301. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50302. /**
  50303. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50304. */
  50305. set snapDistance(value: number);
  50306. get snapDistance(): number;
  50307. /**
  50308. * Ratio for the scale of the gizmo (Default: 1)
  50309. */
  50310. set scaleRatio(value: number);
  50311. get scaleRatio(): number;
  50312. /**
  50313. * Sensitivity factor for dragging (Default: 1)
  50314. */
  50315. set sensitivity(value: number);
  50316. get sensitivity(): number;
  50317. /**
  50318. * Disposes of the gizmo
  50319. */
  50320. dispose(): void;
  50321. }
  50322. }
  50323. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50324. import { Observable } from "babylonjs/Misc/observable";
  50325. import { Nullable } from "babylonjs/types";
  50326. import { Vector3 } from "babylonjs/Maths/math.vector";
  50327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50328. import { Mesh } from "babylonjs/Meshes/mesh";
  50329. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50330. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50331. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50332. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50333. import { Color3 } from "babylonjs/Maths/math.color";
  50334. /**
  50335. * Single axis scale gizmo
  50336. */
  50337. export class AxisScaleGizmo extends Gizmo {
  50338. /**
  50339. * Drag behavior responsible for the gizmos dragging interactions
  50340. */
  50341. dragBehavior: PointerDragBehavior;
  50342. private _pointerObserver;
  50343. /**
  50344. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50345. */
  50346. snapDistance: number;
  50347. /**
  50348. * Event that fires each time the gizmo snaps to a new location.
  50349. * * snapDistance is the the change in distance
  50350. */
  50351. onSnapObservable: Observable<{
  50352. snapDistance: number;
  50353. }>;
  50354. /**
  50355. * If the scaling operation should be done on all axis (default: false)
  50356. */
  50357. uniformScaling: boolean;
  50358. /**
  50359. * Custom sensitivity value for the drag strength
  50360. */
  50361. sensitivity: number;
  50362. private _isEnabled;
  50363. private _parent;
  50364. private _arrow;
  50365. private _coloredMaterial;
  50366. private _hoverMaterial;
  50367. /**
  50368. * Creates an AxisScaleGizmo
  50369. * @param gizmoLayer The utility layer the gizmo will be added to
  50370. * @param dragAxis The axis which the gizmo will be able to scale on
  50371. * @param color The color of the gizmo
  50372. */
  50373. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50374. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50375. /**
  50376. * If the gizmo is enabled
  50377. */
  50378. set isEnabled(value: boolean);
  50379. get isEnabled(): boolean;
  50380. /**
  50381. * Disposes of the gizmo
  50382. */
  50383. dispose(): void;
  50384. /**
  50385. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50386. * @param mesh The mesh to replace the default mesh of the gizmo
  50387. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50388. */
  50389. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50390. }
  50391. }
  50392. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50393. import { Observable } from "babylonjs/Misc/observable";
  50394. import { Nullable } from "babylonjs/types";
  50395. import { Vector3 } from "babylonjs/Maths/math.vector";
  50396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50397. import { Mesh } from "babylonjs/Meshes/mesh";
  50398. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50399. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50400. import { Color3 } from "babylonjs/Maths/math.color";
  50401. import "babylonjs/Meshes/Builders/boxBuilder";
  50402. /**
  50403. * Bounding box gizmo
  50404. */
  50405. export class BoundingBoxGizmo extends Gizmo {
  50406. private _lineBoundingBox;
  50407. private _rotateSpheresParent;
  50408. private _scaleBoxesParent;
  50409. private _boundingDimensions;
  50410. private _renderObserver;
  50411. private _pointerObserver;
  50412. private _scaleDragSpeed;
  50413. private _tmpQuaternion;
  50414. private _tmpVector;
  50415. private _tmpRotationMatrix;
  50416. /**
  50417. * 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)
  50418. */
  50419. ignoreChildren: boolean;
  50420. /**
  50421. * 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)
  50422. */
  50423. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50424. /**
  50425. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50426. */
  50427. rotationSphereSize: number;
  50428. /**
  50429. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50430. */
  50431. scaleBoxSize: number;
  50432. /**
  50433. * 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)
  50434. */
  50435. fixedDragMeshScreenSize: boolean;
  50436. /**
  50437. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50438. */
  50439. fixedDragMeshScreenSizeDistanceFactor: number;
  50440. /**
  50441. * Fired when a rotation sphere or scale box is dragged
  50442. */
  50443. onDragStartObservable: Observable<{}>;
  50444. /**
  50445. * Fired when a scale box is dragged
  50446. */
  50447. onScaleBoxDragObservable: Observable<{}>;
  50448. /**
  50449. * Fired when a scale box drag is ended
  50450. */
  50451. onScaleBoxDragEndObservable: Observable<{}>;
  50452. /**
  50453. * Fired when a rotation sphere is dragged
  50454. */
  50455. onRotationSphereDragObservable: Observable<{}>;
  50456. /**
  50457. * Fired when a rotation sphere drag is ended
  50458. */
  50459. onRotationSphereDragEndObservable: Observable<{}>;
  50460. /**
  50461. * 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)
  50462. */
  50463. scalePivot: Nullable<Vector3>;
  50464. /**
  50465. * Mesh used as a pivot to rotate the attached mesh
  50466. */
  50467. private _anchorMesh;
  50468. private _existingMeshScale;
  50469. private _dragMesh;
  50470. private pointerDragBehavior;
  50471. private coloredMaterial;
  50472. private hoverColoredMaterial;
  50473. /**
  50474. * Sets the color of the bounding box gizmo
  50475. * @param color the color to set
  50476. */
  50477. setColor(color: Color3): void;
  50478. /**
  50479. * Creates an BoundingBoxGizmo
  50480. * @param gizmoLayer The utility layer the gizmo will be added to
  50481. * @param color The color of the gizmo
  50482. */
  50483. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50484. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50485. private _selectNode;
  50486. /**
  50487. * Updates the bounding box information for the Gizmo
  50488. */
  50489. updateBoundingBox(): void;
  50490. private _updateRotationSpheres;
  50491. private _updateScaleBoxes;
  50492. /**
  50493. * Enables rotation on the specified axis and disables rotation on the others
  50494. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50495. */
  50496. setEnabledRotationAxis(axis: string): void;
  50497. /**
  50498. * Enables/disables scaling
  50499. * @param enable if scaling should be enabled
  50500. */
  50501. setEnabledScaling(enable: boolean): void;
  50502. private _updateDummy;
  50503. /**
  50504. * Enables a pointer drag behavior on the bounding box of the gizmo
  50505. */
  50506. enableDragBehavior(): void;
  50507. /**
  50508. * Disposes of the gizmo
  50509. */
  50510. dispose(): void;
  50511. /**
  50512. * 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)
  50513. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50514. * @returns the bounding box mesh with the passed in mesh as a child
  50515. */
  50516. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50517. /**
  50518. * CustomMeshes are not supported by this gizmo
  50519. * @param mesh The mesh to replace the default mesh of the gizmo
  50520. */
  50521. setCustomMesh(mesh: Mesh): void;
  50522. }
  50523. }
  50524. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50525. import { Observable } from "babylonjs/Misc/observable";
  50526. import { Nullable } from "babylonjs/types";
  50527. import { Vector3 } from "babylonjs/Maths/math.vector";
  50528. import { Color3 } from "babylonjs/Maths/math.color";
  50529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50530. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50531. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50532. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50533. import "babylonjs/Meshes/Builders/linesBuilder";
  50534. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50535. /**
  50536. * Single plane rotation gizmo
  50537. */
  50538. export class PlaneRotationGizmo extends Gizmo {
  50539. /**
  50540. * Drag behavior responsible for the gizmos dragging interactions
  50541. */
  50542. dragBehavior: PointerDragBehavior;
  50543. private _pointerObserver;
  50544. /**
  50545. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50546. */
  50547. snapDistance: number;
  50548. /**
  50549. * Event that fires each time the gizmo snaps to a new location.
  50550. * * snapDistance is the the change in distance
  50551. */
  50552. onSnapObservable: Observable<{
  50553. snapDistance: number;
  50554. }>;
  50555. private _isEnabled;
  50556. private _parent;
  50557. /**
  50558. * Creates a PlaneRotationGizmo
  50559. * @param gizmoLayer The utility layer the gizmo will be added to
  50560. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50561. * @param color The color of the gizmo
  50562. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50563. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50564. */
  50565. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50566. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50567. /**
  50568. * If the gizmo is enabled
  50569. */
  50570. set isEnabled(value: boolean);
  50571. get isEnabled(): boolean;
  50572. /**
  50573. * Disposes of the gizmo
  50574. */
  50575. dispose(): void;
  50576. }
  50577. }
  50578. declare module "babylonjs/Gizmos/rotationGizmo" {
  50579. import { Observable } from "babylonjs/Misc/observable";
  50580. import { Nullable } from "babylonjs/types";
  50581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50582. import { Mesh } from "babylonjs/Meshes/mesh";
  50583. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50584. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50585. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50586. /**
  50587. * Gizmo that enables rotating a mesh along 3 axis
  50588. */
  50589. export class RotationGizmo extends Gizmo {
  50590. /**
  50591. * Internal gizmo used for interactions on the x axis
  50592. */
  50593. xGizmo: PlaneRotationGizmo;
  50594. /**
  50595. * Internal gizmo used for interactions on the y axis
  50596. */
  50597. yGizmo: PlaneRotationGizmo;
  50598. /**
  50599. * Internal gizmo used for interactions on the z axis
  50600. */
  50601. zGizmo: PlaneRotationGizmo;
  50602. /** Fires an event when any of it's sub gizmos are dragged */
  50603. onDragStartObservable: Observable<unknown>;
  50604. /** Fires an event when any of it's sub gizmos are released from dragging */
  50605. onDragEndObservable: Observable<unknown>;
  50606. private _meshAttached;
  50607. get attachedMesh(): Nullable<AbstractMesh>;
  50608. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50609. /**
  50610. * Creates a RotationGizmo
  50611. * @param gizmoLayer The utility layer the gizmo will be added to
  50612. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50613. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50614. */
  50615. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50616. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50617. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50618. /**
  50619. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50620. */
  50621. set snapDistance(value: number);
  50622. get snapDistance(): number;
  50623. /**
  50624. * Ratio for the scale of the gizmo (Default: 1)
  50625. */
  50626. set scaleRatio(value: number);
  50627. get scaleRatio(): number;
  50628. /**
  50629. * Disposes of the gizmo
  50630. */
  50631. dispose(): void;
  50632. /**
  50633. * CustomMeshes are not supported by this gizmo
  50634. * @param mesh The mesh to replace the default mesh of the gizmo
  50635. */
  50636. setCustomMesh(mesh: Mesh): void;
  50637. }
  50638. }
  50639. declare module "babylonjs/Gizmos/gizmoManager" {
  50640. import { Observable } from "babylonjs/Misc/observable";
  50641. import { Nullable } from "babylonjs/types";
  50642. import { Scene, IDisposable } from "babylonjs/scene";
  50643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50644. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50645. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50646. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50647. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50648. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50649. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50650. /**
  50651. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50652. */
  50653. export class GizmoManager implements IDisposable {
  50654. private scene;
  50655. /**
  50656. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50657. */
  50658. gizmos: {
  50659. positionGizmo: Nullable<PositionGizmo>;
  50660. rotationGizmo: Nullable<RotationGizmo>;
  50661. scaleGizmo: Nullable<ScaleGizmo>;
  50662. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50663. };
  50664. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50665. clearGizmoOnEmptyPointerEvent: boolean;
  50666. /** Fires an event when the manager is attached to a mesh */
  50667. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50668. private _gizmosEnabled;
  50669. private _pointerObserver;
  50670. private _attachedMesh;
  50671. private _boundingBoxColor;
  50672. private _defaultUtilityLayer;
  50673. private _defaultKeepDepthUtilityLayer;
  50674. /**
  50675. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50676. */
  50677. boundingBoxDragBehavior: SixDofDragBehavior;
  50678. /**
  50679. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50680. */
  50681. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50682. /**
  50683. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50684. */
  50685. usePointerToAttachGizmos: boolean;
  50686. /**
  50687. * Utility layer that the bounding box gizmo belongs to
  50688. */
  50689. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50690. /**
  50691. * Utility layer that all gizmos besides bounding box belong to
  50692. */
  50693. get utilityLayer(): UtilityLayerRenderer;
  50694. /**
  50695. * Instatiates a gizmo manager
  50696. * @param scene the scene to overlay the gizmos on top of
  50697. */
  50698. constructor(scene: Scene);
  50699. /**
  50700. * Attaches a set of gizmos to the specified mesh
  50701. * @param mesh The mesh the gizmo's should be attached to
  50702. */
  50703. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50704. /**
  50705. * If the position gizmo is enabled
  50706. */
  50707. set positionGizmoEnabled(value: boolean);
  50708. get positionGizmoEnabled(): boolean;
  50709. /**
  50710. * If the rotation gizmo is enabled
  50711. */
  50712. set rotationGizmoEnabled(value: boolean);
  50713. get rotationGizmoEnabled(): boolean;
  50714. /**
  50715. * If the scale gizmo is enabled
  50716. */
  50717. set scaleGizmoEnabled(value: boolean);
  50718. get scaleGizmoEnabled(): boolean;
  50719. /**
  50720. * If the boundingBox gizmo is enabled
  50721. */
  50722. set boundingBoxGizmoEnabled(value: boolean);
  50723. get boundingBoxGizmoEnabled(): boolean;
  50724. /**
  50725. * Disposes of the gizmo manager
  50726. */
  50727. dispose(): void;
  50728. }
  50729. }
  50730. declare module "babylonjs/Lights/directionalLight" {
  50731. import { Camera } from "babylonjs/Cameras/camera";
  50732. import { Scene } from "babylonjs/scene";
  50733. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50735. import { Light } from "babylonjs/Lights/light";
  50736. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50737. import { Effect } from "babylonjs/Materials/effect";
  50738. /**
  50739. * A directional light is defined by a direction (what a surprise!).
  50740. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50741. * 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.
  50742. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50743. */
  50744. export class DirectionalLight extends ShadowLight {
  50745. private _shadowFrustumSize;
  50746. /**
  50747. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50748. */
  50749. get shadowFrustumSize(): number;
  50750. /**
  50751. * Specifies a fix frustum size for the shadow generation.
  50752. */
  50753. set shadowFrustumSize(value: number);
  50754. private _shadowOrthoScale;
  50755. /**
  50756. * Gets the shadow projection scale against the optimal computed one.
  50757. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50758. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50759. */
  50760. get shadowOrthoScale(): number;
  50761. /**
  50762. * Sets the shadow projection scale against the optimal computed one.
  50763. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50764. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50765. */
  50766. set shadowOrthoScale(value: number);
  50767. /**
  50768. * Automatically compute the projection matrix to best fit (including all the casters)
  50769. * on each frame.
  50770. */
  50771. autoUpdateExtends: boolean;
  50772. /**
  50773. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50774. * on each frame. autoUpdateExtends must be set to true for this to work
  50775. */
  50776. autoCalcShadowZBounds: boolean;
  50777. private _orthoLeft;
  50778. private _orthoRight;
  50779. private _orthoTop;
  50780. private _orthoBottom;
  50781. /**
  50782. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50783. * The directional light is emitted from everywhere in the given direction.
  50784. * It can cast shadows.
  50785. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50786. * @param name The friendly name of the light
  50787. * @param direction The direction of the light
  50788. * @param scene The scene the light belongs to
  50789. */
  50790. constructor(name: string, direction: Vector3, scene: Scene);
  50791. /**
  50792. * Returns the string "DirectionalLight".
  50793. * @return The class name
  50794. */
  50795. getClassName(): string;
  50796. /**
  50797. * Returns the integer 1.
  50798. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50799. */
  50800. getTypeID(): number;
  50801. /**
  50802. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50803. * Returns the DirectionalLight Shadow projection matrix.
  50804. */
  50805. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50806. /**
  50807. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50808. * Returns the DirectionalLight Shadow projection matrix.
  50809. */
  50810. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50811. /**
  50812. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50813. * Returns the DirectionalLight Shadow projection matrix.
  50814. */
  50815. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50816. protected _buildUniformLayout(): void;
  50817. /**
  50818. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50819. * @param effect The effect to update
  50820. * @param lightIndex The index of the light in the effect to update
  50821. * @returns The directional light
  50822. */
  50823. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50824. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50825. /**
  50826. * Gets the minZ used for shadow according to both the scene and the light.
  50827. *
  50828. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50829. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50830. * @param activeCamera The camera we are returning the min for
  50831. * @returns the depth min z
  50832. */
  50833. getDepthMinZ(activeCamera: Camera): number;
  50834. /**
  50835. * Gets the maxZ used for shadow according to both the scene and the light.
  50836. *
  50837. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50838. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50839. * @param activeCamera The camera we are returning the max for
  50840. * @returns the depth max z
  50841. */
  50842. getDepthMaxZ(activeCamera: Camera): number;
  50843. /**
  50844. * Prepares the list of defines specific to the light type.
  50845. * @param defines the list of defines
  50846. * @param lightIndex defines the index of the light for the effect
  50847. */
  50848. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50849. }
  50850. }
  50851. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50852. import { Mesh } from "babylonjs/Meshes/mesh";
  50853. /**
  50854. * Class containing static functions to help procedurally build meshes
  50855. */
  50856. export class HemisphereBuilder {
  50857. /**
  50858. * Creates a hemisphere mesh
  50859. * @param name defines the name of the mesh
  50860. * @param options defines the options used to create the mesh
  50861. * @param scene defines the hosting scene
  50862. * @returns the hemisphere mesh
  50863. */
  50864. static CreateHemisphere(name: string, options: {
  50865. segments?: number;
  50866. diameter?: number;
  50867. sideOrientation?: number;
  50868. }, scene: any): Mesh;
  50869. }
  50870. }
  50871. declare module "babylonjs/Lights/spotLight" {
  50872. import { Nullable } from "babylonjs/types";
  50873. import { Scene } from "babylonjs/scene";
  50874. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50876. import { Effect } from "babylonjs/Materials/effect";
  50877. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50878. import { Light } from "babylonjs/Lights/light";
  50879. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50880. /**
  50881. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50882. * These values define a cone of light starting from the position, emitting toward the direction.
  50883. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50884. * and the exponent defines the speed of the decay of the light with distance (reach).
  50885. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50886. */
  50887. export class SpotLight extends ShadowLight {
  50888. private _angle;
  50889. private _innerAngle;
  50890. private _cosHalfAngle;
  50891. private _lightAngleScale;
  50892. private _lightAngleOffset;
  50893. /**
  50894. * Gets the cone angle of the spot light in Radians.
  50895. */
  50896. get angle(): number;
  50897. /**
  50898. * Sets the cone angle of the spot light in Radians.
  50899. */
  50900. set angle(value: number);
  50901. /**
  50902. * Only used in gltf falloff mode, this defines the angle where
  50903. * the directional falloff will start before cutting at angle which could be seen
  50904. * as outer angle.
  50905. */
  50906. get innerAngle(): number;
  50907. /**
  50908. * Only used in gltf falloff mode, this defines the angle where
  50909. * the directional falloff will start before cutting at angle which could be seen
  50910. * as outer angle.
  50911. */
  50912. set innerAngle(value: number);
  50913. private _shadowAngleScale;
  50914. /**
  50915. * Allows scaling the angle of the light for shadow generation only.
  50916. */
  50917. get shadowAngleScale(): number;
  50918. /**
  50919. * Allows scaling the angle of the light for shadow generation only.
  50920. */
  50921. set shadowAngleScale(value: number);
  50922. /**
  50923. * The light decay speed with the distance from the emission spot.
  50924. */
  50925. exponent: number;
  50926. private _projectionTextureMatrix;
  50927. /**
  50928. * Allows reading the projecton texture
  50929. */
  50930. get projectionTextureMatrix(): Matrix;
  50931. protected _projectionTextureLightNear: number;
  50932. /**
  50933. * Gets the near clip of the Spotlight for texture projection.
  50934. */
  50935. get projectionTextureLightNear(): number;
  50936. /**
  50937. * Sets the near clip of the Spotlight for texture projection.
  50938. */
  50939. set projectionTextureLightNear(value: number);
  50940. protected _projectionTextureLightFar: number;
  50941. /**
  50942. * Gets the far clip of the Spotlight for texture projection.
  50943. */
  50944. get projectionTextureLightFar(): number;
  50945. /**
  50946. * Sets the far clip of the Spotlight for texture projection.
  50947. */
  50948. set projectionTextureLightFar(value: number);
  50949. protected _projectionTextureUpDirection: Vector3;
  50950. /**
  50951. * Gets the Up vector of the Spotlight for texture projection.
  50952. */
  50953. get projectionTextureUpDirection(): Vector3;
  50954. /**
  50955. * Sets the Up vector of the Spotlight for texture projection.
  50956. */
  50957. set projectionTextureUpDirection(value: Vector3);
  50958. private _projectionTexture;
  50959. /**
  50960. * Gets the projection texture of the light.
  50961. */
  50962. get projectionTexture(): Nullable<BaseTexture>;
  50963. /**
  50964. * Sets the projection texture of the light.
  50965. */
  50966. set projectionTexture(value: Nullable<BaseTexture>);
  50967. private _projectionTextureViewLightDirty;
  50968. private _projectionTextureProjectionLightDirty;
  50969. private _projectionTextureDirty;
  50970. private _projectionTextureViewTargetVector;
  50971. private _projectionTextureViewLightMatrix;
  50972. private _projectionTextureProjectionLightMatrix;
  50973. private _projectionTextureScalingMatrix;
  50974. /**
  50975. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  50976. * It can cast shadows.
  50977. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50978. * @param name The light friendly name
  50979. * @param position The position of the spot light in the scene
  50980. * @param direction The direction of the light in the scene
  50981. * @param angle The cone angle of the light in Radians
  50982. * @param exponent The light decay speed with the distance from the emission spot
  50983. * @param scene The scene the lights belongs to
  50984. */
  50985. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  50986. /**
  50987. * Returns the string "SpotLight".
  50988. * @returns the class name
  50989. */
  50990. getClassName(): string;
  50991. /**
  50992. * Returns the integer 2.
  50993. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50994. */
  50995. getTypeID(): number;
  50996. /**
  50997. * Overrides the direction setter to recompute the projection texture view light Matrix.
  50998. */
  50999. protected _setDirection(value: Vector3): void;
  51000. /**
  51001. * Overrides the position setter to recompute the projection texture view light Matrix.
  51002. */
  51003. protected _setPosition(value: Vector3): void;
  51004. /**
  51005. * 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.
  51006. * Returns the SpotLight.
  51007. */
  51008. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51009. protected _computeProjectionTextureViewLightMatrix(): void;
  51010. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51011. /**
  51012. * Main function for light texture projection matrix computing.
  51013. */
  51014. protected _computeProjectionTextureMatrix(): void;
  51015. protected _buildUniformLayout(): void;
  51016. private _computeAngleValues;
  51017. /**
  51018. * Sets the passed Effect "effect" with the Light textures.
  51019. * @param effect The effect to update
  51020. * @param lightIndex The index of the light in the effect to update
  51021. * @returns The light
  51022. */
  51023. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51024. /**
  51025. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51026. * @param effect The effect to update
  51027. * @param lightIndex The index of the light in the effect to update
  51028. * @returns The spot light
  51029. */
  51030. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51031. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51032. /**
  51033. * Disposes the light and the associated resources.
  51034. */
  51035. dispose(): void;
  51036. /**
  51037. * Prepares the list of defines specific to the light type.
  51038. * @param defines the list of defines
  51039. * @param lightIndex defines the index of the light for the effect
  51040. */
  51041. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51042. }
  51043. }
  51044. declare module "babylonjs/Gizmos/lightGizmo" {
  51045. import { Nullable } from "babylonjs/types";
  51046. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51047. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51048. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51049. import { Light } from "babylonjs/Lights/light";
  51050. /**
  51051. * Gizmo that enables viewing a light
  51052. */
  51053. export class LightGizmo extends Gizmo {
  51054. private _lightMesh;
  51055. private _material;
  51056. private _cachedPosition;
  51057. private _cachedForward;
  51058. private _attachedMeshParent;
  51059. /**
  51060. * Creates a LightGizmo
  51061. * @param gizmoLayer The utility layer the gizmo will be added to
  51062. */
  51063. constructor(gizmoLayer?: UtilityLayerRenderer);
  51064. private _light;
  51065. /**
  51066. * The light that the gizmo is attached to
  51067. */
  51068. set light(light: Nullable<Light>);
  51069. get light(): Nullable<Light>;
  51070. /**
  51071. * Gets the material used to render the light gizmo
  51072. */
  51073. get material(): StandardMaterial;
  51074. /**
  51075. * @hidden
  51076. * Updates the gizmo to match the attached mesh's position/rotation
  51077. */
  51078. protected _update(): void;
  51079. private static _Scale;
  51080. /**
  51081. * Creates the lines for a light mesh
  51082. */
  51083. private static _CreateLightLines;
  51084. /**
  51085. * Disposes of the light gizmo
  51086. */
  51087. dispose(): void;
  51088. private static _CreateHemisphericLightMesh;
  51089. private static _CreatePointLightMesh;
  51090. private static _CreateSpotLightMesh;
  51091. private static _CreateDirectionalLightMesh;
  51092. }
  51093. }
  51094. declare module "babylonjs/Gizmos/index" {
  51095. export * from "babylonjs/Gizmos/axisDragGizmo";
  51096. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51097. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51098. export * from "babylonjs/Gizmos/gizmo";
  51099. export * from "babylonjs/Gizmos/gizmoManager";
  51100. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51101. export * from "babylonjs/Gizmos/positionGizmo";
  51102. export * from "babylonjs/Gizmos/rotationGizmo";
  51103. export * from "babylonjs/Gizmos/scaleGizmo";
  51104. export * from "babylonjs/Gizmos/lightGizmo";
  51105. export * from "babylonjs/Gizmos/planeDragGizmo";
  51106. }
  51107. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51108. /** @hidden */
  51109. export var backgroundFragmentDeclaration: {
  51110. name: string;
  51111. shader: string;
  51112. };
  51113. }
  51114. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51115. /** @hidden */
  51116. export var backgroundUboDeclaration: {
  51117. name: string;
  51118. shader: string;
  51119. };
  51120. }
  51121. declare module "babylonjs/Shaders/background.fragment" {
  51122. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51123. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51124. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51125. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51126. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51127. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51128. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51129. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51130. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51131. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51132. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51133. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51134. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51135. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51136. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51137. /** @hidden */
  51138. export var backgroundPixelShader: {
  51139. name: string;
  51140. shader: string;
  51141. };
  51142. }
  51143. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51144. /** @hidden */
  51145. export var backgroundVertexDeclaration: {
  51146. name: string;
  51147. shader: string;
  51148. };
  51149. }
  51150. declare module "babylonjs/Shaders/background.vertex" {
  51151. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51152. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51153. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51154. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51155. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51156. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51157. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51158. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51159. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51160. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51161. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51162. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51163. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51164. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51165. /** @hidden */
  51166. export var backgroundVertexShader: {
  51167. name: string;
  51168. shader: string;
  51169. };
  51170. }
  51171. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51172. import { Nullable, int, float } from "babylonjs/types";
  51173. import { Scene } from "babylonjs/scene";
  51174. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51175. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51177. import { Mesh } from "babylonjs/Meshes/mesh";
  51178. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51179. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51180. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51181. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51182. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51183. import { Color3 } from "babylonjs/Maths/math.color";
  51184. import "babylonjs/Shaders/background.fragment";
  51185. import "babylonjs/Shaders/background.vertex";
  51186. /**
  51187. * Background material used to create an efficient environement around your scene.
  51188. */
  51189. export class BackgroundMaterial extends PushMaterial {
  51190. /**
  51191. * Standard reflectance value at parallel view angle.
  51192. */
  51193. static StandardReflectance0: number;
  51194. /**
  51195. * Standard reflectance value at grazing angle.
  51196. */
  51197. static StandardReflectance90: number;
  51198. protected _primaryColor: Color3;
  51199. /**
  51200. * Key light Color (multiply against the environement texture)
  51201. */
  51202. primaryColor: Color3;
  51203. protected __perceptualColor: Nullable<Color3>;
  51204. /**
  51205. * Experimental Internal Use Only.
  51206. *
  51207. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51208. * This acts as a helper to set the primary color to a more "human friendly" value.
  51209. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51210. * output color as close as possible from the chosen value.
  51211. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51212. * part of lighting setup.)
  51213. */
  51214. get _perceptualColor(): Nullable<Color3>;
  51215. set _perceptualColor(value: Nullable<Color3>);
  51216. protected _primaryColorShadowLevel: float;
  51217. /**
  51218. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51219. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51220. */
  51221. get primaryColorShadowLevel(): float;
  51222. set primaryColorShadowLevel(value: float);
  51223. protected _primaryColorHighlightLevel: float;
  51224. /**
  51225. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51226. * The primary color is used at the level chosen to define what the white area would look.
  51227. */
  51228. get primaryColorHighlightLevel(): float;
  51229. set primaryColorHighlightLevel(value: float);
  51230. protected _reflectionTexture: Nullable<BaseTexture>;
  51231. /**
  51232. * Reflection Texture used in the material.
  51233. * Should be author in a specific way for the best result (refer to the documentation).
  51234. */
  51235. reflectionTexture: Nullable<BaseTexture>;
  51236. protected _reflectionBlur: float;
  51237. /**
  51238. * Reflection Texture level of blur.
  51239. *
  51240. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51241. * texture twice.
  51242. */
  51243. reflectionBlur: float;
  51244. protected _diffuseTexture: Nullable<BaseTexture>;
  51245. /**
  51246. * Diffuse Texture used in the material.
  51247. * Should be author in a specific way for the best result (refer to the documentation).
  51248. */
  51249. diffuseTexture: Nullable<BaseTexture>;
  51250. protected _shadowLights: Nullable<IShadowLight[]>;
  51251. /**
  51252. * Specify the list of lights casting shadow on the material.
  51253. * All scene shadow lights will be included if null.
  51254. */
  51255. shadowLights: Nullable<IShadowLight[]>;
  51256. protected _shadowLevel: float;
  51257. /**
  51258. * Helps adjusting the shadow to a softer level if required.
  51259. * 0 means black shadows and 1 means no shadows.
  51260. */
  51261. shadowLevel: float;
  51262. protected _sceneCenter: Vector3;
  51263. /**
  51264. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51265. * It is usually zero but might be interesting to modify according to your setup.
  51266. */
  51267. sceneCenter: Vector3;
  51268. protected _opacityFresnel: boolean;
  51269. /**
  51270. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51271. * This helps ensuring a nice transition when the camera goes under the ground.
  51272. */
  51273. opacityFresnel: boolean;
  51274. protected _reflectionFresnel: boolean;
  51275. /**
  51276. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51277. * This helps adding a mirror texture on the ground.
  51278. */
  51279. reflectionFresnel: boolean;
  51280. protected _reflectionFalloffDistance: number;
  51281. /**
  51282. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51283. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51284. */
  51285. reflectionFalloffDistance: number;
  51286. protected _reflectionAmount: number;
  51287. /**
  51288. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51289. */
  51290. reflectionAmount: number;
  51291. protected _reflectionReflectance0: number;
  51292. /**
  51293. * This specifies the weight of the reflection at grazing angle.
  51294. */
  51295. reflectionReflectance0: number;
  51296. protected _reflectionReflectance90: number;
  51297. /**
  51298. * This specifies the weight of the reflection at a perpendicular point of view.
  51299. */
  51300. reflectionReflectance90: number;
  51301. /**
  51302. * Sets the reflection reflectance fresnel values according to the default standard
  51303. * empirically know to work well :-)
  51304. */
  51305. set reflectionStandardFresnelWeight(value: number);
  51306. protected _useRGBColor: boolean;
  51307. /**
  51308. * Helps to directly use the maps channels instead of their level.
  51309. */
  51310. useRGBColor: boolean;
  51311. protected _enableNoise: boolean;
  51312. /**
  51313. * This helps reducing the banding effect that could occur on the background.
  51314. */
  51315. enableNoise: boolean;
  51316. /**
  51317. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51318. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51319. * Recommended to be keep at 1.0 except for special cases.
  51320. */
  51321. get fovMultiplier(): number;
  51322. set fovMultiplier(value: number);
  51323. private _fovMultiplier;
  51324. /**
  51325. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51326. */
  51327. useEquirectangularFOV: boolean;
  51328. private _maxSimultaneousLights;
  51329. /**
  51330. * Number of Simultaneous lights allowed on the material.
  51331. */
  51332. maxSimultaneousLights: int;
  51333. /**
  51334. * Default configuration related to image processing available in the Background Material.
  51335. */
  51336. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51337. /**
  51338. * Keep track of the image processing observer to allow dispose and replace.
  51339. */
  51340. private _imageProcessingObserver;
  51341. /**
  51342. * Attaches a new image processing configuration to the PBR Material.
  51343. * @param configuration (if null the scene configuration will be use)
  51344. */
  51345. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51346. /**
  51347. * Gets the image processing configuration used either in this material.
  51348. */
  51349. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51350. /**
  51351. * Sets the Default image processing configuration used either in the this material.
  51352. *
  51353. * If sets to null, the scene one is in use.
  51354. */
  51355. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51356. /**
  51357. * Gets wether the color curves effect is enabled.
  51358. */
  51359. get cameraColorCurvesEnabled(): boolean;
  51360. /**
  51361. * Sets wether the color curves effect is enabled.
  51362. */
  51363. set cameraColorCurvesEnabled(value: boolean);
  51364. /**
  51365. * Gets wether the color grading effect is enabled.
  51366. */
  51367. get cameraColorGradingEnabled(): boolean;
  51368. /**
  51369. * Gets wether the color grading effect is enabled.
  51370. */
  51371. set cameraColorGradingEnabled(value: boolean);
  51372. /**
  51373. * Gets wether tonemapping is enabled or not.
  51374. */
  51375. get cameraToneMappingEnabled(): boolean;
  51376. /**
  51377. * Sets wether tonemapping is enabled or not
  51378. */
  51379. set cameraToneMappingEnabled(value: boolean);
  51380. /**
  51381. * The camera exposure used on this material.
  51382. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51383. * This corresponds to a photographic exposure.
  51384. */
  51385. get cameraExposure(): float;
  51386. /**
  51387. * The camera exposure used on this material.
  51388. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51389. * This corresponds to a photographic exposure.
  51390. */
  51391. set cameraExposure(value: float);
  51392. /**
  51393. * Gets The camera contrast used on this material.
  51394. */
  51395. get cameraContrast(): float;
  51396. /**
  51397. * Sets The camera contrast used on this material.
  51398. */
  51399. set cameraContrast(value: float);
  51400. /**
  51401. * Gets the Color Grading 2D Lookup Texture.
  51402. */
  51403. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51404. /**
  51405. * Sets the Color Grading 2D Lookup Texture.
  51406. */
  51407. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51408. /**
  51409. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51410. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51411. * 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;
  51412. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51413. */
  51414. get cameraColorCurves(): Nullable<ColorCurves>;
  51415. /**
  51416. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51417. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51418. * 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;
  51419. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51420. */
  51421. set cameraColorCurves(value: Nullable<ColorCurves>);
  51422. /**
  51423. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51424. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51425. */
  51426. switchToBGR: boolean;
  51427. private _renderTargets;
  51428. private _reflectionControls;
  51429. private _white;
  51430. private _primaryShadowColor;
  51431. private _primaryHighlightColor;
  51432. /**
  51433. * Instantiates a Background Material in the given scene
  51434. * @param name The friendly name of the material
  51435. * @param scene The scene to add the material to
  51436. */
  51437. constructor(name: string, scene: Scene);
  51438. /**
  51439. * Gets a boolean indicating that current material needs to register RTT
  51440. */
  51441. get hasRenderTargetTextures(): boolean;
  51442. /**
  51443. * The entire material has been created in order to prevent overdraw.
  51444. * @returns false
  51445. */
  51446. needAlphaTesting(): boolean;
  51447. /**
  51448. * The entire material has been created in order to prevent overdraw.
  51449. * @returns true if blending is enable
  51450. */
  51451. needAlphaBlending(): boolean;
  51452. /**
  51453. * Checks wether the material is ready to be rendered for a given mesh.
  51454. * @param mesh The mesh to render
  51455. * @param subMesh The submesh to check against
  51456. * @param useInstances Specify wether or not the material is used with instances
  51457. * @returns true if all the dependencies are ready (Textures, Effects...)
  51458. */
  51459. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51460. /**
  51461. * Compute the primary color according to the chosen perceptual color.
  51462. */
  51463. private _computePrimaryColorFromPerceptualColor;
  51464. /**
  51465. * Compute the highlights and shadow colors according to their chosen levels.
  51466. */
  51467. private _computePrimaryColors;
  51468. /**
  51469. * Build the uniform buffer used in the material.
  51470. */
  51471. buildUniformLayout(): void;
  51472. /**
  51473. * Unbind the material.
  51474. */
  51475. unbind(): void;
  51476. /**
  51477. * Bind only the world matrix to the material.
  51478. * @param world The world matrix to bind.
  51479. */
  51480. bindOnlyWorldMatrix(world: Matrix): void;
  51481. /**
  51482. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51483. * @param world The world matrix to bind.
  51484. * @param subMesh The submesh to bind for.
  51485. */
  51486. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51487. /**
  51488. * Checks to see if a texture is used in the material.
  51489. * @param texture - Base texture to use.
  51490. * @returns - Boolean specifying if a texture is used in the material.
  51491. */
  51492. hasTexture(texture: BaseTexture): boolean;
  51493. /**
  51494. * Dispose the material.
  51495. * @param forceDisposeEffect Force disposal of the associated effect.
  51496. * @param forceDisposeTextures Force disposal of the associated textures.
  51497. */
  51498. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51499. /**
  51500. * Clones the material.
  51501. * @param name The cloned name.
  51502. * @returns The cloned material.
  51503. */
  51504. clone(name: string): BackgroundMaterial;
  51505. /**
  51506. * Serializes the current material to its JSON representation.
  51507. * @returns The JSON representation.
  51508. */
  51509. serialize(): any;
  51510. /**
  51511. * Gets the class name of the material
  51512. * @returns "BackgroundMaterial"
  51513. */
  51514. getClassName(): string;
  51515. /**
  51516. * Parse a JSON input to create back a background material.
  51517. * @param source The JSON data to parse
  51518. * @param scene The scene to create the parsed material in
  51519. * @param rootUrl The root url of the assets the material depends upon
  51520. * @returns the instantiated BackgroundMaterial.
  51521. */
  51522. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51523. }
  51524. }
  51525. declare module "babylonjs/Helpers/environmentHelper" {
  51526. import { Observable } from "babylonjs/Misc/observable";
  51527. import { Nullable } from "babylonjs/types";
  51528. import { Scene } from "babylonjs/scene";
  51529. import { Vector3 } from "babylonjs/Maths/math.vector";
  51530. import { Color3 } from "babylonjs/Maths/math.color";
  51531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51532. import { Mesh } from "babylonjs/Meshes/mesh";
  51533. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51534. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51535. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51536. import "babylonjs/Meshes/Builders/planeBuilder";
  51537. import "babylonjs/Meshes/Builders/boxBuilder";
  51538. /**
  51539. * Represents the different options available during the creation of
  51540. * a Environment helper.
  51541. *
  51542. * This can control the default ground, skybox and image processing setup of your scene.
  51543. */
  51544. export interface IEnvironmentHelperOptions {
  51545. /**
  51546. * Specifies whether or not to create a ground.
  51547. * True by default.
  51548. */
  51549. createGround: boolean;
  51550. /**
  51551. * Specifies the ground size.
  51552. * 15 by default.
  51553. */
  51554. groundSize: number;
  51555. /**
  51556. * The texture used on the ground for the main color.
  51557. * Comes from the BabylonJS CDN by default.
  51558. *
  51559. * Remarks: Can be either a texture or a url.
  51560. */
  51561. groundTexture: string | BaseTexture;
  51562. /**
  51563. * The color mixed in the ground texture by default.
  51564. * BabylonJS clearColor by default.
  51565. */
  51566. groundColor: Color3;
  51567. /**
  51568. * Specifies the ground opacity.
  51569. * 1 by default.
  51570. */
  51571. groundOpacity: number;
  51572. /**
  51573. * Enables the ground to receive shadows.
  51574. * True by default.
  51575. */
  51576. enableGroundShadow: boolean;
  51577. /**
  51578. * Helps preventing the shadow to be fully black on the ground.
  51579. * 0.5 by default.
  51580. */
  51581. groundShadowLevel: number;
  51582. /**
  51583. * Creates a mirror texture attach to the ground.
  51584. * false by default.
  51585. */
  51586. enableGroundMirror: boolean;
  51587. /**
  51588. * Specifies the ground mirror size ratio.
  51589. * 0.3 by default as the default kernel is 64.
  51590. */
  51591. groundMirrorSizeRatio: number;
  51592. /**
  51593. * Specifies the ground mirror blur kernel size.
  51594. * 64 by default.
  51595. */
  51596. groundMirrorBlurKernel: number;
  51597. /**
  51598. * Specifies the ground mirror visibility amount.
  51599. * 1 by default
  51600. */
  51601. groundMirrorAmount: number;
  51602. /**
  51603. * Specifies the ground mirror reflectance weight.
  51604. * This uses the standard weight of the background material to setup the fresnel effect
  51605. * of the mirror.
  51606. * 1 by default.
  51607. */
  51608. groundMirrorFresnelWeight: number;
  51609. /**
  51610. * Specifies the ground mirror Falloff distance.
  51611. * This can helps reducing the size of the reflection.
  51612. * 0 by Default.
  51613. */
  51614. groundMirrorFallOffDistance: number;
  51615. /**
  51616. * Specifies the ground mirror texture type.
  51617. * Unsigned Int by Default.
  51618. */
  51619. groundMirrorTextureType: number;
  51620. /**
  51621. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51622. * the shown objects.
  51623. */
  51624. groundYBias: number;
  51625. /**
  51626. * Specifies whether or not to create a skybox.
  51627. * True by default.
  51628. */
  51629. createSkybox: boolean;
  51630. /**
  51631. * Specifies the skybox size.
  51632. * 20 by default.
  51633. */
  51634. skyboxSize: number;
  51635. /**
  51636. * The texture used on the skybox for the main color.
  51637. * Comes from the BabylonJS CDN by default.
  51638. *
  51639. * Remarks: Can be either a texture or a url.
  51640. */
  51641. skyboxTexture: string | BaseTexture;
  51642. /**
  51643. * The color mixed in the skybox texture by default.
  51644. * BabylonJS clearColor by default.
  51645. */
  51646. skyboxColor: Color3;
  51647. /**
  51648. * The background rotation around the Y axis of the scene.
  51649. * This helps aligning the key lights of your scene with the background.
  51650. * 0 by default.
  51651. */
  51652. backgroundYRotation: number;
  51653. /**
  51654. * Compute automatically the size of the elements to best fit with the scene.
  51655. */
  51656. sizeAuto: boolean;
  51657. /**
  51658. * Default position of the rootMesh if autoSize is not true.
  51659. */
  51660. rootPosition: Vector3;
  51661. /**
  51662. * Sets up the image processing in the scene.
  51663. * true by default.
  51664. */
  51665. setupImageProcessing: boolean;
  51666. /**
  51667. * The texture used as your environment texture in the scene.
  51668. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51669. *
  51670. * Remarks: Can be either a texture or a url.
  51671. */
  51672. environmentTexture: string | BaseTexture;
  51673. /**
  51674. * The value of the exposure to apply to the scene.
  51675. * 0.6 by default if setupImageProcessing is true.
  51676. */
  51677. cameraExposure: number;
  51678. /**
  51679. * The value of the contrast to apply to the scene.
  51680. * 1.6 by default if setupImageProcessing is true.
  51681. */
  51682. cameraContrast: number;
  51683. /**
  51684. * Specifies whether or not tonemapping should be enabled in the scene.
  51685. * true by default if setupImageProcessing is true.
  51686. */
  51687. toneMappingEnabled: boolean;
  51688. }
  51689. /**
  51690. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51691. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51692. * It also helps with the default setup of your imageProcessing configuration.
  51693. */
  51694. export class EnvironmentHelper {
  51695. /**
  51696. * Default ground texture URL.
  51697. */
  51698. private static _groundTextureCDNUrl;
  51699. /**
  51700. * Default skybox texture URL.
  51701. */
  51702. private static _skyboxTextureCDNUrl;
  51703. /**
  51704. * Default environment texture URL.
  51705. */
  51706. private static _environmentTextureCDNUrl;
  51707. /**
  51708. * Creates the default options for the helper.
  51709. */
  51710. private static _getDefaultOptions;
  51711. private _rootMesh;
  51712. /**
  51713. * Gets the root mesh created by the helper.
  51714. */
  51715. get rootMesh(): Mesh;
  51716. private _skybox;
  51717. /**
  51718. * Gets the skybox created by the helper.
  51719. */
  51720. get skybox(): Nullable<Mesh>;
  51721. private _skyboxTexture;
  51722. /**
  51723. * Gets the skybox texture created by the helper.
  51724. */
  51725. get skyboxTexture(): Nullable<BaseTexture>;
  51726. private _skyboxMaterial;
  51727. /**
  51728. * Gets the skybox material created by the helper.
  51729. */
  51730. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51731. private _ground;
  51732. /**
  51733. * Gets the ground mesh created by the helper.
  51734. */
  51735. get ground(): Nullable<Mesh>;
  51736. private _groundTexture;
  51737. /**
  51738. * Gets the ground texture created by the helper.
  51739. */
  51740. get groundTexture(): Nullable<BaseTexture>;
  51741. private _groundMirror;
  51742. /**
  51743. * Gets the ground mirror created by the helper.
  51744. */
  51745. get groundMirror(): Nullable<MirrorTexture>;
  51746. /**
  51747. * Gets the ground mirror render list to helps pushing the meshes
  51748. * you wish in the ground reflection.
  51749. */
  51750. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51751. private _groundMaterial;
  51752. /**
  51753. * Gets the ground material created by the helper.
  51754. */
  51755. get groundMaterial(): Nullable<BackgroundMaterial>;
  51756. /**
  51757. * Stores the creation options.
  51758. */
  51759. private readonly _scene;
  51760. private _options;
  51761. /**
  51762. * This observable will be notified with any error during the creation of the environment,
  51763. * mainly texture creation errors.
  51764. */
  51765. onErrorObservable: Observable<{
  51766. message?: string;
  51767. exception?: any;
  51768. }>;
  51769. /**
  51770. * constructor
  51771. * @param options Defines the options we want to customize the helper
  51772. * @param scene The scene to add the material to
  51773. */
  51774. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51775. /**
  51776. * Updates the background according to the new options
  51777. * @param options
  51778. */
  51779. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51780. /**
  51781. * Sets the primary color of all the available elements.
  51782. * @param color the main color to affect to the ground and the background
  51783. */
  51784. setMainColor(color: Color3): void;
  51785. /**
  51786. * Setup the image processing according to the specified options.
  51787. */
  51788. private _setupImageProcessing;
  51789. /**
  51790. * Setup the environment texture according to the specified options.
  51791. */
  51792. private _setupEnvironmentTexture;
  51793. /**
  51794. * Setup the background according to the specified options.
  51795. */
  51796. private _setupBackground;
  51797. /**
  51798. * Get the scene sizes according to the setup.
  51799. */
  51800. private _getSceneSize;
  51801. /**
  51802. * Setup the ground according to the specified options.
  51803. */
  51804. private _setupGround;
  51805. /**
  51806. * Setup the ground material according to the specified options.
  51807. */
  51808. private _setupGroundMaterial;
  51809. /**
  51810. * Setup the ground diffuse texture according to the specified options.
  51811. */
  51812. private _setupGroundDiffuseTexture;
  51813. /**
  51814. * Setup the ground mirror texture according to the specified options.
  51815. */
  51816. private _setupGroundMirrorTexture;
  51817. /**
  51818. * Setup the ground to receive the mirror texture.
  51819. */
  51820. private _setupMirrorInGroundMaterial;
  51821. /**
  51822. * Setup the skybox according to the specified options.
  51823. */
  51824. private _setupSkybox;
  51825. /**
  51826. * Setup the skybox material according to the specified options.
  51827. */
  51828. private _setupSkyboxMaterial;
  51829. /**
  51830. * Setup the skybox reflection texture according to the specified options.
  51831. */
  51832. private _setupSkyboxReflectionTexture;
  51833. private _errorHandler;
  51834. /**
  51835. * Dispose all the elements created by the Helper.
  51836. */
  51837. dispose(): void;
  51838. }
  51839. }
  51840. declare module "babylonjs/Helpers/photoDome" {
  51841. import { Observable } from "babylonjs/Misc/observable";
  51842. import { Nullable } from "babylonjs/types";
  51843. import { Scene } from "babylonjs/scene";
  51844. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51845. import { Mesh } from "babylonjs/Meshes/mesh";
  51846. import { Texture } from "babylonjs/Materials/Textures/texture";
  51847. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51848. import "babylonjs/Meshes/Builders/sphereBuilder";
  51849. /**
  51850. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51851. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51852. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51853. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51854. */
  51855. export class PhotoDome extends TransformNode {
  51856. /**
  51857. * Define the image as a Monoscopic panoramic 360 image.
  51858. */
  51859. static readonly MODE_MONOSCOPIC: number;
  51860. /**
  51861. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51862. */
  51863. static readonly MODE_TOPBOTTOM: number;
  51864. /**
  51865. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51866. */
  51867. static readonly MODE_SIDEBYSIDE: number;
  51868. private _useDirectMapping;
  51869. /**
  51870. * The texture being displayed on the sphere
  51871. */
  51872. protected _photoTexture: Texture;
  51873. /**
  51874. * Gets or sets the texture being displayed on the sphere
  51875. */
  51876. get photoTexture(): Texture;
  51877. set photoTexture(value: Texture);
  51878. /**
  51879. * Observable raised when an error occured while loading the 360 image
  51880. */
  51881. onLoadErrorObservable: Observable<string>;
  51882. /**
  51883. * The skybox material
  51884. */
  51885. protected _material: BackgroundMaterial;
  51886. /**
  51887. * The surface used for the skybox
  51888. */
  51889. protected _mesh: Mesh;
  51890. /**
  51891. * Gets the mesh used for the skybox.
  51892. */
  51893. get mesh(): Mesh;
  51894. /**
  51895. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51896. * Also see the options.resolution property.
  51897. */
  51898. get fovMultiplier(): number;
  51899. set fovMultiplier(value: number);
  51900. private _imageMode;
  51901. /**
  51902. * Gets or set the current video mode for the video. It can be:
  51903. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51904. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51905. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51906. */
  51907. get imageMode(): number;
  51908. set imageMode(value: number);
  51909. /**
  51910. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51911. * @param name Element's name, child elements will append suffixes for their own names.
  51912. * @param urlsOfPhoto defines the url of the photo to display
  51913. * @param options defines an object containing optional or exposed sub element properties
  51914. * @param onError defines a callback called when an error occured while loading the texture
  51915. */
  51916. constructor(name: string, urlOfPhoto: string, options: {
  51917. resolution?: number;
  51918. size?: number;
  51919. useDirectMapping?: boolean;
  51920. faceForward?: boolean;
  51921. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51922. private _onBeforeCameraRenderObserver;
  51923. private _changeImageMode;
  51924. /**
  51925. * Releases resources associated with this node.
  51926. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51927. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51928. */
  51929. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51930. }
  51931. }
  51932. declare module "babylonjs/Misc/rgbdTextureTools" {
  51933. import "babylonjs/Shaders/rgbdDecode.fragment";
  51934. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51935. import { Texture } from "babylonjs/Materials/Textures/texture";
  51936. /**
  51937. * Class used to host RGBD texture specific utilities
  51938. */
  51939. export class RGBDTextureTools {
  51940. /**
  51941. * Expand the RGBD Texture from RGBD to Half Float if possible.
  51942. * @param texture the texture to expand.
  51943. */
  51944. static ExpandRGBDTexture(texture: Texture): void;
  51945. }
  51946. }
  51947. declare module "babylonjs/Misc/brdfTextureTools" {
  51948. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51949. import { Scene } from "babylonjs/scene";
  51950. /**
  51951. * Class used to host texture specific utilities
  51952. */
  51953. export class BRDFTextureTools {
  51954. /**
  51955. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  51956. * @param scene defines the hosting scene
  51957. * @returns the environment BRDF texture
  51958. */
  51959. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  51960. private static _environmentBRDFBase64Texture;
  51961. }
  51962. }
  51963. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  51964. import { Nullable } from "babylonjs/types";
  51965. import { Color3 } from "babylonjs/Maths/math.color";
  51966. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51967. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51968. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51969. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51970. import { Engine } from "babylonjs/Engines/engine";
  51971. import { Scene } from "babylonjs/scene";
  51972. /**
  51973. * @hidden
  51974. */
  51975. export interface IMaterialClearCoatDefines {
  51976. CLEARCOAT: boolean;
  51977. CLEARCOAT_DEFAULTIOR: boolean;
  51978. CLEARCOAT_TEXTURE: boolean;
  51979. CLEARCOAT_TEXTUREDIRECTUV: number;
  51980. CLEARCOAT_BUMP: boolean;
  51981. CLEARCOAT_BUMPDIRECTUV: number;
  51982. CLEARCOAT_TINT: boolean;
  51983. CLEARCOAT_TINT_TEXTURE: boolean;
  51984. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51985. /** @hidden */
  51986. _areTexturesDirty: boolean;
  51987. }
  51988. /**
  51989. * Define the code related to the clear coat parameters of the pbr material.
  51990. */
  51991. export class PBRClearCoatConfiguration {
  51992. /**
  51993. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51994. * The default fits with a polyurethane material.
  51995. */
  51996. private static readonly _DefaultIndexOfRefraction;
  51997. private _isEnabled;
  51998. /**
  51999. * Defines if the clear coat is enabled in the material.
  52000. */
  52001. isEnabled: boolean;
  52002. /**
  52003. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52004. */
  52005. intensity: number;
  52006. /**
  52007. * Defines the clear coat layer roughness.
  52008. */
  52009. roughness: number;
  52010. private _indexOfRefraction;
  52011. /**
  52012. * Defines the index of refraction of the clear coat.
  52013. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52014. * The default fits with a polyurethane material.
  52015. * Changing the default value is more performance intensive.
  52016. */
  52017. indexOfRefraction: number;
  52018. private _texture;
  52019. /**
  52020. * Stores the clear coat values in a texture.
  52021. */
  52022. texture: Nullable<BaseTexture>;
  52023. private _bumpTexture;
  52024. /**
  52025. * Define the clear coat specific bump texture.
  52026. */
  52027. bumpTexture: Nullable<BaseTexture>;
  52028. private _isTintEnabled;
  52029. /**
  52030. * Defines if the clear coat tint is enabled in the material.
  52031. */
  52032. isTintEnabled: boolean;
  52033. /**
  52034. * Defines the clear coat tint of the material.
  52035. * This is only use if tint is enabled
  52036. */
  52037. tintColor: Color3;
  52038. /**
  52039. * Defines the distance at which the tint color should be found in the
  52040. * clear coat media.
  52041. * This is only use if tint is enabled
  52042. */
  52043. tintColorAtDistance: number;
  52044. /**
  52045. * Defines the clear coat layer thickness.
  52046. * This is only use if tint is enabled
  52047. */
  52048. tintThickness: number;
  52049. private _tintTexture;
  52050. /**
  52051. * Stores the clear tint values in a texture.
  52052. * rgb is tint
  52053. * a is a thickness factor
  52054. */
  52055. tintTexture: Nullable<BaseTexture>;
  52056. /** @hidden */
  52057. private _internalMarkAllSubMeshesAsTexturesDirty;
  52058. /** @hidden */
  52059. _markAllSubMeshesAsTexturesDirty(): void;
  52060. /**
  52061. * Instantiate a new istance of clear coat configuration.
  52062. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52063. */
  52064. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52065. /**
  52066. * Gets wehter the submesh is ready to be used or not.
  52067. * @param defines the list of "defines" to update.
  52068. * @param scene defines the scene the material belongs to.
  52069. * @param engine defines the engine the material belongs to.
  52070. * @param disableBumpMap defines wether the material disables bump or not.
  52071. * @returns - boolean indicating that the submesh is ready or not.
  52072. */
  52073. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52074. /**
  52075. * Checks to see if a texture is used in the material.
  52076. * @param defines the list of "defines" to update.
  52077. * @param scene defines the scene to the material belongs to.
  52078. */
  52079. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52080. /**
  52081. * Binds the material data.
  52082. * @param uniformBuffer defines the Uniform buffer to fill in.
  52083. * @param scene defines the scene the material belongs to.
  52084. * @param engine defines the engine the material belongs to.
  52085. * @param disableBumpMap defines wether the material disables bump or not.
  52086. * @param isFrozen defines wether the material is frozen or not.
  52087. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52088. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52089. */
  52090. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52091. /**
  52092. * Checks to see if a texture is used in the material.
  52093. * @param texture - Base texture to use.
  52094. * @returns - Boolean specifying if a texture is used in the material.
  52095. */
  52096. hasTexture(texture: BaseTexture): boolean;
  52097. /**
  52098. * Returns an array of the actively used textures.
  52099. * @param activeTextures Array of BaseTextures
  52100. */
  52101. getActiveTextures(activeTextures: BaseTexture[]): void;
  52102. /**
  52103. * Returns the animatable textures.
  52104. * @param animatables Array of animatable textures.
  52105. */
  52106. getAnimatables(animatables: IAnimatable[]): void;
  52107. /**
  52108. * Disposes the resources of the material.
  52109. * @param forceDisposeTextures - Forces the disposal of all textures.
  52110. */
  52111. dispose(forceDisposeTextures?: boolean): void;
  52112. /**
  52113. * Get the current class name of the texture useful for serialization or dynamic coding.
  52114. * @returns "PBRClearCoatConfiguration"
  52115. */
  52116. getClassName(): string;
  52117. /**
  52118. * Add fallbacks to the effect fallbacks list.
  52119. * @param defines defines the Base texture to use.
  52120. * @param fallbacks defines the current fallback list.
  52121. * @param currentRank defines the current fallback rank.
  52122. * @returns the new fallback rank.
  52123. */
  52124. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52125. /**
  52126. * Add the required uniforms to the current list.
  52127. * @param uniforms defines the current uniform list.
  52128. */
  52129. static AddUniforms(uniforms: string[]): void;
  52130. /**
  52131. * Add the required samplers to the current list.
  52132. * @param samplers defines the current sampler list.
  52133. */
  52134. static AddSamplers(samplers: string[]): void;
  52135. /**
  52136. * Add the required uniforms to the current buffer.
  52137. * @param uniformBuffer defines the current uniform buffer.
  52138. */
  52139. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52140. /**
  52141. * Makes a duplicate of the current configuration into another one.
  52142. * @param clearCoatConfiguration define the config where to copy the info
  52143. */
  52144. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52145. /**
  52146. * Serializes this clear coat configuration.
  52147. * @returns - An object with the serialized config.
  52148. */
  52149. serialize(): any;
  52150. /**
  52151. * Parses a anisotropy Configuration from a serialized object.
  52152. * @param source - Serialized object.
  52153. * @param scene Defines the scene we are parsing for
  52154. * @param rootUrl Defines the rootUrl to load from
  52155. */
  52156. parse(source: any, scene: Scene, rootUrl: string): void;
  52157. }
  52158. }
  52159. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52160. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52162. import { Vector2 } from "babylonjs/Maths/math.vector";
  52163. import { Scene } from "babylonjs/scene";
  52164. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52165. import { Nullable } from "babylonjs/types";
  52166. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52167. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52168. /**
  52169. * @hidden
  52170. */
  52171. export interface IMaterialAnisotropicDefines {
  52172. ANISOTROPIC: boolean;
  52173. ANISOTROPIC_TEXTURE: boolean;
  52174. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52175. MAINUV1: boolean;
  52176. _areTexturesDirty: boolean;
  52177. _needUVs: boolean;
  52178. }
  52179. /**
  52180. * Define the code related to the anisotropic parameters of the pbr material.
  52181. */
  52182. export class PBRAnisotropicConfiguration {
  52183. private _isEnabled;
  52184. /**
  52185. * Defines if the anisotropy is enabled in the material.
  52186. */
  52187. isEnabled: boolean;
  52188. /**
  52189. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52190. */
  52191. intensity: number;
  52192. /**
  52193. * Defines if the effect is along the tangents, bitangents or in between.
  52194. * By default, the effect is "strectching" the highlights along the tangents.
  52195. */
  52196. direction: Vector2;
  52197. private _texture;
  52198. /**
  52199. * Stores the anisotropy values in a texture.
  52200. * rg is direction (like normal from -1 to 1)
  52201. * b is a intensity
  52202. */
  52203. texture: Nullable<BaseTexture>;
  52204. /** @hidden */
  52205. private _internalMarkAllSubMeshesAsTexturesDirty;
  52206. /** @hidden */
  52207. _markAllSubMeshesAsTexturesDirty(): void;
  52208. /**
  52209. * Instantiate a new istance of anisotropy configuration.
  52210. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52211. */
  52212. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52213. /**
  52214. * Specifies that the submesh is ready to be used.
  52215. * @param defines the list of "defines" to update.
  52216. * @param scene defines the scene the material belongs to.
  52217. * @returns - boolean indicating that the submesh is ready or not.
  52218. */
  52219. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52220. /**
  52221. * Checks to see if a texture is used in the material.
  52222. * @param defines the list of "defines" to update.
  52223. * @param mesh the mesh we are preparing the defines for.
  52224. * @param scene defines the scene the material belongs to.
  52225. */
  52226. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52227. /**
  52228. * Binds the material data.
  52229. * @param uniformBuffer defines the Uniform buffer to fill in.
  52230. * @param scene defines the scene the material belongs to.
  52231. * @param isFrozen defines wether the material is frozen or not.
  52232. */
  52233. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52234. /**
  52235. * Checks to see if a texture is used in the material.
  52236. * @param texture - Base texture to use.
  52237. * @returns - Boolean specifying if a texture is used in the material.
  52238. */
  52239. hasTexture(texture: BaseTexture): boolean;
  52240. /**
  52241. * Returns an array of the actively used textures.
  52242. * @param activeTextures Array of BaseTextures
  52243. */
  52244. getActiveTextures(activeTextures: BaseTexture[]): void;
  52245. /**
  52246. * Returns the animatable textures.
  52247. * @param animatables Array of animatable textures.
  52248. */
  52249. getAnimatables(animatables: IAnimatable[]): void;
  52250. /**
  52251. * Disposes the resources of the material.
  52252. * @param forceDisposeTextures - Forces the disposal of all textures.
  52253. */
  52254. dispose(forceDisposeTextures?: boolean): void;
  52255. /**
  52256. * Get the current class name of the texture useful for serialization or dynamic coding.
  52257. * @returns "PBRAnisotropicConfiguration"
  52258. */
  52259. getClassName(): string;
  52260. /**
  52261. * Add fallbacks to the effect fallbacks list.
  52262. * @param defines defines the Base texture to use.
  52263. * @param fallbacks defines the current fallback list.
  52264. * @param currentRank defines the current fallback rank.
  52265. * @returns the new fallback rank.
  52266. */
  52267. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52268. /**
  52269. * Add the required uniforms to the current list.
  52270. * @param uniforms defines the current uniform list.
  52271. */
  52272. static AddUniforms(uniforms: string[]): void;
  52273. /**
  52274. * Add the required uniforms to the current buffer.
  52275. * @param uniformBuffer defines the current uniform buffer.
  52276. */
  52277. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52278. /**
  52279. * Add the required samplers to the current list.
  52280. * @param samplers defines the current sampler list.
  52281. */
  52282. static AddSamplers(samplers: string[]): void;
  52283. /**
  52284. * Makes a duplicate of the current configuration into another one.
  52285. * @param anisotropicConfiguration define the config where to copy the info
  52286. */
  52287. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52288. /**
  52289. * Serializes this anisotropy configuration.
  52290. * @returns - An object with the serialized config.
  52291. */
  52292. serialize(): any;
  52293. /**
  52294. * Parses a anisotropy Configuration from a serialized object.
  52295. * @param source - Serialized object.
  52296. * @param scene Defines the scene we are parsing for
  52297. * @param rootUrl Defines the rootUrl to load from
  52298. */
  52299. parse(source: any, scene: Scene, rootUrl: string): void;
  52300. }
  52301. }
  52302. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52303. import { Scene } from "babylonjs/scene";
  52304. /**
  52305. * @hidden
  52306. */
  52307. export interface IMaterialBRDFDefines {
  52308. BRDF_V_HEIGHT_CORRELATED: boolean;
  52309. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52310. SPHERICAL_HARMONICS: boolean;
  52311. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52312. /** @hidden */
  52313. _areMiscDirty: boolean;
  52314. }
  52315. /**
  52316. * Define the code related to the BRDF parameters of the pbr material.
  52317. */
  52318. export class PBRBRDFConfiguration {
  52319. /**
  52320. * Default value used for the energy conservation.
  52321. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52322. */
  52323. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52324. /**
  52325. * Default value used for the Smith Visibility Height Correlated mode.
  52326. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52327. */
  52328. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52329. /**
  52330. * Default value used for the IBL diffuse part.
  52331. * This can help switching back to the polynomials mode globally which is a tiny bit
  52332. * less GPU intensive at the drawback of a lower quality.
  52333. */
  52334. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52335. /**
  52336. * Default value used for activating energy conservation for the specular workflow.
  52337. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52338. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52339. */
  52340. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52341. private _useEnergyConservation;
  52342. /**
  52343. * Defines if the material uses energy conservation.
  52344. */
  52345. useEnergyConservation: boolean;
  52346. private _useSmithVisibilityHeightCorrelated;
  52347. /**
  52348. * LEGACY Mode set to false
  52349. * Defines if the material uses height smith correlated visibility term.
  52350. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52351. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52352. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52353. * Not relying on height correlated will also disable energy conservation.
  52354. */
  52355. useSmithVisibilityHeightCorrelated: boolean;
  52356. private _useSphericalHarmonics;
  52357. /**
  52358. * LEGACY Mode set to false
  52359. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52360. * diffuse part of the IBL.
  52361. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52362. * to the ground truth.
  52363. */
  52364. useSphericalHarmonics: boolean;
  52365. private _useSpecularGlossinessInputEnergyConservation;
  52366. /**
  52367. * Defines if the material uses energy conservation, when the specular workflow is active.
  52368. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52369. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52370. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52371. */
  52372. useSpecularGlossinessInputEnergyConservation: boolean;
  52373. /** @hidden */
  52374. private _internalMarkAllSubMeshesAsMiscDirty;
  52375. /** @hidden */
  52376. _markAllSubMeshesAsMiscDirty(): void;
  52377. /**
  52378. * Instantiate a new istance of clear coat configuration.
  52379. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52380. */
  52381. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52382. /**
  52383. * Checks to see if a texture is used in the material.
  52384. * @param defines the list of "defines" to update.
  52385. */
  52386. prepareDefines(defines: IMaterialBRDFDefines): void;
  52387. /**
  52388. * Get the current class name of the texture useful for serialization or dynamic coding.
  52389. * @returns "PBRClearCoatConfiguration"
  52390. */
  52391. getClassName(): string;
  52392. /**
  52393. * Makes a duplicate of the current configuration into another one.
  52394. * @param brdfConfiguration define the config where to copy the info
  52395. */
  52396. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52397. /**
  52398. * Serializes this BRDF configuration.
  52399. * @returns - An object with the serialized config.
  52400. */
  52401. serialize(): any;
  52402. /**
  52403. * Parses a anisotropy Configuration from a serialized object.
  52404. * @param source - Serialized object.
  52405. * @param scene Defines the scene we are parsing for
  52406. * @param rootUrl Defines the rootUrl to load from
  52407. */
  52408. parse(source: any, scene: Scene, rootUrl: string): void;
  52409. }
  52410. }
  52411. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52412. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52413. import { Color3 } from "babylonjs/Maths/math.color";
  52414. import { Scene } from "babylonjs/scene";
  52415. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52416. import { Nullable } from "babylonjs/types";
  52417. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52418. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52419. /**
  52420. * @hidden
  52421. */
  52422. export interface IMaterialSheenDefines {
  52423. SHEEN: boolean;
  52424. SHEEN_TEXTURE: boolean;
  52425. SHEEN_TEXTUREDIRECTUV: number;
  52426. SHEEN_LINKWITHALBEDO: boolean;
  52427. /** @hidden */
  52428. _areTexturesDirty: boolean;
  52429. }
  52430. /**
  52431. * Define the code related to the Sheen parameters of the pbr material.
  52432. */
  52433. export class PBRSheenConfiguration {
  52434. private _isEnabled;
  52435. /**
  52436. * Defines if the material uses sheen.
  52437. */
  52438. isEnabled: boolean;
  52439. private _linkSheenWithAlbedo;
  52440. /**
  52441. * Defines if the sheen is linked to the sheen color.
  52442. */
  52443. linkSheenWithAlbedo: boolean;
  52444. /**
  52445. * Defines the sheen intensity.
  52446. */
  52447. intensity: number;
  52448. /**
  52449. * Defines the sheen color.
  52450. */
  52451. color: Color3;
  52452. private _texture;
  52453. /**
  52454. * Stores the sheen tint values in a texture.
  52455. * rgb is tint
  52456. * a is a intensity
  52457. */
  52458. texture: Nullable<BaseTexture>;
  52459. /** @hidden */
  52460. private _internalMarkAllSubMeshesAsTexturesDirty;
  52461. /** @hidden */
  52462. _markAllSubMeshesAsTexturesDirty(): void;
  52463. /**
  52464. * Instantiate a new istance of clear coat configuration.
  52465. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52466. */
  52467. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52468. /**
  52469. * Specifies that the submesh is ready to be used.
  52470. * @param defines the list of "defines" to update.
  52471. * @param scene defines the scene the material belongs to.
  52472. * @returns - boolean indicating that the submesh is ready or not.
  52473. */
  52474. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52475. /**
  52476. * Checks to see if a texture is used in the material.
  52477. * @param defines the list of "defines" to update.
  52478. * @param scene defines the scene the material belongs to.
  52479. */
  52480. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52481. /**
  52482. * Binds the material data.
  52483. * @param uniformBuffer defines the Uniform buffer to fill in.
  52484. * @param scene defines the scene the material belongs to.
  52485. * @param isFrozen defines wether the material is frozen or not.
  52486. */
  52487. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52488. /**
  52489. * Checks to see if a texture is used in the material.
  52490. * @param texture - Base texture to use.
  52491. * @returns - Boolean specifying if a texture is used in the material.
  52492. */
  52493. hasTexture(texture: BaseTexture): boolean;
  52494. /**
  52495. * Returns an array of the actively used textures.
  52496. * @param activeTextures Array of BaseTextures
  52497. */
  52498. getActiveTextures(activeTextures: BaseTexture[]): void;
  52499. /**
  52500. * Returns the animatable textures.
  52501. * @param animatables Array of animatable textures.
  52502. */
  52503. getAnimatables(animatables: IAnimatable[]): void;
  52504. /**
  52505. * Disposes the resources of the material.
  52506. * @param forceDisposeTextures - Forces the disposal of all textures.
  52507. */
  52508. dispose(forceDisposeTextures?: boolean): void;
  52509. /**
  52510. * Get the current class name of the texture useful for serialization or dynamic coding.
  52511. * @returns "PBRSheenConfiguration"
  52512. */
  52513. getClassName(): string;
  52514. /**
  52515. * Add fallbacks to the effect fallbacks list.
  52516. * @param defines defines the Base texture to use.
  52517. * @param fallbacks defines the current fallback list.
  52518. * @param currentRank defines the current fallback rank.
  52519. * @returns the new fallback rank.
  52520. */
  52521. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52522. /**
  52523. * Add the required uniforms to the current list.
  52524. * @param uniforms defines the current uniform list.
  52525. */
  52526. static AddUniforms(uniforms: string[]): void;
  52527. /**
  52528. * Add the required uniforms to the current buffer.
  52529. * @param uniformBuffer defines the current uniform buffer.
  52530. */
  52531. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52532. /**
  52533. * Add the required samplers to the current list.
  52534. * @param samplers defines the current sampler list.
  52535. */
  52536. static AddSamplers(samplers: string[]): void;
  52537. /**
  52538. * Makes a duplicate of the current configuration into another one.
  52539. * @param sheenConfiguration define the config where to copy the info
  52540. */
  52541. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52542. /**
  52543. * Serializes this BRDF configuration.
  52544. * @returns - An object with the serialized config.
  52545. */
  52546. serialize(): any;
  52547. /**
  52548. * Parses a anisotropy Configuration from a serialized object.
  52549. * @param source - Serialized object.
  52550. * @param scene Defines the scene we are parsing for
  52551. * @param rootUrl Defines the rootUrl to load from
  52552. */
  52553. parse(source: any, scene: Scene, rootUrl: string): void;
  52554. }
  52555. }
  52556. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52557. import { Nullable } from "babylonjs/types";
  52558. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52559. import { Color3 } from "babylonjs/Maths/math.color";
  52560. import { SmartArray } from "babylonjs/Misc/smartArray";
  52561. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52562. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52563. import { Effect } from "babylonjs/Materials/effect";
  52564. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52565. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52566. import { Engine } from "babylonjs/Engines/engine";
  52567. import { Scene } from "babylonjs/scene";
  52568. /**
  52569. * @hidden
  52570. */
  52571. export interface IMaterialSubSurfaceDefines {
  52572. SUBSURFACE: boolean;
  52573. SS_REFRACTION: boolean;
  52574. SS_TRANSLUCENCY: boolean;
  52575. SS_SCATERRING: boolean;
  52576. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52577. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52578. SS_REFRACTIONMAP_3D: boolean;
  52579. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52580. SS_LODINREFRACTIONALPHA: boolean;
  52581. SS_GAMMAREFRACTION: boolean;
  52582. SS_RGBDREFRACTION: boolean;
  52583. SS_LINEARSPECULARREFRACTION: boolean;
  52584. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52585. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52586. /** @hidden */
  52587. _areTexturesDirty: boolean;
  52588. }
  52589. /**
  52590. * Define the code related to the sub surface parameters of the pbr material.
  52591. */
  52592. export class PBRSubSurfaceConfiguration {
  52593. private _isRefractionEnabled;
  52594. /**
  52595. * Defines if the refraction is enabled in the material.
  52596. */
  52597. isRefractionEnabled: boolean;
  52598. private _isTranslucencyEnabled;
  52599. /**
  52600. * Defines if the translucency is enabled in the material.
  52601. */
  52602. isTranslucencyEnabled: boolean;
  52603. private _isScatteringEnabled;
  52604. /**
  52605. * Defines the refraction intensity of the material.
  52606. * The refraction when enabled replaces the Diffuse part of the material.
  52607. * The intensity helps transitionning between diffuse and refraction.
  52608. */
  52609. refractionIntensity: number;
  52610. /**
  52611. * Defines the translucency intensity of the material.
  52612. * When translucency has been enabled, this defines how much of the "translucency"
  52613. * is addded to the diffuse part of the material.
  52614. */
  52615. translucencyIntensity: number;
  52616. /**
  52617. * Defines the scattering intensity of the material.
  52618. * When scattering has been enabled, this defines how much of the "scattered light"
  52619. * is addded to the diffuse part of the material.
  52620. */
  52621. scatteringIntensity: number;
  52622. private _thicknessTexture;
  52623. /**
  52624. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52625. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52626. * 0 would mean minimumThickness
  52627. * 1 would mean maximumThickness
  52628. * The other channels might be use as a mask to vary the different effects intensity.
  52629. */
  52630. thicknessTexture: Nullable<BaseTexture>;
  52631. private _refractionTexture;
  52632. /**
  52633. * Defines the texture to use for refraction.
  52634. */
  52635. refractionTexture: Nullable<BaseTexture>;
  52636. private _indexOfRefraction;
  52637. /**
  52638. * Defines the index of refraction used in the material.
  52639. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52640. */
  52641. indexOfRefraction: number;
  52642. private _invertRefractionY;
  52643. /**
  52644. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52645. */
  52646. invertRefractionY: boolean;
  52647. private _linkRefractionWithTransparency;
  52648. /**
  52649. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52650. * Materials half opaque for instance using refraction could benefit from this control.
  52651. */
  52652. linkRefractionWithTransparency: boolean;
  52653. /**
  52654. * Defines the minimum thickness stored in the thickness map.
  52655. * If no thickness map is defined, this value will be used to simulate thickness.
  52656. */
  52657. minimumThickness: number;
  52658. /**
  52659. * Defines the maximum thickness stored in the thickness map.
  52660. */
  52661. maximumThickness: number;
  52662. /**
  52663. * Defines the volume tint of the material.
  52664. * This is used for both translucency and scattering.
  52665. */
  52666. tintColor: Color3;
  52667. /**
  52668. * Defines the distance at which the tint color should be found in the media.
  52669. * This is used for refraction only.
  52670. */
  52671. tintColorAtDistance: number;
  52672. /**
  52673. * Defines how far each channel transmit through the media.
  52674. * It is defined as a color to simplify it selection.
  52675. */
  52676. diffusionDistance: Color3;
  52677. private _useMaskFromThicknessTexture;
  52678. /**
  52679. * Stores the intensity of the different subsurface effects in the thickness texture.
  52680. * * the green channel is the translucency intensity.
  52681. * * the blue channel is the scattering intensity.
  52682. * * the alpha channel is the refraction intensity.
  52683. */
  52684. useMaskFromThicknessTexture: boolean;
  52685. /** @hidden */
  52686. private _internalMarkAllSubMeshesAsTexturesDirty;
  52687. /** @hidden */
  52688. _markAllSubMeshesAsTexturesDirty(): void;
  52689. /**
  52690. * Instantiate a new istance of sub surface configuration.
  52691. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52692. */
  52693. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52694. /**
  52695. * Gets wehter the submesh is ready to be used or not.
  52696. * @param defines the list of "defines" to update.
  52697. * @param scene defines the scene the material belongs to.
  52698. * @returns - boolean indicating that the submesh is ready or not.
  52699. */
  52700. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52701. /**
  52702. * Checks to see if a texture is used in the material.
  52703. * @param defines the list of "defines" to update.
  52704. * @param scene defines the scene to the material belongs to.
  52705. */
  52706. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52707. /**
  52708. * Binds the material data.
  52709. * @param uniformBuffer defines the Uniform buffer to fill in.
  52710. * @param scene defines the scene the material belongs to.
  52711. * @param engine defines the engine the material belongs to.
  52712. * @param isFrozen defines wether the material is frozen or not.
  52713. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52714. */
  52715. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52716. /**
  52717. * Unbinds the material from the mesh.
  52718. * @param activeEffect defines the effect that should be unbound from.
  52719. * @returns true if unbound, otherwise false
  52720. */
  52721. unbind(activeEffect: Effect): boolean;
  52722. /**
  52723. * Returns the texture used for refraction or null if none is used.
  52724. * @param scene defines the scene the material belongs to.
  52725. * @returns - Refraction texture if present. If no refraction texture and refraction
  52726. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52727. */
  52728. private _getRefractionTexture;
  52729. /**
  52730. * Returns true if alpha blending should be disabled.
  52731. */
  52732. get disableAlphaBlending(): boolean;
  52733. /**
  52734. * Fills the list of render target textures.
  52735. * @param renderTargets the list of render targets to update
  52736. */
  52737. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52738. /**
  52739. * Checks to see if a texture is used in the material.
  52740. * @param texture - Base texture to use.
  52741. * @returns - Boolean specifying if a texture is used in the material.
  52742. */
  52743. hasTexture(texture: BaseTexture): boolean;
  52744. /**
  52745. * Gets a boolean indicating that current material needs to register RTT
  52746. * @returns true if this uses a render target otherwise false.
  52747. */
  52748. hasRenderTargetTextures(): boolean;
  52749. /**
  52750. * Returns an array of the actively used textures.
  52751. * @param activeTextures Array of BaseTextures
  52752. */
  52753. getActiveTextures(activeTextures: BaseTexture[]): void;
  52754. /**
  52755. * Returns the animatable textures.
  52756. * @param animatables Array of animatable textures.
  52757. */
  52758. getAnimatables(animatables: IAnimatable[]): void;
  52759. /**
  52760. * Disposes the resources of the material.
  52761. * @param forceDisposeTextures - Forces the disposal of all textures.
  52762. */
  52763. dispose(forceDisposeTextures?: boolean): void;
  52764. /**
  52765. * Get the current class name of the texture useful for serialization or dynamic coding.
  52766. * @returns "PBRSubSurfaceConfiguration"
  52767. */
  52768. getClassName(): string;
  52769. /**
  52770. * Add fallbacks to the effect fallbacks list.
  52771. * @param defines defines the Base texture to use.
  52772. * @param fallbacks defines the current fallback list.
  52773. * @param currentRank defines the current fallback rank.
  52774. * @returns the new fallback rank.
  52775. */
  52776. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52777. /**
  52778. * Add the required uniforms to the current list.
  52779. * @param uniforms defines the current uniform list.
  52780. */
  52781. static AddUniforms(uniforms: string[]): void;
  52782. /**
  52783. * Add the required samplers to the current list.
  52784. * @param samplers defines the current sampler list.
  52785. */
  52786. static AddSamplers(samplers: string[]): void;
  52787. /**
  52788. * Add the required uniforms to the current buffer.
  52789. * @param uniformBuffer defines the current uniform buffer.
  52790. */
  52791. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52792. /**
  52793. * Makes a duplicate of the current configuration into another one.
  52794. * @param configuration define the config where to copy the info
  52795. */
  52796. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52797. /**
  52798. * Serializes this Sub Surface configuration.
  52799. * @returns - An object with the serialized config.
  52800. */
  52801. serialize(): any;
  52802. /**
  52803. * Parses a anisotropy Configuration from a serialized object.
  52804. * @param source - Serialized object.
  52805. * @param scene Defines the scene we are parsing for
  52806. * @param rootUrl Defines the rootUrl to load from
  52807. */
  52808. parse(source: any, scene: Scene, rootUrl: string): void;
  52809. }
  52810. }
  52811. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52812. /** @hidden */
  52813. export var pbrFragmentDeclaration: {
  52814. name: string;
  52815. shader: string;
  52816. };
  52817. }
  52818. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52819. /** @hidden */
  52820. export var pbrUboDeclaration: {
  52821. name: string;
  52822. shader: string;
  52823. };
  52824. }
  52825. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52826. /** @hidden */
  52827. export var pbrFragmentExtraDeclaration: {
  52828. name: string;
  52829. shader: string;
  52830. };
  52831. }
  52832. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52833. /** @hidden */
  52834. export var pbrFragmentSamplersDeclaration: {
  52835. name: string;
  52836. shader: string;
  52837. };
  52838. }
  52839. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52840. /** @hidden */
  52841. export var pbrHelperFunctions: {
  52842. name: string;
  52843. shader: string;
  52844. };
  52845. }
  52846. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52847. /** @hidden */
  52848. export var harmonicsFunctions: {
  52849. name: string;
  52850. shader: string;
  52851. };
  52852. }
  52853. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52854. /** @hidden */
  52855. export var pbrDirectLightingSetupFunctions: {
  52856. name: string;
  52857. shader: string;
  52858. };
  52859. }
  52860. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52861. /** @hidden */
  52862. export var pbrDirectLightingFalloffFunctions: {
  52863. name: string;
  52864. shader: string;
  52865. };
  52866. }
  52867. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52868. /** @hidden */
  52869. export var pbrBRDFFunctions: {
  52870. name: string;
  52871. shader: string;
  52872. };
  52873. }
  52874. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52875. /** @hidden */
  52876. export var pbrDirectLightingFunctions: {
  52877. name: string;
  52878. shader: string;
  52879. };
  52880. }
  52881. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52882. /** @hidden */
  52883. export var pbrIBLFunctions: {
  52884. name: string;
  52885. shader: string;
  52886. };
  52887. }
  52888. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52889. /** @hidden */
  52890. export var pbrDebug: {
  52891. name: string;
  52892. shader: string;
  52893. };
  52894. }
  52895. declare module "babylonjs/Shaders/pbr.fragment" {
  52896. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52897. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52898. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52899. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52900. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52901. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52902. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52903. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52904. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52905. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52906. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52907. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52908. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52909. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52910. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52911. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52912. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52913. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52914. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52915. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52916. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52917. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52918. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52919. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52920. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52921. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52922. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52923. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52924. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  52925. /** @hidden */
  52926. export var pbrPixelShader: {
  52927. name: string;
  52928. shader: string;
  52929. };
  52930. }
  52931. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  52932. /** @hidden */
  52933. export var pbrVertexDeclaration: {
  52934. name: string;
  52935. shader: string;
  52936. };
  52937. }
  52938. declare module "babylonjs/Shaders/pbr.vertex" {
  52939. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  52940. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52941. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52942. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52943. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52944. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52945. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  52946. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  52947. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  52948. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52949. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52950. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52951. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52952. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52953. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52954. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52955. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52956. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  52957. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52958. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  52959. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  52960. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  52961. /** @hidden */
  52962. export var pbrVertexShader: {
  52963. name: string;
  52964. shader: string;
  52965. };
  52966. }
  52967. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  52968. import { Nullable } from "babylonjs/types";
  52969. import { Scene } from "babylonjs/scene";
  52970. import { Matrix } from "babylonjs/Maths/math.vector";
  52971. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52973. import { Mesh } from "babylonjs/Meshes/mesh";
  52974. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  52975. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  52976. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  52977. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  52978. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  52979. import { Color3 } from "babylonjs/Maths/math.color";
  52980. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52981. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  52982. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52983. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52984. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52985. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52986. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52987. import "babylonjs/Shaders/pbr.fragment";
  52988. import "babylonjs/Shaders/pbr.vertex";
  52989. /**
  52990. * Manages the defines for the PBR Material.
  52991. * @hidden
  52992. */
  52993. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  52994. PBR: boolean;
  52995. MAINUV1: boolean;
  52996. MAINUV2: boolean;
  52997. UV1: boolean;
  52998. UV2: boolean;
  52999. ALBEDO: boolean;
  53000. GAMMAALBEDO: boolean;
  53001. ALBEDODIRECTUV: number;
  53002. VERTEXCOLOR: boolean;
  53003. AMBIENT: boolean;
  53004. AMBIENTDIRECTUV: number;
  53005. AMBIENTINGRAYSCALE: boolean;
  53006. OPACITY: boolean;
  53007. VERTEXALPHA: boolean;
  53008. OPACITYDIRECTUV: number;
  53009. OPACITYRGB: boolean;
  53010. ALPHATEST: boolean;
  53011. DEPTHPREPASS: boolean;
  53012. ALPHABLEND: boolean;
  53013. ALPHAFROMALBEDO: boolean;
  53014. ALPHATESTVALUE: string;
  53015. SPECULAROVERALPHA: boolean;
  53016. RADIANCEOVERALPHA: boolean;
  53017. ALPHAFRESNEL: boolean;
  53018. LINEARALPHAFRESNEL: boolean;
  53019. PREMULTIPLYALPHA: boolean;
  53020. EMISSIVE: boolean;
  53021. EMISSIVEDIRECTUV: number;
  53022. REFLECTIVITY: boolean;
  53023. REFLECTIVITYDIRECTUV: number;
  53024. SPECULARTERM: boolean;
  53025. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53026. MICROSURFACEAUTOMATIC: boolean;
  53027. LODBASEDMICROSFURACE: boolean;
  53028. MICROSURFACEMAP: boolean;
  53029. MICROSURFACEMAPDIRECTUV: number;
  53030. METALLICWORKFLOW: boolean;
  53031. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53032. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53033. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53034. AOSTOREINMETALMAPRED: boolean;
  53035. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53036. ENVIRONMENTBRDF: boolean;
  53037. ENVIRONMENTBRDF_RGBD: boolean;
  53038. NORMAL: boolean;
  53039. TANGENT: boolean;
  53040. BUMP: boolean;
  53041. BUMPDIRECTUV: number;
  53042. OBJECTSPACE_NORMALMAP: boolean;
  53043. PARALLAX: boolean;
  53044. PARALLAXOCCLUSION: boolean;
  53045. NORMALXYSCALE: boolean;
  53046. LIGHTMAP: boolean;
  53047. LIGHTMAPDIRECTUV: number;
  53048. USELIGHTMAPASSHADOWMAP: boolean;
  53049. GAMMALIGHTMAP: boolean;
  53050. RGBDLIGHTMAP: boolean;
  53051. REFLECTION: boolean;
  53052. REFLECTIONMAP_3D: boolean;
  53053. REFLECTIONMAP_SPHERICAL: boolean;
  53054. REFLECTIONMAP_PLANAR: boolean;
  53055. REFLECTIONMAP_CUBIC: boolean;
  53056. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53057. REFLECTIONMAP_PROJECTION: boolean;
  53058. REFLECTIONMAP_SKYBOX: boolean;
  53059. REFLECTIONMAP_EXPLICIT: boolean;
  53060. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53061. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53062. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53063. INVERTCUBICMAP: boolean;
  53064. USESPHERICALFROMREFLECTIONMAP: boolean;
  53065. USEIRRADIANCEMAP: boolean;
  53066. SPHERICAL_HARMONICS: boolean;
  53067. USESPHERICALINVERTEX: boolean;
  53068. REFLECTIONMAP_OPPOSITEZ: boolean;
  53069. LODINREFLECTIONALPHA: boolean;
  53070. GAMMAREFLECTION: boolean;
  53071. RGBDREFLECTION: boolean;
  53072. LINEARSPECULARREFLECTION: boolean;
  53073. RADIANCEOCCLUSION: boolean;
  53074. HORIZONOCCLUSION: boolean;
  53075. INSTANCES: boolean;
  53076. NUM_BONE_INFLUENCERS: number;
  53077. BonesPerMesh: number;
  53078. BONETEXTURE: boolean;
  53079. NONUNIFORMSCALING: boolean;
  53080. MORPHTARGETS: boolean;
  53081. MORPHTARGETS_NORMAL: boolean;
  53082. MORPHTARGETS_TANGENT: boolean;
  53083. MORPHTARGETS_UV: boolean;
  53084. NUM_MORPH_INFLUENCERS: number;
  53085. IMAGEPROCESSING: boolean;
  53086. VIGNETTE: boolean;
  53087. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53088. VIGNETTEBLENDMODEOPAQUE: boolean;
  53089. TONEMAPPING: boolean;
  53090. TONEMAPPING_ACES: boolean;
  53091. CONTRAST: boolean;
  53092. COLORCURVES: boolean;
  53093. COLORGRADING: boolean;
  53094. COLORGRADING3D: boolean;
  53095. SAMPLER3DGREENDEPTH: boolean;
  53096. SAMPLER3DBGRMAP: boolean;
  53097. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53098. EXPOSURE: boolean;
  53099. MULTIVIEW: boolean;
  53100. USEPHYSICALLIGHTFALLOFF: boolean;
  53101. USEGLTFLIGHTFALLOFF: boolean;
  53102. TWOSIDEDLIGHTING: boolean;
  53103. SHADOWFLOAT: boolean;
  53104. CLIPPLANE: boolean;
  53105. CLIPPLANE2: boolean;
  53106. CLIPPLANE3: boolean;
  53107. CLIPPLANE4: boolean;
  53108. CLIPPLANE5: boolean;
  53109. CLIPPLANE6: boolean;
  53110. POINTSIZE: boolean;
  53111. FOG: boolean;
  53112. LOGARITHMICDEPTH: boolean;
  53113. FORCENORMALFORWARD: boolean;
  53114. SPECULARAA: boolean;
  53115. CLEARCOAT: boolean;
  53116. CLEARCOAT_DEFAULTIOR: boolean;
  53117. CLEARCOAT_TEXTURE: boolean;
  53118. CLEARCOAT_TEXTUREDIRECTUV: number;
  53119. CLEARCOAT_BUMP: boolean;
  53120. CLEARCOAT_BUMPDIRECTUV: number;
  53121. CLEARCOAT_TINT: boolean;
  53122. CLEARCOAT_TINT_TEXTURE: boolean;
  53123. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53124. ANISOTROPIC: boolean;
  53125. ANISOTROPIC_TEXTURE: boolean;
  53126. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53127. BRDF_V_HEIGHT_CORRELATED: boolean;
  53128. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53129. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53130. SHEEN: boolean;
  53131. SHEEN_TEXTURE: boolean;
  53132. SHEEN_TEXTUREDIRECTUV: number;
  53133. SHEEN_LINKWITHALBEDO: boolean;
  53134. SUBSURFACE: boolean;
  53135. SS_REFRACTION: boolean;
  53136. SS_TRANSLUCENCY: boolean;
  53137. SS_SCATERRING: boolean;
  53138. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53139. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53140. SS_REFRACTIONMAP_3D: boolean;
  53141. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53142. SS_LODINREFRACTIONALPHA: boolean;
  53143. SS_GAMMAREFRACTION: boolean;
  53144. SS_RGBDREFRACTION: boolean;
  53145. SS_LINEARSPECULARREFRACTION: boolean;
  53146. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53147. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53148. UNLIT: boolean;
  53149. DEBUGMODE: number;
  53150. /**
  53151. * Initializes the PBR Material defines.
  53152. */
  53153. constructor();
  53154. /**
  53155. * Resets the PBR Material defines.
  53156. */
  53157. reset(): void;
  53158. }
  53159. /**
  53160. * The Physically based material base class of BJS.
  53161. *
  53162. * This offers the main features of a standard PBR material.
  53163. * For more information, please refer to the documentation :
  53164. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53165. */
  53166. export abstract class PBRBaseMaterial extends PushMaterial {
  53167. /**
  53168. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53169. */
  53170. static readonly PBRMATERIAL_OPAQUE: number;
  53171. /**
  53172. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53173. */
  53174. static readonly PBRMATERIAL_ALPHATEST: number;
  53175. /**
  53176. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53177. */
  53178. static readonly PBRMATERIAL_ALPHABLEND: number;
  53179. /**
  53180. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53181. * They are also discarded below the alpha cutoff threshold to improve performances.
  53182. */
  53183. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53184. /**
  53185. * Defines the default value of how much AO map is occluding the analytical lights
  53186. * (point spot...).
  53187. */
  53188. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53189. /**
  53190. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53191. */
  53192. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53193. /**
  53194. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53195. * to enhance interoperability with other engines.
  53196. */
  53197. static readonly LIGHTFALLOFF_GLTF: number;
  53198. /**
  53199. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53200. * to enhance interoperability with other materials.
  53201. */
  53202. static readonly LIGHTFALLOFF_STANDARD: number;
  53203. /**
  53204. * Intensity of the direct lights e.g. the four lights available in your scene.
  53205. * This impacts both the direct diffuse and specular highlights.
  53206. */
  53207. protected _directIntensity: number;
  53208. /**
  53209. * Intensity of the emissive part of the material.
  53210. * This helps controlling the emissive effect without modifying the emissive color.
  53211. */
  53212. protected _emissiveIntensity: number;
  53213. /**
  53214. * Intensity of the environment e.g. how much the environment will light the object
  53215. * either through harmonics for rough material or through the refelction for shiny ones.
  53216. */
  53217. protected _environmentIntensity: number;
  53218. /**
  53219. * This is a special control allowing the reduction of the specular highlights coming from the
  53220. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53221. */
  53222. protected _specularIntensity: number;
  53223. /**
  53224. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53225. */
  53226. private _lightingInfos;
  53227. /**
  53228. * Debug Control allowing disabling the bump map on this material.
  53229. */
  53230. protected _disableBumpMap: boolean;
  53231. /**
  53232. * AKA Diffuse Texture in standard nomenclature.
  53233. */
  53234. protected _albedoTexture: Nullable<BaseTexture>;
  53235. /**
  53236. * AKA Occlusion Texture in other nomenclature.
  53237. */
  53238. protected _ambientTexture: Nullable<BaseTexture>;
  53239. /**
  53240. * AKA Occlusion Texture Intensity in other nomenclature.
  53241. */
  53242. protected _ambientTextureStrength: number;
  53243. /**
  53244. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53245. * 1 means it completely occludes it
  53246. * 0 mean it has no impact
  53247. */
  53248. protected _ambientTextureImpactOnAnalyticalLights: number;
  53249. /**
  53250. * Stores the alpha values in a texture.
  53251. */
  53252. protected _opacityTexture: Nullable<BaseTexture>;
  53253. /**
  53254. * Stores the reflection values in a texture.
  53255. */
  53256. protected _reflectionTexture: Nullable<BaseTexture>;
  53257. /**
  53258. * Stores the emissive values in a texture.
  53259. */
  53260. protected _emissiveTexture: Nullable<BaseTexture>;
  53261. /**
  53262. * AKA Specular texture in other nomenclature.
  53263. */
  53264. protected _reflectivityTexture: Nullable<BaseTexture>;
  53265. /**
  53266. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53267. */
  53268. protected _metallicTexture: Nullable<BaseTexture>;
  53269. /**
  53270. * Specifies the metallic scalar of the metallic/roughness workflow.
  53271. * Can also be used to scale the metalness values of the metallic texture.
  53272. */
  53273. protected _metallic: Nullable<number>;
  53274. /**
  53275. * Specifies the roughness scalar of the metallic/roughness workflow.
  53276. * Can also be used to scale the roughness values of the metallic texture.
  53277. */
  53278. protected _roughness: Nullable<number>;
  53279. /**
  53280. * Specifies the an F0 factor to help configuring the material F0.
  53281. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53282. * to 0.5 the previously hard coded value stays the same.
  53283. * Can also be used to scale the F0 values of the metallic texture.
  53284. */
  53285. protected _metallicF0Factor: number;
  53286. /**
  53287. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53288. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53289. * your expectation as it multiplies with the texture data.
  53290. */
  53291. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53292. /**
  53293. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53294. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53295. */
  53296. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53297. /**
  53298. * Stores surface normal data used to displace a mesh in a texture.
  53299. */
  53300. protected _bumpTexture: Nullable<BaseTexture>;
  53301. /**
  53302. * Stores the pre-calculated light information of a mesh in a texture.
  53303. */
  53304. protected _lightmapTexture: Nullable<BaseTexture>;
  53305. /**
  53306. * The color of a material in ambient lighting.
  53307. */
  53308. protected _ambientColor: Color3;
  53309. /**
  53310. * AKA Diffuse Color in other nomenclature.
  53311. */
  53312. protected _albedoColor: Color3;
  53313. /**
  53314. * AKA Specular Color in other nomenclature.
  53315. */
  53316. protected _reflectivityColor: Color3;
  53317. /**
  53318. * The color applied when light is reflected from a material.
  53319. */
  53320. protected _reflectionColor: Color3;
  53321. /**
  53322. * The color applied when light is emitted from a material.
  53323. */
  53324. protected _emissiveColor: Color3;
  53325. /**
  53326. * AKA Glossiness in other nomenclature.
  53327. */
  53328. protected _microSurface: number;
  53329. /**
  53330. * Specifies that the material will use the light map as a show map.
  53331. */
  53332. protected _useLightmapAsShadowmap: boolean;
  53333. /**
  53334. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53335. * makes the reflect vector face the model (under horizon).
  53336. */
  53337. protected _useHorizonOcclusion: boolean;
  53338. /**
  53339. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53340. * too much the area relying on ambient texture to define their ambient occlusion.
  53341. */
  53342. protected _useRadianceOcclusion: boolean;
  53343. /**
  53344. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53345. */
  53346. protected _useAlphaFromAlbedoTexture: boolean;
  53347. /**
  53348. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53349. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53350. */
  53351. protected _useSpecularOverAlpha: boolean;
  53352. /**
  53353. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53354. */
  53355. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53356. /**
  53357. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53358. */
  53359. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53360. /**
  53361. * Specifies if the metallic texture contains the roughness information in its green channel.
  53362. */
  53363. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53364. /**
  53365. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53366. */
  53367. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53368. /**
  53369. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53370. */
  53371. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53372. /**
  53373. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53374. */
  53375. protected _useAmbientInGrayScale: boolean;
  53376. /**
  53377. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53378. * The material will try to infer what glossiness each pixel should be.
  53379. */
  53380. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53381. /**
  53382. * Defines the falloff type used in this material.
  53383. * It by default is Physical.
  53384. */
  53385. protected _lightFalloff: number;
  53386. /**
  53387. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53388. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53389. */
  53390. protected _useRadianceOverAlpha: boolean;
  53391. /**
  53392. * Allows using an object space normal map (instead of tangent space).
  53393. */
  53394. protected _useObjectSpaceNormalMap: boolean;
  53395. /**
  53396. * Allows using the bump map in parallax mode.
  53397. */
  53398. protected _useParallax: boolean;
  53399. /**
  53400. * Allows using the bump map in parallax occlusion mode.
  53401. */
  53402. protected _useParallaxOcclusion: boolean;
  53403. /**
  53404. * Controls the scale bias of the parallax mode.
  53405. */
  53406. protected _parallaxScaleBias: number;
  53407. /**
  53408. * If sets to true, disables all the lights affecting the material.
  53409. */
  53410. protected _disableLighting: boolean;
  53411. /**
  53412. * Number of Simultaneous lights allowed on the material.
  53413. */
  53414. protected _maxSimultaneousLights: number;
  53415. /**
  53416. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53417. */
  53418. protected _invertNormalMapX: boolean;
  53419. /**
  53420. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53421. */
  53422. protected _invertNormalMapY: boolean;
  53423. /**
  53424. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53425. */
  53426. protected _twoSidedLighting: boolean;
  53427. /**
  53428. * Defines the alpha limits in alpha test mode.
  53429. */
  53430. protected _alphaCutOff: number;
  53431. /**
  53432. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53433. */
  53434. protected _forceAlphaTest: boolean;
  53435. /**
  53436. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53437. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53438. */
  53439. protected _useAlphaFresnel: boolean;
  53440. /**
  53441. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53442. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53443. */
  53444. protected _useLinearAlphaFresnel: boolean;
  53445. /**
  53446. * The transparency mode of the material.
  53447. */
  53448. protected _transparencyMode: Nullable<number>;
  53449. /**
  53450. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53451. * from cos thetav and roughness:
  53452. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53453. */
  53454. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53455. /**
  53456. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53457. */
  53458. protected _forceIrradianceInFragment: boolean;
  53459. /**
  53460. * Force normal to face away from face.
  53461. */
  53462. protected _forceNormalForward: boolean;
  53463. /**
  53464. * Enables specular anti aliasing in the PBR shader.
  53465. * It will both interacts on the Geometry for analytical and IBL lighting.
  53466. * It also prefilter the roughness map based on the bump values.
  53467. */
  53468. protected _enableSpecularAntiAliasing: boolean;
  53469. /**
  53470. * Default configuration related to image processing available in the PBR Material.
  53471. */
  53472. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53473. /**
  53474. * Keep track of the image processing observer to allow dispose and replace.
  53475. */
  53476. private _imageProcessingObserver;
  53477. /**
  53478. * Attaches a new image processing configuration to the PBR Material.
  53479. * @param configuration
  53480. */
  53481. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53482. /**
  53483. * Stores the available render targets.
  53484. */
  53485. private _renderTargets;
  53486. /**
  53487. * Sets the global ambient color for the material used in lighting calculations.
  53488. */
  53489. private _globalAmbientColor;
  53490. /**
  53491. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53492. */
  53493. private _useLogarithmicDepth;
  53494. /**
  53495. * If set to true, no lighting calculations will be applied.
  53496. */
  53497. private _unlit;
  53498. private _debugMode;
  53499. /**
  53500. * @hidden
  53501. * This is reserved for the inspector.
  53502. * Defines the material debug mode.
  53503. * It helps seeing only some components of the material while troubleshooting.
  53504. */
  53505. debugMode: number;
  53506. /**
  53507. * @hidden
  53508. * This is reserved for the inspector.
  53509. * Specify from where on screen the debug mode should start.
  53510. * The value goes from -1 (full screen) to 1 (not visible)
  53511. * It helps with side by side comparison against the final render
  53512. * This defaults to -1
  53513. */
  53514. private debugLimit;
  53515. /**
  53516. * @hidden
  53517. * This is reserved for the inspector.
  53518. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53519. * You can use the factor to better multiply the final value.
  53520. */
  53521. private debugFactor;
  53522. /**
  53523. * Defines the clear coat layer parameters for the material.
  53524. */
  53525. readonly clearCoat: PBRClearCoatConfiguration;
  53526. /**
  53527. * Defines the anisotropic parameters for the material.
  53528. */
  53529. readonly anisotropy: PBRAnisotropicConfiguration;
  53530. /**
  53531. * Defines the BRDF parameters for the material.
  53532. */
  53533. readonly brdf: PBRBRDFConfiguration;
  53534. /**
  53535. * Defines the Sheen parameters for the material.
  53536. */
  53537. readonly sheen: PBRSheenConfiguration;
  53538. /**
  53539. * Defines the SubSurface parameters for the material.
  53540. */
  53541. readonly subSurface: PBRSubSurfaceConfiguration;
  53542. /**
  53543. * Custom callback helping to override the default shader used in the material.
  53544. */
  53545. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53546. protected _rebuildInParallel: boolean;
  53547. /**
  53548. * Instantiates a new PBRMaterial instance.
  53549. *
  53550. * @param name The material name
  53551. * @param scene The scene the material will be use in.
  53552. */
  53553. constructor(name: string, scene: Scene);
  53554. /**
  53555. * Gets a boolean indicating that current material needs to register RTT
  53556. */
  53557. get hasRenderTargetTextures(): boolean;
  53558. /**
  53559. * Gets the name of the material class.
  53560. */
  53561. getClassName(): string;
  53562. /**
  53563. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53564. */
  53565. get useLogarithmicDepth(): boolean;
  53566. /**
  53567. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53568. */
  53569. set useLogarithmicDepth(value: boolean);
  53570. /**
  53571. * Gets the current transparency mode.
  53572. */
  53573. get transparencyMode(): Nullable<number>;
  53574. /**
  53575. * Sets the transparency mode of the material.
  53576. *
  53577. * | Value | Type | Description |
  53578. * | ----- | ----------------------------------- | ----------- |
  53579. * | 0 | OPAQUE | |
  53580. * | 1 | ALPHATEST | |
  53581. * | 2 | ALPHABLEND | |
  53582. * | 3 | ALPHATESTANDBLEND | |
  53583. *
  53584. */
  53585. set transparencyMode(value: Nullable<number>);
  53586. /**
  53587. * Returns true if alpha blending should be disabled.
  53588. */
  53589. private get _disableAlphaBlending();
  53590. /**
  53591. * Specifies whether or not this material should be rendered in alpha blend mode.
  53592. */
  53593. needAlphaBlending(): boolean;
  53594. /**
  53595. * Specifies if the mesh will require alpha blending.
  53596. * @param mesh - BJS mesh.
  53597. */
  53598. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53599. /**
  53600. * Specifies whether or not this material should be rendered in alpha test mode.
  53601. */
  53602. needAlphaTesting(): boolean;
  53603. /**
  53604. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53605. */
  53606. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53607. /**
  53608. * Gets the texture used for the alpha test.
  53609. */
  53610. getAlphaTestTexture(): Nullable<BaseTexture>;
  53611. /**
  53612. * Specifies that the submesh is ready to be used.
  53613. * @param mesh - BJS mesh.
  53614. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53615. * @param useInstances - Specifies that instances should be used.
  53616. * @returns - boolean indicating that the submesh is ready or not.
  53617. */
  53618. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53619. /**
  53620. * Specifies if the material uses metallic roughness workflow.
  53621. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53622. */
  53623. isMetallicWorkflow(): boolean;
  53624. private _prepareEffect;
  53625. private _prepareDefines;
  53626. /**
  53627. * Force shader compilation
  53628. */
  53629. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53630. /**
  53631. * Initializes the uniform buffer layout for the shader.
  53632. */
  53633. buildUniformLayout(): void;
  53634. /**
  53635. * Unbinds the material from the mesh
  53636. */
  53637. unbind(): void;
  53638. /**
  53639. * Binds the submesh data.
  53640. * @param world - The world matrix.
  53641. * @param mesh - The BJS mesh.
  53642. * @param subMesh - A submesh of the BJS mesh.
  53643. */
  53644. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53645. /**
  53646. * Returns the animatable textures.
  53647. * @returns - Array of animatable textures.
  53648. */
  53649. getAnimatables(): IAnimatable[];
  53650. /**
  53651. * Returns the texture used for reflections.
  53652. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53653. */
  53654. private _getReflectionTexture;
  53655. /**
  53656. * Returns an array of the actively used textures.
  53657. * @returns - Array of BaseTextures
  53658. */
  53659. getActiveTextures(): BaseTexture[];
  53660. /**
  53661. * Checks to see if a texture is used in the material.
  53662. * @param texture - Base texture to use.
  53663. * @returns - Boolean specifying if a texture is used in the material.
  53664. */
  53665. hasTexture(texture: BaseTexture): boolean;
  53666. /**
  53667. * Disposes the resources of the material.
  53668. * @param forceDisposeEffect - Forces the disposal of effects.
  53669. * @param forceDisposeTextures - Forces the disposal of all textures.
  53670. */
  53671. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53672. }
  53673. }
  53674. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53675. import { Nullable } from "babylonjs/types";
  53676. import { Scene } from "babylonjs/scene";
  53677. import { Color3 } from "babylonjs/Maths/math.color";
  53678. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53679. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53680. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53681. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53682. /**
  53683. * The Physically based material of BJS.
  53684. *
  53685. * This offers the main features of a standard PBR material.
  53686. * For more information, please refer to the documentation :
  53687. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53688. */
  53689. export class PBRMaterial extends PBRBaseMaterial {
  53690. /**
  53691. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53692. */
  53693. static readonly PBRMATERIAL_OPAQUE: number;
  53694. /**
  53695. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53696. */
  53697. static readonly PBRMATERIAL_ALPHATEST: number;
  53698. /**
  53699. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53700. */
  53701. static readonly PBRMATERIAL_ALPHABLEND: number;
  53702. /**
  53703. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53704. * They are also discarded below the alpha cutoff threshold to improve performances.
  53705. */
  53706. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53707. /**
  53708. * Defines the default value of how much AO map is occluding the analytical lights
  53709. * (point spot...).
  53710. */
  53711. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53712. /**
  53713. * Intensity of the direct lights e.g. the four lights available in your scene.
  53714. * This impacts both the direct diffuse and specular highlights.
  53715. */
  53716. directIntensity: number;
  53717. /**
  53718. * Intensity of the emissive part of the material.
  53719. * This helps controlling the emissive effect without modifying the emissive color.
  53720. */
  53721. emissiveIntensity: number;
  53722. /**
  53723. * Intensity of the environment e.g. how much the environment will light the object
  53724. * either through harmonics for rough material or through the refelction for shiny ones.
  53725. */
  53726. environmentIntensity: number;
  53727. /**
  53728. * This is a special control allowing the reduction of the specular highlights coming from the
  53729. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53730. */
  53731. specularIntensity: number;
  53732. /**
  53733. * Debug Control allowing disabling the bump map on this material.
  53734. */
  53735. disableBumpMap: boolean;
  53736. /**
  53737. * AKA Diffuse Texture in standard nomenclature.
  53738. */
  53739. albedoTexture: BaseTexture;
  53740. /**
  53741. * AKA Occlusion Texture in other nomenclature.
  53742. */
  53743. ambientTexture: BaseTexture;
  53744. /**
  53745. * AKA Occlusion Texture Intensity in other nomenclature.
  53746. */
  53747. ambientTextureStrength: number;
  53748. /**
  53749. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53750. * 1 means it completely occludes it
  53751. * 0 mean it has no impact
  53752. */
  53753. ambientTextureImpactOnAnalyticalLights: number;
  53754. /**
  53755. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53756. */
  53757. opacityTexture: BaseTexture;
  53758. /**
  53759. * Stores the reflection values in a texture.
  53760. */
  53761. reflectionTexture: Nullable<BaseTexture>;
  53762. /**
  53763. * Stores the emissive values in a texture.
  53764. */
  53765. emissiveTexture: BaseTexture;
  53766. /**
  53767. * AKA Specular texture in other nomenclature.
  53768. */
  53769. reflectivityTexture: BaseTexture;
  53770. /**
  53771. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53772. */
  53773. metallicTexture: BaseTexture;
  53774. /**
  53775. * Specifies the metallic scalar of the metallic/roughness workflow.
  53776. * Can also be used to scale the metalness values of the metallic texture.
  53777. */
  53778. metallic: Nullable<number>;
  53779. /**
  53780. * Specifies the roughness scalar of the metallic/roughness workflow.
  53781. * Can also be used to scale the roughness values of the metallic texture.
  53782. */
  53783. roughness: Nullable<number>;
  53784. /**
  53785. * Specifies the an F0 factor to help configuring the material F0.
  53786. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53787. * to 0.5 the previously hard coded value stays the same.
  53788. * Can also be used to scale the F0 values of the metallic texture.
  53789. */
  53790. metallicF0Factor: number;
  53791. /**
  53792. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53793. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53794. * your expectation as it multiplies with the texture data.
  53795. */
  53796. useMetallicF0FactorFromMetallicTexture: boolean;
  53797. /**
  53798. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53799. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53800. */
  53801. microSurfaceTexture: BaseTexture;
  53802. /**
  53803. * Stores surface normal data used to displace a mesh in a texture.
  53804. */
  53805. bumpTexture: BaseTexture;
  53806. /**
  53807. * Stores the pre-calculated light information of a mesh in a texture.
  53808. */
  53809. lightmapTexture: BaseTexture;
  53810. /**
  53811. * Stores the refracted light information in a texture.
  53812. */
  53813. get refractionTexture(): Nullable<BaseTexture>;
  53814. set refractionTexture(value: Nullable<BaseTexture>);
  53815. /**
  53816. * The color of a material in ambient lighting.
  53817. */
  53818. ambientColor: Color3;
  53819. /**
  53820. * AKA Diffuse Color in other nomenclature.
  53821. */
  53822. albedoColor: Color3;
  53823. /**
  53824. * AKA Specular Color in other nomenclature.
  53825. */
  53826. reflectivityColor: Color3;
  53827. /**
  53828. * The color reflected from the material.
  53829. */
  53830. reflectionColor: Color3;
  53831. /**
  53832. * The color emitted from the material.
  53833. */
  53834. emissiveColor: Color3;
  53835. /**
  53836. * AKA Glossiness in other nomenclature.
  53837. */
  53838. microSurface: number;
  53839. /**
  53840. * source material index of refraction (IOR)' / 'destination material IOR.
  53841. */
  53842. get indexOfRefraction(): number;
  53843. set indexOfRefraction(value: number);
  53844. /**
  53845. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53846. */
  53847. get invertRefractionY(): boolean;
  53848. set invertRefractionY(value: boolean);
  53849. /**
  53850. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53851. * Materials half opaque for instance using refraction could benefit from this control.
  53852. */
  53853. get linkRefractionWithTransparency(): boolean;
  53854. set linkRefractionWithTransparency(value: boolean);
  53855. /**
  53856. * If true, the light map contains occlusion information instead of lighting info.
  53857. */
  53858. useLightmapAsShadowmap: boolean;
  53859. /**
  53860. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53861. */
  53862. useAlphaFromAlbedoTexture: boolean;
  53863. /**
  53864. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53865. */
  53866. forceAlphaTest: boolean;
  53867. /**
  53868. * Defines the alpha limits in alpha test mode.
  53869. */
  53870. alphaCutOff: number;
  53871. /**
  53872. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53873. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53874. */
  53875. useSpecularOverAlpha: boolean;
  53876. /**
  53877. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53878. */
  53879. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53880. /**
  53881. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53882. */
  53883. useRoughnessFromMetallicTextureAlpha: boolean;
  53884. /**
  53885. * Specifies if the metallic texture contains the roughness information in its green channel.
  53886. */
  53887. useRoughnessFromMetallicTextureGreen: boolean;
  53888. /**
  53889. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53890. */
  53891. useMetallnessFromMetallicTextureBlue: boolean;
  53892. /**
  53893. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53894. */
  53895. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53896. /**
  53897. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53898. */
  53899. useAmbientInGrayScale: boolean;
  53900. /**
  53901. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53902. * The material will try to infer what glossiness each pixel should be.
  53903. */
  53904. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53905. /**
  53906. * BJS is using an harcoded light falloff based on a manually sets up range.
  53907. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53908. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53909. */
  53910. get usePhysicalLightFalloff(): boolean;
  53911. /**
  53912. * BJS is using an harcoded light falloff based on a manually sets up range.
  53913. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53914. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53915. */
  53916. set usePhysicalLightFalloff(value: boolean);
  53917. /**
  53918. * In order to support the falloff compatibility with gltf, a special mode has been added
  53919. * to reproduce the gltf light falloff.
  53920. */
  53921. get useGLTFLightFalloff(): boolean;
  53922. /**
  53923. * In order to support the falloff compatibility with gltf, a special mode has been added
  53924. * to reproduce the gltf light falloff.
  53925. */
  53926. set useGLTFLightFalloff(value: boolean);
  53927. /**
  53928. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53929. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53930. */
  53931. useRadianceOverAlpha: boolean;
  53932. /**
  53933. * Allows using an object space normal map (instead of tangent space).
  53934. */
  53935. useObjectSpaceNormalMap: boolean;
  53936. /**
  53937. * Allows using the bump map in parallax mode.
  53938. */
  53939. useParallax: boolean;
  53940. /**
  53941. * Allows using the bump map in parallax occlusion mode.
  53942. */
  53943. useParallaxOcclusion: boolean;
  53944. /**
  53945. * Controls the scale bias of the parallax mode.
  53946. */
  53947. parallaxScaleBias: number;
  53948. /**
  53949. * If sets to true, disables all the lights affecting the material.
  53950. */
  53951. disableLighting: boolean;
  53952. /**
  53953. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53954. */
  53955. forceIrradianceInFragment: boolean;
  53956. /**
  53957. * Number of Simultaneous lights allowed on the material.
  53958. */
  53959. maxSimultaneousLights: number;
  53960. /**
  53961. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53962. */
  53963. invertNormalMapX: boolean;
  53964. /**
  53965. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53966. */
  53967. invertNormalMapY: boolean;
  53968. /**
  53969. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53970. */
  53971. twoSidedLighting: boolean;
  53972. /**
  53973. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53974. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53975. */
  53976. useAlphaFresnel: boolean;
  53977. /**
  53978. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53979. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53980. */
  53981. useLinearAlphaFresnel: boolean;
  53982. /**
  53983. * Let user defines the brdf lookup texture used for IBL.
  53984. * A default 8bit version is embedded but you could point at :
  53985. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  53986. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  53987. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  53988. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  53989. */
  53990. environmentBRDFTexture: Nullable<BaseTexture>;
  53991. /**
  53992. * Force normal to face away from face.
  53993. */
  53994. forceNormalForward: boolean;
  53995. /**
  53996. * Enables specular anti aliasing in the PBR shader.
  53997. * It will both interacts on the Geometry for analytical and IBL lighting.
  53998. * It also prefilter the roughness map based on the bump values.
  53999. */
  54000. enableSpecularAntiAliasing: boolean;
  54001. /**
  54002. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54003. * makes the reflect vector face the model (under horizon).
  54004. */
  54005. useHorizonOcclusion: boolean;
  54006. /**
  54007. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54008. * too much the area relying on ambient texture to define their ambient occlusion.
  54009. */
  54010. useRadianceOcclusion: boolean;
  54011. /**
  54012. * If set to true, no lighting calculations will be applied.
  54013. */
  54014. unlit: boolean;
  54015. /**
  54016. * Gets the image processing configuration used either in this material.
  54017. */
  54018. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54019. /**
  54020. * Sets the Default image processing configuration used either in the this material.
  54021. *
  54022. * If sets to null, the scene one is in use.
  54023. */
  54024. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54025. /**
  54026. * Gets wether the color curves effect is enabled.
  54027. */
  54028. get cameraColorCurvesEnabled(): boolean;
  54029. /**
  54030. * Sets wether the color curves effect is enabled.
  54031. */
  54032. set cameraColorCurvesEnabled(value: boolean);
  54033. /**
  54034. * Gets wether the color grading effect is enabled.
  54035. */
  54036. get cameraColorGradingEnabled(): boolean;
  54037. /**
  54038. * Gets wether the color grading effect is enabled.
  54039. */
  54040. set cameraColorGradingEnabled(value: boolean);
  54041. /**
  54042. * Gets wether tonemapping is enabled or not.
  54043. */
  54044. get cameraToneMappingEnabled(): boolean;
  54045. /**
  54046. * Sets wether tonemapping is enabled or not
  54047. */
  54048. set cameraToneMappingEnabled(value: boolean);
  54049. /**
  54050. * The camera exposure used on this material.
  54051. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54052. * This corresponds to a photographic exposure.
  54053. */
  54054. get cameraExposure(): number;
  54055. /**
  54056. * The camera exposure used on this material.
  54057. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54058. * This corresponds to a photographic exposure.
  54059. */
  54060. set cameraExposure(value: number);
  54061. /**
  54062. * Gets The camera contrast used on this material.
  54063. */
  54064. get cameraContrast(): number;
  54065. /**
  54066. * Sets The camera contrast used on this material.
  54067. */
  54068. set cameraContrast(value: number);
  54069. /**
  54070. * Gets the Color Grading 2D Lookup Texture.
  54071. */
  54072. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54073. /**
  54074. * Sets the Color Grading 2D Lookup Texture.
  54075. */
  54076. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54077. /**
  54078. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54079. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54080. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  54081. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54082. */
  54083. get cameraColorCurves(): Nullable<ColorCurves>;
  54084. /**
  54085. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54086. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54087. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  54088. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54089. */
  54090. set cameraColorCurves(value: Nullable<ColorCurves>);
  54091. /**
  54092. * Instantiates a new PBRMaterial instance.
  54093. *
  54094. * @param name The material name
  54095. * @param scene The scene the material will be use in.
  54096. */
  54097. constructor(name: string, scene: Scene);
  54098. /**
  54099. * Returns the name of this material class.
  54100. */
  54101. getClassName(): string;
  54102. /**
  54103. * Makes a duplicate of the current material.
  54104. * @param name - name to use for the new material.
  54105. */
  54106. clone(name: string): PBRMaterial;
  54107. /**
  54108. * Serializes this PBR Material.
  54109. * @returns - An object with the serialized material.
  54110. */
  54111. serialize(): any;
  54112. /**
  54113. * Parses a PBR Material from a serialized object.
  54114. * @param source - Serialized object.
  54115. * @param scene - BJS scene instance.
  54116. * @param rootUrl - url for the scene object
  54117. * @returns - PBRMaterial
  54118. */
  54119. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54120. }
  54121. }
  54122. declare module "babylonjs/Misc/dds" {
  54123. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54124. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54125. import { Nullable } from "babylonjs/types";
  54126. import { Scene } from "babylonjs/scene";
  54127. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54128. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54129. /**
  54130. * Direct draw surface info
  54131. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54132. */
  54133. export interface DDSInfo {
  54134. /**
  54135. * Width of the texture
  54136. */
  54137. width: number;
  54138. /**
  54139. * Width of the texture
  54140. */
  54141. height: number;
  54142. /**
  54143. * Number of Mipmaps for the texture
  54144. * @see https://en.wikipedia.org/wiki/Mipmap
  54145. */
  54146. mipmapCount: number;
  54147. /**
  54148. * If the textures format is a known fourCC format
  54149. * @see https://www.fourcc.org/
  54150. */
  54151. isFourCC: boolean;
  54152. /**
  54153. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54154. */
  54155. isRGB: boolean;
  54156. /**
  54157. * If the texture is a lumincance format
  54158. */
  54159. isLuminance: boolean;
  54160. /**
  54161. * If this is a cube texture
  54162. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54163. */
  54164. isCube: boolean;
  54165. /**
  54166. * If the texture is a compressed format eg. FOURCC_DXT1
  54167. */
  54168. isCompressed: boolean;
  54169. /**
  54170. * The dxgiFormat of the texture
  54171. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54172. */
  54173. dxgiFormat: number;
  54174. /**
  54175. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54176. */
  54177. textureType: number;
  54178. /**
  54179. * Sphericle polynomial created for the dds texture
  54180. */
  54181. sphericalPolynomial?: SphericalPolynomial;
  54182. }
  54183. /**
  54184. * Class used to provide DDS decompression tools
  54185. */
  54186. export class DDSTools {
  54187. /**
  54188. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54189. */
  54190. static StoreLODInAlphaChannel: boolean;
  54191. /**
  54192. * Gets DDS information from an array buffer
  54193. * @param data defines the array buffer view to read data from
  54194. * @returns the DDS information
  54195. */
  54196. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54197. private static _FloatView;
  54198. private static _Int32View;
  54199. private static _ToHalfFloat;
  54200. private static _FromHalfFloat;
  54201. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54202. private static _GetHalfFloatRGBAArrayBuffer;
  54203. private static _GetFloatRGBAArrayBuffer;
  54204. private static _GetFloatAsUIntRGBAArrayBuffer;
  54205. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54206. private static _GetRGBAArrayBuffer;
  54207. private static _ExtractLongWordOrder;
  54208. private static _GetRGBArrayBuffer;
  54209. private static _GetLuminanceArrayBuffer;
  54210. /**
  54211. * Uploads DDS Levels to a Babylon Texture
  54212. * @hidden
  54213. */
  54214. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54215. }
  54216. module "babylonjs/Engines/thinEngine" {
  54217. interface ThinEngine {
  54218. /**
  54219. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54220. * @param rootUrl defines the url where the file to load is located
  54221. * @param scene defines the current scene
  54222. * @param lodScale defines scale to apply to the mip map selection
  54223. * @param lodOffset defines offset to apply to the mip map selection
  54224. * @param onLoad defines an optional callback raised when the texture is loaded
  54225. * @param onError defines an optional callback raised if there is an issue to load the texture
  54226. * @param format defines the format of the data
  54227. * @param forcedExtension defines the extension to use to pick the right loader
  54228. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54229. * @returns the cube texture as an InternalTexture
  54230. */
  54231. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  54232. }
  54233. }
  54234. }
  54235. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54236. import { Nullable } from "babylonjs/types";
  54237. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54238. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54239. /**
  54240. * Implementation of the DDS Texture Loader.
  54241. * @hidden
  54242. */
  54243. export class _DDSTextureLoader implements IInternalTextureLoader {
  54244. /**
  54245. * Defines wether the loader supports cascade loading the different faces.
  54246. */
  54247. readonly supportCascades: boolean;
  54248. /**
  54249. * This returns if the loader support the current file information.
  54250. * @param extension defines the file extension of the file being loaded
  54251. * @returns true if the loader can load the specified file
  54252. */
  54253. canLoad(extension: string): boolean;
  54254. /**
  54255. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54256. * @param data contains the texture data
  54257. * @param texture defines the BabylonJS internal texture
  54258. * @param createPolynomials will be true if polynomials have been requested
  54259. * @param onLoad defines the callback to trigger once the texture is ready
  54260. * @param onError defines the callback to trigger in case of error
  54261. */
  54262. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54263. /**
  54264. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54265. * @param data contains the texture data
  54266. * @param texture defines the BabylonJS internal texture
  54267. * @param callback defines the method to call once ready to upload
  54268. */
  54269. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54270. }
  54271. }
  54272. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54273. import { Nullable } from "babylonjs/types";
  54274. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54275. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54276. /**
  54277. * Implementation of the ENV Texture Loader.
  54278. * @hidden
  54279. */
  54280. export class _ENVTextureLoader implements IInternalTextureLoader {
  54281. /**
  54282. * Defines wether the loader supports cascade loading the different faces.
  54283. */
  54284. readonly supportCascades: boolean;
  54285. /**
  54286. * This returns if the loader support the current file information.
  54287. * @param extension defines the file extension of the file being loaded
  54288. * @returns true if the loader can load the specified file
  54289. */
  54290. canLoad(extension: string): boolean;
  54291. /**
  54292. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54293. * @param data contains the texture data
  54294. * @param texture defines the BabylonJS internal texture
  54295. * @param createPolynomials will be true if polynomials have been requested
  54296. * @param onLoad defines the callback to trigger once the texture is ready
  54297. * @param onError defines the callback to trigger in case of error
  54298. */
  54299. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54300. /**
  54301. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54302. * @param data contains the texture data
  54303. * @param texture defines the BabylonJS internal texture
  54304. * @param callback defines the method to call once ready to upload
  54305. */
  54306. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54307. }
  54308. }
  54309. declare module "babylonjs/Misc/khronosTextureContainer" {
  54310. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54311. /**
  54312. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54313. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54314. */
  54315. export class KhronosTextureContainer {
  54316. /** contents of the KTX container file */
  54317. data: ArrayBufferView;
  54318. private static HEADER_LEN;
  54319. private static COMPRESSED_2D;
  54320. private static COMPRESSED_3D;
  54321. private static TEX_2D;
  54322. private static TEX_3D;
  54323. /**
  54324. * Gets the openGL type
  54325. */
  54326. glType: number;
  54327. /**
  54328. * Gets the openGL type size
  54329. */
  54330. glTypeSize: number;
  54331. /**
  54332. * Gets the openGL format
  54333. */
  54334. glFormat: number;
  54335. /**
  54336. * Gets the openGL internal format
  54337. */
  54338. glInternalFormat: number;
  54339. /**
  54340. * Gets the base internal format
  54341. */
  54342. glBaseInternalFormat: number;
  54343. /**
  54344. * Gets image width in pixel
  54345. */
  54346. pixelWidth: number;
  54347. /**
  54348. * Gets image height in pixel
  54349. */
  54350. pixelHeight: number;
  54351. /**
  54352. * Gets image depth in pixels
  54353. */
  54354. pixelDepth: number;
  54355. /**
  54356. * Gets the number of array elements
  54357. */
  54358. numberOfArrayElements: number;
  54359. /**
  54360. * Gets the number of faces
  54361. */
  54362. numberOfFaces: number;
  54363. /**
  54364. * Gets the number of mipmap levels
  54365. */
  54366. numberOfMipmapLevels: number;
  54367. /**
  54368. * Gets the bytes of key value data
  54369. */
  54370. bytesOfKeyValueData: number;
  54371. /**
  54372. * Gets the load type
  54373. */
  54374. loadType: number;
  54375. /**
  54376. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54377. */
  54378. isInvalid: boolean;
  54379. /**
  54380. * Creates a new KhronosTextureContainer
  54381. * @param data contents of the KTX container file
  54382. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54383. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54384. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54385. */
  54386. constructor(
  54387. /** contents of the KTX container file */
  54388. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54389. /**
  54390. * Uploads KTX content to a Babylon Texture.
  54391. * It is assumed that the texture has already been created & is currently bound
  54392. * @hidden
  54393. */
  54394. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54395. private _upload2DCompressedLevels;
  54396. /**
  54397. * Checks if the given data starts with a KTX file identifier.
  54398. * @param data the data to check
  54399. * @returns true if the data is a KTX file or false otherwise
  54400. */
  54401. static IsValid(data: ArrayBufferView): boolean;
  54402. }
  54403. }
  54404. declare module "babylonjs/Misc/khronosTextureContainer2" {
  54405. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54406. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54407. /**
  54408. * Class for loading KTX2 files
  54409. * !!! Experimental Extension Subject to Changes !!!
  54410. * @hidden
  54411. */
  54412. export class KhronosTextureContainer2 {
  54413. private static _ModulePromise;
  54414. private static _TranscodeFormat;
  54415. constructor(engine: ThinEngine);
  54416. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  54417. private _determineTranscodeFormat;
  54418. /**
  54419. * Checks if the given data starts with a KTX2 file identifier.
  54420. * @param data the data to check
  54421. * @returns true if the data is a KTX2 file or false otherwise
  54422. */
  54423. static IsValid(data: ArrayBufferView): boolean;
  54424. }
  54425. }
  54426. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54427. import { Nullable } from "babylonjs/types";
  54428. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54429. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54430. /**
  54431. * Implementation of the KTX Texture Loader.
  54432. * @hidden
  54433. */
  54434. export class _KTXTextureLoader implements IInternalTextureLoader {
  54435. /**
  54436. * Defines wether the loader supports cascade loading the different faces.
  54437. */
  54438. readonly supportCascades: boolean;
  54439. /**
  54440. * This returns if the loader support the current file information.
  54441. * @param extension defines the file extension of the file being loaded
  54442. * @returns true if the loader can load the specified file
  54443. */
  54444. canLoad(extension: string): boolean;
  54445. /**
  54446. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54447. * @param data contains the texture data
  54448. * @param texture defines the BabylonJS internal texture
  54449. * @param createPolynomials will be true if polynomials have been requested
  54450. * @param onLoad defines the callback to trigger once the texture is ready
  54451. * @param onError defines the callback to trigger in case of error
  54452. */
  54453. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54454. /**
  54455. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54456. * @param data contains the texture data
  54457. * @param texture defines the BabylonJS internal texture
  54458. * @param callback defines the method to call once ready to upload
  54459. */
  54460. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54461. }
  54462. }
  54463. declare module "babylonjs/Helpers/sceneHelpers" {
  54464. import { Nullable } from "babylonjs/types";
  54465. import { Mesh } from "babylonjs/Meshes/mesh";
  54466. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54467. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54468. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54469. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54470. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54471. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54472. import "babylonjs/Meshes/Builders/boxBuilder";
  54473. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54474. /** @hidden */
  54475. export var _forceSceneHelpersToBundle: boolean;
  54476. module "babylonjs/scene" {
  54477. interface Scene {
  54478. /**
  54479. * Creates a default light for the scene.
  54480. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54481. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54482. */
  54483. createDefaultLight(replace?: boolean): void;
  54484. /**
  54485. * Creates a default camera for the scene.
  54486. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54487. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54488. * @param replace has default false, when true replaces the active camera in the scene
  54489. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54490. */
  54491. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54492. /**
  54493. * Creates a default camera and a default light.
  54494. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54495. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54496. * @param replace has the default false, when true replaces the active camera/light in the scene
  54497. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54498. */
  54499. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54500. /**
  54501. * Creates a new sky box
  54502. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54503. * @param environmentTexture defines the texture to use as environment texture
  54504. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54505. * @param scale defines the overall scale of the skybox
  54506. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54507. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54508. * @returns a new mesh holding the sky box
  54509. */
  54510. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54511. /**
  54512. * Creates a new environment
  54513. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54514. * @param options defines the options you can use to configure the environment
  54515. * @returns the new EnvironmentHelper
  54516. */
  54517. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54518. /**
  54519. * Creates a new VREXperienceHelper
  54520. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54521. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54522. * @returns a new VREXperienceHelper
  54523. */
  54524. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54525. /**
  54526. * Creates a new WebXRDefaultExperience
  54527. * @see http://doc.babylonjs.com/how_to/webxr
  54528. * @param options experience options
  54529. * @returns a promise for a new WebXRDefaultExperience
  54530. */
  54531. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54532. }
  54533. }
  54534. }
  54535. declare module "babylonjs/Helpers/videoDome" {
  54536. import { Scene } from "babylonjs/scene";
  54537. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54538. import { Mesh } from "babylonjs/Meshes/mesh";
  54539. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54540. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54541. import "babylonjs/Meshes/Builders/sphereBuilder";
  54542. /**
  54543. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54544. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54545. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54546. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54547. */
  54548. export class VideoDome extends TransformNode {
  54549. /**
  54550. * Define the video source as a Monoscopic panoramic 360 video.
  54551. */
  54552. static readonly MODE_MONOSCOPIC: number;
  54553. /**
  54554. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54555. */
  54556. static readonly MODE_TOPBOTTOM: number;
  54557. /**
  54558. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54559. */
  54560. static readonly MODE_SIDEBYSIDE: number;
  54561. private _halfDome;
  54562. private _useDirectMapping;
  54563. /**
  54564. * The video texture being displayed on the sphere
  54565. */
  54566. protected _videoTexture: VideoTexture;
  54567. /**
  54568. * Gets the video texture being displayed on the sphere
  54569. */
  54570. get videoTexture(): VideoTexture;
  54571. /**
  54572. * The skybox material
  54573. */
  54574. protected _material: BackgroundMaterial;
  54575. /**
  54576. * The surface used for the skybox
  54577. */
  54578. protected _mesh: Mesh;
  54579. /**
  54580. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54581. */
  54582. private _halfDomeMask;
  54583. /**
  54584. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54585. * Also see the options.resolution property.
  54586. */
  54587. get fovMultiplier(): number;
  54588. set fovMultiplier(value: number);
  54589. private _videoMode;
  54590. /**
  54591. * Gets or set the current video mode for the video. It can be:
  54592. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54593. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54594. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54595. */
  54596. get videoMode(): number;
  54597. set videoMode(value: number);
  54598. /**
  54599. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54600. *
  54601. */
  54602. get halfDome(): boolean;
  54603. /**
  54604. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54605. */
  54606. set halfDome(enabled: boolean);
  54607. /**
  54608. * Oberserver used in Stereoscopic VR Mode.
  54609. */
  54610. private _onBeforeCameraRenderObserver;
  54611. /**
  54612. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54613. * @param name Element's name, child elements will append suffixes for their own names.
  54614. * @param urlsOrVideo defines the url(s) or the video element to use
  54615. * @param options An object containing optional or exposed sub element properties
  54616. */
  54617. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54618. resolution?: number;
  54619. clickToPlay?: boolean;
  54620. autoPlay?: boolean;
  54621. loop?: boolean;
  54622. size?: number;
  54623. poster?: string;
  54624. faceForward?: boolean;
  54625. useDirectMapping?: boolean;
  54626. halfDomeMode?: boolean;
  54627. }, scene: Scene);
  54628. private _changeVideoMode;
  54629. /**
  54630. * Releases resources associated with this node.
  54631. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54632. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54633. */
  54634. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54635. }
  54636. }
  54637. declare module "babylonjs/Helpers/index" {
  54638. export * from "babylonjs/Helpers/environmentHelper";
  54639. export * from "babylonjs/Helpers/photoDome";
  54640. export * from "babylonjs/Helpers/sceneHelpers";
  54641. export * from "babylonjs/Helpers/videoDome";
  54642. }
  54643. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54644. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54645. import { IDisposable } from "babylonjs/scene";
  54646. import { Engine } from "babylonjs/Engines/engine";
  54647. /**
  54648. * This class can be used to get instrumentation data from a Babylon engine
  54649. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54650. */
  54651. export class EngineInstrumentation implements IDisposable {
  54652. /**
  54653. * Define the instrumented engine.
  54654. */
  54655. engine: Engine;
  54656. private _captureGPUFrameTime;
  54657. private _gpuFrameTimeToken;
  54658. private _gpuFrameTime;
  54659. private _captureShaderCompilationTime;
  54660. private _shaderCompilationTime;
  54661. private _onBeginFrameObserver;
  54662. private _onEndFrameObserver;
  54663. private _onBeforeShaderCompilationObserver;
  54664. private _onAfterShaderCompilationObserver;
  54665. /**
  54666. * Gets the perf counter used for GPU frame time
  54667. */
  54668. get gpuFrameTimeCounter(): PerfCounter;
  54669. /**
  54670. * Gets the GPU frame time capture status
  54671. */
  54672. get captureGPUFrameTime(): boolean;
  54673. /**
  54674. * Enable or disable the GPU frame time capture
  54675. */
  54676. set captureGPUFrameTime(value: boolean);
  54677. /**
  54678. * Gets the perf counter used for shader compilation time
  54679. */
  54680. get shaderCompilationTimeCounter(): PerfCounter;
  54681. /**
  54682. * Gets the shader compilation time capture status
  54683. */
  54684. get captureShaderCompilationTime(): boolean;
  54685. /**
  54686. * Enable or disable the shader compilation time capture
  54687. */
  54688. set captureShaderCompilationTime(value: boolean);
  54689. /**
  54690. * Instantiates a new engine instrumentation.
  54691. * This class can be used to get instrumentation data from a Babylon engine
  54692. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54693. * @param engine Defines the engine to instrument
  54694. */
  54695. constructor(
  54696. /**
  54697. * Define the instrumented engine.
  54698. */
  54699. engine: Engine);
  54700. /**
  54701. * Dispose and release associated resources.
  54702. */
  54703. dispose(): void;
  54704. }
  54705. }
  54706. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54707. import { Scene, IDisposable } from "babylonjs/scene";
  54708. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54709. /**
  54710. * This class can be used to get instrumentation data from a Babylon engine
  54711. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54712. */
  54713. export class SceneInstrumentation implements IDisposable {
  54714. /**
  54715. * Defines the scene to instrument
  54716. */
  54717. scene: Scene;
  54718. private _captureActiveMeshesEvaluationTime;
  54719. private _activeMeshesEvaluationTime;
  54720. private _captureRenderTargetsRenderTime;
  54721. private _renderTargetsRenderTime;
  54722. private _captureFrameTime;
  54723. private _frameTime;
  54724. private _captureRenderTime;
  54725. private _renderTime;
  54726. private _captureInterFrameTime;
  54727. private _interFrameTime;
  54728. private _captureParticlesRenderTime;
  54729. private _particlesRenderTime;
  54730. private _captureSpritesRenderTime;
  54731. private _spritesRenderTime;
  54732. private _capturePhysicsTime;
  54733. private _physicsTime;
  54734. private _captureAnimationsTime;
  54735. private _animationsTime;
  54736. private _captureCameraRenderTime;
  54737. private _cameraRenderTime;
  54738. private _onBeforeActiveMeshesEvaluationObserver;
  54739. private _onAfterActiveMeshesEvaluationObserver;
  54740. private _onBeforeRenderTargetsRenderObserver;
  54741. private _onAfterRenderTargetsRenderObserver;
  54742. private _onAfterRenderObserver;
  54743. private _onBeforeDrawPhaseObserver;
  54744. private _onAfterDrawPhaseObserver;
  54745. private _onBeforeAnimationsObserver;
  54746. private _onBeforeParticlesRenderingObserver;
  54747. private _onAfterParticlesRenderingObserver;
  54748. private _onBeforeSpritesRenderingObserver;
  54749. private _onAfterSpritesRenderingObserver;
  54750. private _onBeforePhysicsObserver;
  54751. private _onAfterPhysicsObserver;
  54752. private _onAfterAnimationsObserver;
  54753. private _onBeforeCameraRenderObserver;
  54754. private _onAfterCameraRenderObserver;
  54755. /**
  54756. * Gets the perf counter used for active meshes evaluation time
  54757. */
  54758. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54759. /**
  54760. * Gets the active meshes evaluation time capture status
  54761. */
  54762. get captureActiveMeshesEvaluationTime(): boolean;
  54763. /**
  54764. * Enable or disable the active meshes evaluation time capture
  54765. */
  54766. set captureActiveMeshesEvaluationTime(value: boolean);
  54767. /**
  54768. * Gets the perf counter used for render targets render time
  54769. */
  54770. get renderTargetsRenderTimeCounter(): PerfCounter;
  54771. /**
  54772. * Gets the render targets render time capture status
  54773. */
  54774. get captureRenderTargetsRenderTime(): boolean;
  54775. /**
  54776. * Enable or disable the render targets render time capture
  54777. */
  54778. set captureRenderTargetsRenderTime(value: boolean);
  54779. /**
  54780. * Gets the perf counter used for particles render time
  54781. */
  54782. get particlesRenderTimeCounter(): PerfCounter;
  54783. /**
  54784. * Gets the particles render time capture status
  54785. */
  54786. get captureParticlesRenderTime(): boolean;
  54787. /**
  54788. * Enable or disable the particles render time capture
  54789. */
  54790. set captureParticlesRenderTime(value: boolean);
  54791. /**
  54792. * Gets the perf counter used for sprites render time
  54793. */
  54794. get spritesRenderTimeCounter(): PerfCounter;
  54795. /**
  54796. * Gets the sprites render time capture status
  54797. */
  54798. get captureSpritesRenderTime(): boolean;
  54799. /**
  54800. * Enable or disable the sprites render time capture
  54801. */
  54802. set captureSpritesRenderTime(value: boolean);
  54803. /**
  54804. * Gets the perf counter used for physics time
  54805. */
  54806. get physicsTimeCounter(): PerfCounter;
  54807. /**
  54808. * Gets the physics time capture status
  54809. */
  54810. get capturePhysicsTime(): boolean;
  54811. /**
  54812. * Enable or disable the physics time capture
  54813. */
  54814. set capturePhysicsTime(value: boolean);
  54815. /**
  54816. * Gets the perf counter used for animations time
  54817. */
  54818. get animationsTimeCounter(): PerfCounter;
  54819. /**
  54820. * Gets the animations time capture status
  54821. */
  54822. get captureAnimationsTime(): boolean;
  54823. /**
  54824. * Enable or disable the animations time capture
  54825. */
  54826. set captureAnimationsTime(value: boolean);
  54827. /**
  54828. * Gets the perf counter used for frame time capture
  54829. */
  54830. get frameTimeCounter(): PerfCounter;
  54831. /**
  54832. * Gets the frame time capture status
  54833. */
  54834. get captureFrameTime(): boolean;
  54835. /**
  54836. * Enable or disable the frame time capture
  54837. */
  54838. set captureFrameTime(value: boolean);
  54839. /**
  54840. * Gets the perf counter used for inter-frames time capture
  54841. */
  54842. get interFrameTimeCounter(): PerfCounter;
  54843. /**
  54844. * Gets the inter-frames time capture status
  54845. */
  54846. get captureInterFrameTime(): boolean;
  54847. /**
  54848. * Enable or disable the inter-frames time capture
  54849. */
  54850. set captureInterFrameTime(value: boolean);
  54851. /**
  54852. * Gets the perf counter used for render time capture
  54853. */
  54854. get renderTimeCounter(): PerfCounter;
  54855. /**
  54856. * Gets the render time capture status
  54857. */
  54858. get captureRenderTime(): boolean;
  54859. /**
  54860. * Enable or disable the render time capture
  54861. */
  54862. set captureRenderTime(value: boolean);
  54863. /**
  54864. * Gets the perf counter used for camera render time capture
  54865. */
  54866. get cameraRenderTimeCounter(): PerfCounter;
  54867. /**
  54868. * Gets the camera render time capture status
  54869. */
  54870. get captureCameraRenderTime(): boolean;
  54871. /**
  54872. * Enable or disable the camera render time capture
  54873. */
  54874. set captureCameraRenderTime(value: boolean);
  54875. /**
  54876. * Gets the perf counter used for draw calls
  54877. */
  54878. get drawCallsCounter(): PerfCounter;
  54879. /**
  54880. * Instantiates a new scene instrumentation.
  54881. * This class can be used to get instrumentation data from a Babylon engine
  54882. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54883. * @param scene Defines the scene to instrument
  54884. */
  54885. constructor(
  54886. /**
  54887. * Defines the scene to instrument
  54888. */
  54889. scene: Scene);
  54890. /**
  54891. * Dispose and release associated resources.
  54892. */
  54893. dispose(): void;
  54894. }
  54895. }
  54896. declare module "babylonjs/Instrumentation/index" {
  54897. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54898. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54899. export * from "babylonjs/Instrumentation/timeToken";
  54900. }
  54901. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54902. /** @hidden */
  54903. export var glowMapGenerationPixelShader: {
  54904. name: string;
  54905. shader: string;
  54906. };
  54907. }
  54908. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54909. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54910. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54911. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54912. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54913. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54914. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54915. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54916. /** @hidden */
  54917. export var glowMapGenerationVertexShader: {
  54918. name: string;
  54919. shader: string;
  54920. };
  54921. }
  54922. declare module "babylonjs/Layers/effectLayer" {
  54923. import { Observable } from "babylonjs/Misc/observable";
  54924. import { Nullable } from "babylonjs/types";
  54925. import { Camera } from "babylonjs/Cameras/camera";
  54926. import { Scene } from "babylonjs/scene";
  54927. import { ISize } from "babylonjs/Maths/math.size";
  54928. import { Color4 } from "babylonjs/Maths/math.color";
  54929. import { Engine } from "babylonjs/Engines/engine";
  54930. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54932. import { Mesh } from "babylonjs/Meshes/mesh";
  54933. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54934. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54935. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54936. import { Effect } from "babylonjs/Materials/effect";
  54937. import { Material } from "babylonjs/Materials/material";
  54938. import "babylonjs/Shaders/glowMapGeneration.fragment";
  54939. import "babylonjs/Shaders/glowMapGeneration.vertex";
  54940. /**
  54941. * Effect layer options. This helps customizing the behaviour
  54942. * of the effect layer.
  54943. */
  54944. export interface IEffectLayerOptions {
  54945. /**
  54946. * Multiplication factor apply to the canvas size to compute the render target size
  54947. * used to generated the objects (the smaller the faster).
  54948. */
  54949. mainTextureRatio: number;
  54950. /**
  54951. * Enforces a fixed size texture to ensure effect stability across devices.
  54952. */
  54953. mainTextureFixedSize?: number;
  54954. /**
  54955. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  54956. */
  54957. alphaBlendingMode: number;
  54958. /**
  54959. * The camera attached to the layer.
  54960. */
  54961. camera: Nullable<Camera>;
  54962. /**
  54963. * The rendering group to draw the layer in.
  54964. */
  54965. renderingGroupId: number;
  54966. }
  54967. /**
  54968. * The effect layer Helps adding post process effect blended with the main pass.
  54969. *
  54970. * This can be for instance use to generate glow or higlight effects on the scene.
  54971. *
  54972. * The effect layer class can not be used directly and is intented to inherited from to be
  54973. * customized per effects.
  54974. */
  54975. export abstract class EffectLayer {
  54976. private _vertexBuffers;
  54977. private _indexBuffer;
  54978. private _cachedDefines;
  54979. private _effectLayerMapGenerationEffect;
  54980. private _effectLayerOptions;
  54981. private _mergeEffect;
  54982. protected _scene: Scene;
  54983. protected _engine: Engine;
  54984. protected _maxSize: number;
  54985. protected _mainTextureDesiredSize: ISize;
  54986. protected _mainTexture: RenderTargetTexture;
  54987. protected _shouldRender: boolean;
  54988. protected _postProcesses: PostProcess[];
  54989. protected _textures: BaseTexture[];
  54990. protected _emissiveTextureAndColor: {
  54991. texture: Nullable<BaseTexture>;
  54992. color: Color4;
  54993. };
  54994. /**
  54995. * The name of the layer
  54996. */
  54997. name: string;
  54998. /**
  54999. * The clear color of the texture used to generate the glow map.
  55000. */
  55001. neutralColor: Color4;
  55002. /**
  55003. * Specifies whether the highlight layer is enabled or not.
  55004. */
  55005. isEnabled: boolean;
  55006. /**
  55007. * Gets the camera attached to the layer.
  55008. */
  55009. get camera(): Nullable<Camera>;
  55010. /**
  55011. * Gets the rendering group id the layer should render in.
  55012. */
  55013. get renderingGroupId(): number;
  55014. set renderingGroupId(renderingGroupId: number);
  55015. /**
  55016. * An event triggered when the effect layer has been disposed.
  55017. */
  55018. onDisposeObservable: Observable<EffectLayer>;
  55019. /**
  55020. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55021. */
  55022. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55023. /**
  55024. * An event triggered when the generated texture is being merged in the scene.
  55025. */
  55026. onBeforeComposeObservable: Observable<EffectLayer>;
  55027. /**
  55028. * An event triggered when the mesh is rendered into the effect render target.
  55029. */
  55030. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55031. /**
  55032. * An event triggered after the mesh has been rendered into the effect render target.
  55033. */
  55034. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55035. /**
  55036. * An event triggered when the generated texture has been merged in the scene.
  55037. */
  55038. onAfterComposeObservable: Observable<EffectLayer>;
  55039. /**
  55040. * An event triggered when the efffect layer changes its size.
  55041. */
  55042. onSizeChangedObservable: Observable<EffectLayer>;
  55043. /** @hidden */
  55044. static _SceneComponentInitialization: (scene: Scene) => void;
  55045. /**
  55046. * Instantiates a new effect Layer and references it in the scene.
  55047. * @param name The name of the layer
  55048. * @param scene The scene to use the layer in
  55049. */
  55050. constructor(
  55051. /** The Friendly of the effect in the scene */
  55052. name: string, scene: Scene);
  55053. /**
  55054. * Get the effect name of the layer.
  55055. * @return The effect name
  55056. */
  55057. abstract getEffectName(): string;
  55058. /**
  55059. * Checks for the readiness of the element composing the layer.
  55060. * @param subMesh the mesh to check for
  55061. * @param useInstances specify whether or not to use instances to render the mesh
  55062. * @return true if ready otherwise, false
  55063. */
  55064. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55065. /**
  55066. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55067. * @returns true if the effect requires stencil during the main canvas render pass.
  55068. */
  55069. abstract needStencil(): boolean;
  55070. /**
  55071. * Create the merge effect. This is the shader use to blit the information back
  55072. * to the main canvas at the end of the scene rendering.
  55073. * @returns The effect containing the shader used to merge the effect on the main canvas
  55074. */
  55075. protected abstract _createMergeEffect(): Effect;
  55076. /**
  55077. * Creates the render target textures and post processes used in the effect layer.
  55078. */
  55079. protected abstract _createTextureAndPostProcesses(): void;
  55080. /**
  55081. * Implementation specific of rendering the generating effect on the main canvas.
  55082. * @param effect The effect used to render through
  55083. */
  55084. protected abstract _internalRender(effect: Effect): void;
  55085. /**
  55086. * Sets the required values for both the emissive texture and and the main color.
  55087. */
  55088. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55089. /**
  55090. * Free any resources and references associated to a mesh.
  55091. * Internal use
  55092. * @param mesh The mesh to free.
  55093. */
  55094. abstract _disposeMesh(mesh: Mesh): void;
  55095. /**
  55096. * Serializes this layer (Glow or Highlight for example)
  55097. * @returns a serialized layer object
  55098. */
  55099. abstract serialize?(): any;
  55100. /**
  55101. * Initializes the effect layer with the required options.
  55102. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55103. */
  55104. protected _init(options: Partial<IEffectLayerOptions>): void;
  55105. /**
  55106. * Generates the index buffer of the full screen quad blending to the main canvas.
  55107. */
  55108. private _generateIndexBuffer;
  55109. /**
  55110. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55111. */
  55112. private _generateVertexBuffer;
  55113. /**
  55114. * Sets the main texture desired size which is the closest power of two
  55115. * of the engine canvas size.
  55116. */
  55117. private _setMainTextureSize;
  55118. /**
  55119. * Creates the main texture for the effect layer.
  55120. */
  55121. protected _createMainTexture(): void;
  55122. /**
  55123. * Adds specific effects defines.
  55124. * @param defines The defines to add specifics to.
  55125. */
  55126. protected _addCustomEffectDefines(defines: string[]): void;
  55127. /**
  55128. * Checks for the readiness of the element composing the layer.
  55129. * @param subMesh the mesh to check for
  55130. * @param useInstances specify whether or not to use instances to render the mesh
  55131. * @param emissiveTexture the associated emissive texture used to generate the glow
  55132. * @return true if ready otherwise, false
  55133. */
  55134. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55135. /**
  55136. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55137. */
  55138. render(): void;
  55139. /**
  55140. * Determine if a given mesh will be used in the current effect.
  55141. * @param mesh mesh to test
  55142. * @returns true if the mesh will be used
  55143. */
  55144. hasMesh(mesh: AbstractMesh): boolean;
  55145. /**
  55146. * Returns true if the layer contains information to display, otherwise false.
  55147. * @returns true if the glow layer should be rendered
  55148. */
  55149. shouldRender(): boolean;
  55150. /**
  55151. * Returns true if the mesh should render, otherwise false.
  55152. * @param mesh The mesh to render
  55153. * @returns true if it should render otherwise false
  55154. */
  55155. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55156. /**
  55157. * Returns true if the mesh can be rendered, otherwise false.
  55158. * @param mesh The mesh to render
  55159. * @param material The material used on the mesh
  55160. * @returns true if it can be rendered otherwise false
  55161. */
  55162. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55163. /**
  55164. * Returns true if the mesh should render, otherwise false.
  55165. * @param mesh The mesh to render
  55166. * @returns true if it should render otherwise false
  55167. */
  55168. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55169. /**
  55170. * Renders the submesh passed in parameter to the generation map.
  55171. */
  55172. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55173. /**
  55174. * Defines whether the current material of the mesh should be use to render the effect.
  55175. * @param mesh defines the current mesh to render
  55176. */
  55177. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55178. /**
  55179. * Rebuild the required buffers.
  55180. * @hidden Internal use only.
  55181. */
  55182. _rebuild(): void;
  55183. /**
  55184. * Dispose only the render target textures and post process.
  55185. */
  55186. private _disposeTextureAndPostProcesses;
  55187. /**
  55188. * Dispose the highlight layer and free resources.
  55189. */
  55190. dispose(): void;
  55191. /**
  55192. * Gets the class name of the effect layer
  55193. * @returns the string with the class name of the effect layer
  55194. */
  55195. getClassName(): string;
  55196. /**
  55197. * Creates an effect layer from parsed effect layer data
  55198. * @param parsedEffectLayer defines effect layer data
  55199. * @param scene defines the current scene
  55200. * @param rootUrl defines the root URL containing the effect layer information
  55201. * @returns a parsed effect Layer
  55202. */
  55203. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55204. }
  55205. }
  55206. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55207. import { Scene } from "babylonjs/scene";
  55208. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55209. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55210. import { AbstractScene } from "babylonjs/abstractScene";
  55211. module "babylonjs/abstractScene" {
  55212. interface AbstractScene {
  55213. /**
  55214. * The list of effect layers (highlights/glow) added to the scene
  55215. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55216. * @see http://doc.babylonjs.com/how_to/glow_layer
  55217. */
  55218. effectLayers: Array<EffectLayer>;
  55219. /**
  55220. * Removes the given effect layer from this scene.
  55221. * @param toRemove defines the effect layer to remove
  55222. * @returns the index of the removed effect layer
  55223. */
  55224. removeEffectLayer(toRemove: EffectLayer): number;
  55225. /**
  55226. * Adds the given effect layer to this scene
  55227. * @param newEffectLayer defines the effect layer to add
  55228. */
  55229. addEffectLayer(newEffectLayer: EffectLayer): void;
  55230. }
  55231. }
  55232. /**
  55233. * Defines the layer scene component responsible to manage any effect layers
  55234. * in a given scene.
  55235. */
  55236. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55237. /**
  55238. * The component name helpfull to identify the component in the list of scene components.
  55239. */
  55240. readonly name: string;
  55241. /**
  55242. * The scene the component belongs to.
  55243. */
  55244. scene: Scene;
  55245. private _engine;
  55246. private _renderEffects;
  55247. private _needStencil;
  55248. private _previousStencilState;
  55249. /**
  55250. * Creates a new instance of the component for the given scene
  55251. * @param scene Defines the scene to register the component in
  55252. */
  55253. constructor(scene: Scene);
  55254. /**
  55255. * Registers the component in a given scene
  55256. */
  55257. register(): void;
  55258. /**
  55259. * Rebuilds the elements related to this component in case of
  55260. * context lost for instance.
  55261. */
  55262. rebuild(): void;
  55263. /**
  55264. * Serializes the component data to the specified json object
  55265. * @param serializationObject The object to serialize to
  55266. */
  55267. serialize(serializationObject: any): void;
  55268. /**
  55269. * Adds all the elements from the container to the scene
  55270. * @param container the container holding the elements
  55271. */
  55272. addFromContainer(container: AbstractScene): void;
  55273. /**
  55274. * Removes all the elements in the container from the scene
  55275. * @param container contains the elements to remove
  55276. * @param dispose if the removed element should be disposed (default: false)
  55277. */
  55278. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55279. /**
  55280. * Disposes the component and the associated ressources.
  55281. */
  55282. dispose(): void;
  55283. private _isReadyForMesh;
  55284. private _renderMainTexture;
  55285. private _setStencil;
  55286. private _setStencilBack;
  55287. private _draw;
  55288. private _drawCamera;
  55289. private _drawRenderingGroup;
  55290. }
  55291. }
  55292. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55293. /** @hidden */
  55294. export var glowMapMergePixelShader: {
  55295. name: string;
  55296. shader: string;
  55297. };
  55298. }
  55299. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55300. /** @hidden */
  55301. export var glowMapMergeVertexShader: {
  55302. name: string;
  55303. shader: string;
  55304. };
  55305. }
  55306. declare module "babylonjs/Layers/glowLayer" {
  55307. import { Nullable } from "babylonjs/types";
  55308. import { Camera } from "babylonjs/Cameras/camera";
  55309. import { Scene } from "babylonjs/scene";
  55310. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55312. import { Mesh } from "babylonjs/Meshes/mesh";
  55313. import { Texture } from "babylonjs/Materials/Textures/texture";
  55314. import { Effect } from "babylonjs/Materials/effect";
  55315. import { Material } from "babylonjs/Materials/material";
  55316. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55317. import { Color4 } from "babylonjs/Maths/math.color";
  55318. import "babylonjs/Shaders/glowMapMerge.fragment";
  55319. import "babylonjs/Shaders/glowMapMerge.vertex";
  55320. import "babylonjs/Layers/effectLayerSceneComponent";
  55321. module "babylonjs/abstractScene" {
  55322. interface AbstractScene {
  55323. /**
  55324. * Return a the first highlight layer of the scene with a given name.
  55325. * @param name The name of the highlight layer to look for.
  55326. * @return The highlight layer if found otherwise null.
  55327. */
  55328. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55329. }
  55330. }
  55331. /**
  55332. * Glow layer options. This helps customizing the behaviour
  55333. * of the glow layer.
  55334. */
  55335. export interface IGlowLayerOptions {
  55336. /**
  55337. * Multiplication factor apply to the canvas size to compute the render target size
  55338. * used to generated the glowing objects (the smaller the faster).
  55339. */
  55340. mainTextureRatio: number;
  55341. /**
  55342. * Enforces a fixed size texture to ensure resize independant blur.
  55343. */
  55344. mainTextureFixedSize?: number;
  55345. /**
  55346. * How big is the kernel of the blur texture.
  55347. */
  55348. blurKernelSize: number;
  55349. /**
  55350. * The camera attached to the layer.
  55351. */
  55352. camera: Nullable<Camera>;
  55353. /**
  55354. * Enable MSAA by chosing the number of samples.
  55355. */
  55356. mainTextureSamples?: number;
  55357. /**
  55358. * The rendering group to draw the layer in.
  55359. */
  55360. renderingGroupId: number;
  55361. }
  55362. /**
  55363. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55364. *
  55365. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55366. *
  55367. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55368. */
  55369. export class GlowLayer extends EffectLayer {
  55370. /**
  55371. * Effect Name of the layer.
  55372. */
  55373. static readonly EffectName: string;
  55374. /**
  55375. * The default blur kernel size used for the glow.
  55376. */
  55377. static DefaultBlurKernelSize: number;
  55378. /**
  55379. * The default texture size ratio used for the glow.
  55380. */
  55381. static DefaultTextureRatio: number;
  55382. /**
  55383. * Sets the kernel size of the blur.
  55384. */
  55385. set blurKernelSize(value: number);
  55386. /**
  55387. * Gets the kernel size of the blur.
  55388. */
  55389. get blurKernelSize(): number;
  55390. /**
  55391. * Sets the glow intensity.
  55392. */
  55393. set intensity(value: number);
  55394. /**
  55395. * Gets the glow intensity.
  55396. */
  55397. get intensity(): number;
  55398. private _options;
  55399. private _intensity;
  55400. private _horizontalBlurPostprocess1;
  55401. private _verticalBlurPostprocess1;
  55402. private _horizontalBlurPostprocess2;
  55403. private _verticalBlurPostprocess2;
  55404. private _blurTexture1;
  55405. private _blurTexture2;
  55406. private _postProcesses1;
  55407. private _postProcesses2;
  55408. private _includedOnlyMeshes;
  55409. private _excludedMeshes;
  55410. private _meshesUsingTheirOwnMaterials;
  55411. /**
  55412. * Callback used to let the user override the color selection on a per mesh basis
  55413. */
  55414. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55415. /**
  55416. * Callback used to let the user override the texture selection on a per mesh basis
  55417. */
  55418. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55419. /**
  55420. * Instantiates a new glow Layer and references it to the scene.
  55421. * @param name The name of the layer
  55422. * @param scene The scene to use the layer in
  55423. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55424. */
  55425. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55426. /**
  55427. * Get the effect name of the layer.
  55428. * @return The effect name
  55429. */
  55430. getEffectName(): string;
  55431. /**
  55432. * Create the merge effect. This is the shader use to blit the information back
  55433. * to the main canvas at the end of the scene rendering.
  55434. */
  55435. protected _createMergeEffect(): Effect;
  55436. /**
  55437. * Creates the render target textures and post processes used in the glow layer.
  55438. */
  55439. protected _createTextureAndPostProcesses(): void;
  55440. /**
  55441. * Checks for the readiness of the element composing the layer.
  55442. * @param subMesh the mesh to check for
  55443. * @param useInstances specify wether or not to use instances to render the mesh
  55444. * @param emissiveTexture the associated emissive texture used to generate the glow
  55445. * @return true if ready otherwise, false
  55446. */
  55447. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55448. /**
  55449. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55450. */
  55451. needStencil(): boolean;
  55452. /**
  55453. * Returns true if the mesh can be rendered, otherwise false.
  55454. * @param mesh The mesh to render
  55455. * @param material The material used on the mesh
  55456. * @returns true if it can be rendered otherwise false
  55457. */
  55458. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55459. /**
  55460. * Implementation specific of rendering the generating effect on the main canvas.
  55461. * @param effect The effect used to render through
  55462. */
  55463. protected _internalRender(effect: Effect): void;
  55464. /**
  55465. * Sets the required values for both the emissive texture and and the main color.
  55466. */
  55467. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55468. /**
  55469. * Returns true if the mesh should render, otherwise false.
  55470. * @param mesh The mesh to render
  55471. * @returns true if it should render otherwise false
  55472. */
  55473. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55474. /**
  55475. * Adds specific effects defines.
  55476. * @param defines The defines to add specifics to.
  55477. */
  55478. protected _addCustomEffectDefines(defines: string[]): void;
  55479. /**
  55480. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55481. * @param mesh The mesh to exclude from the glow layer
  55482. */
  55483. addExcludedMesh(mesh: Mesh): void;
  55484. /**
  55485. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55486. * @param mesh The mesh to remove
  55487. */
  55488. removeExcludedMesh(mesh: Mesh): void;
  55489. /**
  55490. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55491. * @param mesh The mesh to include in the glow layer
  55492. */
  55493. addIncludedOnlyMesh(mesh: Mesh): void;
  55494. /**
  55495. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55496. * @param mesh The mesh to remove
  55497. */
  55498. removeIncludedOnlyMesh(mesh: Mesh): void;
  55499. /**
  55500. * Determine if a given mesh will be used in the glow layer
  55501. * @param mesh The mesh to test
  55502. * @returns true if the mesh will be highlighted by the current glow layer
  55503. */
  55504. hasMesh(mesh: AbstractMesh): boolean;
  55505. /**
  55506. * Defines whether the current material of the mesh should be use to render the effect.
  55507. * @param mesh defines the current mesh to render
  55508. */
  55509. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55510. /**
  55511. * Add a mesh to be rendered through its own material and not with emissive only.
  55512. * @param mesh The mesh for which we need to use its material
  55513. */
  55514. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55515. /**
  55516. * Remove a mesh from being rendered through its own material and not with emissive only.
  55517. * @param mesh The mesh for which we need to not use its material
  55518. */
  55519. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55520. /**
  55521. * Free any resources and references associated to a mesh.
  55522. * Internal use
  55523. * @param mesh The mesh to free.
  55524. * @hidden
  55525. */
  55526. _disposeMesh(mesh: Mesh): void;
  55527. /**
  55528. * Gets the class name of the effect layer
  55529. * @returns the string with the class name of the effect layer
  55530. */
  55531. getClassName(): string;
  55532. /**
  55533. * Serializes this glow layer
  55534. * @returns a serialized glow layer object
  55535. */
  55536. serialize(): any;
  55537. /**
  55538. * Creates a Glow Layer from parsed glow layer data
  55539. * @param parsedGlowLayer defines glow layer data
  55540. * @param scene defines the current scene
  55541. * @param rootUrl defines the root URL containing the glow layer information
  55542. * @returns a parsed Glow Layer
  55543. */
  55544. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55545. }
  55546. }
  55547. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55548. /** @hidden */
  55549. export var glowBlurPostProcessPixelShader: {
  55550. name: string;
  55551. shader: string;
  55552. };
  55553. }
  55554. declare module "babylonjs/Layers/highlightLayer" {
  55555. import { Observable } from "babylonjs/Misc/observable";
  55556. import { Nullable } from "babylonjs/types";
  55557. import { Camera } from "babylonjs/Cameras/camera";
  55558. import { Scene } from "babylonjs/scene";
  55559. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55561. import { Mesh } from "babylonjs/Meshes/mesh";
  55562. import { Effect } from "babylonjs/Materials/effect";
  55563. import { Material } from "babylonjs/Materials/material";
  55564. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55565. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55566. import "babylonjs/Shaders/glowMapMerge.fragment";
  55567. import "babylonjs/Shaders/glowMapMerge.vertex";
  55568. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55569. module "babylonjs/abstractScene" {
  55570. interface AbstractScene {
  55571. /**
  55572. * Return a the first highlight layer of the scene with a given name.
  55573. * @param name The name of the highlight layer to look for.
  55574. * @return The highlight layer if found otherwise null.
  55575. */
  55576. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55577. }
  55578. }
  55579. /**
  55580. * Highlight layer options. This helps customizing the behaviour
  55581. * of the highlight layer.
  55582. */
  55583. export interface IHighlightLayerOptions {
  55584. /**
  55585. * Multiplication factor apply to the canvas size to compute the render target size
  55586. * used to generated the glowing objects (the smaller the faster).
  55587. */
  55588. mainTextureRatio: number;
  55589. /**
  55590. * Enforces a fixed size texture to ensure resize independant blur.
  55591. */
  55592. mainTextureFixedSize?: number;
  55593. /**
  55594. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55595. * of the picture to blur (the smaller the faster).
  55596. */
  55597. blurTextureSizeRatio: number;
  55598. /**
  55599. * How big in texel of the blur texture is the vertical blur.
  55600. */
  55601. blurVerticalSize: number;
  55602. /**
  55603. * How big in texel of the blur texture is the horizontal blur.
  55604. */
  55605. blurHorizontalSize: number;
  55606. /**
  55607. * Alpha blending mode used to apply the blur. Default is combine.
  55608. */
  55609. alphaBlendingMode: number;
  55610. /**
  55611. * The camera attached to the layer.
  55612. */
  55613. camera: Nullable<Camera>;
  55614. /**
  55615. * Should we display highlight as a solid stroke?
  55616. */
  55617. isStroke?: boolean;
  55618. /**
  55619. * The rendering group to draw the layer in.
  55620. */
  55621. renderingGroupId: number;
  55622. }
  55623. /**
  55624. * The highlight layer Helps adding a glow effect around a mesh.
  55625. *
  55626. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55627. * glowy meshes to your scene.
  55628. *
  55629. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55630. */
  55631. export class HighlightLayer extends EffectLayer {
  55632. name: string;
  55633. /**
  55634. * Effect Name of the highlight layer.
  55635. */
  55636. static readonly EffectName: string;
  55637. /**
  55638. * The neutral color used during the preparation of the glow effect.
  55639. * This is black by default as the blend operation is a blend operation.
  55640. */
  55641. static NeutralColor: Color4;
  55642. /**
  55643. * Stencil value used for glowing meshes.
  55644. */
  55645. static GlowingMeshStencilReference: number;
  55646. /**
  55647. * Stencil value used for the other meshes in the scene.
  55648. */
  55649. static NormalMeshStencilReference: number;
  55650. /**
  55651. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55652. */
  55653. innerGlow: boolean;
  55654. /**
  55655. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55656. */
  55657. outerGlow: boolean;
  55658. /**
  55659. * Specifies the horizontal size of the blur.
  55660. */
  55661. set blurHorizontalSize(value: number);
  55662. /**
  55663. * Specifies the vertical size of the blur.
  55664. */
  55665. set blurVerticalSize(value: number);
  55666. /**
  55667. * Gets the horizontal size of the blur.
  55668. */
  55669. get blurHorizontalSize(): number;
  55670. /**
  55671. * Gets the vertical size of the blur.
  55672. */
  55673. get blurVerticalSize(): number;
  55674. /**
  55675. * An event triggered when the highlight layer is being blurred.
  55676. */
  55677. onBeforeBlurObservable: Observable<HighlightLayer>;
  55678. /**
  55679. * An event triggered when the highlight layer has been blurred.
  55680. */
  55681. onAfterBlurObservable: Observable<HighlightLayer>;
  55682. private _instanceGlowingMeshStencilReference;
  55683. private _options;
  55684. private _downSamplePostprocess;
  55685. private _horizontalBlurPostprocess;
  55686. private _verticalBlurPostprocess;
  55687. private _blurTexture;
  55688. private _meshes;
  55689. private _excludedMeshes;
  55690. /**
  55691. * Instantiates a new highlight Layer and references it to the scene..
  55692. * @param name The name of the layer
  55693. * @param scene The scene to use the layer in
  55694. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55695. */
  55696. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55697. /**
  55698. * Get the effect name of the layer.
  55699. * @return The effect name
  55700. */
  55701. getEffectName(): string;
  55702. /**
  55703. * Create the merge effect. This is the shader use to blit the information back
  55704. * to the main canvas at the end of the scene rendering.
  55705. */
  55706. protected _createMergeEffect(): Effect;
  55707. /**
  55708. * Creates the render target textures and post processes used in the highlight layer.
  55709. */
  55710. protected _createTextureAndPostProcesses(): void;
  55711. /**
  55712. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55713. */
  55714. needStencil(): boolean;
  55715. /**
  55716. * Checks for the readiness of the element composing the layer.
  55717. * @param subMesh the mesh to check for
  55718. * @param useInstances specify wether or not to use instances to render the mesh
  55719. * @param emissiveTexture the associated emissive texture used to generate the glow
  55720. * @return true if ready otherwise, false
  55721. */
  55722. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55723. /**
  55724. * Implementation specific of rendering the generating effect on the main canvas.
  55725. * @param effect The effect used to render through
  55726. */
  55727. protected _internalRender(effect: Effect): void;
  55728. /**
  55729. * Returns true if the layer contains information to display, otherwise false.
  55730. */
  55731. shouldRender(): boolean;
  55732. /**
  55733. * Returns true if the mesh should render, otherwise false.
  55734. * @param mesh The mesh to render
  55735. * @returns true if it should render otherwise false
  55736. */
  55737. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55738. /**
  55739. * Sets the required values for both the emissive texture and and the main color.
  55740. */
  55741. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55742. /**
  55743. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55744. * @param mesh The mesh to exclude from the highlight layer
  55745. */
  55746. addExcludedMesh(mesh: Mesh): void;
  55747. /**
  55748. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55749. * @param mesh The mesh to highlight
  55750. */
  55751. removeExcludedMesh(mesh: Mesh): void;
  55752. /**
  55753. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55754. * @param mesh mesh to test
  55755. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55756. */
  55757. hasMesh(mesh: AbstractMesh): boolean;
  55758. /**
  55759. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55760. * @param mesh The mesh to highlight
  55761. * @param color The color of the highlight
  55762. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55763. */
  55764. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55765. /**
  55766. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55767. * @param mesh The mesh to highlight
  55768. */
  55769. removeMesh(mesh: Mesh): void;
  55770. /**
  55771. * Remove all the meshes currently referenced in the highlight layer
  55772. */
  55773. removeAllMeshes(): void;
  55774. /**
  55775. * Force the stencil to the normal expected value for none glowing parts
  55776. */
  55777. private _defaultStencilReference;
  55778. /**
  55779. * Free any resources and references associated to a mesh.
  55780. * Internal use
  55781. * @param mesh The mesh to free.
  55782. * @hidden
  55783. */
  55784. _disposeMesh(mesh: Mesh): void;
  55785. /**
  55786. * Dispose the highlight layer and free resources.
  55787. */
  55788. dispose(): void;
  55789. /**
  55790. * Gets the class name of the effect layer
  55791. * @returns the string with the class name of the effect layer
  55792. */
  55793. getClassName(): string;
  55794. /**
  55795. * Serializes this Highlight layer
  55796. * @returns a serialized Highlight layer object
  55797. */
  55798. serialize(): any;
  55799. /**
  55800. * Creates a Highlight layer from parsed Highlight layer data
  55801. * @param parsedHightlightLayer defines the Highlight layer data
  55802. * @param scene defines the current scene
  55803. * @param rootUrl defines the root URL containing the Highlight layer information
  55804. * @returns a parsed Highlight layer
  55805. */
  55806. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55807. }
  55808. }
  55809. declare module "babylonjs/Layers/layerSceneComponent" {
  55810. import { Scene } from "babylonjs/scene";
  55811. import { ISceneComponent } from "babylonjs/sceneComponent";
  55812. import { Layer } from "babylonjs/Layers/layer";
  55813. import { AbstractScene } from "babylonjs/abstractScene";
  55814. module "babylonjs/abstractScene" {
  55815. interface AbstractScene {
  55816. /**
  55817. * The list of layers (background and foreground) of the scene
  55818. */
  55819. layers: Array<Layer>;
  55820. }
  55821. }
  55822. /**
  55823. * Defines the layer scene component responsible to manage any layers
  55824. * in a given scene.
  55825. */
  55826. export class LayerSceneComponent implements ISceneComponent {
  55827. /**
  55828. * The component name helpfull to identify the component in the list of scene components.
  55829. */
  55830. readonly name: string;
  55831. /**
  55832. * The scene the component belongs to.
  55833. */
  55834. scene: Scene;
  55835. private _engine;
  55836. /**
  55837. * Creates a new instance of the component for the given scene
  55838. * @param scene Defines the scene to register the component in
  55839. */
  55840. constructor(scene: Scene);
  55841. /**
  55842. * Registers the component in a given scene
  55843. */
  55844. register(): void;
  55845. /**
  55846. * Rebuilds the elements related to this component in case of
  55847. * context lost for instance.
  55848. */
  55849. rebuild(): void;
  55850. /**
  55851. * Disposes the component and the associated ressources.
  55852. */
  55853. dispose(): void;
  55854. private _draw;
  55855. private _drawCameraPredicate;
  55856. private _drawCameraBackground;
  55857. private _drawCameraForeground;
  55858. private _drawRenderTargetPredicate;
  55859. private _drawRenderTargetBackground;
  55860. private _drawRenderTargetForeground;
  55861. /**
  55862. * Adds all the elements from the container to the scene
  55863. * @param container the container holding the elements
  55864. */
  55865. addFromContainer(container: AbstractScene): void;
  55866. /**
  55867. * Removes all the elements in the container from the scene
  55868. * @param container contains the elements to remove
  55869. * @param dispose if the removed element should be disposed (default: false)
  55870. */
  55871. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55872. }
  55873. }
  55874. declare module "babylonjs/Shaders/layer.fragment" {
  55875. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55876. /** @hidden */
  55877. export var layerPixelShader: {
  55878. name: string;
  55879. shader: string;
  55880. };
  55881. }
  55882. declare module "babylonjs/Shaders/layer.vertex" {
  55883. /** @hidden */
  55884. export var layerVertexShader: {
  55885. name: string;
  55886. shader: string;
  55887. };
  55888. }
  55889. declare module "babylonjs/Layers/layer" {
  55890. import { Observable } from "babylonjs/Misc/observable";
  55891. import { Nullable } from "babylonjs/types";
  55892. import { Scene } from "babylonjs/scene";
  55893. import { Vector2 } from "babylonjs/Maths/math.vector";
  55894. import { Color4 } from "babylonjs/Maths/math.color";
  55895. import { Texture } from "babylonjs/Materials/Textures/texture";
  55896. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55897. import "babylonjs/Shaders/layer.fragment";
  55898. import "babylonjs/Shaders/layer.vertex";
  55899. /**
  55900. * This represents a full screen 2d layer.
  55901. * This can be useful to display a picture in the background of your scene for instance.
  55902. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55903. */
  55904. export class Layer {
  55905. /**
  55906. * Define the name of the layer.
  55907. */
  55908. name: string;
  55909. /**
  55910. * Define the texture the layer should display.
  55911. */
  55912. texture: Nullable<Texture>;
  55913. /**
  55914. * Is the layer in background or foreground.
  55915. */
  55916. isBackground: boolean;
  55917. /**
  55918. * Define the color of the layer (instead of texture).
  55919. */
  55920. color: Color4;
  55921. /**
  55922. * Define the scale of the layer in order to zoom in out of the texture.
  55923. */
  55924. scale: Vector2;
  55925. /**
  55926. * Define an offset for the layer in order to shift the texture.
  55927. */
  55928. offset: Vector2;
  55929. /**
  55930. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  55931. */
  55932. alphaBlendingMode: number;
  55933. /**
  55934. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  55935. * Alpha test will not mix with the background color in case of transparency.
  55936. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  55937. */
  55938. alphaTest: boolean;
  55939. /**
  55940. * Define a mask to restrict the layer to only some of the scene cameras.
  55941. */
  55942. layerMask: number;
  55943. /**
  55944. * Define the list of render target the layer is visible into.
  55945. */
  55946. renderTargetTextures: RenderTargetTexture[];
  55947. /**
  55948. * Define if the layer is only used in renderTarget or if it also
  55949. * renders in the main frame buffer of the canvas.
  55950. */
  55951. renderOnlyInRenderTargetTextures: boolean;
  55952. private _scene;
  55953. private _vertexBuffers;
  55954. private _indexBuffer;
  55955. private _effect;
  55956. private _previousDefines;
  55957. /**
  55958. * An event triggered when the layer is disposed.
  55959. */
  55960. onDisposeObservable: Observable<Layer>;
  55961. private _onDisposeObserver;
  55962. /**
  55963. * Back compatibility with callback before the onDisposeObservable existed.
  55964. * The set callback will be triggered when the layer has been disposed.
  55965. */
  55966. set onDispose(callback: () => void);
  55967. /**
  55968. * An event triggered before rendering the scene
  55969. */
  55970. onBeforeRenderObservable: Observable<Layer>;
  55971. private _onBeforeRenderObserver;
  55972. /**
  55973. * Back compatibility with callback before the onBeforeRenderObservable existed.
  55974. * The set callback will be triggered just before rendering the layer.
  55975. */
  55976. set onBeforeRender(callback: () => void);
  55977. /**
  55978. * An event triggered after rendering the scene
  55979. */
  55980. onAfterRenderObservable: Observable<Layer>;
  55981. private _onAfterRenderObserver;
  55982. /**
  55983. * Back compatibility with callback before the onAfterRenderObservable existed.
  55984. * The set callback will be triggered just after rendering the layer.
  55985. */
  55986. set onAfterRender(callback: () => void);
  55987. /**
  55988. * Instantiates a new layer.
  55989. * This represents a full screen 2d layer.
  55990. * This can be useful to display a picture in the background of your scene for instance.
  55991. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55992. * @param name Define the name of the layer in the scene
  55993. * @param imgUrl Define the url of the texture to display in the layer
  55994. * @param scene Define the scene the layer belongs to
  55995. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  55996. * @param color Defines a color for the layer
  55997. */
  55998. constructor(
  55999. /**
  56000. * Define the name of the layer.
  56001. */
  56002. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56003. private _createIndexBuffer;
  56004. /** @hidden */
  56005. _rebuild(): void;
  56006. /**
  56007. * Renders the layer in the scene.
  56008. */
  56009. render(): void;
  56010. /**
  56011. * Disposes and releases the associated ressources.
  56012. */
  56013. dispose(): void;
  56014. }
  56015. }
  56016. declare module "babylonjs/Layers/index" {
  56017. export * from "babylonjs/Layers/effectLayer";
  56018. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56019. export * from "babylonjs/Layers/glowLayer";
  56020. export * from "babylonjs/Layers/highlightLayer";
  56021. export * from "babylonjs/Layers/layer";
  56022. export * from "babylonjs/Layers/layerSceneComponent";
  56023. }
  56024. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56025. /** @hidden */
  56026. export var lensFlarePixelShader: {
  56027. name: string;
  56028. shader: string;
  56029. };
  56030. }
  56031. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56032. /** @hidden */
  56033. export var lensFlareVertexShader: {
  56034. name: string;
  56035. shader: string;
  56036. };
  56037. }
  56038. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56039. import { Scene } from "babylonjs/scene";
  56040. import { Vector3 } from "babylonjs/Maths/math.vector";
  56041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56042. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56043. import "babylonjs/Shaders/lensFlare.fragment";
  56044. import "babylonjs/Shaders/lensFlare.vertex";
  56045. import { Viewport } from "babylonjs/Maths/math.viewport";
  56046. /**
  56047. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56048. * It is usually composed of several `lensFlare`.
  56049. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56050. */
  56051. export class LensFlareSystem {
  56052. /**
  56053. * Define the name of the lens flare system
  56054. */
  56055. name: string;
  56056. /**
  56057. * List of lens flares used in this system.
  56058. */
  56059. lensFlares: LensFlare[];
  56060. /**
  56061. * Define a limit from the border the lens flare can be visible.
  56062. */
  56063. borderLimit: number;
  56064. /**
  56065. * Define a viewport border we do not want to see the lens flare in.
  56066. */
  56067. viewportBorder: number;
  56068. /**
  56069. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56070. */
  56071. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56072. /**
  56073. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56074. */
  56075. layerMask: number;
  56076. /**
  56077. * Define the id of the lens flare system in the scene.
  56078. * (equal to name by default)
  56079. */
  56080. id: string;
  56081. private _scene;
  56082. private _emitter;
  56083. private _vertexBuffers;
  56084. private _indexBuffer;
  56085. private _effect;
  56086. private _positionX;
  56087. private _positionY;
  56088. private _isEnabled;
  56089. /** @hidden */
  56090. static _SceneComponentInitialization: (scene: Scene) => void;
  56091. /**
  56092. * Instantiates a lens flare system.
  56093. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56094. * It is usually composed of several `lensFlare`.
  56095. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56096. * @param name Define the name of the lens flare system in the scene
  56097. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56098. * @param scene Define the scene the lens flare system belongs to
  56099. */
  56100. constructor(
  56101. /**
  56102. * Define the name of the lens flare system
  56103. */
  56104. name: string, emitter: any, scene: Scene);
  56105. /**
  56106. * Define if the lens flare system is enabled.
  56107. */
  56108. get isEnabled(): boolean;
  56109. set isEnabled(value: boolean);
  56110. /**
  56111. * Get the scene the effects belongs to.
  56112. * @returns the scene holding the lens flare system
  56113. */
  56114. getScene(): Scene;
  56115. /**
  56116. * Get the emitter of the lens flare system.
  56117. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56118. * @returns the emitter of the lens flare system
  56119. */
  56120. getEmitter(): any;
  56121. /**
  56122. * Set the emitter of the lens flare system.
  56123. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56124. * @param newEmitter Define the new emitter of the system
  56125. */
  56126. setEmitter(newEmitter: any): void;
  56127. /**
  56128. * Get the lens flare system emitter position.
  56129. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56130. * @returns the position
  56131. */
  56132. getEmitterPosition(): Vector3;
  56133. /**
  56134. * @hidden
  56135. */
  56136. computeEffectivePosition(globalViewport: Viewport): boolean;
  56137. /** @hidden */
  56138. _isVisible(): boolean;
  56139. /**
  56140. * @hidden
  56141. */
  56142. render(): boolean;
  56143. /**
  56144. * Dispose and release the lens flare with its associated resources.
  56145. */
  56146. dispose(): void;
  56147. /**
  56148. * Parse a lens flare system from a JSON repressentation
  56149. * @param parsedLensFlareSystem Define the JSON to parse
  56150. * @param scene Define the scene the parsed system should be instantiated in
  56151. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56152. * @returns the parsed system
  56153. */
  56154. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56155. /**
  56156. * Serialize the current Lens Flare System into a JSON representation.
  56157. * @returns the serialized JSON
  56158. */
  56159. serialize(): any;
  56160. }
  56161. }
  56162. declare module "babylonjs/LensFlares/lensFlare" {
  56163. import { Nullable } from "babylonjs/types";
  56164. import { Color3 } from "babylonjs/Maths/math.color";
  56165. import { Texture } from "babylonjs/Materials/Textures/texture";
  56166. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56167. /**
  56168. * This represents one of the lens effect in a `lensFlareSystem`.
  56169. * It controls one of the indiviual texture used in the effect.
  56170. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56171. */
  56172. export class LensFlare {
  56173. /**
  56174. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56175. */
  56176. size: number;
  56177. /**
  56178. * 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.
  56179. */
  56180. position: number;
  56181. /**
  56182. * Define the lens color.
  56183. */
  56184. color: Color3;
  56185. /**
  56186. * Define the lens texture.
  56187. */
  56188. texture: Nullable<Texture>;
  56189. /**
  56190. * Define the alpha mode to render this particular lens.
  56191. */
  56192. alphaMode: number;
  56193. private _system;
  56194. /**
  56195. * Creates a new Lens Flare.
  56196. * This represents one of the lens effect in a `lensFlareSystem`.
  56197. * It controls one of the indiviual texture used in the effect.
  56198. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56199. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56200. * @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.
  56201. * @param color Define the lens color
  56202. * @param imgUrl Define the lens texture url
  56203. * @param system Define the `lensFlareSystem` this flare is part of
  56204. * @returns The newly created Lens Flare
  56205. */
  56206. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56207. /**
  56208. * Instantiates a new Lens Flare.
  56209. * This represents one of the lens effect in a `lensFlareSystem`.
  56210. * It controls one of the indiviual texture used in the effect.
  56211. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56212. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56213. * @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.
  56214. * @param color Define the lens color
  56215. * @param imgUrl Define the lens texture url
  56216. * @param system Define the `lensFlareSystem` this flare is part of
  56217. */
  56218. constructor(
  56219. /**
  56220. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56221. */
  56222. size: number,
  56223. /**
  56224. * 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.
  56225. */
  56226. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56227. /**
  56228. * Dispose and release the lens flare with its associated resources.
  56229. */
  56230. dispose(): void;
  56231. }
  56232. }
  56233. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56234. import { Nullable } from "babylonjs/types";
  56235. import { Scene } from "babylonjs/scene";
  56236. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56237. import { AbstractScene } from "babylonjs/abstractScene";
  56238. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56239. module "babylonjs/abstractScene" {
  56240. interface AbstractScene {
  56241. /**
  56242. * The list of lens flare system added to the scene
  56243. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56244. */
  56245. lensFlareSystems: Array<LensFlareSystem>;
  56246. /**
  56247. * Removes the given lens flare system from this scene.
  56248. * @param toRemove The lens flare system to remove
  56249. * @returns The index of the removed lens flare system
  56250. */
  56251. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56252. /**
  56253. * Adds the given lens flare system to this scene
  56254. * @param newLensFlareSystem The lens flare system to add
  56255. */
  56256. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56257. /**
  56258. * Gets a lens flare system using its name
  56259. * @param name defines the name to look for
  56260. * @returns the lens flare system or null if not found
  56261. */
  56262. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56263. /**
  56264. * Gets a lens flare system using its id
  56265. * @param id defines the id to look for
  56266. * @returns the lens flare system or null if not found
  56267. */
  56268. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56269. }
  56270. }
  56271. /**
  56272. * Defines the lens flare scene component responsible to manage any lens flares
  56273. * in a given scene.
  56274. */
  56275. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56276. /**
  56277. * The component name helpfull to identify the component in the list of scene components.
  56278. */
  56279. readonly name: string;
  56280. /**
  56281. * The scene the component belongs to.
  56282. */
  56283. scene: Scene;
  56284. /**
  56285. * Creates a new instance of the component for the given scene
  56286. * @param scene Defines the scene to register the component in
  56287. */
  56288. constructor(scene: Scene);
  56289. /**
  56290. * Registers the component in a given scene
  56291. */
  56292. register(): void;
  56293. /**
  56294. * Rebuilds the elements related to this component in case of
  56295. * context lost for instance.
  56296. */
  56297. rebuild(): void;
  56298. /**
  56299. * Adds all the elements from the container to the scene
  56300. * @param container the container holding the elements
  56301. */
  56302. addFromContainer(container: AbstractScene): void;
  56303. /**
  56304. * Removes all the elements in the container from the scene
  56305. * @param container contains the elements to remove
  56306. * @param dispose if the removed element should be disposed (default: false)
  56307. */
  56308. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56309. /**
  56310. * Serializes the component data to the specified json object
  56311. * @param serializationObject The object to serialize to
  56312. */
  56313. serialize(serializationObject: any): void;
  56314. /**
  56315. * Disposes the component and the associated ressources.
  56316. */
  56317. dispose(): void;
  56318. private _draw;
  56319. }
  56320. }
  56321. declare module "babylonjs/LensFlares/index" {
  56322. export * from "babylonjs/LensFlares/lensFlare";
  56323. export * from "babylonjs/LensFlares/lensFlareSystem";
  56324. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56325. }
  56326. declare module "babylonjs/Shaders/depth.fragment" {
  56327. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56328. /** @hidden */
  56329. export var depthPixelShader: {
  56330. name: string;
  56331. shader: string;
  56332. };
  56333. }
  56334. declare module "babylonjs/Shaders/depth.vertex" {
  56335. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56336. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56337. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56338. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56339. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56340. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56341. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56342. /** @hidden */
  56343. export var depthVertexShader: {
  56344. name: string;
  56345. shader: string;
  56346. };
  56347. }
  56348. declare module "babylonjs/Rendering/depthRenderer" {
  56349. import { Nullable } from "babylonjs/types";
  56350. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56351. import { Scene } from "babylonjs/scene";
  56352. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56353. import { Camera } from "babylonjs/Cameras/camera";
  56354. import "babylonjs/Shaders/depth.fragment";
  56355. import "babylonjs/Shaders/depth.vertex";
  56356. /**
  56357. * This represents a depth renderer in Babylon.
  56358. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56359. */
  56360. export class DepthRenderer {
  56361. private _scene;
  56362. private _depthMap;
  56363. private _effect;
  56364. private readonly _storeNonLinearDepth;
  56365. private readonly _clearColor;
  56366. /** Get if the depth renderer is using packed depth or not */
  56367. readonly isPacked: boolean;
  56368. private _cachedDefines;
  56369. private _camera;
  56370. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56371. enabled: boolean;
  56372. /**
  56373. * Specifiess that the depth renderer will only be used within
  56374. * the camera it is created for.
  56375. * This can help forcing its rendering during the camera processing.
  56376. */
  56377. useOnlyInActiveCamera: boolean;
  56378. /** @hidden */
  56379. static _SceneComponentInitialization: (scene: Scene) => void;
  56380. /**
  56381. * Instantiates a depth renderer
  56382. * @param scene The scene the renderer belongs to
  56383. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56384. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56385. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56386. */
  56387. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56388. /**
  56389. * Creates the depth rendering effect and checks if the effect is ready.
  56390. * @param subMesh The submesh to be used to render the depth map of
  56391. * @param useInstances If multiple world instances should be used
  56392. * @returns if the depth renderer is ready to render the depth map
  56393. */
  56394. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56395. /**
  56396. * Gets the texture which the depth map will be written to.
  56397. * @returns The depth map texture
  56398. */
  56399. getDepthMap(): RenderTargetTexture;
  56400. /**
  56401. * Disposes of the depth renderer.
  56402. */
  56403. dispose(): void;
  56404. }
  56405. }
  56406. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56407. /** @hidden */
  56408. export var minmaxReduxPixelShader: {
  56409. name: string;
  56410. shader: string;
  56411. };
  56412. }
  56413. declare module "babylonjs/Misc/minMaxReducer" {
  56414. import { Nullable } from "babylonjs/types";
  56415. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56416. import { Camera } from "babylonjs/Cameras/camera";
  56417. import { Observer } from "babylonjs/Misc/observable";
  56418. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56419. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56420. import { Observable } from "babylonjs/Misc/observable";
  56421. import "babylonjs/Shaders/minmaxRedux.fragment";
  56422. /**
  56423. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56424. * and maximum values from all values of the texture.
  56425. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56426. * The source values are read from the red channel of the texture.
  56427. */
  56428. export class MinMaxReducer {
  56429. /**
  56430. * Observable triggered when the computation has been performed
  56431. */
  56432. onAfterReductionPerformed: Observable<{
  56433. min: number;
  56434. max: number;
  56435. }>;
  56436. protected _camera: Camera;
  56437. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56438. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56439. protected _postProcessManager: PostProcessManager;
  56440. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56441. protected _forceFullscreenViewport: boolean;
  56442. /**
  56443. * Creates a min/max reducer
  56444. * @param camera The camera to use for the post processes
  56445. */
  56446. constructor(camera: Camera);
  56447. /**
  56448. * Gets the texture used to read the values from.
  56449. */
  56450. get sourceTexture(): Nullable<RenderTargetTexture>;
  56451. /**
  56452. * Sets the source texture to read the values from.
  56453. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56454. * because in such textures '1' value must not be taken into account to compute the maximum
  56455. * as this value is used to clear the texture.
  56456. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56457. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56458. * @param depthRedux Indicates if the texture is a depth texture or not
  56459. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56460. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56461. */
  56462. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56463. /**
  56464. * Defines the refresh rate of the computation.
  56465. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56466. */
  56467. get refreshRate(): number;
  56468. set refreshRate(value: number);
  56469. protected _activated: boolean;
  56470. /**
  56471. * Gets the activation status of the reducer
  56472. */
  56473. get activated(): boolean;
  56474. /**
  56475. * Activates the reduction computation.
  56476. * When activated, the observers registered in onAfterReductionPerformed are
  56477. * called after the compuation is performed
  56478. */
  56479. activate(): void;
  56480. /**
  56481. * Deactivates the reduction computation.
  56482. */
  56483. deactivate(): void;
  56484. /**
  56485. * Disposes the min/max reducer
  56486. * @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.
  56487. */
  56488. dispose(disposeAll?: boolean): void;
  56489. }
  56490. }
  56491. declare module "babylonjs/Misc/depthReducer" {
  56492. import { Nullable } from "babylonjs/types";
  56493. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56494. import { Camera } from "babylonjs/Cameras/camera";
  56495. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56496. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56497. /**
  56498. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56499. */
  56500. export class DepthReducer extends MinMaxReducer {
  56501. private _depthRenderer;
  56502. private _depthRendererId;
  56503. /**
  56504. * Gets the depth renderer used for the computation.
  56505. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56506. */
  56507. get depthRenderer(): Nullable<DepthRenderer>;
  56508. /**
  56509. * Creates a depth reducer
  56510. * @param camera The camera used to render the depth texture
  56511. */
  56512. constructor(camera: Camera);
  56513. /**
  56514. * Sets the depth renderer to use to generate the depth map
  56515. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56516. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56517. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56518. */
  56519. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56520. /** @hidden */
  56521. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56522. /**
  56523. * Activates the reduction computation.
  56524. * When activated, the observers registered in onAfterReductionPerformed are
  56525. * called after the compuation is performed
  56526. */
  56527. activate(): void;
  56528. /**
  56529. * Deactivates the reduction computation.
  56530. */
  56531. deactivate(): void;
  56532. /**
  56533. * Disposes the depth reducer
  56534. * @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.
  56535. */
  56536. dispose(disposeAll?: boolean): void;
  56537. }
  56538. }
  56539. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56540. import { Nullable } from "babylonjs/types";
  56541. import { Scene } from "babylonjs/scene";
  56542. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56543. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56544. import { Effect } from "babylonjs/Materials/effect";
  56545. import "babylonjs/Shaders/shadowMap.fragment";
  56546. import "babylonjs/Shaders/shadowMap.vertex";
  56547. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56548. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56549. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56550. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56551. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56552. /**
  56553. * A CSM implementation allowing casting shadows on large scenes.
  56554. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56555. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56556. */
  56557. export class CascadedShadowGenerator extends ShadowGenerator {
  56558. private static readonly frustumCornersNDCSpace;
  56559. /**
  56560. * Name of the CSM class
  56561. */
  56562. static CLASSNAME: string;
  56563. /**
  56564. * Defines the default number of cascades used by the CSM.
  56565. */
  56566. static readonly DEFAULT_CASCADES_COUNT: number;
  56567. /**
  56568. * Defines the minimum number of cascades used by the CSM.
  56569. */
  56570. static readonly MIN_CASCADES_COUNT: number;
  56571. /**
  56572. * Defines the maximum number of cascades used by the CSM.
  56573. */
  56574. static readonly MAX_CASCADES_COUNT: number;
  56575. protected _validateFilter(filter: number): number;
  56576. /**
  56577. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56578. */
  56579. penumbraDarkness: number;
  56580. private _numCascades;
  56581. /**
  56582. * Gets or set the number of cascades used by the CSM.
  56583. */
  56584. get numCascades(): number;
  56585. set numCascades(value: number);
  56586. /**
  56587. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56588. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56589. */
  56590. stabilizeCascades: boolean;
  56591. private _freezeShadowCastersBoundingInfo;
  56592. private _freezeShadowCastersBoundingInfoObservable;
  56593. /**
  56594. * Enables or disables the shadow casters bounding info computation.
  56595. * If your shadow casters don't move, you can disable this feature.
  56596. * If it is enabled, the bounding box computation is done every frame.
  56597. */
  56598. get freezeShadowCastersBoundingInfo(): boolean;
  56599. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56600. private _scbiMin;
  56601. private _scbiMax;
  56602. protected _computeShadowCastersBoundingInfo(): void;
  56603. protected _shadowCastersBoundingInfo: BoundingInfo;
  56604. /**
  56605. * Gets or sets the shadow casters bounding info.
  56606. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56607. * so that the system won't overwrite the bounds you provide
  56608. */
  56609. get shadowCastersBoundingInfo(): BoundingInfo;
  56610. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56611. protected _breaksAreDirty: boolean;
  56612. protected _minDistance: number;
  56613. protected _maxDistance: number;
  56614. /**
  56615. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56616. *
  56617. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56618. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56619. * @param min minimal distance for the breaks (default to 0.)
  56620. * @param max maximal distance for the breaks (default to 1.)
  56621. */
  56622. setMinMaxDistance(min: number, max: number): void;
  56623. /** Gets the minimal distance used in the cascade break computation */
  56624. get minDistance(): number;
  56625. /** Gets the maximal distance used in the cascade break computation */
  56626. get maxDistance(): number;
  56627. /**
  56628. * Gets the class name of that object
  56629. * @returns "CascadedShadowGenerator"
  56630. */
  56631. getClassName(): string;
  56632. private _cascadeMinExtents;
  56633. private _cascadeMaxExtents;
  56634. /**
  56635. * Gets a cascade minimum extents
  56636. * @param cascadeIndex index of the cascade
  56637. * @returns the minimum cascade extents
  56638. */
  56639. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56640. /**
  56641. * Gets a cascade maximum extents
  56642. * @param cascadeIndex index of the cascade
  56643. * @returns the maximum cascade extents
  56644. */
  56645. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56646. private _cascades;
  56647. private _currentLayer;
  56648. private _viewSpaceFrustumsZ;
  56649. private _viewMatrices;
  56650. private _projectionMatrices;
  56651. private _transformMatrices;
  56652. private _transformMatricesAsArray;
  56653. private _frustumLengths;
  56654. private _lightSizeUVCorrection;
  56655. private _depthCorrection;
  56656. private _frustumCornersWorldSpace;
  56657. private _frustumCenter;
  56658. private _shadowCameraPos;
  56659. private _shadowMaxZ;
  56660. /**
  56661. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56662. * It defaults to camera.maxZ
  56663. */
  56664. get shadowMaxZ(): number;
  56665. /**
  56666. * Sets the shadow max z distance.
  56667. */
  56668. set shadowMaxZ(value: number);
  56669. protected _debug: boolean;
  56670. /**
  56671. * Gets or sets the debug flag.
  56672. * When enabled, the cascades are materialized by different colors on the screen.
  56673. */
  56674. get debug(): boolean;
  56675. set debug(dbg: boolean);
  56676. private _depthClamp;
  56677. /**
  56678. * Gets or sets the depth clamping value.
  56679. *
  56680. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56681. * to account for the shadow casters far away.
  56682. *
  56683. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56684. */
  56685. get depthClamp(): boolean;
  56686. set depthClamp(value: boolean);
  56687. private _cascadeBlendPercentage;
  56688. /**
  56689. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56690. * It defaults to 0.1 (10% blending).
  56691. */
  56692. get cascadeBlendPercentage(): number;
  56693. set cascadeBlendPercentage(value: number);
  56694. private _lambda;
  56695. /**
  56696. * Gets or set the lambda parameter.
  56697. * This parameter is used to split the camera frustum and create the cascades.
  56698. * 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.
  56699. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56700. */
  56701. get lambda(): number;
  56702. set lambda(value: number);
  56703. /**
  56704. * Gets the view matrix corresponding to a given cascade
  56705. * @param cascadeNum cascade to retrieve the view matrix from
  56706. * @returns the cascade view matrix
  56707. */
  56708. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56709. /**
  56710. * Gets the projection matrix corresponding to a given cascade
  56711. * @param cascadeNum cascade to retrieve the projection matrix from
  56712. * @returns the cascade projection matrix
  56713. */
  56714. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56715. /**
  56716. * Gets the transformation matrix corresponding to a given cascade
  56717. * @param cascadeNum cascade to retrieve the transformation matrix from
  56718. * @returns the cascade transformation matrix
  56719. */
  56720. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56721. private _depthRenderer;
  56722. /**
  56723. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56724. *
  56725. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56726. *
  56727. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56728. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56729. * @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
  56730. */
  56731. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56732. private _depthReducer;
  56733. private _autoCalcDepthBounds;
  56734. /**
  56735. * Gets or sets the autoCalcDepthBounds property.
  56736. *
  56737. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56738. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56739. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56740. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56741. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56742. */
  56743. get autoCalcDepthBounds(): boolean;
  56744. set autoCalcDepthBounds(value: boolean);
  56745. /**
  56746. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56747. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56748. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56749. * for setting the refresh rate on the renderer yourself!
  56750. */
  56751. get autoCalcDepthBoundsRefreshRate(): number;
  56752. set autoCalcDepthBoundsRefreshRate(value: number);
  56753. /**
  56754. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56755. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56756. * you change the camera near/far planes!
  56757. */
  56758. splitFrustum(): void;
  56759. private _splitFrustum;
  56760. private _computeMatrices;
  56761. private _computeFrustumInWorldSpace;
  56762. private _computeCascadeFrustum;
  56763. /** @hidden */
  56764. static _SceneComponentInitialization: (scene: Scene) => void;
  56765. /**
  56766. * Creates a Cascaded Shadow Generator object.
  56767. * A ShadowGenerator is the required tool to use the shadows.
  56768. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56769. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56770. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56771. * @param light The directional light object generating the shadows.
  56772. * @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.
  56773. */
  56774. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56775. protected _initializeGenerator(): void;
  56776. protected _createTargetRenderTexture(): void;
  56777. protected _initializeShadowMap(): void;
  56778. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56779. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56780. /**
  56781. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56782. * @param defines Defines of the material we want to update
  56783. * @param lightIndex Index of the light in the enabled light list of the material
  56784. */
  56785. prepareDefines(defines: any, lightIndex: number): void;
  56786. /**
  56787. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  56788. * defined in the generator but impacting the effect).
  56789. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  56790. * @param effect The effect we are binfing the information for
  56791. */
  56792. bindShadowLight(lightIndex: string, effect: Effect): void;
  56793. /**
  56794. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  56795. * (eq to view projection * shadow projection matrices)
  56796. * @returns The transform matrix used to create the shadow map
  56797. */
  56798. getTransformMatrix(): Matrix;
  56799. /**
  56800. * Disposes the ShadowGenerator.
  56801. * Returns nothing.
  56802. */
  56803. dispose(): void;
  56804. /**
  56805. * Serializes the shadow generator setup to a json object.
  56806. * @returns The serialized JSON object
  56807. */
  56808. serialize(): any;
  56809. /**
  56810. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  56811. * @param parsedShadowGenerator The JSON object to parse
  56812. * @param scene The scene to create the shadow map for
  56813. * @returns The parsed shadow generator
  56814. */
  56815. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  56816. }
  56817. }
  56818. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56819. import { Scene } from "babylonjs/scene";
  56820. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56821. import { AbstractScene } from "babylonjs/abstractScene";
  56822. /**
  56823. * Defines the shadow generator component responsible to manage any shadow generators
  56824. * in a given scene.
  56825. */
  56826. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56827. /**
  56828. * The component name helpfull to identify the component in the list of scene components.
  56829. */
  56830. readonly name: string;
  56831. /**
  56832. * The scene the component belongs to.
  56833. */
  56834. scene: Scene;
  56835. /**
  56836. * Creates a new instance of the component for the given scene
  56837. * @param scene Defines the scene to register the component in
  56838. */
  56839. constructor(scene: Scene);
  56840. /**
  56841. * Registers the component in a given scene
  56842. */
  56843. register(): void;
  56844. /**
  56845. * Rebuilds the elements related to this component in case of
  56846. * context lost for instance.
  56847. */
  56848. rebuild(): void;
  56849. /**
  56850. * Serializes the component data to the specified json object
  56851. * @param serializationObject The object to serialize to
  56852. */
  56853. serialize(serializationObject: any): void;
  56854. /**
  56855. * Adds all the elements from the container to the scene
  56856. * @param container the container holding the elements
  56857. */
  56858. addFromContainer(container: AbstractScene): void;
  56859. /**
  56860. * Removes all the elements in the container from the scene
  56861. * @param container contains the elements to remove
  56862. * @param dispose if the removed element should be disposed (default: false)
  56863. */
  56864. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56865. /**
  56866. * Rebuilds the elements related to this component in case of
  56867. * context lost for instance.
  56868. */
  56869. dispose(): void;
  56870. private _gatherRenderTargets;
  56871. }
  56872. }
  56873. declare module "babylonjs/Lights/Shadows/index" {
  56874. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56875. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  56876. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56877. }
  56878. declare module "babylonjs/Lights/pointLight" {
  56879. import { Scene } from "babylonjs/scene";
  56880. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56882. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56883. import { Effect } from "babylonjs/Materials/effect";
  56884. /**
  56885. * A point light is a light defined by an unique point in world space.
  56886. * The light is emitted in every direction from this point.
  56887. * A good example of a point light is a standard light bulb.
  56888. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56889. */
  56890. export class PointLight extends ShadowLight {
  56891. private _shadowAngle;
  56892. /**
  56893. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56894. * This specifies what angle the shadow will use to be created.
  56895. *
  56896. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56897. */
  56898. get shadowAngle(): number;
  56899. /**
  56900. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56901. * This specifies what angle the shadow will use to be created.
  56902. *
  56903. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56904. */
  56905. set shadowAngle(value: number);
  56906. /**
  56907. * Gets the direction if it has been set.
  56908. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56909. */
  56910. get direction(): Vector3;
  56911. /**
  56912. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56913. */
  56914. set direction(value: Vector3);
  56915. /**
  56916. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56917. * A PointLight emits the light in every direction.
  56918. * It can cast shadows.
  56919. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56920. * ```javascript
  56921. * var pointLight = new PointLight("pl", camera.position, scene);
  56922. * ```
  56923. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56924. * @param name The light friendly name
  56925. * @param position The position of the point light in the scene
  56926. * @param scene The scene the lights belongs to
  56927. */
  56928. constructor(name: string, position: Vector3, scene: Scene);
  56929. /**
  56930. * Returns the string "PointLight"
  56931. * @returns the class name
  56932. */
  56933. getClassName(): string;
  56934. /**
  56935. * Returns the integer 0.
  56936. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56937. */
  56938. getTypeID(): number;
  56939. /**
  56940. * Specifies wether or not the shadowmap should be a cube texture.
  56941. * @returns true if the shadowmap needs to be a cube texture.
  56942. */
  56943. needCube(): boolean;
  56944. /**
  56945. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  56946. * @param faceIndex The index of the face we are computed the direction to generate shadow
  56947. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  56948. */
  56949. getShadowDirection(faceIndex?: number): Vector3;
  56950. /**
  56951. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  56952. * - fov = PI / 2
  56953. * - aspect ratio : 1.0
  56954. * - z-near and far equal to the active camera minZ and maxZ.
  56955. * Returns the PointLight.
  56956. */
  56957. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56958. protected _buildUniformLayout(): void;
  56959. /**
  56960. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  56961. * @param effect The effect to update
  56962. * @param lightIndex The index of the light in the effect to update
  56963. * @returns The point light
  56964. */
  56965. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  56966. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56967. /**
  56968. * Prepares the list of defines specific to the light type.
  56969. * @param defines the list of defines
  56970. * @param lightIndex defines the index of the light for the effect
  56971. */
  56972. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56973. }
  56974. }
  56975. declare module "babylonjs/Lights/index" {
  56976. export * from "babylonjs/Lights/light";
  56977. export * from "babylonjs/Lights/shadowLight";
  56978. export * from "babylonjs/Lights/Shadows/index";
  56979. export * from "babylonjs/Lights/directionalLight";
  56980. export * from "babylonjs/Lights/hemisphericLight";
  56981. export * from "babylonjs/Lights/pointLight";
  56982. export * from "babylonjs/Lights/spotLight";
  56983. }
  56984. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  56985. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56986. /**
  56987. * Header information of HDR texture files.
  56988. */
  56989. export interface HDRInfo {
  56990. /**
  56991. * The height of the texture in pixels.
  56992. */
  56993. height: number;
  56994. /**
  56995. * The width of the texture in pixels.
  56996. */
  56997. width: number;
  56998. /**
  56999. * The index of the beginning of the data in the binary file.
  57000. */
  57001. dataPosition: number;
  57002. }
  57003. /**
  57004. * This groups tools to convert HDR texture to native colors array.
  57005. */
  57006. export class HDRTools {
  57007. private static Ldexp;
  57008. private static Rgbe2float;
  57009. private static readStringLine;
  57010. /**
  57011. * Reads header information from an RGBE texture stored in a native array.
  57012. * More information on this format are available here:
  57013. * https://en.wikipedia.org/wiki/RGBE_image_format
  57014. *
  57015. * @param uint8array The binary file stored in native array.
  57016. * @return The header information.
  57017. */
  57018. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57019. /**
  57020. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57021. * This RGBE texture needs to store the information as a panorama.
  57022. *
  57023. * More information on this format are available here:
  57024. * https://en.wikipedia.org/wiki/RGBE_image_format
  57025. *
  57026. * @param buffer The binary file stored in an array buffer.
  57027. * @param size The expected size of the extracted cubemap.
  57028. * @return The Cube Map information.
  57029. */
  57030. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57031. /**
  57032. * Returns the pixels data extracted from an RGBE texture.
  57033. * This pixels will be stored left to right up to down in the R G B order in one array.
  57034. *
  57035. * More information on this format are available here:
  57036. * https://en.wikipedia.org/wiki/RGBE_image_format
  57037. *
  57038. * @param uint8array The binary file stored in an array buffer.
  57039. * @param hdrInfo The header information of the file.
  57040. * @return The pixels data in RGB right to left up to down order.
  57041. */
  57042. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57043. private static RGBE_ReadPixels_RLE;
  57044. }
  57045. }
  57046. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57047. import { Nullable } from "babylonjs/types";
  57048. import { Scene } from "babylonjs/scene";
  57049. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57050. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57051. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57052. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57053. /**
  57054. * This represents a texture coming from an HDR input.
  57055. *
  57056. * The only supported format is currently panorama picture stored in RGBE format.
  57057. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57058. */
  57059. export class HDRCubeTexture extends BaseTexture {
  57060. private static _facesMapping;
  57061. private _generateHarmonics;
  57062. private _noMipmap;
  57063. private _textureMatrix;
  57064. private _size;
  57065. private _onLoad;
  57066. private _onError;
  57067. /**
  57068. * The texture URL.
  57069. */
  57070. url: string;
  57071. /**
  57072. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57073. */
  57074. coordinatesMode: number;
  57075. protected _isBlocking: boolean;
  57076. /**
  57077. * Sets wether or not the texture is blocking during loading.
  57078. */
  57079. set isBlocking(value: boolean);
  57080. /**
  57081. * Gets wether or not the texture is blocking during loading.
  57082. */
  57083. get isBlocking(): boolean;
  57084. protected _rotationY: number;
  57085. /**
  57086. * Sets texture matrix rotation angle around Y axis in radians.
  57087. */
  57088. set rotationY(value: number);
  57089. /**
  57090. * Gets texture matrix rotation angle around Y axis radians.
  57091. */
  57092. get rotationY(): number;
  57093. /**
  57094. * Gets or sets the center of the bounding box associated with the cube texture
  57095. * It must define where the camera used to render the texture was set
  57096. */
  57097. boundingBoxPosition: Vector3;
  57098. private _boundingBoxSize;
  57099. /**
  57100. * Gets or sets the size of the bounding box associated with the cube texture
  57101. * When defined, the cubemap will switch to local mode
  57102. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57103. * @example https://www.babylonjs-playground.com/#RNASML
  57104. */
  57105. set boundingBoxSize(value: Vector3);
  57106. get boundingBoxSize(): Vector3;
  57107. /**
  57108. * Instantiates an HDRTexture from the following parameters.
  57109. *
  57110. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57111. * @param scene The scene the texture will be used in
  57112. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57113. * @param noMipmap Forces to not generate the mipmap if true
  57114. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57115. * @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)
  57116. * @param reserved Reserved flag for internal use.
  57117. */
  57118. 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>);
  57119. /**
  57120. * Get the current class name of the texture useful for serialization or dynamic coding.
  57121. * @returns "HDRCubeTexture"
  57122. */
  57123. getClassName(): string;
  57124. /**
  57125. * Occurs when the file is raw .hdr file.
  57126. */
  57127. private loadTexture;
  57128. clone(): HDRCubeTexture;
  57129. delayLoad(): void;
  57130. /**
  57131. * Get the texture reflection matrix used to rotate/transform the reflection.
  57132. * @returns the reflection matrix
  57133. */
  57134. getReflectionTextureMatrix(): Matrix;
  57135. /**
  57136. * Set the texture reflection matrix used to rotate/transform the reflection.
  57137. * @param value Define the reflection matrix to set
  57138. */
  57139. setReflectionTextureMatrix(value: Matrix): void;
  57140. /**
  57141. * Parses a JSON representation of an HDR Texture in order to create the texture
  57142. * @param parsedTexture Define the JSON representation
  57143. * @param scene Define the scene the texture should be created in
  57144. * @param rootUrl Define the root url in case we need to load relative dependencies
  57145. * @returns the newly created texture after parsing
  57146. */
  57147. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57148. serialize(): any;
  57149. }
  57150. }
  57151. declare module "babylonjs/Physics/physicsEngine" {
  57152. import { Nullable } from "babylonjs/types";
  57153. import { Vector3 } from "babylonjs/Maths/math.vector";
  57154. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57155. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57156. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57157. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57158. /**
  57159. * Class used to control physics engine
  57160. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57161. */
  57162. export class PhysicsEngine implements IPhysicsEngine {
  57163. private _physicsPlugin;
  57164. /**
  57165. * Global value used to control the smallest number supported by the simulation
  57166. */
  57167. static Epsilon: number;
  57168. private _impostors;
  57169. private _joints;
  57170. private _subTimeStep;
  57171. /**
  57172. * Gets the gravity vector used by the simulation
  57173. */
  57174. gravity: Vector3;
  57175. /**
  57176. * Factory used to create the default physics plugin.
  57177. * @returns The default physics plugin
  57178. */
  57179. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57180. /**
  57181. * Creates a new Physics Engine
  57182. * @param gravity defines the gravity vector used by the simulation
  57183. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57184. */
  57185. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57186. /**
  57187. * Sets the gravity vector used by the simulation
  57188. * @param gravity defines the gravity vector to use
  57189. */
  57190. setGravity(gravity: Vector3): void;
  57191. /**
  57192. * Set the time step of the physics engine.
  57193. * Default is 1/60.
  57194. * To slow it down, enter 1/600 for example.
  57195. * To speed it up, 1/30
  57196. * @param newTimeStep defines the new timestep to apply to this world.
  57197. */
  57198. setTimeStep(newTimeStep?: number): void;
  57199. /**
  57200. * Get the time step of the physics engine.
  57201. * @returns the current time step
  57202. */
  57203. getTimeStep(): number;
  57204. /**
  57205. * Set the sub time step of the physics engine.
  57206. * Default is 0 meaning there is no sub steps
  57207. * To increase physics resolution precision, set a small value (like 1 ms)
  57208. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57209. */
  57210. setSubTimeStep(subTimeStep?: number): void;
  57211. /**
  57212. * Get the sub time step of the physics engine.
  57213. * @returns the current sub time step
  57214. */
  57215. getSubTimeStep(): number;
  57216. /**
  57217. * Release all resources
  57218. */
  57219. dispose(): void;
  57220. /**
  57221. * Gets the name of the current physics plugin
  57222. * @returns the name of the plugin
  57223. */
  57224. getPhysicsPluginName(): string;
  57225. /**
  57226. * Adding a new impostor for the impostor tracking.
  57227. * This will be done by the impostor itself.
  57228. * @param impostor the impostor to add
  57229. */
  57230. addImpostor(impostor: PhysicsImpostor): void;
  57231. /**
  57232. * Remove an impostor from the engine.
  57233. * This impostor and its mesh will not longer be updated by the physics engine.
  57234. * @param impostor the impostor to remove
  57235. */
  57236. removeImpostor(impostor: PhysicsImpostor): void;
  57237. /**
  57238. * Add a joint to the physics engine
  57239. * @param mainImpostor defines the main impostor to which the joint is added.
  57240. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57241. * @param joint defines the joint that will connect both impostors.
  57242. */
  57243. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57244. /**
  57245. * Removes a joint from the simulation
  57246. * @param mainImpostor defines the impostor used with the joint
  57247. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57248. * @param joint defines the joint to remove
  57249. */
  57250. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57251. /**
  57252. * Called by the scene. No need to call it.
  57253. * @param delta defines the timespam between frames
  57254. */
  57255. _step(delta: number): void;
  57256. /**
  57257. * Gets the current plugin used to run the simulation
  57258. * @returns current plugin
  57259. */
  57260. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57261. /**
  57262. * Gets the list of physic impostors
  57263. * @returns an array of PhysicsImpostor
  57264. */
  57265. getImpostors(): Array<PhysicsImpostor>;
  57266. /**
  57267. * Gets the impostor for a physics enabled object
  57268. * @param object defines the object impersonated by the impostor
  57269. * @returns the PhysicsImpostor or null if not found
  57270. */
  57271. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57272. /**
  57273. * Gets the impostor for a physics body object
  57274. * @param body defines physics body used by the impostor
  57275. * @returns the PhysicsImpostor or null if not found
  57276. */
  57277. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57278. /**
  57279. * Does a raycast in the physics world
  57280. * @param from when should the ray start?
  57281. * @param to when should the ray end?
  57282. * @returns PhysicsRaycastResult
  57283. */
  57284. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57285. }
  57286. }
  57287. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57288. import { Nullable } from "babylonjs/types";
  57289. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57291. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57292. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57293. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57294. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57295. /** @hidden */
  57296. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57297. private _useDeltaForWorldStep;
  57298. world: any;
  57299. name: string;
  57300. private _physicsMaterials;
  57301. private _fixedTimeStep;
  57302. private _cannonRaycastResult;
  57303. private _raycastResult;
  57304. private _physicsBodysToRemoveAfterStep;
  57305. BJSCANNON: any;
  57306. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57307. setGravity(gravity: Vector3): void;
  57308. setTimeStep(timeStep: number): void;
  57309. getTimeStep(): number;
  57310. executeStep(delta: number): void;
  57311. private _removeMarkedPhysicsBodiesFromWorld;
  57312. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57313. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57314. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57315. private _processChildMeshes;
  57316. removePhysicsBody(impostor: PhysicsImpostor): void;
  57317. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57318. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57319. private _addMaterial;
  57320. private _checkWithEpsilon;
  57321. private _createShape;
  57322. private _createHeightmap;
  57323. private _minus90X;
  57324. private _plus90X;
  57325. private _tmpPosition;
  57326. private _tmpDeltaPosition;
  57327. private _tmpUnityRotation;
  57328. private _updatePhysicsBodyTransformation;
  57329. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57330. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57331. isSupported(): boolean;
  57332. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57333. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57334. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57335. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57336. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57337. getBodyMass(impostor: PhysicsImpostor): number;
  57338. getBodyFriction(impostor: PhysicsImpostor): number;
  57339. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57340. getBodyRestitution(impostor: PhysicsImpostor): number;
  57341. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57342. sleepBody(impostor: PhysicsImpostor): void;
  57343. wakeUpBody(impostor: PhysicsImpostor): void;
  57344. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57345. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57346. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57347. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57348. getRadius(impostor: PhysicsImpostor): number;
  57349. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57350. dispose(): void;
  57351. private _extendNamespace;
  57352. /**
  57353. * Does a raycast in the physics world
  57354. * @param from when should the ray start?
  57355. * @param to when should the ray end?
  57356. * @returns PhysicsRaycastResult
  57357. */
  57358. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57359. }
  57360. }
  57361. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57362. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57363. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57364. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57365. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57366. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57367. import { Nullable } from "babylonjs/types";
  57368. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57369. /** @hidden */
  57370. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57371. world: any;
  57372. name: string;
  57373. BJSOIMO: any;
  57374. private _raycastResult;
  57375. constructor(iterations?: number, oimoInjection?: any);
  57376. setGravity(gravity: Vector3): void;
  57377. setTimeStep(timeStep: number): void;
  57378. getTimeStep(): number;
  57379. private _tmpImpostorsArray;
  57380. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57381. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57382. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57383. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57384. private _tmpPositionVector;
  57385. removePhysicsBody(impostor: PhysicsImpostor): void;
  57386. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57387. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57388. isSupported(): boolean;
  57389. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57390. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57391. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57392. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57393. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57394. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57395. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57396. getBodyMass(impostor: PhysicsImpostor): number;
  57397. getBodyFriction(impostor: PhysicsImpostor): number;
  57398. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57399. getBodyRestitution(impostor: PhysicsImpostor): number;
  57400. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57401. sleepBody(impostor: PhysicsImpostor): void;
  57402. wakeUpBody(impostor: PhysicsImpostor): void;
  57403. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57404. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57405. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57406. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57407. getRadius(impostor: PhysicsImpostor): number;
  57408. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57409. dispose(): void;
  57410. /**
  57411. * Does a raycast in the physics world
  57412. * @param from when should the ray start?
  57413. * @param to when should the ray end?
  57414. * @returns PhysicsRaycastResult
  57415. */
  57416. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57417. }
  57418. }
  57419. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57420. import { Nullable } from "babylonjs/types";
  57421. import { Scene } from "babylonjs/scene";
  57422. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57423. import { Color4 } from "babylonjs/Maths/math.color";
  57424. import { Mesh } from "babylonjs/Meshes/mesh";
  57425. /**
  57426. * Class containing static functions to help procedurally build meshes
  57427. */
  57428. export class RibbonBuilder {
  57429. /**
  57430. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57431. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57432. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57433. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57434. * * 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
  57435. * * 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
  57436. * * 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
  57437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57438. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57439. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57440. * * 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
  57441. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57442. * * 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
  57443. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57445. * @param name defines the name of the mesh
  57446. * @param options defines the options used to create the mesh
  57447. * @param scene defines the hosting scene
  57448. * @returns the ribbon mesh
  57449. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57450. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57451. */
  57452. static CreateRibbon(name: string, options: {
  57453. pathArray: Vector3[][];
  57454. closeArray?: boolean;
  57455. closePath?: boolean;
  57456. offset?: number;
  57457. updatable?: boolean;
  57458. sideOrientation?: number;
  57459. frontUVs?: Vector4;
  57460. backUVs?: Vector4;
  57461. instance?: Mesh;
  57462. invertUV?: boolean;
  57463. uvs?: Vector2[];
  57464. colors?: Color4[];
  57465. }, scene?: Nullable<Scene>): Mesh;
  57466. }
  57467. }
  57468. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57469. import { Nullable } from "babylonjs/types";
  57470. import { Scene } from "babylonjs/scene";
  57471. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57472. import { Mesh } from "babylonjs/Meshes/mesh";
  57473. /**
  57474. * Class containing static functions to help procedurally build meshes
  57475. */
  57476. export class ShapeBuilder {
  57477. /**
  57478. * 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.
  57479. * * 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.
  57480. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57481. * * 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.
  57482. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57483. * * 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
  57484. * * 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
  57485. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57487. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57488. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57490. * @param name defines the name of the mesh
  57491. * @param options defines the options used to create the mesh
  57492. * @param scene defines the hosting scene
  57493. * @returns the extruded shape mesh
  57494. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57495. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57496. */
  57497. static ExtrudeShape(name: string, options: {
  57498. shape: Vector3[];
  57499. path: Vector3[];
  57500. scale?: number;
  57501. rotation?: number;
  57502. cap?: number;
  57503. updatable?: boolean;
  57504. sideOrientation?: number;
  57505. frontUVs?: Vector4;
  57506. backUVs?: Vector4;
  57507. instance?: Mesh;
  57508. invertUV?: boolean;
  57509. }, scene?: Nullable<Scene>): Mesh;
  57510. /**
  57511. * Creates an custom extruded shape mesh.
  57512. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57513. * * 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.
  57514. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57515. * * 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
  57516. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57517. * * 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
  57518. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57519. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57520. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57521. * * 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
  57522. * * 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
  57523. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57524. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57525. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57526. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57528. * @param name defines the name of the mesh
  57529. * @param options defines the options used to create the mesh
  57530. * @param scene defines the hosting scene
  57531. * @returns the custom extruded shape mesh
  57532. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57533. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57534. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57535. */
  57536. static ExtrudeShapeCustom(name: string, options: {
  57537. shape: Vector3[];
  57538. path: Vector3[];
  57539. scaleFunction?: any;
  57540. rotationFunction?: any;
  57541. ribbonCloseArray?: boolean;
  57542. ribbonClosePath?: boolean;
  57543. cap?: number;
  57544. updatable?: boolean;
  57545. sideOrientation?: number;
  57546. frontUVs?: Vector4;
  57547. backUVs?: Vector4;
  57548. instance?: Mesh;
  57549. invertUV?: boolean;
  57550. }, scene?: Nullable<Scene>): Mesh;
  57551. private static _ExtrudeShapeGeneric;
  57552. }
  57553. }
  57554. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57555. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57556. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57557. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57558. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57559. import { Nullable } from "babylonjs/types";
  57560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57561. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57562. /**
  57563. * AmmoJS Physics plugin
  57564. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57565. * @see https://github.com/kripken/ammo.js/
  57566. */
  57567. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57568. private _useDeltaForWorldStep;
  57569. /**
  57570. * Reference to the Ammo library
  57571. */
  57572. bjsAMMO: any;
  57573. /**
  57574. * Created ammoJS world which physics bodies are added to
  57575. */
  57576. world: any;
  57577. /**
  57578. * Name of the plugin
  57579. */
  57580. name: string;
  57581. private _timeStep;
  57582. private _fixedTimeStep;
  57583. private _maxSteps;
  57584. private _tmpQuaternion;
  57585. private _tmpAmmoTransform;
  57586. private _tmpAmmoQuaternion;
  57587. private _tmpAmmoConcreteContactResultCallback;
  57588. private _collisionConfiguration;
  57589. private _dispatcher;
  57590. private _overlappingPairCache;
  57591. private _solver;
  57592. private _softBodySolver;
  57593. private _tmpAmmoVectorA;
  57594. private _tmpAmmoVectorB;
  57595. private _tmpAmmoVectorC;
  57596. private _tmpAmmoVectorD;
  57597. private _tmpContactCallbackResult;
  57598. private _tmpAmmoVectorRCA;
  57599. private _tmpAmmoVectorRCB;
  57600. private _raycastResult;
  57601. private static readonly DISABLE_COLLISION_FLAG;
  57602. private static readonly KINEMATIC_FLAG;
  57603. private static readonly DISABLE_DEACTIVATION_FLAG;
  57604. /**
  57605. * Initializes the ammoJS plugin
  57606. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57607. * @param ammoInjection can be used to inject your own ammo reference
  57608. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57609. */
  57610. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57611. /**
  57612. * Sets the gravity of the physics world (m/(s^2))
  57613. * @param gravity Gravity to set
  57614. */
  57615. setGravity(gravity: Vector3): void;
  57616. /**
  57617. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57618. * @param timeStep timestep to use in seconds
  57619. */
  57620. setTimeStep(timeStep: number): void;
  57621. /**
  57622. * 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)
  57623. * @param fixedTimeStep fixedTimeStep to use in seconds
  57624. */
  57625. setFixedTimeStep(fixedTimeStep: number): void;
  57626. /**
  57627. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57628. * @param maxSteps the maximum number of steps by the physics engine per frame
  57629. */
  57630. setMaxSteps(maxSteps: number): void;
  57631. /**
  57632. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57633. * @returns the current timestep in seconds
  57634. */
  57635. getTimeStep(): number;
  57636. /**
  57637. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57638. */
  57639. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57640. private _isImpostorInContact;
  57641. private _isImpostorPairInContact;
  57642. private _stepSimulation;
  57643. /**
  57644. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57645. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57646. * After the step the babylon meshes are set to the position of the physics imposters
  57647. * @param delta amount of time to step forward
  57648. * @param impostors array of imposters to update before/after the step
  57649. */
  57650. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57651. /**
  57652. * Update babylon mesh to match physics world object
  57653. * @param impostor imposter to match
  57654. */
  57655. private _afterSoftStep;
  57656. /**
  57657. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57658. * @param impostor imposter to match
  57659. */
  57660. private _ropeStep;
  57661. /**
  57662. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57663. * @param impostor imposter to match
  57664. */
  57665. private _softbodyOrClothStep;
  57666. private _tmpVector;
  57667. private _tmpMatrix;
  57668. /**
  57669. * Applies an impulse on the imposter
  57670. * @param impostor imposter to apply impulse to
  57671. * @param force amount of force to be applied to the imposter
  57672. * @param contactPoint the location to apply the impulse on the imposter
  57673. */
  57674. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57675. /**
  57676. * Applies a force on the imposter
  57677. * @param impostor imposter to apply force
  57678. * @param force amount of force to be applied to the imposter
  57679. * @param contactPoint the location to apply the force on the imposter
  57680. */
  57681. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57682. /**
  57683. * Creates a physics body using the plugin
  57684. * @param impostor the imposter to create the physics body on
  57685. */
  57686. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57687. /**
  57688. * Removes the physics body from the imposter and disposes of the body's memory
  57689. * @param impostor imposter to remove the physics body from
  57690. */
  57691. removePhysicsBody(impostor: PhysicsImpostor): void;
  57692. /**
  57693. * Generates a joint
  57694. * @param impostorJoint the imposter joint to create the joint with
  57695. */
  57696. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57697. /**
  57698. * Removes a joint
  57699. * @param impostorJoint the imposter joint to remove the joint from
  57700. */
  57701. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57702. private _addMeshVerts;
  57703. /**
  57704. * Initialise the soft body vertices to match its object's (mesh) vertices
  57705. * Softbody vertices (nodes) are in world space and to match this
  57706. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57707. * @param impostor to create the softbody for
  57708. */
  57709. private _softVertexData;
  57710. /**
  57711. * Create an impostor's soft body
  57712. * @param impostor to create the softbody for
  57713. */
  57714. private _createSoftbody;
  57715. /**
  57716. * Create cloth for an impostor
  57717. * @param impostor to create the softbody for
  57718. */
  57719. private _createCloth;
  57720. /**
  57721. * Create rope for an impostor
  57722. * @param impostor to create the softbody for
  57723. */
  57724. private _createRope;
  57725. /**
  57726. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57727. * @param impostor to create the custom physics shape for
  57728. */
  57729. private _createCustom;
  57730. private _addHullVerts;
  57731. private _createShape;
  57732. /**
  57733. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57734. * @param impostor imposter containing the physics body and babylon object
  57735. */
  57736. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57737. /**
  57738. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57739. * @param impostor imposter containing the physics body and babylon object
  57740. * @param newPosition new position
  57741. * @param newRotation new rotation
  57742. */
  57743. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57744. /**
  57745. * If this plugin is supported
  57746. * @returns true if its supported
  57747. */
  57748. isSupported(): boolean;
  57749. /**
  57750. * Sets the linear velocity of the physics body
  57751. * @param impostor imposter to set the velocity on
  57752. * @param velocity velocity to set
  57753. */
  57754. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57755. /**
  57756. * Sets the angular velocity of the physics body
  57757. * @param impostor imposter to set the velocity on
  57758. * @param velocity velocity to set
  57759. */
  57760. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57761. /**
  57762. * gets the linear velocity
  57763. * @param impostor imposter to get linear velocity from
  57764. * @returns linear velocity
  57765. */
  57766. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57767. /**
  57768. * gets the angular velocity
  57769. * @param impostor imposter to get angular velocity from
  57770. * @returns angular velocity
  57771. */
  57772. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57773. /**
  57774. * Sets the mass of physics body
  57775. * @param impostor imposter to set the mass on
  57776. * @param mass mass to set
  57777. */
  57778. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57779. /**
  57780. * Gets the mass of the physics body
  57781. * @param impostor imposter to get the mass from
  57782. * @returns mass
  57783. */
  57784. getBodyMass(impostor: PhysicsImpostor): number;
  57785. /**
  57786. * Gets friction of the impostor
  57787. * @param impostor impostor to get friction from
  57788. * @returns friction value
  57789. */
  57790. getBodyFriction(impostor: PhysicsImpostor): number;
  57791. /**
  57792. * Sets friction of the impostor
  57793. * @param impostor impostor to set friction on
  57794. * @param friction friction value
  57795. */
  57796. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57797. /**
  57798. * Gets restitution of the impostor
  57799. * @param impostor impostor to get restitution from
  57800. * @returns restitution value
  57801. */
  57802. getBodyRestitution(impostor: PhysicsImpostor): number;
  57803. /**
  57804. * Sets resitution of the impostor
  57805. * @param impostor impostor to set resitution on
  57806. * @param restitution resitution value
  57807. */
  57808. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57809. /**
  57810. * Gets pressure inside the impostor
  57811. * @param impostor impostor to get pressure from
  57812. * @returns pressure value
  57813. */
  57814. getBodyPressure(impostor: PhysicsImpostor): number;
  57815. /**
  57816. * Sets pressure inside a soft body impostor
  57817. * Cloth and rope must remain 0 pressure
  57818. * @param impostor impostor to set pressure on
  57819. * @param pressure pressure value
  57820. */
  57821. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57822. /**
  57823. * Gets stiffness of the impostor
  57824. * @param impostor impostor to get stiffness from
  57825. * @returns pressure value
  57826. */
  57827. getBodyStiffness(impostor: PhysicsImpostor): number;
  57828. /**
  57829. * Sets stiffness of the impostor
  57830. * @param impostor impostor to set stiffness on
  57831. * @param stiffness stiffness value from 0 to 1
  57832. */
  57833. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57834. /**
  57835. * Gets velocityIterations of the impostor
  57836. * @param impostor impostor to get velocity iterations from
  57837. * @returns velocityIterations value
  57838. */
  57839. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57840. /**
  57841. * Sets velocityIterations of the impostor
  57842. * @param impostor impostor to set velocity iterations on
  57843. * @param velocityIterations velocityIterations value
  57844. */
  57845. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57846. /**
  57847. * Gets positionIterations of the impostor
  57848. * @param impostor impostor to get position iterations from
  57849. * @returns positionIterations value
  57850. */
  57851. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57852. /**
  57853. * Sets positionIterations of the impostor
  57854. * @param impostor impostor to set position on
  57855. * @param positionIterations positionIterations value
  57856. */
  57857. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57858. /**
  57859. * Append an anchor to a cloth object
  57860. * @param impostor is the cloth impostor to add anchor to
  57861. * @param otherImpostor is the rigid impostor to anchor to
  57862. * @param width ratio across width from 0 to 1
  57863. * @param height ratio up height from 0 to 1
  57864. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57865. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57866. */
  57867. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57868. /**
  57869. * Append an hook to a rope object
  57870. * @param impostor is the rope impostor to add hook to
  57871. * @param otherImpostor is the rigid impostor to hook to
  57872. * @param length ratio along the rope from 0 to 1
  57873. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57874. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57875. */
  57876. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57877. /**
  57878. * Sleeps the physics body and stops it from being active
  57879. * @param impostor impostor to sleep
  57880. */
  57881. sleepBody(impostor: PhysicsImpostor): void;
  57882. /**
  57883. * Activates the physics body
  57884. * @param impostor impostor to activate
  57885. */
  57886. wakeUpBody(impostor: PhysicsImpostor): void;
  57887. /**
  57888. * Updates the distance parameters of the joint
  57889. * @param joint joint to update
  57890. * @param maxDistance maximum distance of the joint
  57891. * @param minDistance minimum distance of the joint
  57892. */
  57893. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57894. /**
  57895. * Sets a motor on the joint
  57896. * @param joint joint to set motor on
  57897. * @param speed speed of the motor
  57898. * @param maxForce maximum force of the motor
  57899. * @param motorIndex index of the motor
  57900. */
  57901. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57902. /**
  57903. * Sets the motors limit
  57904. * @param joint joint to set limit on
  57905. * @param upperLimit upper limit
  57906. * @param lowerLimit lower limit
  57907. */
  57908. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57909. /**
  57910. * Syncs the position and rotation of a mesh with the impostor
  57911. * @param mesh mesh to sync
  57912. * @param impostor impostor to update the mesh with
  57913. */
  57914. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57915. /**
  57916. * Gets the radius of the impostor
  57917. * @param impostor impostor to get radius from
  57918. * @returns the radius
  57919. */
  57920. getRadius(impostor: PhysicsImpostor): number;
  57921. /**
  57922. * Gets the box size of the impostor
  57923. * @param impostor impostor to get box size from
  57924. * @param result the resulting box size
  57925. */
  57926. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57927. /**
  57928. * Disposes of the impostor
  57929. */
  57930. dispose(): void;
  57931. /**
  57932. * Does a raycast in the physics world
  57933. * @param from when should the ray start?
  57934. * @param to when should the ray end?
  57935. * @returns PhysicsRaycastResult
  57936. */
  57937. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57938. }
  57939. }
  57940. declare module "babylonjs/Probes/reflectionProbe" {
  57941. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57942. import { Vector3 } from "babylonjs/Maths/math.vector";
  57943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57944. import { Nullable } from "babylonjs/types";
  57945. import { Scene } from "babylonjs/scene";
  57946. module "babylonjs/abstractScene" {
  57947. interface AbstractScene {
  57948. /**
  57949. * The list of reflection probes added to the scene
  57950. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57951. */
  57952. reflectionProbes: Array<ReflectionProbe>;
  57953. /**
  57954. * Removes the given reflection probe from this scene.
  57955. * @param toRemove The reflection probe to remove
  57956. * @returns The index of the removed reflection probe
  57957. */
  57958. removeReflectionProbe(toRemove: ReflectionProbe): number;
  57959. /**
  57960. * Adds the given reflection probe to this scene.
  57961. * @param newReflectionProbe The reflection probe to add
  57962. */
  57963. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  57964. }
  57965. }
  57966. /**
  57967. * Class used to generate realtime reflection / refraction cube textures
  57968. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57969. */
  57970. export class ReflectionProbe {
  57971. /** defines the name of the probe */
  57972. name: string;
  57973. private _scene;
  57974. private _renderTargetTexture;
  57975. private _projectionMatrix;
  57976. private _viewMatrix;
  57977. private _target;
  57978. private _add;
  57979. private _attachedMesh;
  57980. private _invertYAxis;
  57981. /** Gets or sets probe position (center of the cube map) */
  57982. position: Vector3;
  57983. /**
  57984. * Creates a new reflection probe
  57985. * @param name defines the name of the probe
  57986. * @param size defines the texture resolution (for each face)
  57987. * @param scene defines the hosting scene
  57988. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  57989. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  57990. */
  57991. constructor(
  57992. /** defines the name of the probe */
  57993. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  57994. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  57995. get samples(): number;
  57996. set samples(value: number);
  57997. /** Gets or sets the refresh rate to use (on every frame by default) */
  57998. get refreshRate(): number;
  57999. set refreshRate(value: number);
  58000. /**
  58001. * Gets the hosting scene
  58002. * @returns a Scene
  58003. */
  58004. getScene(): Scene;
  58005. /** Gets the internal CubeTexture used to render to */
  58006. get cubeTexture(): RenderTargetTexture;
  58007. /** Gets the list of meshes to render */
  58008. get renderList(): Nullable<AbstractMesh[]>;
  58009. /**
  58010. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58011. * @param mesh defines the mesh to attach to
  58012. */
  58013. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58014. /**
  58015. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58016. * @param renderingGroupId The rendering group id corresponding to its index
  58017. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58018. */
  58019. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58020. /**
  58021. * Clean all associated resources
  58022. */
  58023. dispose(): void;
  58024. /**
  58025. * Converts the reflection probe information to a readable string for debug purpose.
  58026. * @param fullDetails Supports for multiple levels of logging within scene loading
  58027. * @returns the human readable reflection probe info
  58028. */
  58029. toString(fullDetails?: boolean): string;
  58030. /**
  58031. * Get the class name of the relfection probe.
  58032. * @returns "ReflectionProbe"
  58033. */
  58034. getClassName(): string;
  58035. /**
  58036. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58037. * @returns The JSON representation of the texture
  58038. */
  58039. serialize(): any;
  58040. /**
  58041. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58042. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58043. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58044. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58045. * @returns The parsed reflection probe if successful
  58046. */
  58047. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58048. }
  58049. }
  58050. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58051. /** @hidden */
  58052. export var _BabylonLoaderRegistered: boolean;
  58053. /**
  58054. * Helps setting up some configuration for the babylon file loader.
  58055. */
  58056. export class BabylonFileLoaderConfiguration {
  58057. /**
  58058. * The loader does not allow injecting custom physix engine into the plugins.
  58059. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58060. * So you could set this variable to your engine import to make it work.
  58061. */
  58062. static LoaderInjectedPhysicsEngine: any;
  58063. }
  58064. }
  58065. declare module "babylonjs/Loading/Plugins/index" {
  58066. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58067. }
  58068. declare module "babylonjs/Loading/index" {
  58069. export * from "babylonjs/Loading/loadingScreen";
  58070. export * from "babylonjs/Loading/Plugins/index";
  58071. export * from "babylonjs/Loading/sceneLoader";
  58072. export * from "babylonjs/Loading/sceneLoaderFlags";
  58073. }
  58074. declare module "babylonjs/Materials/Background/index" {
  58075. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58076. }
  58077. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58078. import { Scene } from "babylonjs/scene";
  58079. import { Color3 } from "babylonjs/Maths/math.color";
  58080. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58081. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58082. /**
  58083. * The Physically based simple base material of BJS.
  58084. *
  58085. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58086. * It is used as the base class for both the specGloss and metalRough conventions.
  58087. */
  58088. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58089. /**
  58090. * Number of Simultaneous lights allowed on the material.
  58091. */
  58092. maxSimultaneousLights: number;
  58093. /**
  58094. * If sets to true, disables all the lights affecting the material.
  58095. */
  58096. disableLighting: boolean;
  58097. /**
  58098. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58099. */
  58100. environmentTexture: BaseTexture;
  58101. /**
  58102. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58103. */
  58104. invertNormalMapX: boolean;
  58105. /**
  58106. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58107. */
  58108. invertNormalMapY: boolean;
  58109. /**
  58110. * Normal map used in the model.
  58111. */
  58112. normalTexture: BaseTexture;
  58113. /**
  58114. * Emissivie color used to self-illuminate the model.
  58115. */
  58116. emissiveColor: Color3;
  58117. /**
  58118. * Emissivie texture used to self-illuminate the model.
  58119. */
  58120. emissiveTexture: BaseTexture;
  58121. /**
  58122. * Occlusion Channel Strenght.
  58123. */
  58124. occlusionStrength: number;
  58125. /**
  58126. * Occlusion Texture of the material (adding extra occlusion effects).
  58127. */
  58128. occlusionTexture: BaseTexture;
  58129. /**
  58130. * Defines the alpha limits in alpha test mode.
  58131. */
  58132. alphaCutOff: number;
  58133. /**
  58134. * Gets the current double sided mode.
  58135. */
  58136. get doubleSided(): boolean;
  58137. /**
  58138. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58139. */
  58140. set doubleSided(value: boolean);
  58141. /**
  58142. * Stores the pre-calculated light information of a mesh in a texture.
  58143. */
  58144. lightmapTexture: BaseTexture;
  58145. /**
  58146. * If true, the light map contains occlusion information instead of lighting info.
  58147. */
  58148. useLightmapAsShadowmap: boolean;
  58149. /**
  58150. * Instantiates a new PBRMaterial instance.
  58151. *
  58152. * @param name The material name
  58153. * @param scene The scene the material will be use in.
  58154. */
  58155. constructor(name: string, scene: Scene);
  58156. getClassName(): string;
  58157. }
  58158. }
  58159. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58160. import { Scene } from "babylonjs/scene";
  58161. import { Color3 } from "babylonjs/Maths/math.color";
  58162. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58163. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58164. /**
  58165. * The PBR material of BJS following the metal roughness convention.
  58166. *
  58167. * This fits to the PBR convention in the GLTF definition:
  58168. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58169. */
  58170. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58171. /**
  58172. * The base color has two different interpretations depending on the value of metalness.
  58173. * When the material is a metal, the base color is the specific measured reflectance value
  58174. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58175. * of the material.
  58176. */
  58177. baseColor: Color3;
  58178. /**
  58179. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58180. * well as opacity information in the alpha channel.
  58181. */
  58182. baseTexture: BaseTexture;
  58183. /**
  58184. * Specifies the metallic scalar value of the material.
  58185. * Can also be used to scale the metalness values of the metallic texture.
  58186. */
  58187. metallic: number;
  58188. /**
  58189. * Specifies the roughness scalar value of the material.
  58190. * Can also be used to scale the roughness values of the metallic texture.
  58191. */
  58192. roughness: number;
  58193. /**
  58194. * Texture containing both the metallic value in the B channel and the
  58195. * roughness value in the G channel to keep better precision.
  58196. */
  58197. metallicRoughnessTexture: BaseTexture;
  58198. /**
  58199. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58200. *
  58201. * @param name The material name
  58202. * @param scene The scene the material will be use in.
  58203. */
  58204. constructor(name: string, scene: Scene);
  58205. /**
  58206. * Return the currrent class name of the material.
  58207. */
  58208. getClassName(): string;
  58209. /**
  58210. * Makes a duplicate of the current material.
  58211. * @param name - name to use for the new material.
  58212. */
  58213. clone(name: string): PBRMetallicRoughnessMaterial;
  58214. /**
  58215. * Serialize the material to a parsable JSON object.
  58216. */
  58217. serialize(): any;
  58218. /**
  58219. * Parses a JSON object correponding to the serialize function.
  58220. */
  58221. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58222. }
  58223. }
  58224. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58225. import { Scene } from "babylonjs/scene";
  58226. import { Color3 } from "babylonjs/Maths/math.color";
  58227. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58228. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58229. /**
  58230. * The PBR material of BJS following the specular glossiness convention.
  58231. *
  58232. * This fits to the PBR convention in the GLTF definition:
  58233. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58234. */
  58235. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58236. /**
  58237. * Specifies the diffuse color of the material.
  58238. */
  58239. diffuseColor: Color3;
  58240. /**
  58241. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58242. * channel.
  58243. */
  58244. diffuseTexture: BaseTexture;
  58245. /**
  58246. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58247. */
  58248. specularColor: Color3;
  58249. /**
  58250. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58251. */
  58252. glossiness: number;
  58253. /**
  58254. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58255. */
  58256. specularGlossinessTexture: BaseTexture;
  58257. /**
  58258. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58259. *
  58260. * @param name The material name
  58261. * @param scene The scene the material will be use in.
  58262. */
  58263. constructor(name: string, scene: Scene);
  58264. /**
  58265. * Return the currrent class name of the material.
  58266. */
  58267. getClassName(): string;
  58268. /**
  58269. * Makes a duplicate of the current material.
  58270. * @param name - name to use for the new material.
  58271. */
  58272. clone(name: string): PBRSpecularGlossinessMaterial;
  58273. /**
  58274. * Serialize the material to a parsable JSON object.
  58275. */
  58276. serialize(): any;
  58277. /**
  58278. * Parses a JSON object correponding to the serialize function.
  58279. */
  58280. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58281. }
  58282. }
  58283. declare module "babylonjs/Materials/PBR/index" {
  58284. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58285. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58286. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58287. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58288. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58289. }
  58290. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58291. import { Nullable } from "babylonjs/types";
  58292. import { Scene } from "babylonjs/scene";
  58293. import { Matrix } from "babylonjs/Maths/math.vector";
  58294. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58295. /**
  58296. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58297. * It can help converting any input color in a desired output one. This can then be used to create effects
  58298. * from sepia, black and white to sixties or futuristic rendering...
  58299. *
  58300. * The only supported format is currently 3dl.
  58301. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58302. */
  58303. export class ColorGradingTexture extends BaseTexture {
  58304. /**
  58305. * The current texture matrix. (will always be identity in color grading texture)
  58306. */
  58307. private _textureMatrix;
  58308. /**
  58309. * The texture URL.
  58310. */
  58311. url: string;
  58312. /**
  58313. * Empty line regex stored for GC.
  58314. */
  58315. private static _noneEmptyLineRegex;
  58316. private _engine;
  58317. /**
  58318. * Instantiates a ColorGradingTexture from the following parameters.
  58319. *
  58320. * @param url The location of the color gradind data (currently only supporting 3dl)
  58321. * @param scene The scene the texture will be used in
  58322. */
  58323. constructor(url: string, scene: Scene);
  58324. /**
  58325. * Returns the texture matrix used in most of the material.
  58326. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58327. */
  58328. getTextureMatrix(): Matrix;
  58329. /**
  58330. * Occurs when the file being loaded is a .3dl LUT file.
  58331. */
  58332. private load3dlTexture;
  58333. /**
  58334. * Starts the loading process of the texture.
  58335. */
  58336. private loadTexture;
  58337. /**
  58338. * Clones the color gradind texture.
  58339. */
  58340. clone(): ColorGradingTexture;
  58341. /**
  58342. * Called during delayed load for textures.
  58343. */
  58344. delayLoad(): void;
  58345. /**
  58346. * Parses a color grading texture serialized by Babylon.
  58347. * @param parsedTexture The texture information being parsedTexture
  58348. * @param scene The scene to load the texture in
  58349. * @param rootUrl The root url of the data assets to load
  58350. * @return A color gradind texture
  58351. */
  58352. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58353. /**
  58354. * Serializes the LUT texture to json format.
  58355. */
  58356. serialize(): any;
  58357. }
  58358. }
  58359. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58360. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58361. import { Scene } from "babylonjs/scene";
  58362. import { Nullable } from "babylonjs/types";
  58363. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58364. /**
  58365. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58366. */
  58367. export class EquiRectangularCubeTexture extends BaseTexture {
  58368. /** The six faces of the cube. */
  58369. private static _FacesMapping;
  58370. private _noMipmap;
  58371. private _onLoad;
  58372. private _onError;
  58373. /** The size of the cubemap. */
  58374. private _size;
  58375. /** The buffer of the image. */
  58376. private _buffer;
  58377. /** The width of the input image. */
  58378. private _width;
  58379. /** The height of the input image. */
  58380. private _height;
  58381. /** The URL to the image. */
  58382. url: string;
  58383. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58384. coordinatesMode: number;
  58385. /**
  58386. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58387. * @param url The location of the image
  58388. * @param scene The scene the texture will be used in
  58389. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58390. * @param noMipmap Forces to not generate the mipmap if true
  58391. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58392. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58393. * @param onLoad — defines a callback called when texture is loaded
  58394. * @param onError — defines a callback called if there is an error
  58395. */
  58396. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58397. /**
  58398. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58399. */
  58400. private loadImage;
  58401. /**
  58402. * Convert the image buffer into a cubemap and create a CubeTexture.
  58403. */
  58404. private loadTexture;
  58405. /**
  58406. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58407. * @param buffer The ArrayBuffer that should be converted.
  58408. * @returns The buffer as Float32Array.
  58409. */
  58410. private getFloat32ArrayFromArrayBuffer;
  58411. /**
  58412. * Get the current class name of the texture useful for serialization or dynamic coding.
  58413. * @returns "EquiRectangularCubeTexture"
  58414. */
  58415. getClassName(): string;
  58416. /**
  58417. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58418. * @returns A clone of the current EquiRectangularCubeTexture.
  58419. */
  58420. clone(): EquiRectangularCubeTexture;
  58421. }
  58422. }
  58423. declare module "babylonjs/Misc/tga" {
  58424. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58425. /**
  58426. * Based on jsTGALoader - Javascript loader for TGA file
  58427. * By Vincent Thibault
  58428. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58429. */
  58430. export class TGATools {
  58431. private static _TYPE_INDEXED;
  58432. private static _TYPE_RGB;
  58433. private static _TYPE_GREY;
  58434. private static _TYPE_RLE_INDEXED;
  58435. private static _TYPE_RLE_RGB;
  58436. private static _TYPE_RLE_GREY;
  58437. private static _ORIGIN_MASK;
  58438. private static _ORIGIN_SHIFT;
  58439. private static _ORIGIN_BL;
  58440. private static _ORIGIN_BR;
  58441. private static _ORIGIN_UL;
  58442. private static _ORIGIN_UR;
  58443. /**
  58444. * Gets the header of a TGA file
  58445. * @param data defines the TGA data
  58446. * @returns the header
  58447. */
  58448. static GetTGAHeader(data: Uint8Array): any;
  58449. /**
  58450. * Uploads TGA content to a Babylon Texture
  58451. * @hidden
  58452. */
  58453. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58454. /** @hidden */
  58455. 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;
  58456. /** @hidden */
  58457. 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;
  58458. /** @hidden */
  58459. 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;
  58460. /** @hidden */
  58461. 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;
  58462. /** @hidden */
  58463. 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;
  58464. /** @hidden */
  58465. 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;
  58466. }
  58467. }
  58468. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58469. import { Nullable } from "babylonjs/types";
  58470. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58471. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58472. /**
  58473. * Implementation of the TGA Texture Loader.
  58474. * @hidden
  58475. */
  58476. export class _TGATextureLoader implements IInternalTextureLoader {
  58477. /**
  58478. * Defines wether the loader supports cascade loading the different faces.
  58479. */
  58480. readonly supportCascades: boolean;
  58481. /**
  58482. * This returns if the loader support the current file information.
  58483. * @param extension defines the file extension of the file being loaded
  58484. * @returns true if the loader can load the specified file
  58485. */
  58486. canLoad(extension: string): boolean;
  58487. /**
  58488. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58489. * @param data contains the texture data
  58490. * @param texture defines the BabylonJS internal texture
  58491. * @param createPolynomials will be true if polynomials have been requested
  58492. * @param onLoad defines the callback to trigger once the texture is ready
  58493. * @param onError defines the callback to trigger in case of error
  58494. */
  58495. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58496. /**
  58497. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58498. * @param data contains the texture data
  58499. * @param texture defines the BabylonJS internal texture
  58500. * @param callback defines the method to call once ready to upload
  58501. */
  58502. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58503. }
  58504. }
  58505. declare module "babylonjs/Misc/basis" {
  58506. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58507. /**
  58508. * Info about the .basis files
  58509. */
  58510. class BasisFileInfo {
  58511. /**
  58512. * If the file has alpha
  58513. */
  58514. hasAlpha: boolean;
  58515. /**
  58516. * Info about each image of the basis file
  58517. */
  58518. images: Array<{
  58519. levels: Array<{
  58520. width: number;
  58521. height: number;
  58522. transcodedPixels: ArrayBufferView;
  58523. }>;
  58524. }>;
  58525. }
  58526. /**
  58527. * Result of transcoding a basis file
  58528. */
  58529. class TranscodeResult {
  58530. /**
  58531. * Info about the .basis file
  58532. */
  58533. fileInfo: BasisFileInfo;
  58534. /**
  58535. * Format to use when loading the file
  58536. */
  58537. format: number;
  58538. }
  58539. /**
  58540. * Configuration options for the Basis transcoder
  58541. */
  58542. export class BasisTranscodeConfiguration {
  58543. /**
  58544. * Supported compression formats used to determine the supported output format of the transcoder
  58545. */
  58546. supportedCompressionFormats?: {
  58547. /**
  58548. * etc1 compression format
  58549. */
  58550. etc1?: boolean;
  58551. /**
  58552. * s3tc compression format
  58553. */
  58554. s3tc?: boolean;
  58555. /**
  58556. * pvrtc compression format
  58557. */
  58558. pvrtc?: boolean;
  58559. /**
  58560. * etc2 compression format
  58561. */
  58562. etc2?: boolean;
  58563. };
  58564. /**
  58565. * If mipmap levels should be loaded for transcoded images (Default: true)
  58566. */
  58567. loadMipmapLevels?: boolean;
  58568. /**
  58569. * Index of a single image to load (Default: all images)
  58570. */
  58571. loadSingleImage?: number;
  58572. }
  58573. /**
  58574. * Used to load .Basis files
  58575. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58576. */
  58577. export class BasisTools {
  58578. private static _IgnoreSupportedFormats;
  58579. /**
  58580. * URL to use when loading the basis transcoder
  58581. */
  58582. static JSModuleURL: string;
  58583. /**
  58584. * URL to use when loading the wasm module for the transcoder
  58585. */
  58586. static WasmModuleURL: string;
  58587. /**
  58588. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58589. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58590. * @returns internal format corresponding to the Basis format
  58591. */
  58592. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58593. private static _WorkerPromise;
  58594. private static _Worker;
  58595. private static _actionId;
  58596. private static _CreateWorkerAsync;
  58597. /**
  58598. * Transcodes a loaded image file to compressed pixel data
  58599. * @param data image data to transcode
  58600. * @param config configuration options for the transcoding
  58601. * @returns a promise resulting in the transcoded image
  58602. */
  58603. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58604. /**
  58605. * Loads a texture from the transcode result
  58606. * @param texture texture load to
  58607. * @param transcodeResult the result of transcoding the basis file to load from
  58608. */
  58609. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58610. }
  58611. }
  58612. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58613. import { Nullable } from "babylonjs/types";
  58614. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58615. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58616. /**
  58617. * Loader for .basis file format
  58618. */
  58619. export class _BasisTextureLoader implements IInternalTextureLoader {
  58620. /**
  58621. * Defines whether the loader supports cascade loading the different faces.
  58622. */
  58623. readonly supportCascades: boolean;
  58624. /**
  58625. * This returns if the loader support the current file information.
  58626. * @param extension defines the file extension of the file being loaded
  58627. * @returns true if the loader can load the specified file
  58628. */
  58629. canLoad(extension: string): boolean;
  58630. /**
  58631. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58632. * @param data contains the texture data
  58633. * @param texture defines the BabylonJS internal texture
  58634. * @param createPolynomials will be true if polynomials have been requested
  58635. * @param onLoad defines the callback to trigger once the texture is ready
  58636. * @param onError defines the callback to trigger in case of error
  58637. */
  58638. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58639. /**
  58640. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58641. * @param data contains the texture data
  58642. * @param texture defines the BabylonJS internal texture
  58643. * @param callback defines the method to call once ready to upload
  58644. */
  58645. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58646. }
  58647. }
  58648. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58649. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58650. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58651. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58652. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58653. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58654. }
  58655. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58656. import { Scene } from "babylonjs/scene";
  58657. import { Texture } from "babylonjs/Materials/Textures/texture";
  58658. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58659. /**
  58660. * 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.
  58661. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58662. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58663. */
  58664. export class CustomProceduralTexture extends ProceduralTexture {
  58665. private _animate;
  58666. private _time;
  58667. private _config;
  58668. private _texturePath;
  58669. /**
  58670. * Instantiates a new Custom Procedural Texture.
  58671. * 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.
  58672. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58673. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58674. * @param name Define the name of the texture
  58675. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58676. * @param size Define the size of the texture to create
  58677. * @param scene Define the scene the texture belongs to
  58678. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58679. * @param generateMipMaps Define if the texture should creates mip maps or not
  58680. */
  58681. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58682. private _loadJson;
  58683. /**
  58684. * Is the texture ready to be used ? (rendered at least once)
  58685. * @returns true if ready, otherwise, false.
  58686. */
  58687. isReady(): boolean;
  58688. /**
  58689. * Render the texture to its associated render target.
  58690. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58691. */
  58692. render(useCameraPostProcess?: boolean): void;
  58693. /**
  58694. * Update the list of dependant textures samplers in the shader.
  58695. */
  58696. updateTextures(): void;
  58697. /**
  58698. * Update the uniform values of the procedural texture in the shader.
  58699. */
  58700. updateShaderUniforms(): void;
  58701. /**
  58702. * Define if the texture animates or not.
  58703. */
  58704. get animate(): boolean;
  58705. set animate(value: boolean);
  58706. }
  58707. }
  58708. declare module "babylonjs/Shaders/noise.fragment" {
  58709. /** @hidden */
  58710. export var noisePixelShader: {
  58711. name: string;
  58712. shader: string;
  58713. };
  58714. }
  58715. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58716. import { Nullable } from "babylonjs/types";
  58717. import { Scene } from "babylonjs/scene";
  58718. import { Texture } from "babylonjs/Materials/Textures/texture";
  58719. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58720. import "babylonjs/Shaders/noise.fragment";
  58721. /**
  58722. * Class used to generate noise procedural textures
  58723. */
  58724. export class NoiseProceduralTexture extends ProceduralTexture {
  58725. private _time;
  58726. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58727. brightness: number;
  58728. /** Defines the number of octaves to process */
  58729. octaves: number;
  58730. /** Defines the level of persistence (0.8 by default) */
  58731. persistence: number;
  58732. /** Gets or sets animation speed factor (default is 1) */
  58733. animationSpeedFactor: number;
  58734. /**
  58735. * Creates a new NoiseProceduralTexture
  58736. * @param name defines the name fo the texture
  58737. * @param size defines the size of the texture (default is 256)
  58738. * @param scene defines the hosting scene
  58739. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58740. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58741. */
  58742. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58743. private _updateShaderUniforms;
  58744. protected _getDefines(): string;
  58745. /** Generate the current state of the procedural texture */
  58746. render(useCameraPostProcess?: boolean): void;
  58747. /**
  58748. * Serializes this noise procedural texture
  58749. * @returns a serialized noise procedural texture object
  58750. */
  58751. serialize(): any;
  58752. /**
  58753. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58754. * @param parsedTexture defines parsed texture data
  58755. * @param scene defines the current scene
  58756. * @param rootUrl defines the root URL containing noise procedural texture information
  58757. * @returns a parsed NoiseProceduralTexture
  58758. */
  58759. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58760. }
  58761. }
  58762. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58763. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58764. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58765. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58766. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58767. }
  58768. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58769. import { Nullable } from "babylonjs/types";
  58770. import { Scene } from "babylonjs/scene";
  58771. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58772. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58773. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58774. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58775. /**
  58776. * Raw cube texture where the raw buffers are passed in
  58777. */
  58778. export class RawCubeTexture extends CubeTexture {
  58779. /**
  58780. * Creates a cube texture where the raw buffers are passed in.
  58781. * @param scene defines the scene the texture is attached to
  58782. * @param data defines the array of data to use to create each face
  58783. * @param size defines the size of the textures
  58784. * @param format defines the format of the data
  58785. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58786. * @param generateMipMaps defines if the engine should generate the mip levels
  58787. * @param invertY defines if data must be stored with Y axis inverted
  58788. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58789. * @param compression defines the compression used (null by default)
  58790. */
  58791. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58792. /**
  58793. * Updates the raw cube texture.
  58794. * @param data defines the data to store
  58795. * @param format defines the data format
  58796. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58797. * @param invertY defines if data must be stored with Y axis inverted
  58798. * @param compression defines the compression used (null by default)
  58799. * @param level defines which level of the texture to update
  58800. */
  58801. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58802. /**
  58803. * Updates a raw cube texture with RGBD encoded data.
  58804. * @param data defines the array of data [mipmap][face] to use to create each face
  58805. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58806. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58807. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58808. * @returns a promsie that resolves when the operation is complete
  58809. */
  58810. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58811. /**
  58812. * Clones the raw cube texture.
  58813. * @return a new cube texture
  58814. */
  58815. clone(): CubeTexture;
  58816. /** @hidden */
  58817. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58818. }
  58819. }
  58820. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58821. import { Scene } from "babylonjs/scene";
  58822. import { Texture } from "babylonjs/Materials/Textures/texture";
  58823. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58824. /**
  58825. * Class used to store 3D textures containing user data
  58826. */
  58827. export class RawTexture3D extends Texture {
  58828. /** Gets or sets the texture format to use */
  58829. format: number;
  58830. private _engine;
  58831. /**
  58832. * Create a new RawTexture3D
  58833. * @param data defines the data of the texture
  58834. * @param width defines the width of the texture
  58835. * @param height defines the height of the texture
  58836. * @param depth defines the depth of the texture
  58837. * @param format defines the texture format to use
  58838. * @param scene defines the hosting scene
  58839. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58840. * @param invertY defines if texture must be stored with Y axis inverted
  58841. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58842. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58843. */
  58844. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58845. /** Gets or sets the texture format to use */
  58846. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58847. /**
  58848. * Update the texture with new data
  58849. * @param data defines the data to store in the texture
  58850. */
  58851. update(data: ArrayBufferView): void;
  58852. }
  58853. }
  58854. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58855. import { Scene } from "babylonjs/scene";
  58856. import { Texture } from "babylonjs/Materials/Textures/texture";
  58857. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58858. /**
  58859. * Class used to store 2D array textures containing user data
  58860. */
  58861. export class RawTexture2DArray extends Texture {
  58862. /** Gets or sets the texture format to use */
  58863. format: number;
  58864. private _engine;
  58865. /**
  58866. * Create a new RawTexture2DArray
  58867. * @param data defines the data of the texture
  58868. * @param width defines the width of the texture
  58869. * @param height defines the height of the texture
  58870. * @param depth defines the number of layers of the texture
  58871. * @param format defines the texture format to use
  58872. * @param scene defines the hosting scene
  58873. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58874. * @param invertY defines if texture must be stored with Y axis inverted
  58875. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58876. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58877. */
  58878. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58879. /** Gets or sets the texture format to use */
  58880. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58881. /**
  58882. * Update the texture with new data
  58883. * @param data defines the data to store in the texture
  58884. */
  58885. update(data: ArrayBufferView): void;
  58886. }
  58887. }
  58888. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58889. import { Scene } from "babylonjs/scene";
  58890. import { Plane } from "babylonjs/Maths/math.plane";
  58891. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58892. /**
  58893. * Creates a refraction texture used by refraction channel of the standard material.
  58894. * It is like a mirror but to see through a material.
  58895. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58896. */
  58897. export class RefractionTexture extends RenderTargetTexture {
  58898. /**
  58899. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58900. * 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.
  58901. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58902. */
  58903. refractionPlane: Plane;
  58904. /**
  58905. * Define how deep under the surface we should see.
  58906. */
  58907. depth: number;
  58908. /**
  58909. * Creates a refraction texture used by refraction channel of the standard material.
  58910. * It is like a mirror but to see through a material.
  58911. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58912. * @param name Define the texture name
  58913. * @param size Define the size of the underlying texture
  58914. * @param scene Define the scene the refraction belongs to
  58915. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58916. */
  58917. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58918. /**
  58919. * Clone the refraction texture.
  58920. * @returns the cloned texture
  58921. */
  58922. clone(): RefractionTexture;
  58923. /**
  58924. * Serialize the texture to a JSON representation you could use in Parse later on
  58925. * @returns the serialized JSON representation
  58926. */
  58927. serialize(): any;
  58928. }
  58929. }
  58930. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  58931. import { Nullable } from "babylonjs/types";
  58932. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58933. import { Matrix } from "babylonjs/Maths/math.vector";
  58934. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58935. import "babylonjs/Engines/Extensions/engine.videoTexture";
  58936. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58937. import { Scene } from "babylonjs/scene";
  58938. /**
  58939. * Defines the options related to the creation of an HtmlElementTexture
  58940. */
  58941. export interface IHtmlElementTextureOptions {
  58942. /**
  58943. * Defines wether mip maps should be created or not.
  58944. */
  58945. generateMipMaps?: boolean;
  58946. /**
  58947. * Defines the sampling mode of the texture.
  58948. */
  58949. samplingMode?: number;
  58950. /**
  58951. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  58952. */
  58953. engine: Nullable<ThinEngine>;
  58954. /**
  58955. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  58956. */
  58957. scene: Nullable<Scene>;
  58958. }
  58959. /**
  58960. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  58961. * To be as efficient as possible depending on your constraints nothing aside the first upload
  58962. * is automatically managed.
  58963. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  58964. * in your application.
  58965. *
  58966. * As the update is not automatic, you need to call them manually.
  58967. */
  58968. export class HtmlElementTexture extends BaseTexture {
  58969. /**
  58970. * The texture URL.
  58971. */
  58972. element: HTMLVideoElement | HTMLCanvasElement;
  58973. private static readonly DefaultOptions;
  58974. private _textureMatrix;
  58975. private _engine;
  58976. private _isVideo;
  58977. private _generateMipMaps;
  58978. private _samplingMode;
  58979. /**
  58980. * Instantiates a HtmlElementTexture from the following parameters.
  58981. *
  58982. * @param name Defines the name of the texture
  58983. * @param element Defines the video or canvas the texture is filled with
  58984. * @param options Defines the other none mandatory texture creation options
  58985. */
  58986. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  58987. private _createInternalTexture;
  58988. /**
  58989. * Returns the texture matrix used in most of the material.
  58990. */
  58991. getTextureMatrix(): Matrix;
  58992. /**
  58993. * Updates the content of the texture.
  58994. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  58995. */
  58996. update(invertY?: Nullable<boolean>): void;
  58997. }
  58998. }
  58999. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59000. import { Vector2 } from "babylonjs/Maths/math.vector";
  59001. /**
  59002. * Defines the basic options interface of a TexturePacker Frame
  59003. */
  59004. export interface ITexturePackerFrame {
  59005. /**
  59006. * The frame ID
  59007. */
  59008. id: number;
  59009. /**
  59010. * The frames Scale
  59011. */
  59012. scale: Vector2;
  59013. /**
  59014. * The Frames offset
  59015. */
  59016. offset: Vector2;
  59017. }
  59018. /**
  59019. * This is a support class for frame Data on texture packer sets.
  59020. */
  59021. export class TexturePackerFrame implements ITexturePackerFrame {
  59022. /**
  59023. * The frame ID
  59024. */
  59025. id: number;
  59026. /**
  59027. * The frames Scale
  59028. */
  59029. scale: Vector2;
  59030. /**
  59031. * The Frames offset
  59032. */
  59033. offset: Vector2;
  59034. /**
  59035. * Initializes a texture package frame.
  59036. * @param id The numerical frame identifier
  59037. * @param scale Scalar Vector2 for UV frame
  59038. * @param offset Vector2 for the frame position in UV units.
  59039. * @returns TexturePackerFrame
  59040. */
  59041. constructor(id: number, scale: Vector2, offset: Vector2);
  59042. }
  59043. }
  59044. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59046. import { Scene } from "babylonjs/scene";
  59047. import { Nullable } from "babylonjs/types";
  59048. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59049. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59050. /**
  59051. * Defines the basic options interface of a TexturePacker
  59052. */
  59053. export interface ITexturePackerOptions {
  59054. /**
  59055. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59056. */
  59057. map?: string[];
  59058. /**
  59059. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59060. */
  59061. uvsIn?: string;
  59062. /**
  59063. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59064. */
  59065. uvsOut?: string;
  59066. /**
  59067. * number representing the layout style. Defaults to LAYOUT_STRIP
  59068. */
  59069. layout?: number;
  59070. /**
  59071. * number of columns if using custom column count layout(2). This defaults to 4.
  59072. */
  59073. colnum?: number;
  59074. /**
  59075. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59076. */
  59077. updateInputMeshes?: boolean;
  59078. /**
  59079. * boolean flag to dispose all the source textures. Defaults to true.
  59080. */
  59081. disposeSources?: boolean;
  59082. /**
  59083. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59084. */
  59085. fillBlanks?: boolean;
  59086. /**
  59087. * string value representing the context fill style color. Defaults to 'black'.
  59088. */
  59089. customFillColor?: string;
  59090. /**
  59091. * Width and Height Value of each Frame in the TexturePacker Sets
  59092. */
  59093. frameSize?: number;
  59094. /**
  59095. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59096. */
  59097. paddingRatio?: number;
  59098. /**
  59099. * Number that declares the fill method for the padding gutter.
  59100. */
  59101. paddingMode?: number;
  59102. /**
  59103. * If in SUBUV_COLOR padding mode what color to use.
  59104. */
  59105. paddingColor?: Color3 | Color4;
  59106. }
  59107. /**
  59108. * Defines the basic interface of a TexturePacker JSON File
  59109. */
  59110. export interface ITexturePackerJSON {
  59111. /**
  59112. * The frame ID
  59113. */
  59114. name: string;
  59115. /**
  59116. * The base64 channel data
  59117. */
  59118. sets: any;
  59119. /**
  59120. * The options of the Packer
  59121. */
  59122. options: ITexturePackerOptions;
  59123. /**
  59124. * The frame data of the Packer
  59125. */
  59126. frames: Array<number>;
  59127. }
  59128. /**
  59129. * This is a support class that generates a series of packed texture sets.
  59130. * @see https://doc.babylonjs.com/babylon101/materials
  59131. */
  59132. export class TexturePacker {
  59133. /** Packer Layout Constant 0 */
  59134. static readonly LAYOUT_STRIP: number;
  59135. /** Packer Layout Constant 1 */
  59136. static readonly LAYOUT_POWER2: number;
  59137. /** Packer Layout Constant 2 */
  59138. static readonly LAYOUT_COLNUM: number;
  59139. /** Packer Layout Constant 0 */
  59140. static readonly SUBUV_WRAP: number;
  59141. /** Packer Layout Constant 1 */
  59142. static readonly SUBUV_EXTEND: number;
  59143. /** Packer Layout Constant 2 */
  59144. static readonly SUBUV_COLOR: number;
  59145. /** The Name of the Texture Package */
  59146. name: string;
  59147. /** The scene scope of the TexturePacker */
  59148. scene: Scene;
  59149. /** The Meshes to target */
  59150. meshes: AbstractMesh[];
  59151. /** Arguments passed with the Constructor */
  59152. options: ITexturePackerOptions;
  59153. /** The promise that is started upon initialization */
  59154. promise: Nullable<Promise<TexturePacker | string>>;
  59155. /** The Container object for the channel sets that are generated */
  59156. sets: object;
  59157. /** The Container array for the frames that are generated */
  59158. frames: TexturePackerFrame[];
  59159. /** The expected number of textures the system is parsing. */
  59160. private _expecting;
  59161. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59162. private _paddingValue;
  59163. /**
  59164. * Initializes a texture package series from an array of meshes or a single mesh.
  59165. * @param name The name of the package
  59166. * @param meshes The target meshes to compose the package from
  59167. * @param options The arguments that texture packer should follow while building.
  59168. * @param scene The scene which the textures are scoped to.
  59169. * @returns TexturePacker
  59170. */
  59171. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59172. /**
  59173. * Starts the package process
  59174. * @param resolve The promises resolution function
  59175. * @returns TexturePacker
  59176. */
  59177. private _createFrames;
  59178. /**
  59179. * Calculates the Size of the Channel Sets
  59180. * @returns Vector2
  59181. */
  59182. private _calculateSize;
  59183. /**
  59184. * Calculates the UV data for the frames.
  59185. * @param baseSize the base frameSize
  59186. * @param padding the base frame padding
  59187. * @param dtSize size of the Dynamic Texture for that channel
  59188. * @param dtUnits is 1/dtSize
  59189. * @param update flag to update the input meshes
  59190. */
  59191. private _calculateMeshUVFrames;
  59192. /**
  59193. * Calculates the frames Offset.
  59194. * @param index of the frame
  59195. * @returns Vector2
  59196. */
  59197. private _getFrameOffset;
  59198. /**
  59199. * Updates a Mesh to the frame data
  59200. * @param mesh that is the target
  59201. * @param frameID or the frame index
  59202. */
  59203. private _updateMeshUV;
  59204. /**
  59205. * Updates a Meshes materials to use the texture packer channels
  59206. * @param m is the mesh to target
  59207. * @param force all channels on the packer to be set.
  59208. */
  59209. private _updateTextureReferences;
  59210. /**
  59211. * Public method to set a Mesh to a frame
  59212. * @param m that is the target
  59213. * @param frameID or the frame index
  59214. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59215. */
  59216. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59217. /**
  59218. * Starts the async promise to compile the texture packer.
  59219. * @returns Promise<void>
  59220. */
  59221. processAsync(): Promise<void>;
  59222. /**
  59223. * Disposes all textures associated with this packer
  59224. */
  59225. dispose(): void;
  59226. /**
  59227. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59228. * @param imageType is the image type to use.
  59229. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59230. */
  59231. download(imageType?: string, quality?: number): void;
  59232. /**
  59233. * Public method to load a texturePacker JSON file.
  59234. * @param data of the JSON file in string format.
  59235. */
  59236. updateFromJSON(data: string): void;
  59237. }
  59238. }
  59239. declare module "babylonjs/Materials/Textures/Packer/index" {
  59240. export * from "babylonjs/Materials/Textures/Packer/packer";
  59241. export * from "babylonjs/Materials/Textures/Packer/frame";
  59242. }
  59243. declare module "babylonjs/Materials/Textures/index" {
  59244. export * from "babylonjs/Materials/Textures/baseTexture";
  59245. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59246. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59247. export * from "babylonjs/Materials/Textures/cubeTexture";
  59248. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59249. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59250. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59251. export * from "babylonjs/Materials/Textures/internalTexture";
  59252. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59253. export * from "babylonjs/Materials/Textures/Loaders/index";
  59254. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59255. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59256. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59257. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59258. export * from "babylonjs/Materials/Textures/rawTexture";
  59259. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59260. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59261. export * from "babylonjs/Materials/Textures/refractionTexture";
  59262. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59263. export * from "babylonjs/Materials/Textures/texture";
  59264. export * from "babylonjs/Materials/Textures/videoTexture";
  59265. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59266. export * from "babylonjs/Materials/Textures/Packer/index";
  59267. }
  59268. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59269. /**
  59270. * Enum used to define the target of a block
  59271. */
  59272. export enum NodeMaterialBlockTargets {
  59273. /** Vertex shader */
  59274. Vertex = 1,
  59275. /** Fragment shader */
  59276. Fragment = 2,
  59277. /** Neutral */
  59278. Neutral = 4,
  59279. /** Vertex and Fragment */
  59280. VertexAndFragment = 3
  59281. }
  59282. }
  59283. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59284. /**
  59285. * Defines the kind of connection point for node based material
  59286. */
  59287. export enum NodeMaterialBlockConnectionPointTypes {
  59288. /** Float */
  59289. Float = 1,
  59290. /** Int */
  59291. Int = 2,
  59292. /** Vector2 */
  59293. Vector2 = 4,
  59294. /** Vector3 */
  59295. Vector3 = 8,
  59296. /** Vector4 */
  59297. Vector4 = 16,
  59298. /** Color3 */
  59299. Color3 = 32,
  59300. /** Color4 */
  59301. Color4 = 64,
  59302. /** Matrix */
  59303. Matrix = 128,
  59304. /** Detect type based on connection */
  59305. AutoDetect = 1024,
  59306. /** Output type that will be defined by input type */
  59307. BasedOnInput = 2048
  59308. }
  59309. }
  59310. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59311. /**
  59312. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59313. */
  59314. export enum NodeMaterialBlockConnectionPointMode {
  59315. /** Value is an uniform */
  59316. Uniform = 0,
  59317. /** Value is a mesh attribute */
  59318. Attribute = 1,
  59319. /** Value is a varying between vertex and fragment shaders */
  59320. Varying = 2,
  59321. /** Mode is undefined */
  59322. Undefined = 3
  59323. }
  59324. }
  59325. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59326. /**
  59327. * Enum used to define system values e.g. values automatically provided by the system
  59328. */
  59329. export enum NodeMaterialSystemValues {
  59330. /** World */
  59331. World = 1,
  59332. /** View */
  59333. View = 2,
  59334. /** Projection */
  59335. Projection = 3,
  59336. /** ViewProjection */
  59337. ViewProjection = 4,
  59338. /** WorldView */
  59339. WorldView = 5,
  59340. /** WorldViewProjection */
  59341. WorldViewProjection = 6,
  59342. /** CameraPosition */
  59343. CameraPosition = 7,
  59344. /** Fog Color */
  59345. FogColor = 8,
  59346. /** Delta time */
  59347. DeltaTime = 9
  59348. }
  59349. }
  59350. declare module "babylonjs/Materials/Node/Enums/index" {
  59351. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59352. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59353. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59354. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59355. }
  59356. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59357. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59358. /**
  59359. * Root class for all node material optimizers
  59360. */
  59361. export class NodeMaterialOptimizer {
  59362. /**
  59363. * Function used to optimize a NodeMaterial graph
  59364. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59365. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59366. */
  59367. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59368. }
  59369. }
  59370. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59371. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59372. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59373. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59374. import { Scene } from "babylonjs/scene";
  59375. /**
  59376. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59377. */
  59378. export class TransformBlock extends NodeMaterialBlock {
  59379. /**
  59380. * Defines the value to use to complement W value to transform it to a Vector4
  59381. */
  59382. complementW: number;
  59383. /**
  59384. * Defines the value to use to complement z value to transform it to a Vector4
  59385. */
  59386. complementZ: number;
  59387. /**
  59388. * Creates a new TransformBlock
  59389. * @param name defines the block name
  59390. */
  59391. constructor(name: string);
  59392. /**
  59393. * Gets the current class name
  59394. * @returns the class name
  59395. */
  59396. getClassName(): string;
  59397. /**
  59398. * Gets the vector input
  59399. */
  59400. get vector(): NodeMaterialConnectionPoint;
  59401. /**
  59402. * Gets the output component
  59403. */
  59404. get output(): NodeMaterialConnectionPoint;
  59405. /**
  59406. * Gets the xyz output component
  59407. */
  59408. get xyz(): NodeMaterialConnectionPoint;
  59409. /**
  59410. * Gets the matrix transform input
  59411. */
  59412. get transform(): NodeMaterialConnectionPoint;
  59413. protected _buildBlock(state: NodeMaterialBuildState): this;
  59414. serialize(): any;
  59415. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59416. protected _dumpPropertiesCode(): string;
  59417. }
  59418. }
  59419. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59420. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59421. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59422. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59423. /**
  59424. * Block used to output the vertex position
  59425. */
  59426. export class VertexOutputBlock extends NodeMaterialBlock {
  59427. /**
  59428. * Creates a new VertexOutputBlock
  59429. * @param name defines the block name
  59430. */
  59431. constructor(name: string);
  59432. /**
  59433. * Gets the current class name
  59434. * @returns the class name
  59435. */
  59436. getClassName(): string;
  59437. /**
  59438. * Gets the vector input component
  59439. */
  59440. get vector(): NodeMaterialConnectionPoint;
  59441. protected _buildBlock(state: NodeMaterialBuildState): this;
  59442. }
  59443. }
  59444. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59445. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59446. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59447. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59448. /**
  59449. * Block used to output the final color
  59450. */
  59451. export class FragmentOutputBlock extends NodeMaterialBlock {
  59452. /**
  59453. * Create a new FragmentOutputBlock
  59454. * @param name defines the block name
  59455. */
  59456. constructor(name: string);
  59457. /**
  59458. * Gets the current class name
  59459. * @returns the class name
  59460. */
  59461. getClassName(): string;
  59462. /**
  59463. * Gets the rgba input component
  59464. */
  59465. get rgba(): NodeMaterialConnectionPoint;
  59466. /**
  59467. * Gets the rgb input component
  59468. */
  59469. get rgb(): NodeMaterialConnectionPoint;
  59470. /**
  59471. * Gets the a input component
  59472. */
  59473. get a(): NodeMaterialConnectionPoint;
  59474. protected _buildBlock(state: NodeMaterialBuildState): this;
  59475. }
  59476. }
  59477. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59478. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59479. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59480. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59481. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59483. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59484. import { Effect } from "babylonjs/Materials/effect";
  59485. import { Mesh } from "babylonjs/Meshes/mesh";
  59486. import { Nullable } from "babylonjs/types";
  59487. import { Scene } from "babylonjs/scene";
  59488. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59489. /**
  59490. * Block used to read a reflection texture from a sampler
  59491. */
  59492. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59493. private _define3DName;
  59494. private _defineCubicName;
  59495. private _defineExplicitName;
  59496. private _defineProjectionName;
  59497. private _defineLocalCubicName;
  59498. private _defineSphericalName;
  59499. private _definePlanarName;
  59500. private _defineEquirectangularName;
  59501. private _defineMirroredEquirectangularFixedName;
  59502. private _defineEquirectangularFixedName;
  59503. private _defineSkyboxName;
  59504. private _cubeSamplerName;
  59505. private _2DSamplerName;
  59506. private _positionUVWName;
  59507. private _directionWName;
  59508. private _reflectionCoordsName;
  59509. private _reflection2DCoordsName;
  59510. private _reflectionColorName;
  59511. private _reflectionMatrixName;
  59512. /**
  59513. * Gets or sets the texture associated with the node
  59514. */
  59515. texture: Nullable<BaseTexture>;
  59516. /**
  59517. * Create a new TextureBlock
  59518. * @param name defines the block name
  59519. */
  59520. constructor(name: string);
  59521. /**
  59522. * Gets the current class name
  59523. * @returns the class name
  59524. */
  59525. getClassName(): string;
  59526. /**
  59527. * Gets the world position input component
  59528. */
  59529. get position(): NodeMaterialConnectionPoint;
  59530. /**
  59531. * Gets the world position input component
  59532. */
  59533. get worldPosition(): NodeMaterialConnectionPoint;
  59534. /**
  59535. * Gets the world normal input component
  59536. */
  59537. get worldNormal(): NodeMaterialConnectionPoint;
  59538. /**
  59539. * Gets the world input component
  59540. */
  59541. get world(): NodeMaterialConnectionPoint;
  59542. /**
  59543. * Gets the camera (or eye) position component
  59544. */
  59545. get cameraPosition(): NodeMaterialConnectionPoint;
  59546. /**
  59547. * Gets the view input component
  59548. */
  59549. get view(): NodeMaterialConnectionPoint;
  59550. /**
  59551. * Gets the rgb output component
  59552. */
  59553. get rgb(): NodeMaterialConnectionPoint;
  59554. /**
  59555. * Gets the r output component
  59556. */
  59557. get r(): NodeMaterialConnectionPoint;
  59558. /**
  59559. * Gets the g output component
  59560. */
  59561. get g(): NodeMaterialConnectionPoint;
  59562. /**
  59563. * Gets the b output component
  59564. */
  59565. get b(): NodeMaterialConnectionPoint;
  59566. autoConfigure(material: NodeMaterial): void;
  59567. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59568. isReady(): boolean;
  59569. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59570. private _injectVertexCode;
  59571. private _writeOutput;
  59572. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59573. protected _dumpPropertiesCode(): string;
  59574. serialize(): any;
  59575. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59576. }
  59577. }
  59578. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59579. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59580. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59581. import { Scene } from "babylonjs/scene";
  59582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59583. import { Matrix } from "babylonjs/Maths/math.vector";
  59584. import { Mesh } from "babylonjs/Meshes/mesh";
  59585. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59586. import { Observable } from "babylonjs/Misc/observable";
  59587. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59588. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59589. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59590. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59591. import { Nullable } from "babylonjs/types";
  59592. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59593. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59594. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59595. /**
  59596. * Interface used to configure the node material editor
  59597. */
  59598. export interface INodeMaterialEditorOptions {
  59599. /** Define the URl to load node editor script */
  59600. editorURL?: string;
  59601. }
  59602. /** @hidden */
  59603. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59604. NORMAL: boolean;
  59605. TANGENT: boolean;
  59606. UV1: boolean;
  59607. /** BONES */
  59608. NUM_BONE_INFLUENCERS: number;
  59609. BonesPerMesh: number;
  59610. BONETEXTURE: boolean;
  59611. /** MORPH TARGETS */
  59612. MORPHTARGETS: boolean;
  59613. MORPHTARGETS_NORMAL: boolean;
  59614. MORPHTARGETS_TANGENT: boolean;
  59615. MORPHTARGETS_UV: boolean;
  59616. NUM_MORPH_INFLUENCERS: number;
  59617. /** IMAGE PROCESSING */
  59618. IMAGEPROCESSING: boolean;
  59619. VIGNETTE: boolean;
  59620. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59621. VIGNETTEBLENDMODEOPAQUE: boolean;
  59622. TONEMAPPING: boolean;
  59623. TONEMAPPING_ACES: boolean;
  59624. CONTRAST: boolean;
  59625. EXPOSURE: boolean;
  59626. COLORCURVES: boolean;
  59627. COLORGRADING: boolean;
  59628. COLORGRADING3D: boolean;
  59629. SAMPLER3DGREENDEPTH: boolean;
  59630. SAMPLER3DBGRMAP: boolean;
  59631. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59632. /** MISC. */
  59633. BUMPDIRECTUV: number;
  59634. constructor();
  59635. setValue(name: string, value: boolean): void;
  59636. }
  59637. /**
  59638. * Class used to configure NodeMaterial
  59639. */
  59640. export interface INodeMaterialOptions {
  59641. /**
  59642. * Defines if blocks should emit comments
  59643. */
  59644. emitComments: boolean;
  59645. }
  59646. /**
  59647. * Class used to create a node based material built by assembling shader blocks
  59648. */
  59649. export class NodeMaterial extends PushMaterial {
  59650. private static _BuildIdGenerator;
  59651. private _options;
  59652. private _vertexCompilationState;
  59653. private _fragmentCompilationState;
  59654. private _sharedData;
  59655. private _buildId;
  59656. private _buildWasSuccessful;
  59657. private _cachedWorldViewMatrix;
  59658. private _cachedWorldViewProjectionMatrix;
  59659. private _optimizers;
  59660. private _animationFrame;
  59661. /** Define the Url to load node editor script */
  59662. static EditorURL: string;
  59663. /** Define the Url to load snippets */
  59664. static SnippetUrl: string;
  59665. private BJSNODEMATERIALEDITOR;
  59666. /** Get the inspector from bundle or global */
  59667. private _getGlobalNodeMaterialEditor;
  59668. /**
  59669. * Gets or sets data used by visual editor
  59670. * @see https://nme.babylonjs.com
  59671. */
  59672. editorData: any;
  59673. /**
  59674. * 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)
  59675. */
  59676. ignoreAlpha: boolean;
  59677. /**
  59678. * Defines the maximum number of lights that can be used in the material
  59679. */
  59680. maxSimultaneousLights: number;
  59681. /**
  59682. * Observable raised when the material is built
  59683. */
  59684. onBuildObservable: Observable<NodeMaterial>;
  59685. /**
  59686. * Gets or sets the root nodes of the material vertex shader
  59687. */
  59688. _vertexOutputNodes: NodeMaterialBlock[];
  59689. /**
  59690. * Gets or sets the root nodes of the material fragment (pixel) shader
  59691. */
  59692. _fragmentOutputNodes: NodeMaterialBlock[];
  59693. /** Gets or sets options to control the node material overall behavior */
  59694. get options(): INodeMaterialOptions;
  59695. set options(options: INodeMaterialOptions);
  59696. /**
  59697. * Default configuration related to image processing available in the standard Material.
  59698. */
  59699. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59700. /**
  59701. * Gets the image processing configuration used either in this material.
  59702. */
  59703. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59704. /**
  59705. * Sets the Default image processing configuration used either in the this material.
  59706. *
  59707. * If sets to null, the scene one is in use.
  59708. */
  59709. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59710. /**
  59711. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59712. */
  59713. attachedBlocks: NodeMaterialBlock[];
  59714. /**
  59715. * Create a new node based material
  59716. * @param name defines the material name
  59717. * @param scene defines the hosting scene
  59718. * @param options defines creation option
  59719. */
  59720. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59721. /**
  59722. * Gets the current class name of the material e.g. "NodeMaterial"
  59723. * @returns the class name
  59724. */
  59725. getClassName(): string;
  59726. /**
  59727. * Keep track of the image processing observer to allow dispose and replace.
  59728. */
  59729. private _imageProcessingObserver;
  59730. /**
  59731. * Attaches a new image processing configuration to the Standard Material.
  59732. * @param configuration
  59733. */
  59734. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59735. /**
  59736. * Get a block by its name
  59737. * @param name defines the name of the block to retrieve
  59738. * @returns the required block or null if not found
  59739. */
  59740. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59741. /**
  59742. * Get a block by its name
  59743. * @param predicate defines the predicate used to find the good candidate
  59744. * @returns the required block or null if not found
  59745. */
  59746. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59747. /**
  59748. * Get an input block by its name
  59749. * @param predicate defines the predicate used to find the good candidate
  59750. * @returns the required input block or null if not found
  59751. */
  59752. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59753. /**
  59754. * Gets the list of input blocks attached to this material
  59755. * @returns an array of InputBlocks
  59756. */
  59757. getInputBlocks(): InputBlock[];
  59758. /**
  59759. * Adds a new optimizer to the list of optimizers
  59760. * @param optimizer defines the optimizers to add
  59761. * @returns the current material
  59762. */
  59763. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59764. /**
  59765. * Remove an optimizer from the list of optimizers
  59766. * @param optimizer defines the optimizers to remove
  59767. * @returns the current material
  59768. */
  59769. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59770. /**
  59771. * Add a new block to the list of output nodes
  59772. * @param node defines the node to add
  59773. * @returns the current material
  59774. */
  59775. addOutputNode(node: NodeMaterialBlock): this;
  59776. /**
  59777. * Remove a block from the list of root nodes
  59778. * @param node defines the node to remove
  59779. * @returns the current material
  59780. */
  59781. removeOutputNode(node: NodeMaterialBlock): this;
  59782. private _addVertexOutputNode;
  59783. private _removeVertexOutputNode;
  59784. private _addFragmentOutputNode;
  59785. private _removeFragmentOutputNode;
  59786. /**
  59787. * Specifies if the material will require alpha blending
  59788. * @returns a boolean specifying if alpha blending is needed
  59789. */
  59790. needAlphaBlending(): boolean;
  59791. /**
  59792. * Specifies if this material should be rendered in alpha test mode
  59793. * @returns a boolean specifying if an alpha test is needed.
  59794. */
  59795. needAlphaTesting(): boolean;
  59796. private _initializeBlock;
  59797. private _resetDualBlocks;
  59798. /**
  59799. * Remove a block from the current node material
  59800. * @param block defines the block to remove
  59801. */
  59802. removeBlock(block: NodeMaterialBlock): void;
  59803. /**
  59804. * Build the material and generates the inner effect
  59805. * @param verbose defines if the build should log activity
  59806. */
  59807. build(verbose?: boolean): void;
  59808. /**
  59809. * Runs an otpimization phase to try to improve the shader code
  59810. */
  59811. optimize(): void;
  59812. private _prepareDefinesForAttributes;
  59813. /**
  59814. * Get if the submesh is ready to be used and all its information available.
  59815. * Child classes can use it to update shaders
  59816. * @param mesh defines the mesh to check
  59817. * @param subMesh defines which submesh to check
  59818. * @param useInstances specifies that instances should be used
  59819. * @returns a boolean indicating that the submesh is ready or not
  59820. */
  59821. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59822. /**
  59823. * Get a string representing the shaders built by the current node graph
  59824. */
  59825. get compiledShaders(): string;
  59826. /**
  59827. * Binds the world matrix to the material
  59828. * @param world defines the world transformation matrix
  59829. */
  59830. bindOnlyWorldMatrix(world: Matrix): void;
  59831. /**
  59832. * Binds the submesh to this material by preparing the effect and shader to draw
  59833. * @param world defines the world transformation matrix
  59834. * @param mesh defines the mesh containing the submesh
  59835. * @param subMesh defines the submesh to bind the material to
  59836. */
  59837. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59838. /**
  59839. * Gets the active textures from the material
  59840. * @returns an array of textures
  59841. */
  59842. getActiveTextures(): BaseTexture[];
  59843. /**
  59844. * Gets the list of texture blocks
  59845. * @returns an array of texture blocks
  59846. */
  59847. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59848. /**
  59849. * Specifies if the material uses a texture
  59850. * @param texture defines the texture to check against the material
  59851. * @returns a boolean specifying if the material uses the texture
  59852. */
  59853. hasTexture(texture: BaseTexture): boolean;
  59854. /**
  59855. * Disposes the material
  59856. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59857. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59858. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59859. */
  59860. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59861. /** Creates the node editor window. */
  59862. private _createNodeEditor;
  59863. /**
  59864. * Launch the node material editor
  59865. * @param config Define the configuration of the editor
  59866. * @return a promise fulfilled when the node editor is visible
  59867. */
  59868. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59869. /**
  59870. * Clear the current material
  59871. */
  59872. clear(): void;
  59873. /**
  59874. * Clear the current material and set it to a default state
  59875. */
  59876. setToDefault(): void;
  59877. /**
  59878. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  59879. * @param url defines the url to load from
  59880. * @returns a promise that will fullfil when the material is fully loaded
  59881. */
  59882. loadAsync(url: string): Promise<void>;
  59883. private _gatherBlocks;
  59884. /**
  59885. * Generate a string containing the code declaration required to create an equivalent of this material
  59886. * @returns a string
  59887. */
  59888. generateCode(): string;
  59889. /**
  59890. * Serializes this material in a JSON representation
  59891. * @returns the serialized material object
  59892. */
  59893. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  59894. private _restoreConnections;
  59895. /**
  59896. * Clear the current graph and load a new one from a serialization object
  59897. * @param source defines the JSON representation of the material
  59898. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59899. */
  59900. loadFromSerialization(source: any, rootUrl?: string): void;
  59901. /**
  59902. * Creates a node material from parsed material data
  59903. * @param source defines the JSON representation of the material
  59904. * @param scene defines the hosting scene
  59905. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59906. * @returns a new node material
  59907. */
  59908. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  59909. /**
  59910. * Creates a node material from a snippet saved in a remote file
  59911. * @param name defines the name of the material to create
  59912. * @param url defines the url to load from
  59913. * @param scene defines the hosting scene
  59914. * @returns a promise that will resolve to the new node material
  59915. */
  59916. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  59917. /**
  59918. * Creates a node material from a snippet saved by the node material editor
  59919. * @param snippetId defines the snippet to load
  59920. * @param scene defines the hosting scene
  59921. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59922. * @returns a promise that will resolve to the new node material
  59923. */
  59924. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  59925. /**
  59926. * Creates a new node material set to default basic configuration
  59927. * @param name defines the name of the material
  59928. * @param scene defines the hosting scene
  59929. * @returns a new NodeMaterial
  59930. */
  59931. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  59932. }
  59933. }
  59934. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  59935. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59936. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59937. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59938. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59940. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59941. import { Effect } from "babylonjs/Materials/effect";
  59942. import { Mesh } from "babylonjs/Meshes/mesh";
  59943. import { Nullable } from "babylonjs/types";
  59944. import { Texture } from "babylonjs/Materials/Textures/texture";
  59945. import { Scene } from "babylonjs/scene";
  59946. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59947. /**
  59948. * Block used to read a texture from a sampler
  59949. */
  59950. export class TextureBlock extends NodeMaterialBlock {
  59951. private _defineName;
  59952. private _linearDefineName;
  59953. private _tempTextureRead;
  59954. private _samplerName;
  59955. private _transformedUVName;
  59956. private _textureTransformName;
  59957. private _textureInfoName;
  59958. private _mainUVName;
  59959. private _mainUVDefineName;
  59960. /**
  59961. * Gets or sets the texture associated with the node
  59962. */
  59963. texture: Nullable<Texture>;
  59964. /**
  59965. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  59966. */
  59967. convertToGammaSpace: boolean;
  59968. /**
  59969. * Create a new TextureBlock
  59970. * @param name defines the block name
  59971. */
  59972. constructor(name: string);
  59973. /**
  59974. * Gets the current class name
  59975. * @returns the class name
  59976. */
  59977. getClassName(): string;
  59978. /**
  59979. * Gets the uv input component
  59980. */
  59981. get uv(): NodeMaterialConnectionPoint;
  59982. /**
  59983. * Gets the rgba output component
  59984. */
  59985. get rgba(): NodeMaterialConnectionPoint;
  59986. /**
  59987. * Gets the rgb output component
  59988. */
  59989. get rgb(): NodeMaterialConnectionPoint;
  59990. /**
  59991. * Gets the r output component
  59992. */
  59993. get r(): NodeMaterialConnectionPoint;
  59994. /**
  59995. * Gets the g output component
  59996. */
  59997. get g(): NodeMaterialConnectionPoint;
  59998. /**
  59999. * Gets the b output component
  60000. */
  60001. get b(): NodeMaterialConnectionPoint;
  60002. /**
  60003. * Gets the a output component
  60004. */
  60005. get a(): NodeMaterialConnectionPoint;
  60006. get target(): NodeMaterialBlockTargets;
  60007. autoConfigure(material: NodeMaterial): void;
  60008. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60009. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60010. isReady(): boolean;
  60011. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60012. private get _isMixed();
  60013. private _injectVertexCode;
  60014. private _writeTextureRead;
  60015. private _writeOutput;
  60016. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60017. protected _dumpPropertiesCode(): string;
  60018. serialize(): any;
  60019. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60020. }
  60021. }
  60022. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60023. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60025. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60026. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60027. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60028. import { Scene } from "babylonjs/scene";
  60029. /**
  60030. * Class used to store shared data between 2 NodeMaterialBuildState
  60031. */
  60032. export class NodeMaterialBuildStateSharedData {
  60033. /**
  60034. * Gets the list of emitted varyings
  60035. */
  60036. temps: string[];
  60037. /**
  60038. * Gets the list of emitted varyings
  60039. */
  60040. varyings: string[];
  60041. /**
  60042. * Gets the varying declaration string
  60043. */
  60044. varyingDeclaration: string;
  60045. /**
  60046. * Input blocks
  60047. */
  60048. inputBlocks: InputBlock[];
  60049. /**
  60050. * Input blocks
  60051. */
  60052. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60053. /**
  60054. * Bindable blocks (Blocks that need to set data to the effect)
  60055. */
  60056. bindableBlocks: NodeMaterialBlock[];
  60057. /**
  60058. * List of blocks that can provide a compilation fallback
  60059. */
  60060. blocksWithFallbacks: NodeMaterialBlock[];
  60061. /**
  60062. * List of blocks that can provide a define update
  60063. */
  60064. blocksWithDefines: NodeMaterialBlock[];
  60065. /**
  60066. * List of blocks that can provide a repeatable content
  60067. */
  60068. repeatableContentBlocks: NodeMaterialBlock[];
  60069. /**
  60070. * List of blocks that can provide a dynamic list of uniforms
  60071. */
  60072. dynamicUniformBlocks: NodeMaterialBlock[];
  60073. /**
  60074. * List of blocks that can block the isReady function for the material
  60075. */
  60076. blockingBlocks: NodeMaterialBlock[];
  60077. /**
  60078. * Gets the list of animated inputs
  60079. */
  60080. animatedInputs: InputBlock[];
  60081. /**
  60082. * Build Id used to avoid multiple recompilations
  60083. */
  60084. buildId: number;
  60085. /** List of emitted variables */
  60086. variableNames: {
  60087. [key: string]: number;
  60088. };
  60089. /** List of emitted defines */
  60090. defineNames: {
  60091. [key: string]: number;
  60092. };
  60093. /** Should emit comments? */
  60094. emitComments: boolean;
  60095. /** Emit build activity */
  60096. verbose: boolean;
  60097. /** Gets or sets the hosting scene */
  60098. scene: Scene;
  60099. /**
  60100. * Gets the compilation hints emitted at compilation time
  60101. */
  60102. hints: {
  60103. needWorldViewMatrix: boolean;
  60104. needWorldViewProjectionMatrix: boolean;
  60105. needAlphaBlending: boolean;
  60106. needAlphaTesting: boolean;
  60107. };
  60108. /**
  60109. * List of compilation checks
  60110. */
  60111. checks: {
  60112. emitVertex: boolean;
  60113. emitFragment: boolean;
  60114. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60115. };
  60116. /** Creates a new shared data */
  60117. constructor();
  60118. /**
  60119. * Emits console errors and exceptions if there is a failing check
  60120. */
  60121. emitErrors(): void;
  60122. }
  60123. }
  60124. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60125. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60126. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60127. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60128. /**
  60129. * Class used to store node based material build state
  60130. */
  60131. export class NodeMaterialBuildState {
  60132. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60133. supportUniformBuffers: boolean;
  60134. /**
  60135. * Gets the list of emitted attributes
  60136. */
  60137. attributes: string[];
  60138. /**
  60139. * Gets the list of emitted uniforms
  60140. */
  60141. uniforms: string[];
  60142. /**
  60143. * Gets the list of emitted constants
  60144. */
  60145. constants: string[];
  60146. /**
  60147. * Gets the list of emitted samplers
  60148. */
  60149. samplers: string[];
  60150. /**
  60151. * Gets the list of emitted functions
  60152. */
  60153. functions: {
  60154. [key: string]: string;
  60155. };
  60156. /**
  60157. * Gets the list of emitted extensions
  60158. */
  60159. extensions: {
  60160. [key: string]: string;
  60161. };
  60162. /**
  60163. * Gets the target of the compilation state
  60164. */
  60165. target: NodeMaterialBlockTargets;
  60166. /**
  60167. * Gets the list of emitted counters
  60168. */
  60169. counters: {
  60170. [key: string]: number;
  60171. };
  60172. /**
  60173. * Shared data between multiple NodeMaterialBuildState instances
  60174. */
  60175. sharedData: NodeMaterialBuildStateSharedData;
  60176. /** @hidden */
  60177. _vertexState: NodeMaterialBuildState;
  60178. /** @hidden */
  60179. _attributeDeclaration: string;
  60180. /** @hidden */
  60181. _uniformDeclaration: string;
  60182. /** @hidden */
  60183. _constantDeclaration: string;
  60184. /** @hidden */
  60185. _samplerDeclaration: string;
  60186. /** @hidden */
  60187. _varyingTransfer: string;
  60188. private _repeatableContentAnchorIndex;
  60189. /** @hidden */
  60190. _builtCompilationString: string;
  60191. /**
  60192. * Gets the emitted compilation strings
  60193. */
  60194. compilationString: string;
  60195. /**
  60196. * Finalize the compilation strings
  60197. * @param state defines the current compilation state
  60198. */
  60199. finalize(state: NodeMaterialBuildState): void;
  60200. /** @hidden */
  60201. get _repeatableContentAnchor(): string;
  60202. /** @hidden */
  60203. _getFreeVariableName(prefix: string): string;
  60204. /** @hidden */
  60205. _getFreeDefineName(prefix: string): string;
  60206. /** @hidden */
  60207. _excludeVariableName(name: string): void;
  60208. /** @hidden */
  60209. _emit2DSampler(name: string): void;
  60210. /** @hidden */
  60211. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60212. /** @hidden */
  60213. _emitExtension(name: string, extension: string): void;
  60214. /** @hidden */
  60215. _emitFunction(name: string, code: string, comments: string): void;
  60216. /** @hidden */
  60217. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60218. replaceStrings?: {
  60219. search: RegExp;
  60220. replace: string;
  60221. }[];
  60222. repeatKey?: string;
  60223. }): string;
  60224. /** @hidden */
  60225. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60226. repeatKey?: string;
  60227. removeAttributes?: boolean;
  60228. removeUniforms?: boolean;
  60229. removeVaryings?: boolean;
  60230. removeIfDef?: boolean;
  60231. replaceStrings?: {
  60232. search: RegExp;
  60233. replace: string;
  60234. }[];
  60235. }, storeKey?: string): void;
  60236. /** @hidden */
  60237. _registerTempVariable(name: string): boolean;
  60238. /** @hidden */
  60239. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60240. /** @hidden */
  60241. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60242. /** @hidden */
  60243. _emitFloat(value: number): string;
  60244. }
  60245. }
  60246. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60247. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60248. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60249. import { Nullable } from "babylonjs/types";
  60250. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60251. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60252. import { Effect } from "babylonjs/Materials/effect";
  60253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60254. import { Mesh } from "babylonjs/Meshes/mesh";
  60255. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60256. import { Scene } from "babylonjs/scene";
  60257. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60258. /**
  60259. * Defines a block that can be used inside a node based material
  60260. */
  60261. export class NodeMaterialBlock {
  60262. private _buildId;
  60263. private _buildTarget;
  60264. private _target;
  60265. private _isFinalMerger;
  60266. private _isInput;
  60267. protected _isUnique: boolean;
  60268. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60269. inputsAreExclusive: boolean;
  60270. /** @hidden */
  60271. _codeVariableName: string;
  60272. /** @hidden */
  60273. _inputs: NodeMaterialConnectionPoint[];
  60274. /** @hidden */
  60275. _outputs: NodeMaterialConnectionPoint[];
  60276. /** @hidden */
  60277. _preparationId: number;
  60278. /**
  60279. * Gets or sets the name of the block
  60280. */
  60281. name: string;
  60282. /**
  60283. * Gets or sets the unique id of the node
  60284. */
  60285. uniqueId: number;
  60286. /**
  60287. * Gets or sets the comments associated with this block
  60288. */
  60289. comments: string;
  60290. /**
  60291. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60292. */
  60293. get isUnique(): boolean;
  60294. /**
  60295. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60296. */
  60297. get isFinalMerger(): boolean;
  60298. /**
  60299. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60300. */
  60301. get isInput(): boolean;
  60302. /**
  60303. * Gets or sets the build Id
  60304. */
  60305. get buildId(): number;
  60306. set buildId(value: number);
  60307. /**
  60308. * Gets or sets the target of the block
  60309. */
  60310. get target(): NodeMaterialBlockTargets;
  60311. set target(value: NodeMaterialBlockTargets);
  60312. /**
  60313. * Gets the list of input points
  60314. */
  60315. get inputs(): NodeMaterialConnectionPoint[];
  60316. /** Gets the list of output points */
  60317. get outputs(): NodeMaterialConnectionPoint[];
  60318. /**
  60319. * Find an input by its name
  60320. * @param name defines the name of the input to look for
  60321. * @returns the input or null if not found
  60322. */
  60323. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60324. /**
  60325. * Find an output by its name
  60326. * @param name defines the name of the outputto look for
  60327. * @returns the output or null if not found
  60328. */
  60329. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60330. /**
  60331. * Creates a new NodeMaterialBlock
  60332. * @param name defines the block name
  60333. * @param target defines the target of that block (Vertex by default)
  60334. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60335. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60336. */
  60337. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60338. /**
  60339. * Initialize the block and prepare the context for build
  60340. * @param state defines the state that will be used for the build
  60341. */
  60342. initialize(state: NodeMaterialBuildState): void;
  60343. /**
  60344. * Bind data to effect. Will only be called for blocks with isBindable === true
  60345. * @param effect defines the effect to bind data to
  60346. * @param nodeMaterial defines the hosting NodeMaterial
  60347. * @param mesh defines the mesh that will be rendered
  60348. */
  60349. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60350. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60351. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60352. protected _writeFloat(value: number): string;
  60353. /**
  60354. * Gets the current class name e.g. "NodeMaterialBlock"
  60355. * @returns the class name
  60356. */
  60357. getClassName(): string;
  60358. /**
  60359. * Register a new input. Must be called inside a block constructor
  60360. * @param name defines the connection point name
  60361. * @param type defines the connection point type
  60362. * @param isOptional defines a boolean indicating that this input can be omitted
  60363. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60364. * @returns the current block
  60365. */
  60366. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60367. /**
  60368. * Register a new output. Must be called inside a block constructor
  60369. * @param name defines the connection point name
  60370. * @param type defines the connection point type
  60371. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60372. * @returns the current block
  60373. */
  60374. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60375. /**
  60376. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60377. * @param forOutput defines an optional connection point to check compatibility with
  60378. * @returns the first available input or null
  60379. */
  60380. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60381. /**
  60382. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60383. * @param forBlock defines an optional block to check compatibility with
  60384. * @returns the first available input or null
  60385. */
  60386. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60387. /**
  60388. * Gets the sibling of the given output
  60389. * @param current defines the current output
  60390. * @returns the next output in the list or null
  60391. */
  60392. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60393. /**
  60394. * Connect current block with another block
  60395. * @param other defines the block to connect with
  60396. * @param options define the various options to help pick the right connections
  60397. * @returns the current block
  60398. */
  60399. connectTo(other: NodeMaterialBlock, options?: {
  60400. input?: string;
  60401. output?: string;
  60402. outputSwizzle?: string;
  60403. }): this | undefined;
  60404. protected _buildBlock(state: NodeMaterialBuildState): void;
  60405. /**
  60406. * Add uniforms, samplers and uniform buffers at compilation time
  60407. * @param state defines the state to update
  60408. * @param nodeMaterial defines the node material requesting the update
  60409. * @param defines defines the material defines to update
  60410. * @param uniformBuffers defines the list of uniform buffer names
  60411. */
  60412. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60413. /**
  60414. * Add potential fallbacks if shader compilation fails
  60415. * @param mesh defines the mesh to be rendered
  60416. * @param fallbacks defines the current prioritized list of fallbacks
  60417. */
  60418. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60419. /**
  60420. * Initialize defines for shader compilation
  60421. * @param mesh defines the mesh to be rendered
  60422. * @param nodeMaterial defines the node material requesting the update
  60423. * @param defines defines the material defines to update
  60424. * @param useInstances specifies that instances should be used
  60425. */
  60426. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60427. /**
  60428. * Update defines for shader compilation
  60429. * @param mesh defines the mesh to be rendered
  60430. * @param nodeMaterial defines the node material requesting the update
  60431. * @param defines defines the material defines to update
  60432. * @param useInstances specifies that instances should be used
  60433. */
  60434. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60435. /**
  60436. * Lets the block try to connect some inputs automatically
  60437. * @param material defines the hosting NodeMaterial
  60438. */
  60439. autoConfigure(material: NodeMaterial): void;
  60440. /**
  60441. * Function called when a block is declared as repeatable content generator
  60442. * @param vertexShaderState defines the current compilation state for the vertex shader
  60443. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60444. * @param mesh defines the mesh to be rendered
  60445. * @param defines defines the material defines to update
  60446. */
  60447. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60448. /**
  60449. * Checks if the block is ready
  60450. * @param mesh defines the mesh to be rendered
  60451. * @param nodeMaterial defines the node material requesting the update
  60452. * @param defines defines the material defines to update
  60453. * @param useInstances specifies that instances should be used
  60454. * @returns true if the block is ready
  60455. */
  60456. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60457. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60458. private _processBuild;
  60459. /**
  60460. * Compile the current node and generate the shader code
  60461. * @param state defines the current compilation state (uniforms, samplers, current string)
  60462. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60463. * @returns true if already built
  60464. */
  60465. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60466. protected _inputRename(name: string): string;
  60467. protected _outputRename(name: string): string;
  60468. protected _dumpPropertiesCode(): string;
  60469. /** @hidden */
  60470. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60471. /** @hidden */
  60472. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60473. /**
  60474. * Clone the current block to a new identical block
  60475. * @param scene defines the hosting scene
  60476. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60477. * @returns a copy of the current block
  60478. */
  60479. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60480. /**
  60481. * Serializes this block in a JSON representation
  60482. * @returns the serialized block object
  60483. */
  60484. serialize(): any;
  60485. /** @hidden */
  60486. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60487. /**
  60488. * Release resources
  60489. */
  60490. dispose(): void;
  60491. }
  60492. }
  60493. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60494. /**
  60495. * Enum defining the type of animations supported by InputBlock
  60496. */
  60497. export enum AnimatedInputBlockTypes {
  60498. /** No animation */
  60499. None = 0,
  60500. /** Time based animation. Will only work for floats */
  60501. Time = 1
  60502. }
  60503. }
  60504. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60505. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60506. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60507. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60508. import { Nullable } from "babylonjs/types";
  60509. import { Effect } from "babylonjs/Materials/effect";
  60510. import { Matrix } from "babylonjs/Maths/math.vector";
  60511. import { Scene } from "babylonjs/scene";
  60512. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60513. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60514. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60515. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60516. import { Observable } from "babylonjs/Misc/observable";
  60517. /**
  60518. * Block used to expose an input value
  60519. */
  60520. export class InputBlock extends NodeMaterialBlock {
  60521. private _mode;
  60522. private _associatedVariableName;
  60523. private _storedValue;
  60524. private _valueCallback;
  60525. private _type;
  60526. private _animationType;
  60527. /** Gets or set a value used to limit the range of float values */
  60528. min: number;
  60529. /** Gets or set a value used to limit the range of float values */
  60530. max: number;
  60531. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60532. isBoolean: boolean;
  60533. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60534. matrixMode: number;
  60535. /** @hidden */
  60536. _systemValue: Nullable<NodeMaterialSystemValues>;
  60537. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60538. visibleInInspector: boolean;
  60539. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60540. isConstant: boolean;
  60541. /** Gets or sets the group to use to display this block in the Inspector */
  60542. groupInInspector: string;
  60543. /** Gets an observable raised when the value is changed */
  60544. onValueChangedObservable: Observable<InputBlock>;
  60545. /**
  60546. * Gets or sets the connection point type (default is float)
  60547. */
  60548. get type(): NodeMaterialBlockConnectionPointTypes;
  60549. /**
  60550. * Creates a new InputBlock
  60551. * @param name defines the block name
  60552. * @param target defines the target of that block (Vertex by default)
  60553. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60554. */
  60555. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60556. /**
  60557. * Gets the output component
  60558. */
  60559. get output(): NodeMaterialConnectionPoint;
  60560. /**
  60561. * Set the source of this connection point to a vertex attribute
  60562. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60563. * @returns the current connection point
  60564. */
  60565. setAsAttribute(attributeName?: string): InputBlock;
  60566. /**
  60567. * Set the source of this connection point to a system value
  60568. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60569. * @returns the current connection point
  60570. */
  60571. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60572. /**
  60573. * Gets or sets the value of that point.
  60574. * Please note that this value will be ignored if valueCallback is defined
  60575. */
  60576. get value(): any;
  60577. set value(value: any);
  60578. /**
  60579. * Gets or sets a callback used to get the value of that point.
  60580. * Please note that setting this value will force the connection point to ignore the value property
  60581. */
  60582. get valueCallback(): () => any;
  60583. set valueCallback(value: () => any);
  60584. /**
  60585. * Gets or sets the associated variable name in the shader
  60586. */
  60587. get associatedVariableName(): string;
  60588. set associatedVariableName(value: string);
  60589. /** Gets or sets the type of animation applied to the input */
  60590. get animationType(): AnimatedInputBlockTypes;
  60591. set animationType(value: AnimatedInputBlockTypes);
  60592. /**
  60593. * Gets a boolean indicating that this connection point not defined yet
  60594. */
  60595. get isUndefined(): boolean;
  60596. /**
  60597. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60598. * In this case the connection point name must be the name of the uniform to use.
  60599. * Can only be set on inputs
  60600. */
  60601. get isUniform(): boolean;
  60602. set isUniform(value: boolean);
  60603. /**
  60604. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60605. * In this case the connection point name must be the name of the attribute to use
  60606. * Can only be set on inputs
  60607. */
  60608. get isAttribute(): boolean;
  60609. set isAttribute(value: boolean);
  60610. /**
  60611. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60612. * Can only be set on exit points
  60613. */
  60614. get isVarying(): boolean;
  60615. set isVarying(value: boolean);
  60616. /**
  60617. * Gets a boolean indicating that the current connection point is a system value
  60618. */
  60619. get isSystemValue(): boolean;
  60620. /**
  60621. * Gets or sets the current well known value or null if not defined as a system value
  60622. */
  60623. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60624. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60625. /**
  60626. * Gets the current class name
  60627. * @returns the class name
  60628. */
  60629. getClassName(): string;
  60630. /**
  60631. * Animate the input if animationType !== None
  60632. * @param scene defines the rendering scene
  60633. */
  60634. animate(scene: Scene): void;
  60635. private _emitDefine;
  60636. initialize(state: NodeMaterialBuildState): void;
  60637. /**
  60638. * Set the input block to its default value (based on its type)
  60639. */
  60640. setDefaultValue(): void;
  60641. private _emitConstant;
  60642. private _emit;
  60643. /** @hidden */
  60644. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60645. /** @hidden */
  60646. _transmit(effect: Effect, scene: Scene): void;
  60647. protected _buildBlock(state: NodeMaterialBuildState): void;
  60648. protected _dumpPropertiesCode(): string;
  60649. dispose(): void;
  60650. serialize(): any;
  60651. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60652. }
  60653. }
  60654. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60655. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60656. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60657. import { Nullable } from "babylonjs/types";
  60658. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60659. import { Observable } from "babylonjs/Misc/observable";
  60660. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60661. /**
  60662. * Enum used to define the compatibility state between two connection points
  60663. */
  60664. export enum NodeMaterialConnectionPointCompatibilityStates {
  60665. /** Points are compatibles */
  60666. Compatible = 0,
  60667. /** Points are incompatible because of their types */
  60668. TypeIncompatible = 1,
  60669. /** Points are incompatible because of their targets (vertex vs fragment) */
  60670. TargetIncompatible = 2
  60671. }
  60672. /**
  60673. * Defines the direction of a connection point
  60674. */
  60675. export enum NodeMaterialConnectionPointDirection {
  60676. /** Input */
  60677. Input = 0,
  60678. /** Output */
  60679. Output = 1
  60680. }
  60681. /**
  60682. * Defines a connection point for a block
  60683. */
  60684. export class NodeMaterialConnectionPoint {
  60685. /** @hidden */
  60686. _ownerBlock: NodeMaterialBlock;
  60687. /** @hidden */
  60688. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60689. private _endpoints;
  60690. private _associatedVariableName;
  60691. private _direction;
  60692. /** @hidden */
  60693. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60694. /** @hidden */
  60695. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60696. private _type;
  60697. /** @hidden */
  60698. _enforceAssociatedVariableName: boolean;
  60699. /** Gets the direction of the point */
  60700. get direction(): NodeMaterialConnectionPointDirection;
  60701. /**
  60702. * Gets or sets the additional types supported by this connection point
  60703. */
  60704. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60705. /**
  60706. * Gets or sets the additional types excluded by this connection point
  60707. */
  60708. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60709. /**
  60710. * Observable triggered when this point is connected
  60711. */
  60712. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60713. /**
  60714. * Gets or sets the associated variable name in the shader
  60715. */
  60716. get associatedVariableName(): string;
  60717. set associatedVariableName(value: string);
  60718. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  60719. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60720. /**
  60721. * Gets or sets the connection point type (default is float)
  60722. */
  60723. get type(): NodeMaterialBlockConnectionPointTypes;
  60724. set type(value: NodeMaterialBlockConnectionPointTypes);
  60725. /**
  60726. * Gets or sets the connection point name
  60727. */
  60728. name: string;
  60729. /**
  60730. * Gets or sets a boolean indicating that this connection point can be omitted
  60731. */
  60732. isOptional: boolean;
  60733. /**
  60734. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60735. */
  60736. define: string;
  60737. /** @hidden */
  60738. _prioritizeVertex: boolean;
  60739. private _target;
  60740. /** Gets or sets the target of that connection point */
  60741. get target(): NodeMaterialBlockTargets;
  60742. set target(value: NodeMaterialBlockTargets);
  60743. /**
  60744. * Gets a boolean indicating that the current point is connected
  60745. */
  60746. get isConnected(): boolean;
  60747. /**
  60748. * Gets a boolean indicating that the current point is connected to an input block
  60749. */
  60750. get isConnectedToInputBlock(): boolean;
  60751. /**
  60752. * Gets a the connected input block (if any)
  60753. */
  60754. get connectInputBlock(): Nullable<InputBlock>;
  60755. /** Get the other side of the connection (if any) */
  60756. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60757. /** Get the block that owns this connection point */
  60758. get ownerBlock(): NodeMaterialBlock;
  60759. /** Get the block connected on the other side of this connection (if any) */
  60760. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60761. /** Get the block connected on the endpoints of this connection (if any) */
  60762. get connectedBlocks(): Array<NodeMaterialBlock>;
  60763. /** Gets the list of connected endpoints */
  60764. get endpoints(): NodeMaterialConnectionPoint[];
  60765. /** Gets a boolean indicating if that output point is connected to at least one input */
  60766. get hasEndpoints(): boolean;
  60767. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60768. get isConnectedInVertexShader(): boolean;
  60769. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60770. get isConnectedInFragmentShader(): boolean;
  60771. /**
  60772. * Creates a new connection point
  60773. * @param name defines the connection point name
  60774. * @param ownerBlock defines the block hosting this connection point
  60775. * @param direction defines the direction of the connection point
  60776. */
  60777. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60778. /**
  60779. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60780. * @returns the class name
  60781. */
  60782. getClassName(): string;
  60783. /**
  60784. * Gets a boolean indicating if the current point can be connected to another point
  60785. * @param connectionPoint defines the other connection point
  60786. * @returns a boolean
  60787. */
  60788. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60789. /**
  60790. * Gets a number indicating if the current point can be connected to another point
  60791. * @param connectionPoint defines the other connection point
  60792. * @returns a number defining the compatibility state
  60793. */
  60794. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60795. /**
  60796. * Connect this point to another connection point
  60797. * @param connectionPoint defines the other connection point
  60798. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60799. * @returns the current connection point
  60800. */
  60801. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60802. /**
  60803. * Disconnect this point from one of his endpoint
  60804. * @param endpoint defines the other connection point
  60805. * @returns the current connection point
  60806. */
  60807. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60808. /**
  60809. * Serializes this point in a JSON representation
  60810. * @returns the serialized point object
  60811. */
  60812. serialize(): any;
  60813. /**
  60814. * Release resources
  60815. */
  60816. dispose(): void;
  60817. }
  60818. }
  60819. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60820. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60821. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60822. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60823. import { Mesh } from "babylonjs/Meshes/mesh";
  60824. import { Effect } from "babylonjs/Materials/effect";
  60825. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60826. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60827. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60828. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60829. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60830. /**
  60831. * Block used to add support for vertex skinning (bones)
  60832. */
  60833. export class BonesBlock extends NodeMaterialBlock {
  60834. /**
  60835. * Creates a new BonesBlock
  60836. * @param name defines the block name
  60837. */
  60838. constructor(name: string);
  60839. /**
  60840. * Initialize the block and prepare the context for build
  60841. * @param state defines the state that will be used for the build
  60842. */
  60843. initialize(state: NodeMaterialBuildState): void;
  60844. /**
  60845. * Gets the current class name
  60846. * @returns the class name
  60847. */
  60848. getClassName(): string;
  60849. /**
  60850. * Gets the matrix indices input component
  60851. */
  60852. get matricesIndices(): NodeMaterialConnectionPoint;
  60853. /**
  60854. * Gets the matrix weights input component
  60855. */
  60856. get matricesWeights(): NodeMaterialConnectionPoint;
  60857. /**
  60858. * Gets the extra matrix indices input component
  60859. */
  60860. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60861. /**
  60862. * Gets the extra matrix weights input component
  60863. */
  60864. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60865. /**
  60866. * Gets the world input component
  60867. */
  60868. get world(): NodeMaterialConnectionPoint;
  60869. /**
  60870. * Gets the output component
  60871. */
  60872. get output(): NodeMaterialConnectionPoint;
  60873. autoConfigure(material: NodeMaterial): void;
  60874. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60875. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60876. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60877. protected _buildBlock(state: NodeMaterialBuildState): this;
  60878. }
  60879. }
  60880. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60881. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60882. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60883. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60884. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60885. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60886. /**
  60887. * Block used to add support for instances
  60888. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60889. */
  60890. export class InstancesBlock extends NodeMaterialBlock {
  60891. /**
  60892. * Creates a new InstancesBlock
  60893. * @param name defines the block name
  60894. */
  60895. constructor(name: string);
  60896. /**
  60897. * Gets the current class name
  60898. * @returns the class name
  60899. */
  60900. getClassName(): string;
  60901. /**
  60902. * Gets the first world row input component
  60903. */
  60904. get world0(): NodeMaterialConnectionPoint;
  60905. /**
  60906. * Gets the second world row input component
  60907. */
  60908. get world1(): NodeMaterialConnectionPoint;
  60909. /**
  60910. * Gets the third world row input component
  60911. */
  60912. get world2(): NodeMaterialConnectionPoint;
  60913. /**
  60914. * Gets the forth world row input component
  60915. */
  60916. get world3(): NodeMaterialConnectionPoint;
  60917. /**
  60918. * Gets the world input component
  60919. */
  60920. get world(): NodeMaterialConnectionPoint;
  60921. /**
  60922. * Gets the output component
  60923. */
  60924. get output(): NodeMaterialConnectionPoint;
  60925. /**
  60926. * Gets the isntanceID component
  60927. */
  60928. get instanceID(): NodeMaterialConnectionPoint;
  60929. autoConfigure(material: NodeMaterial): void;
  60930. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60931. protected _buildBlock(state: NodeMaterialBuildState): this;
  60932. }
  60933. }
  60934. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  60935. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60936. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60937. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60939. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60940. import { Effect } from "babylonjs/Materials/effect";
  60941. import { Mesh } from "babylonjs/Meshes/mesh";
  60942. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60943. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60944. /**
  60945. * Block used to add morph targets support to vertex shader
  60946. */
  60947. export class MorphTargetsBlock extends NodeMaterialBlock {
  60948. private _repeatableContentAnchor;
  60949. /**
  60950. * Create a new MorphTargetsBlock
  60951. * @param name defines the block name
  60952. */
  60953. constructor(name: string);
  60954. /**
  60955. * Gets the current class name
  60956. * @returns the class name
  60957. */
  60958. getClassName(): string;
  60959. /**
  60960. * Gets the position input component
  60961. */
  60962. get position(): NodeMaterialConnectionPoint;
  60963. /**
  60964. * Gets the normal input component
  60965. */
  60966. get normal(): NodeMaterialConnectionPoint;
  60967. /**
  60968. * Gets the tangent input component
  60969. */
  60970. get tangent(): NodeMaterialConnectionPoint;
  60971. /**
  60972. * Gets the tangent input component
  60973. */
  60974. get uv(): NodeMaterialConnectionPoint;
  60975. /**
  60976. * Gets the position output component
  60977. */
  60978. get positionOutput(): NodeMaterialConnectionPoint;
  60979. /**
  60980. * Gets the normal output component
  60981. */
  60982. get normalOutput(): NodeMaterialConnectionPoint;
  60983. /**
  60984. * Gets the tangent output component
  60985. */
  60986. get tangentOutput(): NodeMaterialConnectionPoint;
  60987. /**
  60988. * Gets the tangent output component
  60989. */
  60990. get uvOutput(): NodeMaterialConnectionPoint;
  60991. initialize(state: NodeMaterialBuildState): void;
  60992. autoConfigure(material: NodeMaterial): void;
  60993. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60994. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60995. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60996. protected _buildBlock(state: NodeMaterialBuildState): this;
  60997. }
  60998. }
  60999. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61000. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61001. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61002. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61003. import { Nullable } from "babylonjs/types";
  61004. import { Scene } from "babylonjs/scene";
  61005. import { Effect } from "babylonjs/Materials/effect";
  61006. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61007. import { Mesh } from "babylonjs/Meshes/mesh";
  61008. import { Light } from "babylonjs/Lights/light";
  61009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61010. /**
  61011. * Block used to get data information from a light
  61012. */
  61013. export class LightInformationBlock extends NodeMaterialBlock {
  61014. private _lightDataUniformName;
  61015. private _lightColorUniformName;
  61016. private _lightTypeDefineName;
  61017. /**
  61018. * Gets or sets the light associated with this block
  61019. */
  61020. light: Nullable<Light>;
  61021. /**
  61022. * Creates a new LightInformationBlock
  61023. * @param name defines the block name
  61024. */
  61025. constructor(name: string);
  61026. /**
  61027. * Gets the current class name
  61028. * @returns the class name
  61029. */
  61030. getClassName(): string;
  61031. /**
  61032. * Gets the world position input component
  61033. */
  61034. get worldPosition(): NodeMaterialConnectionPoint;
  61035. /**
  61036. * Gets the direction output component
  61037. */
  61038. get direction(): NodeMaterialConnectionPoint;
  61039. /**
  61040. * Gets the direction output component
  61041. */
  61042. get color(): NodeMaterialConnectionPoint;
  61043. /**
  61044. * Gets the direction output component
  61045. */
  61046. get intensity(): NodeMaterialConnectionPoint;
  61047. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61048. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61049. protected _buildBlock(state: NodeMaterialBuildState): this;
  61050. serialize(): any;
  61051. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61052. }
  61053. }
  61054. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61055. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61056. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61057. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61058. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61059. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61060. }
  61061. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61062. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61063. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61064. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61066. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61067. import { Effect } from "babylonjs/Materials/effect";
  61068. import { Mesh } from "babylonjs/Meshes/mesh";
  61069. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61070. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61071. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61072. /**
  61073. * Block used to add image processing support to fragment shader
  61074. */
  61075. export class ImageProcessingBlock extends NodeMaterialBlock {
  61076. /**
  61077. * Create a new ImageProcessingBlock
  61078. * @param name defines the block name
  61079. */
  61080. constructor(name: string);
  61081. /**
  61082. * Gets the current class name
  61083. * @returns the class name
  61084. */
  61085. getClassName(): string;
  61086. /**
  61087. * Gets the color input component
  61088. */
  61089. get color(): NodeMaterialConnectionPoint;
  61090. /**
  61091. * Gets the output component
  61092. */
  61093. get output(): NodeMaterialConnectionPoint;
  61094. /**
  61095. * Initialize the block and prepare the context for build
  61096. * @param state defines the state that will be used for the build
  61097. */
  61098. initialize(state: NodeMaterialBuildState): void;
  61099. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61100. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61101. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61102. protected _buildBlock(state: NodeMaterialBuildState): this;
  61103. }
  61104. }
  61105. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61106. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61107. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61108. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61109. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61111. import { Effect } from "babylonjs/Materials/effect";
  61112. import { Mesh } from "babylonjs/Meshes/mesh";
  61113. import { Scene } from "babylonjs/scene";
  61114. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61115. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61116. /**
  61117. * Block used to pertub normals based on a normal map
  61118. */
  61119. export class PerturbNormalBlock extends NodeMaterialBlock {
  61120. private _tangentSpaceParameterName;
  61121. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61122. invertX: boolean;
  61123. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61124. invertY: boolean;
  61125. /**
  61126. * Create a new PerturbNormalBlock
  61127. * @param name defines the block name
  61128. */
  61129. constructor(name: string);
  61130. /**
  61131. * Gets the current class name
  61132. * @returns the class name
  61133. */
  61134. getClassName(): string;
  61135. /**
  61136. * Gets the world position input component
  61137. */
  61138. get worldPosition(): NodeMaterialConnectionPoint;
  61139. /**
  61140. * Gets the world normal input component
  61141. */
  61142. get worldNormal(): NodeMaterialConnectionPoint;
  61143. /**
  61144. * Gets the world tangent input component
  61145. */
  61146. get worldTangent(): NodeMaterialConnectionPoint;
  61147. /**
  61148. * Gets the uv input component
  61149. */
  61150. get uv(): NodeMaterialConnectionPoint;
  61151. /**
  61152. * Gets the normal map color input component
  61153. */
  61154. get normalMapColor(): NodeMaterialConnectionPoint;
  61155. /**
  61156. * Gets the strength input component
  61157. */
  61158. get strength(): NodeMaterialConnectionPoint;
  61159. /**
  61160. * Gets the output component
  61161. */
  61162. get output(): NodeMaterialConnectionPoint;
  61163. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61164. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61165. autoConfigure(material: NodeMaterial): void;
  61166. protected _buildBlock(state: NodeMaterialBuildState): this;
  61167. protected _dumpPropertiesCode(): string;
  61168. serialize(): any;
  61169. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61170. }
  61171. }
  61172. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61173. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61174. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61175. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61176. /**
  61177. * Block used to discard a pixel if a value is smaller than a cutoff
  61178. */
  61179. export class DiscardBlock extends NodeMaterialBlock {
  61180. /**
  61181. * Create a new DiscardBlock
  61182. * @param name defines the block name
  61183. */
  61184. constructor(name: string);
  61185. /**
  61186. * Gets the current class name
  61187. * @returns the class name
  61188. */
  61189. getClassName(): string;
  61190. /**
  61191. * Gets the color input component
  61192. */
  61193. get value(): NodeMaterialConnectionPoint;
  61194. /**
  61195. * Gets the cutoff input component
  61196. */
  61197. get cutoff(): NodeMaterialConnectionPoint;
  61198. protected _buildBlock(state: NodeMaterialBuildState): this;
  61199. }
  61200. }
  61201. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61202. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61203. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61204. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61205. /**
  61206. * Block used to test if the fragment shader is front facing
  61207. */
  61208. export class FrontFacingBlock extends NodeMaterialBlock {
  61209. /**
  61210. * Creates a new FrontFacingBlock
  61211. * @param name defines the block name
  61212. */
  61213. constructor(name: string);
  61214. /**
  61215. * Gets the current class name
  61216. * @returns the class name
  61217. */
  61218. getClassName(): string;
  61219. /**
  61220. * Gets the output component
  61221. */
  61222. get output(): NodeMaterialConnectionPoint;
  61223. protected _buildBlock(state: NodeMaterialBuildState): this;
  61224. }
  61225. }
  61226. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61227. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61228. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61229. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61230. /**
  61231. * Block used to get the derivative value on x and y of a given input
  61232. */
  61233. export class DerivativeBlock extends NodeMaterialBlock {
  61234. /**
  61235. * Create a new DerivativeBlock
  61236. * @param name defines the block name
  61237. */
  61238. constructor(name: string);
  61239. /**
  61240. * Gets the current class name
  61241. * @returns the class name
  61242. */
  61243. getClassName(): string;
  61244. /**
  61245. * Gets the input component
  61246. */
  61247. get input(): NodeMaterialConnectionPoint;
  61248. /**
  61249. * Gets the derivative output on x
  61250. */
  61251. get dx(): NodeMaterialConnectionPoint;
  61252. /**
  61253. * Gets the derivative output on y
  61254. */
  61255. get dy(): NodeMaterialConnectionPoint;
  61256. protected _buildBlock(state: NodeMaterialBuildState): this;
  61257. }
  61258. }
  61259. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61260. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61261. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61262. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61263. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61264. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61265. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61266. }
  61267. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61268. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61269. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61270. import { Mesh } from "babylonjs/Meshes/mesh";
  61271. import { Effect } from "babylonjs/Materials/effect";
  61272. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61274. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61275. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61276. /**
  61277. * Block used to add support for scene fog
  61278. */
  61279. export class FogBlock extends NodeMaterialBlock {
  61280. private _fogDistanceName;
  61281. private _fogParameters;
  61282. /**
  61283. * Create a new FogBlock
  61284. * @param name defines the block name
  61285. */
  61286. constructor(name: string);
  61287. /**
  61288. * Gets the current class name
  61289. * @returns the class name
  61290. */
  61291. getClassName(): string;
  61292. /**
  61293. * Gets the world position input component
  61294. */
  61295. get worldPosition(): NodeMaterialConnectionPoint;
  61296. /**
  61297. * Gets the view input component
  61298. */
  61299. get view(): NodeMaterialConnectionPoint;
  61300. /**
  61301. * Gets the color input component
  61302. */
  61303. get input(): NodeMaterialConnectionPoint;
  61304. /**
  61305. * Gets the fog color input component
  61306. */
  61307. get fogColor(): NodeMaterialConnectionPoint;
  61308. /**
  61309. * Gets the output component
  61310. */
  61311. get output(): NodeMaterialConnectionPoint;
  61312. autoConfigure(material: NodeMaterial): void;
  61313. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61314. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61315. protected _buildBlock(state: NodeMaterialBuildState): this;
  61316. }
  61317. }
  61318. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61319. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61320. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61321. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61323. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61324. import { Effect } from "babylonjs/Materials/effect";
  61325. import { Mesh } from "babylonjs/Meshes/mesh";
  61326. import { Light } from "babylonjs/Lights/light";
  61327. import { Nullable } from "babylonjs/types";
  61328. import { Scene } from "babylonjs/scene";
  61329. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61330. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61331. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61332. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61333. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61334. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61335. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61336. /**
  61337. * Block used to add light in the fragment shader
  61338. */
  61339. export class LightBlock extends NodeMaterialBlock {
  61340. private _lightId;
  61341. /**
  61342. * Gets or sets the light associated with this block
  61343. */
  61344. light: Nullable<Light>;
  61345. /**
  61346. * Create a new LightBlock
  61347. * @param name defines the block name
  61348. */
  61349. constructor(name: string);
  61350. /**
  61351. * Gets the current class name
  61352. * @returns the class name
  61353. */
  61354. getClassName(): string;
  61355. /**
  61356. * Gets the world position input component
  61357. */
  61358. get worldPosition(): NodeMaterialConnectionPoint;
  61359. /**
  61360. * Gets the world normal input component
  61361. */
  61362. get worldNormal(): NodeMaterialConnectionPoint;
  61363. /**
  61364. * Gets the camera (or eye) position component
  61365. */
  61366. get cameraPosition(): NodeMaterialConnectionPoint;
  61367. /**
  61368. * Gets the glossiness component
  61369. */
  61370. get glossiness(): NodeMaterialConnectionPoint;
  61371. /**
  61372. * Gets the glossinness power component
  61373. */
  61374. get glossPower(): NodeMaterialConnectionPoint;
  61375. /**
  61376. * Gets the diffuse color component
  61377. */
  61378. get diffuseColor(): NodeMaterialConnectionPoint;
  61379. /**
  61380. * Gets the specular color component
  61381. */
  61382. get specularColor(): NodeMaterialConnectionPoint;
  61383. /**
  61384. * Gets the diffuse output component
  61385. */
  61386. get diffuseOutput(): NodeMaterialConnectionPoint;
  61387. /**
  61388. * Gets the specular output component
  61389. */
  61390. get specularOutput(): NodeMaterialConnectionPoint;
  61391. /**
  61392. * Gets the shadow output component
  61393. */
  61394. get shadow(): NodeMaterialConnectionPoint;
  61395. autoConfigure(material: NodeMaterial): void;
  61396. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61397. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61398. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61399. private _injectVertexCode;
  61400. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61401. serialize(): any;
  61402. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61403. }
  61404. }
  61405. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61406. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61407. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61408. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61409. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61410. }
  61411. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61412. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61413. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61414. }
  61415. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61416. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61417. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61418. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61419. /**
  61420. * Block used to multiply 2 values
  61421. */
  61422. export class MultiplyBlock extends NodeMaterialBlock {
  61423. /**
  61424. * Creates a new MultiplyBlock
  61425. * @param name defines the block name
  61426. */
  61427. constructor(name: string);
  61428. /**
  61429. * Gets the current class name
  61430. * @returns the class name
  61431. */
  61432. getClassName(): string;
  61433. /**
  61434. * Gets the left operand input component
  61435. */
  61436. get left(): NodeMaterialConnectionPoint;
  61437. /**
  61438. * Gets the right operand input component
  61439. */
  61440. get right(): NodeMaterialConnectionPoint;
  61441. /**
  61442. * Gets the output component
  61443. */
  61444. get output(): NodeMaterialConnectionPoint;
  61445. protected _buildBlock(state: NodeMaterialBuildState): this;
  61446. }
  61447. }
  61448. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61449. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61450. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61451. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61452. /**
  61453. * Block used to add 2 vectors
  61454. */
  61455. export class AddBlock extends NodeMaterialBlock {
  61456. /**
  61457. * Creates a new AddBlock
  61458. * @param name defines the block name
  61459. */
  61460. constructor(name: string);
  61461. /**
  61462. * Gets the current class name
  61463. * @returns the class name
  61464. */
  61465. getClassName(): string;
  61466. /**
  61467. * Gets the left operand input component
  61468. */
  61469. get left(): NodeMaterialConnectionPoint;
  61470. /**
  61471. * Gets the right operand input component
  61472. */
  61473. get right(): NodeMaterialConnectionPoint;
  61474. /**
  61475. * Gets the output component
  61476. */
  61477. get output(): NodeMaterialConnectionPoint;
  61478. protected _buildBlock(state: NodeMaterialBuildState): this;
  61479. }
  61480. }
  61481. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61482. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61484. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61485. /**
  61486. * Block used to scale a vector by a float
  61487. */
  61488. export class ScaleBlock extends NodeMaterialBlock {
  61489. /**
  61490. * Creates a new ScaleBlock
  61491. * @param name defines the block name
  61492. */
  61493. constructor(name: string);
  61494. /**
  61495. * Gets the current class name
  61496. * @returns the class name
  61497. */
  61498. getClassName(): string;
  61499. /**
  61500. * Gets the input component
  61501. */
  61502. get input(): NodeMaterialConnectionPoint;
  61503. /**
  61504. * Gets the factor input component
  61505. */
  61506. get factor(): NodeMaterialConnectionPoint;
  61507. /**
  61508. * Gets the output component
  61509. */
  61510. get output(): NodeMaterialConnectionPoint;
  61511. protected _buildBlock(state: NodeMaterialBuildState): this;
  61512. }
  61513. }
  61514. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61515. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61516. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61517. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61518. import { Scene } from "babylonjs/scene";
  61519. /**
  61520. * Block used to clamp a float
  61521. */
  61522. export class ClampBlock extends NodeMaterialBlock {
  61523. /** Gets or sets the minimum range */
  61524. minimum: number;
  61525. /** Gets or sets the maximum range */
  61526. maximum: number;
  61527. /**
  61528. * Creates a new ClampBlock
  61529. * @param name defines the block name
  61530. */
  61531. constructor(name: string);
  61532. /**
  61533. * Gets the current class name
  61534. * @returns the class name
  61535. */
  61536. getClassName(): string;
  61537. /**
  61538. * Gets the value input component
  61539. */
  61540. get value(): NodeMaterialConnectionPoint;
  61541. /**
  61542. * Gets the output component
  61543. */
  61544. get output(): NodeMaterialConnectionPoint;
  61545. protected _buildBlock(state: NodeMaterialBuildState): this;
  61546. protected _dumpPropertiesCode(): string;
  61547. serialize(): any;
  61548. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61549. }
  61550. }
  61551. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61552. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61553. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61554. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61555. /**
  61556. * Block used to apply a cross product between 2 vectors
  61557. */
  61558. export class CrossBlock extends NodeMaterialBlock {
  61559. /**
  61560. * Creates a new CrossBlock
  61561. * @param name defines the block name
  61562. */
  61563. constructor(name: string);
  61564. /**
  61565. * Gets the current class name
  61566. * @returns the class name
  61567. */
  61568. getClassName(): string;
  61569. /**
  61570. * Gets the left operand input component
  61571. */
  61572. get left(): NodeMaterialConnectionPoint;
  61573. /**
  61574. * Gets the right operand input component
  61575. */
  61576. get right(): NodeMaterialConnectionPoint;
  61577. /**
  61578. * Gets the output component
  61579. */
  61580. get output(): NodeMaterialConnectionPoint;
  61581. protected _buildBlock(state: NodeMaterialBuildState): this;
  61582. }
  61583. }
  61584. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61585. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61586. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61587. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61588. /**
  61589. * Block used to apply a dot product between 2 vectors
  61590. */
  61591. export class DotBlock extends NodeMaterialBlock {
  61592. /**
  61593. * Creates a new DotBlock
  61594. * @param name defines the block name
  61595. */
  61596. constructor(name: string);
  61597. /**
  61598. * Gets the current class name
  61599. * @returns the class name
  61600. */
  61601. getClassName(): string;
  61602. /**
  61603. * Gets the left operand input component
  61604. */
  61605. get left(): NodeMaterialConnectionPoint;
  61606. /**
  61607. * Gets the right operand input component
  61608. */
  61609. get right(): NodeMaterialConnectionPoint;
  61610. /**
  61611. * Gets the output component
  61612. */
  61613. get output(): NodeMaterialConnectionPoint;
  61614. protected _buildBlock(state: NodeMaterialBuildState): this;
  61615. }
  61616. }
  61617. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61618. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61619. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61620. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61621. import { Vector2 } from "babylonjs/Maths/math.vector";
  61622. import { Scene } from "babylonjs/scene";
  61623. /**
  61624. * Block used to remap a float from a range to a new one
  61625. */
  61626. export class RemapBlock extends NodeMaterialBlock {
  61627. /**
  61628. * Gets or sets the source range
  61629. */
  61630. sourceRange: Vector2;
  61631. /**
  61632. * Gets or sets the target range
  61633. */
  61634. targetRange: Vector2;
  61635. /**
  61636. * Creates a new RemapBlock
  61637. * @param name defines the block name
  61638. */
  61639. constructor(name: string);
  61640. /**
  61641. * Gets the current class name
  61642. * @returns the class name
  61643. */
  61644. getClassName(): string;
  61645. /**
  61646. * Gets the input component
  61647. */
  61648. get input(): NodeMaterialConnectionPoint;
  61649. /**
  61650. * Gets the source min input component
  61651. */
  61652. get sourceMin(): NodeMaterialConnectionPoint;
  61653. /**
  61654. * Gets the source max input component
  61655. */
  61656. get sourceMax(): NodeMaterialConnectionPoint;
  61657. /**
  61658. * Gets the target min input component
  61659. */
  61660. get targetMin(): NodeMaterialConnectionPoint;
  61661. /**
  61662. * Gets the target max input component
  61663. */
  61664. get targetMax(): NodeMaterialConnectionPoint;
  61665. /**
  61666. * Gets the output component
  61667. */
  61668. get output(): NodeMaterialConnectionPoint;
  61669. protected _buildBlock(state: NodeMaterialBuildState): this;
  61670. protected _dumpPropertiesCode(): string;
  61671. serialize(): any;
  61672. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61673. }
  61674. }
  61675. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61676. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61677. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61678. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61679. /**
  61680. * Block used to normalize a vector
  61681. */
  61682. export class NormalizeBlock extends NodeMaterialBlock {
  61683. /**
  61684. * Creates a new NormalizeBlock
  61685. * @param name defines the block name
  61686. */
  61687. constructor(name: string);
  61688. /**
  61689. * Gets the current class name
  61690. * @returns the class name
  61691. */
  61692. getClassName(): string;
  61693. /**
  61694. * Gets the input component
  61695. */
  61696. get input(): NodeMaterialConnectionPoint;
  61697. /**
  61698. * Gets the output component
  61699. */
  61700. get output(): NodeMaterialConnectionPoint;
  61701. protected _buildBlock(state: NodeMaterialBuildState): this;
  61702. }
  61703. }
  61704. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61705. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61706. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61707. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61708. import { Scene } from "babylonjs/scene";
  61709. /**
  61710. * Operations supported by the Trigonometry block
  61711. */
  61712. export enum TrigonometryBlockOperations {
  61713. /** Cos */
  61714. Cos = 0,
  61715. /** Sin */
  61716. Sin = 1,
  61717. /** Abs */
  61718. Abs = 2,
  61719. /** Exp */
  61720. Exp = 3,
  61721. /** Exp2 */
  61722. Exp2 = 4,
  61723. /** Round */
  61724. Round = 5,
  61725. /** Floor */
  61726. Floor = 6,
  61727. /** Ceiling */
  61728. Ceiling = 7,
  61729. /** Square root */
  61730. Sqrt = 8,
  61731. /** Log */
  61732. Log = 9,
  61733. /** Tangent */
  61734. Tan = 10,
  61735. /** Arc tangent */
  61736. ArcTan = 11,
  61737. /** Arc cosinus */
  61738. ArcCos = 12,
  61739. /** Arc sinus */
  61740. ArcSin = 13,
  61741. /** Fraction */
  61742. Fract = 14,
  61743. /** Sign */
  61744. Sign = 15,
  61745. /** To radians (from degrees) */
  61746. Radians = 16,
  61747. /** To degrees (from radians) */
  61748. Degrees = 17
  61749. }
  61750. /**
  61751. * Block used to apply trigonometry operation to floats
  61752. */
  61753. export class TrigonometryBlock extends NodeMaterialBlock {
  61754. /**
  61755. * Gets or sets the operation applied by the block
  61756. */
  61757. operation: TrigonometryBlockOperations;
  61758. /**
  61759. * Creates a new TrigonometryBlock
  61760. * @param name defines the block name
  61761. */
  61762. constructor(name: string);
  61763. /**
  61764. * Gets the current class name
  61765. * @returns the class name
  61766. */
  61767. getClassName(): string;
  61768. /**
  61769. * Gets the input component
  61770. */
  61771. get input(): NodeMaterialConnectionPoint;
  61772. /**
  61773. * Gets the output component
  61774. */
  61775. get output(): NodeMaterialConnectionPoint;
  61776. protected _buildBlock(state: NodeMaterialBuildState): this;
  61777. serialize(): any;
  61778. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61779. protected _dumpPropertiesCode(): string;
  61780. }
  61781. }
  61782. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61783. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61784. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61785. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61786. /**
  61787. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61788. */
  61789. export class ColorMergerBlock extends NodeMaterialBlock {
  61790. /**
  61791. * Create a new ColorMergerBlock
  61792. * @param name defines the block name
  61793. */
  61794. constructor(name: string);
  61795. /**
  61796. * Gets the current class name
  61797. * @returns the class name
  61798. */
  61799. getClassName(): string;
  61800. /**
  61801. * Gets the rgb component (input)
  61802. */
  61803. get rgbIn(): NodeMaterialConnectionPoint;
  61804. /**
  61805. * Gets the r component (input)
  61806. */
  61807. get r(): NodeMaterialConnectionPoint;
  61808. /**
  61809. * Gets the g component (input)
  61810. */
  61811. get g(): NodeMaterialConnectionPoint;
  61812. /**
  61813. * Gets the b component (input)
  61814. */
  61815. get b(): NodeMaterialConnectionPoint;
  61816. /**
  61817. * Gets the a component (input)
  61818. */
  61819. get a(): NodeMaterialConnectionPoint;
  61820. /**
  61821. * Gets the rgba component (output)
  61822. */
  61823. get rgba(): NodeMaterialConnectionPoint;
  61824. /**
  61825. * Gets the rgb component (output)
  61826. */
  61827. get rgbOut(): NodeMaterialConnectionPoint;
  61828. /**
  61829. * Gets the rgb component (output)
  61830. * @deprecated Please use rgbOut instead.
  61831. */
  61832. get rgb(): NodeMaterialConnectionPoint;
  61833. protected _buildBlock(state: NodeMaterialBuildState): this;
  61834. }
  61835. }
  61836. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  61837. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61838. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61839. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61840. /**
  61841. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61842. */
  61843. export class VectorMergerBlock extends NodeMaterialBlock {
  61844. /**
  61845. * Create a new VectorMergerBlock
  61846. * @param name defines the block name
  61847. */
  61848. constructor(name: string);
  61849. /**
  61850. * Gets the current class name
  61851. * @returns the class name
  61852. */
  61853. getClassName(): string;
  61854. /**
  61855. * Gets the xyz component (input)
  61856. */
  61857. get xyzIn(): NodeMaterialConnectionPoint;
  61858. /**
  61859. * Gets the xy component (input)
  61860. */
  61861. get xyIn(): NodeMaterialConnectionPoint;
  61862. /**
  61863. * Gets the x component (input)
  61864. */
  61865. get x(): NodeMaterialConnectionPoint;
  61866. /**
  61867. * Gets the y component (input)
  61868. */
  61869. get y(): NodeMaterialConnectionPoint;
  61870. /**
  61871. * Gets the z component (input)
  61872. */
  61873. get z(): NodeMaterialConnectionPoint;
  61874. /**
  61875. * Gets the w component (input)
  61876. */
  61877. get w(): NodeMaterialConnectionPoint;
  61878. /**
  61879. * Gets the xyzw component (output)
  61880. */
  61881. get xyzw(): NodeMaterialConnectionPoint;
  61882. /**
  61883. * Gets the xyz component (output)
  61884. */
  61885. get xyzOut(): NodeMaterialConnectionPoint;
  61886. /**
  61887. * Gets the xy component (output)
  61888. */
  61889. get xyOut(): NodeMaterialConnectionPoint;
  61890. /**
  61891. * Gets the xy component (output)
  61892. * @deprecated Please use xyOut instead.
  61893. */
  61894. get xy(): NodeMaterialConnectionPoint;
  61895. /**
  61896. * Gets the xyz component (output)
  61897. * @deprecated Please use xyzOut instead.
  61898. */
  61899. get xyz(): NodeMaterialConnectionPoint;
  61900. protected _buildBlock(state: NodeMaterialBuildState): this;
  61901. }
  61902. }
  61903. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61904. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61905. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61906. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61907. /**
  61908. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  61909. */
  61910. export class ColorSplitterBlock extends NodeMaterialBlock {
  61911. /**
  61912. * Create a new ColorSplitterBlock
  61913. * @param name defines the block name
  61914. */
  61915. constructor(name: string);
  61916. /**
  61917. * Gets the current class name
  61918. * @returns the class name
  61919. */
  61920. getClassName(): string;
  61921. /**
  61922. * Gets the rgba component (input)
  61923. */
  61924. get rgba(): NodeMaterialConnectionPoint;
  61925. /**
  61926. * Gets the rgb component (input)
  61927. */
  61928. get rgbIn(): NodeMaterialConnectionPoint;
  61929. /**
  61930. * Gets the rgb component (output)
  61931. */
  61932. get rgbOut(): NodeMaterialConnectionPoint;
  61933. /**
  61934. * Gets the r component (output)
  61935. */
  61936. get r(): NodeMaterialConnectionPoint;
  61937. /**
  61938. * Gets the g component (output)
  61939. */
  61940. get g(): NodeMaterialConnectionPoint;
  61941. /**
  61942. * Gets the b component (output)
  61943. */
  61944. get b(): NodeMaterialConnectionPoint;
  61945. /**
  61946. * Gets the a component (output)
  61947. */
  61948. get a(): NodeMaterialConnectionPoint;
  61949. protected _inputRename(name: string): string;
  61950. protected _outputRename(name: string): string;
  61951. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61952. }
  61953. }
  61954. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  61955. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61956. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61957. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61958. /**
  61959. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61960. */
  61961. export class VectorSplitterBlock extends NodeMaterialBlock {
  61962. /**
  61963. * Create a new VectorSplitterBlock
  61964. * @param name defines the block name
  61965. */
  61966. constructor(name: string);
  61967. /**
  61968. * Gets the current class name
  61969. * @returns the class name
  61970. */
  61971. getClassName(): string;
  61972. /**
  61973. * Gets the xyzw component (input)
  61974. */
  61975. get xyzw(): NodeMaterialConnectionPoint;
  61976. /**
  61977. * Gets the xyz component (input)
  61978. */
  61979. get xyzIn(): NodeMaterialConnectionPoint;
  61980. /**
  61981. * Gets the xy component (input)
  61982. */
  61983. get xyIn(): NodeMaterialConnectionPoint;
  61984. /**
  61985. * Gets the xyz component (output)
  61986. */
  61987. get xyzOut(): NodeMaterialConnectionPoint;
  61988. /**
  61989. * Gets the xy component (output)
  61990. */
  61991. get xyOut(): NodeMaterialConnectionPoint;
  61992. /**
  61993. * Gets the x component (output)
  61994. */
  61995. get x(): NodeMaterialConnectionPoint;
  61996. /**
  61997. * Gets the y component (output)
  61998. */
  61999. get y(): NodeMaterialConnectionPoint;
  62000. /**
  62001. * Gets the z component (output)
  62002. */
  62003. get z(): NodeMaterialConnectionPoint;
  62004. /**
  62005. * Gets the w component (output)
  62006. */
  62007. get w(): NodeMaterialConnectionPoint;
  62008. protected _inputRename(name: string): string;
  62009. protected _outputRename(name: string): string;
  62010. protected _buildBlock(state: NodeMaterialBuildState): this;
  62011. }
  62012. }
  62013. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62014. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62015. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62016. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62017. /**
  62018. * Block used to lerp between 2 values
  62019. */
  62020. export class LerpBlock extends NodeMaterialBlock {
  62021. /**
  62022. * Creates a new LerpBlock
  62023. * @param name defines the block name
  62024. */
  62025. constructor(name: string);
  62026. /**
  62027. * Gets the current class name
  62028. * @returns the class name
  62029. */
  62030. getClassName(): string;
  62031. /**
  62032. * Gets the left operand input component
  62033. */
  62034. get left(): NodeMaterialConnectionPoint;
  62035. /**
  62036. * Gets the right operand input component
  62037. */
  62038. get right(): NodeMaterialConnectionPoint;
  62039. /**
  62040. * Gets the gradient operand input component
  62041. */
  62042. get gradient(): NodeMaterialConnectionPoint;
  62043. /**
  62044. * Gets the output component
  62045. */
  62046. get output(): NodeMaterialConnectionPoint;
  62047. protected _buildBlock(state: NodeMaterialBuildState): this;
  62048. }
  62049. }
  62050. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62051. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62052. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62053. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62054. /**
  62055. * Block used to divide 2 vectors
  62056. */
  62057. export class DivideBlock extends NodeMaterialBlock {
  62058. /**
  62059. * Creates a new DivideBlock
  62060. * @param name defines the block name
  62061. */
  62062. constructor(name: string);
  62063. /**
  62064. * Gets the current class name
  62065. * @returns the class name
  62066. */
  62067. getClassName(): string;
  62068. /**
  62069. * Gets the left operand input component
  62070. */
  62071. get left(): NodeMaterialConnectionPoint;
  62072. /**
  62073. * Gets the right operand input component
  62074. */
  62075. get right(): NodeMaterialConnectionPoint;
  62076. /**
  62077. * Gets the output component
  62078. */
  62079. get output(): NodeMaterialConnectionPoint;
  62080. protected _buildBlock(state: NodeMaterialBuildState): this;
  62081. }
  62082. }
  62083. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62084. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62085. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62086. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62087. /**
  62088. * Block used to subtract 2 vectors
  62089. */
  62090. export class SubtractBlock extends NodeMaterialBlock {
  62091. /**
  62092. * Creates a new SubtractBlock
  62093. * @param name defines the block name
  62094. */
  62095. constructor(name: string);
  62096. /**
  62097. * Gets the current class name
  62098. * @returns the class name
  62099. */
  62100. getClassName(): string;
  62101. /**
  62102. * Gets the left operand input component
  62103. */
  62104. get left(): NodeMaterialConnectionPoint;
  62105. /**
  62106. * Gets the right operand input component
  62107. */
  62108. get right(): NodeMaterialConnectionPoint;
  62109. /**
  62110. * Gets the output component
  62111. */
  62112. get output(): NodeMaterialConnectionPoint;
  62113. protected _buildBlock(state: NodeMaterialBuildState): this;
  62114. }
  62115. }
  62116. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62117. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62118. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62119. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62120. /**
  62121. * Block used to step a value
  62122. */
  62123. export class StepBlock extends NodeMaterialBlock {
  62124. /**
  62125. * Creates a new StepBlock
  62126. * @param name defines the block name
  62127. */
  62128. constructor(name: string);
  62129. /**
  62130. * Gets the current class name
  62131. * @returns the class name
  62132. */
  62133. getClassName(): string;
  62134. /**
  62135. * Gets the value operand input component
  62136. */
  62137. get value(): NodeMaterialConnectionPoint;
  62138. /**
  62139. * Gets the edge operand input component
  62140. */
  62141. get edge(): NodeMaterialConnectionPoint;
  62142. /**
  62143. * Gets the output component
  62144. */
  62145. get output(): NodeMaterialConnectionPoint;
  62146. protected _buildBlock(state: NodeMaterialBuildState): this;
  62147. }
  62148. }
  62149. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62150. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62151. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62152. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62153. /**
  62154. * Block used to get the opposite (1 - x) of a value
  62155. */
  62156. export class OneMinusBlock extends NodeMaterialBlock {
  62157. /**
  62158. * Creates a new OneMinusBlock
  62159. * @param name defines the block name
  62160. */
  62161. constructor(name: string);
  62162. /**
  62163. * Gets the current class name
  62164. * @returns the class name
  62165. */
  62166. getClassName(): string;
  62167. /**
  62168. * Gets the input component
  62169. */
  62170. get input(): NodeMaterialConnectionPoint;
  62171. /**
  62172. * Gets the output component
  62173. */
  62174. get output(): NodeMaterialConnectionPoint;
  62175. protected _buildBlock(state: NodeMaterialBuildState): this;
  62176. }
  62177. }
  62178. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62179. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62180. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62181. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62182. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62183. /**
  62184. * Block used to get the view direction
  62185. */
  62186. export class ViewDirectionBlock extends NodeMaterialBlock {
  62187. /**
  62188. * Creates a new ViewDirectionBlock
  62189. * @param name defines the block name
  62190. */
  62191. constructor(name: string);
  62192. /**
  62193. * Gets the current class name
  62194. * @returns the class name
  62195. */
  62196. getClassName(): string;
  62197. /**
  62198. * Gets the world position component
  62199. */
  62200. get worldPosition(): NodeMaterialConnectionPoint;
  62201. /**
  62202. * Gets the camera position component
  62203. */
  62204. get cameraPosition(): NodeMaterialConnectionPoint;
  62205. /**
  62206. * Gets the output component
  62207. */
  62208. get output(): NodeMaterialConnectionPoint;
  62209. autoConfigure(material: NodeMaterial): void;
  62210. protected _buildBlock(state: NodeMaterialBuildState): this;
  62211. }
  62212. }
  62213. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62214. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62215. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62216. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62217. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62218. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62219. /**
  62220. * Block used to compute fresnel value
  62221. */
  62222. export class FresnelBlock extends NodeMaterialBlock {
  62223. /**
  62224. * Create a new FresnelBlock
  62225. * @param name defines the block name
  62226. */
  62227. constructor(name: string);
  62228. /**
  62229. * Gets the current class name
  62230. * @returns the class name
  62231. */
  62232. getClassName(): string;
  62233. /**
  62234. * Gets the world normal input component
  62235. */
  62236. get worldNormal(): NodeMaterialConnectionPoint;
  62237. /**
  62238. * Gets the view direction input component
  62239. */
  62240. get viewDirection(): NodeMaterialConnectionPoint;
  62241. /**
  62242. * Gets the bias input component
  62243. */
  62244. get bias(): NodeMaterialConnectionPoint;
  62245. /**
  62246. * Gets the camera (or eye) position component
  62247. */
  62248. get power(): NodeMaterialConnectionPoint;
  62249. /**
  62250. * Gets the fresnel output component
  62251. */
  62252. get fresnel(): NodeMaterialConnectionPoint;
  62253. autoConfigure(material: NodeMaterial): void;
  62254. protected _buildBlock(state: NodeMaterialBuildState): this;
  62255. }
  62256. }
  62257. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62258. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62259. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62260. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62261. /**
  62262. * Block used to get the max of 2 values
  62263. */
  62264. export class MaxBlock extends NodeMaterialBlock {
  62265. /**
  62266. * Creates a new MaxBlock
  62267. * @param name defines the block name
  62268. */
  62269. constructor(name: string);
  62270. /**
  62271. * Gets the current class name
  62272. * @returns the class name
  62273. */
  62274. getClassName(): string;
  62275. /**
  62276. * Gets the left operand input component
  62277. */
  62278. get left(): NodeMaterialConnectionPoint;
  62279. /**
  62280. * Gets the right operand input component
  62281. */
  62282. get right(): NodeMaterialConnectionPoint;
  62283. /**
  62284. * Gets the output component
  62285. */
  62286. get output(): NodeMaterialConnectionPoint;
  62287. protected _buildBlock(state: NodeMaterialBuildState): this;
  62288. }
  62289. }
  62290. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62291. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62292. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62293. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62294. /**
  62295. * Block used to get the min of 2 values
  62296. */
  62297. export class MinBlock extends NodeMaterialBlock {
  62298. /**
  62299. * Creates a new MinBlock
  62300. * @param name defines the block name
  62301. */
  62302. constructor(name: string);
  62303. /**
  62304. * Gets the current class name
  62305. * @returns the class name
  62306. */
  62307. getClassName(): string;
  62308. /**
  62309. * Gets the left operand input component
  62310. */
  62311. get left(): NodeMaterialConnectionPoint;
  62312. /**
  62313. * Gets the right operand input component
  62314. */
  62315. get right(): NodeMaterialConnectionPoint;
  62316. /**
  62317. * Gets the output component
  62318. */
  62319. get output(): NodeMaterialConnectionPoint;
  62320. protected _buildBlock(state: NodeMaterialBuildState): this;
  62321. }
  62322. }
  62323. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62324. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62325. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62326. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62327. /**
  62328. * Block used to get the distance between 2 values
  62329. */
  62330. export class DistanceBlock extends NodeMaterialBlock {
  62331. /**
  62332. * Creates a new DistanceBlock
  62333. * @param name defines the block name
  62334. */
  62335. constructor(name: string);
  62336. /**
  62337. * Gets the current class name
  62338. * @returns the class name
  62339. */
  62340. getClassName(): string;
  62341. /**
  62342. * Gets the left operand input component
  62343. */
  62344. get left(): NodeMaterialConnectionPoint;
  62345. /**
  62346. * Gets the right operand input component
  62347. */
  62348. get right(): NodeMaterialConnectionPoint;
  62349. /**
  62350. * Gets the output component
  62351. */
  62352. get output(): NodeMaterialConnectionPoint;
  62353. protected _buildBlock(state: NodeMaterialBuildState): this;
  62354. }
  62355. }
  62356. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62357. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62358. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62359. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62360. /**
  62361. * Block used to get the length of a vector
  62362. */
  62363. export class LengthBlock extends NodeMaterialBlock {
  62364. /**
  62365. * Creates a new LengthBlock
  62366. * @param name defines the block name
  62367. */
  62368. constructor(name: string);
  62369. /**
  62370. * Gets the current class name
  62371. * @returns the class name
  62372. */
  62373. getClassName(): string;
  62374. /**
  62375. * Gets the value input component
  62376. */
  62377. get value(): NodeMaterialConnectionPoint;
  62378. /**
  62379. * Gets the output component
  62380. */
  62381. get output(): NodeMaterialConnectionPoint;
  62382. protected _buildBlock(state: NodeMaterialBuildState): this;
  62383. }
  62384. }
  62385. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62386. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62387. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62388. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62389. /**
  62390. * Block used to get negative version of a value (i.e. x * -1)
  62391. */
  62392. export class NegateBlock extends NodeMaterialBlock {
  62393. /**
  62394. * Creates a new NegateBlock
  62395. * @param name defines the block name
  62396. */
  62397. constructor(name: string);
  62398. /**
  62399. * Gets the current class name
  62400. * @returns the class name
  62401. */
  62402. getClassName(): string;
  62403. /**
  62404. * Gets the value input component
  62405. */
  62406. get value(): NodeMaterialConnectionPoint;
  62407. /**
  62408. * Gets the output component
  62409. */
  62410. get output(): NodeMaterialConnectionPoint;
  62411. protected _buildBlock(state: NodeMaterialBuildState): this;
  62412. }
  62413. }
  62414. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62415. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62416. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62417. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62418. /**
  62419. * Block used to get the value of the first parameter raised to the power of the second
  62420. */
  62421. export class PowBlock extends NodeMaterialBlock {
  62422. /**
  62423. * Creates a new PowBlock
  62424. * @param name defines the block name
  62425. */
  62426. constructor(name: string);
  62427. /**
  62428. * Gets the current class name
  62429. * @returns the class name
  62430. */
  62431. getClassName(): string;
  62432. /**
  62433. * Gets the value operand input component
  62434. */
  62435. get value(): NodeMaterialConnectionPoint;
  62436. /**
  62437. * Gets the power operand input component
  62438. */
  62439. get power(): NodeMaterialConnectionPoint;
  62440. /**
  62441. * Gets the output component
  62442. */
  62443. get output(): NodeMaterialConnectionPoint;
  62444. protected _buildBlock(state: NodeMaterialBuildState): this;
  62445. }
  62446. }
  62447. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62448. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62449. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62450. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62451. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62452. /**
  62453. * Block used to get a random number
  62454. */
  62455. export class RandomNumberBlock extends NodeMaterialBlock {
  62456. /**
  62457. * Creates a new RandomNumberBlock
  62458. * @param name defines the block name
  62459. */
  62460. constructor(name: string);
  62461. /**
  62462. * Gets the current class name
  62463. * @returns the class name
  62464. */
  62465. getClassName(): string;
  62466. /**
  62467. * Gets the seed input component
  62468. */
  62469. get seed(): NodeMaterialConnectionPoint;
  62470. /**
  62471. * Gets the output component
  62472. */
  62473. get output(): NodeMaterialConnectionPoint;
  62474. protected _buildBlock(state: NodeMaterialBuildState): this;
  62475. }
  62476. }
  62477. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62478. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62479. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62480. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62481. /**
  62482. * Block used to compute arc tangent of 2 values
  62483. */
  62484. export class ArcTan2Block extends NodeMaterialBlock {
  62485. /**
  62486. * Creates a new ArcTan2Block
  62487. * @param name defines the block name
  62488. */
  62489. constructor(name: string);
  62490. /**
  62491. * Gets the current class name
  62492. * @returns the class name
  62493. */
  62494. getClassName(): string;
  62495. /**
  62496. * Gets the x operand input component
  62497. */
  62498. get x(): NodeMaterialConnectionPoint;
  62499. /**
  62500. * Gets the y operand input component
  62501. */
  62502. get y(): NodeMaterialConnectionPoint;
  62503. /**
  62504. * Gets the output component
  62505. */
  62506. get output(): NodeMaterialConnectionPoint;
  62507. protected _buildBlock(state: NodeMaterialBuildState): this;
  62508. }
  62509. }
  62510. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62511. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62512. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62513. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62514. /**
  62515. * Block used to smooth step a value
  62516. */
  62517. export class SmoothStepBlock extends NodeMaterialBlock {
  62518. /**
  62519. * Creates a new SmoothStepBlock
  62520. * @param name defines the block name
  62521. */
  62522. constructor(name: string);
  62523. /**
  62524. * Gets the current class name
  62525. * @returns the class name
  62526. */
  62527. getClassName(): string;
  62528. /**
  62529. * Gets the value operand input component
  62530. */
  62531. get value(): NodeMaterialConnectionPoint;
  62532. /**
  62533. * Gets the first edge operand input component
  62534. */
  62535. get edge0(): NodeMaterialConnectionPoint;
  62536. /**
  62537. * Gets the second edge operand input component
  62538. */
  62539. get edge1(): NodeMaterialConnectionPoint;
  62540. /**
  62541. * Gets the output component
  62542. */
  62543. get output(): NodeMaterialConnectionPoint;
  62544. protected _buildBlock(state: NodeMaterialBuildState): this;
  62545. }
  62546. }
  62547. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62548. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62549. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62550. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62551. /**
  62552. * Block used to get the reciprocal (1 / x) of a value
  62553. */
  62554. export class ReciprocalBlock extends NodeMaterialBlock {
  62555. /**
  62556. * Creates a new ReciprocalBlock
  62557. * @param name defines the block name
  62558. */
  62559. constructor(name: string);
  62560. /**
  62561. * Gets the current class name
  62562. * @returns the class name
  62563. */
  62564. getClassName(): string;
  62565. /**
  62566. * Gets the input component
  62567. */
  62568. get input(): NodeMaterialConnectionPoint;
  62569. /**
  62570. * Gets the output component
  62571. */
  62572. get output(): NodeMaterialConnectionPoint;
  62573. protected _buildBlock(state: NodeMaterialBuildState): this;
  62574. }
  62575. }
  62576. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62577. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62578. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62579. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62580. /**
  62581. * Block used to replace a color by another one
  62582. */
  62583. export class ReplaceColorBlock extends NodeMaterialBlock {
  62584. /**
  62585. * Creates a new ReplaceColorBlock
  62586. * @param name defines the block name
  62587. */
  62588. constructor(name: string);
  62589. /**
  62590. * Gets the current class name
  62591. * @returns the class name
  62592. */
  62593. getClassName(): string;
  62594. /**
  62595. * Gets the value input component
  62596. */
  62597. get value(): NodeMaterialConnectionPoint;
  62598. /**
  62599. * Gets the reference input component
  62600. */
  62601. get reference(): NodeMaterialConnectionPoint;
  62602. /**
  62603. * Gets the distance input component
  62604. */
  62605. get distance(): NodeMaterialConnectionPoint;
  62606. /**
  62607. * Gets the replacement input component
  62608. */
  62609. get replacement(): NodeMaterialConnectionPoint;
  62610. /**
  62611. * Gets the output component
  62612. */
  62613. get output(): NodeMaterialConnectionPoint;
  62614. protected _buildBlock(state: NodeMaterialBuildState): this;
  62615. }
  62616. }
  62617. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62618. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62619. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62620. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62621. /**
  62622. * Block used to posterize a value
  62623. * @see https://en.wikipedia.org/wiki/Posterization
  62624. */
  62625. export class PosterizeBlock extends NodeMaterialBlock {
  62626. /**
  62627. * Creates a new PosterizeBlock
  62628. * @param name defines the block name
  62629. */
  62630. constructor(name: string);
  62631. /**
  62632. * Gets the current class name
  62633. * @returns the class name
  62634. */
  62635. getClassName(): string;
  62636. /**
  62637. * Gets the value input component
  62638. */
  62639. get value(): NodeMaterialConnectionPoint;
  62640. /**
  62641. * Gets the steps input component
  62642. */
  62643. get steps(): NodeMaterialConnectionPoint;
  62644. /**
  62645. * Gets the output component
  62646. */
  62647. get output(): NodeMaterialConnectionPoint;
  62648. protected _buildBlock(state: NodeMaterialBuildState): this;
  62649. }
  62650. }
  62651. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62652. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62653. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62654. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62655. import { Scene } from "babylonjs/scene";
  62656. /**
  62657. * Operations supported by the Wave block
  62658. */
  62659. export enum WaveBlockKind {
  62660. /** SawTooth */
  62661. SawTooth = 0,
  62662. /** Square */
  62663. Square = 1,
  62664. /** Triangle */
  62665. Triangle = 2
  62666. }
  62667. /**
  62668. * Block used to apply wave operation to floats
  62669. */
  62670. export class WaveBlock extends NodeMaterialBlock {
  62671. /**
  62672. * Gets or sets the kibnd of wave to be applied by the block
  62673. */
  62674. kind: WaveBlockKind;
  62675. /**
  62676. * Creates a new WaveBlock
  62677. * @param name defines the block name
  62678. */
  62679. constructor(name: string);
  62680. /**
  62681. * Gets the current class name
  62682. * @returns the class name
  62683. */
  62684. getClassName(): string;
  62685. /**
  62686. * Gets the input component
  62687. */
  62688. get input(): NodeMaterialConnectionPoint;
  62689. /**
  62690. * Gets the output component
  62691. */
  62692. get output(): NodeMaterialConnectionPoint;
  62693. protected _buildBlock(state: NodeMaterialBuildState): this;
  62694. serialize(): any;
  62695. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62696. }
  62697. }
  62698. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62699. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62700. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62701. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62702. import { Color3 } from "babylonjs/Maths/math.color";
  62703. import { Scene } from "babylonjs/scene";
  62704. /**
  62705. * Class used to store a color step for the GradientBlock
  62706. */
  62707. export class GradientBlockColorStep {
  62708. /**
  62709. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62710. */
  62711. step: number;
  62712. /**
  62713. * Gets or sets the color associated with this step
  62714. */
  62715. color: Color3;
  62716. /**
  62717. * Creates a new GradientBlockColorStep
  62718. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62719. * @param color defines the color associated with this step
  62720. */
  62721. constructor(
  62722. /**
  62723. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62724. */
  62725. step: number,
  62726. /**
  62727. * Gets or sets the color associated with this step
  62728. */
  62729. color: Color3);
  62730. }
  62731. /**
  62732. * Block used to return a color from a gradient based on an input value between 0 and 1
  62733. */
  62734. export class GradientBlock extends NodeMaterialBlock {
  62735. /**
  62736. * Gets or sets the list of color steps
  62737. */
  62738. colorSteps: GradientBlockColorStep[];
  62739. /**
  62740. * Creates a new GradientBlock
  62741. * @param name defines the block name
  62742. */
  62743. constructor(name: string);
  62744. /**
  62745. * Gets the current class name
  62746. * @returns the class name
  62747. */
  62748. getClassName(): string;
  62749. /**
  62750. * Gets the gradient input component
  62751. */
  62752. get gradient(): NodeMaterialConnectionPoint;
  62753. /**
  62754. * Gets the output component
  62755. */
  62756. get output(): NodeMaterialConnectionPoint;
  62757. private _writeColorConstant;
  62758. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62759. serialize(): any;
  62760. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62761. protected _dumpPropertiesCode(): string;
  62762. }
  62763. }
  62764. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62765. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62766. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62767. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62768. /**
  62769. * Block used to normalize lerp between 2 values
  62770. */
  62771. export class NLerpBlock extends NodeMaterialBlock {
  62772. /**
  62773. * Creates a new NLerpBlock
  62774. * @param name defines the block name
  62775. */
  62776. constructor(name: string);
  62777. /**
  62778. * Gets the current class name
  62779. * @returns the class name
  62780. */
  62781. getClassName(): string;
  62782. /**
  62783. * Gets the left operand input component
  62784. */
  62785. get left(): NodeMaterialConnectionPoint;
  62786. /**
  62787. * Gets the right operand input component
  62788. */
  62789. get right(): NodeMaterialConnectionPoint;
  62790. /**
  62791. * Gets the gradient operand input component
  62792. */
  62793. get gradient(): NodeMaterialConnectionPoint;
  62794. /**
  62795. * Gets the output component
  62796. */
  62797. get output(): NodeMaterialConnectionPoint;
  62798. protected _buildBlock(state: NodeMaterialBuildState): this;
  62799. }
  62800. }
  62801. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62802. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62803. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62804. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62805. import { Scene } from "babylonjs/scene";
  62806. /**
  62807. * block used to Generate a Worley Noise 3D Noise Pattern
  62808. */
  62809. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62810. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62811. manhattanDistance: boolean;
  62812. /**
  62813. * Creates a new WorleyNoise3DBlock
  62814. * @param name defines the block name
  62815. */
  62816. constructor(name: string);
  62817. /**
  62818. * Gets the current class name
  62819. * @returns the class name
  62820. */
  62821. getClassName(): string;
  62822. /**
  62823. * Gets the seed input component
  62824. */
  62825. get seed(): NodeMaterialConnectionPoint;
  62826. /**
  62827. * Gets the jitter input component
  62828. */
  62829. get jitter(): NodeMaterialConnectionPoint;
  62830. /**
  62831. * Gets the output component
  62832. */
  62833. get output(): NodeMaterialConnectionPoint;
  62834. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62835. /**
  62836. * Exposes the properties to the UI?
  62837. */
  62838. protected _dumpPropertiesCode(): string;
  62839. /**
  62840. * Exposes the properties to the Seralize?
  62841. */
  62842. serialize(): any;
  62843. /**
  62844. * Exposes the properties to the deseralize?
  62845. */
  62846. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62847. }
  62848. }
  62849. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  62850. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62851. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62852. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62853. /**
  62854. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62855. */
  62856. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62857. /**
  62858. * Creates a new SimplexPerlin3DBlock
  62859. * @param name defines the block name
  62860. */
  62861. constructor(name: string);
  62862. /**
  62863. * Gets the current class name
  62864. * @returns the class name
  62865. */
  62866. getClassName(): string;
  62867. /**
  62868. * Gets the seed operand input component
  62869. */
  62870. get seed(): NodeMaterialConnectionPoint;
  62871. /**
  62872. * Gets the output component
  62873. */
  62874. get output(): NodeMaterialConnectionPoint;
  62875. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62876. }
  62877. }
  62878. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62879. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62880. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62881. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62882. /**
  62883. * Block used to blend normals
  62884. */
  62885. export class NormalBlendBlock extends NodeMaterialBlock {
  62886. /**
  62887. * Creates a new NormalBlendBlock
  62888. * @param name defines the block name
  62889. */
  62890. constructor(name: string);
  62891. /**
  62892. * Gets the current class name
  62893. * @returns the class name
  62894. */
  62895. getClassName(): string;
  62896. /**
  62897. * Gets the first input component
  62898. */
  62899. get normalMap0(): NodeMaterialConnectionPoint;
  62900. /**
  62901. * Gets the second input component
  62902. */
  62903. get normalMap1(): NodeMaterialConnectionPoint;
  62904. /**
  62905. * Gets the output component
  62906. */
  62907. get output(): NodeMaterialConnectionPoint;
  62908. protected _buildBlock(state: NodeMaterialBuildState): this;
  62909. }
  62910. }
  62911. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  62912. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62913. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62914. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62915. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62916. /**
  62917. * Block used to rotate a 2d vector by a given angle
  62918. */
  62919. export class Rotate2dBlock extends NodeMaterialBlock {
  62920. /**
  62921. * Creates a new Rotate2dBlock
  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 input vector
  62932. */
  62933. get input(): NodeMaterialConnectionPoint;
  62934. /**
  62935. * Gets the input angle
  62936. */
  62937. get angle(): NodeMaterialConnectionPoint;
  62938. /**
  62939. * Gets the output component
  62940. */
  62941. get output(): NodeMaterialConnectionPoint;
  62942. autoConfigure(material: NodeMaterial): void;
  62943. protected _buildBlock(state: NodeMaterialBuildState): this;
  62944. }
  62945. }
  62946. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  62947. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62948. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62949. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62950. /**
  62951. * Block used to get the reflected vector from a direction and a normal
  62952. */
  62953. export class ReflectBlock extends NodeMaterialBlock {
  62954. /**
  62955. * Creates a new ReflectBlock
  62956. * @param name defines the block name
  62957. */
  62958. constructor(name: string);
  62959. /**
  62960. * Gets the current class name
  62961. * @returns the class name
  62962. */
  62963. getClassName(): string;
  62964. /**
  62965. * Gets the incident component
  62966. */
  62967. get incident(): NodeMaterialConnectionPoint;
  62968. /**
  62969. * Gets the normal component
  62970. */
  62971. get normal(): NodeMaterialConnectionPoint;
  62972. /**
  62973. * Gets the output component
  62974. */
  62975. get output(): NodeMaterialConnectionPoint;
  62976. protected _buildBlock(state: NodeMaterialBuildState): this;
  62977. }
  62978. }
  62979. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  62980. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62981. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62982. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62983. /**
  62984. * Block used to get the refracted vector from a direction and a normal
  62985. */
  62986. export class RefractBlock extends NodeMaterialBlock {
  62987. /**
  62988. * Creates a new RefractBlock
  62989. * @param name defines the block name
  62990. */
  62991. constructor(name: string);
  62992. /**
  62993. * Gets the current class name
  62994. * @returns the class name
  62995. */
  62996. getClassName(): string;
  62997. /**
  62998. * Gets the incident component
  62999. */
  63000. get incident(): NodeMaterialConnectionPoint;
  63001. /**
  63002. * Gets the normal component
  63003. */
  63004. get normal(): NodeMaterialConnectionPoint;
  63005. /**
  63006. * Gets the index of refraction component
  63007. */
  63008. get ior(): NodeMaterialConnectionPoint;
  63009. /**
  63010. * Gets the output component
  63011. */
  63012. get output(): NodeMaterialConnectionPoint;
  63013. protected _buildBlock(state: NodeMaterialBuildState): this;
  63014. }
  63015. }
  63016. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63017. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63018. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63019. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63020. /**
  63021. * Block used to desaturate a color
  63022. */
  63023. export class DesaturateBlock extends NodeMaterialBlock {
  63024. /**
  63025. * Creates a new DesaturateBlock
  63026. * @param name defines the block name
  63027. */
  63028. constructor(name: string);
  63029. /**
  63030. * Gets the current class name
  63031. * @returns the class name
  63032. */
  63033. getClassName(): string;
  63034. /**
  63035. * Gets the color operand input component
  63036. */
  63037. get color(): NodeMaterialConnectionPoint;
  63038. /**
  63039. * Gets the level operand input component
  63040. */
  63041. get level(): NodeMaterialConnectionPoint;
  63042. /**
  63043. * Gets the output component
  63044. */
  63045. get output(): NodeMaterialConnectionPoint;
  63046. protected _buildBlock(state: NodeMaterialBuildState): this;
  63047. }
  63048. }
  63049. declare module "babylonjs/Materials/Node/Blocks/index" {
  63050. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63051. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63052. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63053. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63054. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63055. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63056. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63057. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63058. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63059. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63060. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63061. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63062. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63063. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63064. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63065. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63066. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63067. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63068. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63069. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63070. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63071. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63072. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63073. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63074. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63075. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63076. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63077. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63078. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63079. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63080. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63081. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63082. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63083. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63084. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63085. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63086. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63087. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63088. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63089. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63090. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63091. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63092. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63093. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63094. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63095. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63096. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63097. }
  63098. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63099. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63100. }
  63101. declare module "babylonjs/Materials/Node/index" {
  63102. export * from "babylonjs/Materials/Node/Enums/index";
  63103. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63104. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63105. export * from "babylonjs/Materials/Node/nodeMaterial";
  63106. export * from "babylonjs/Materials/Node/Blocks/index";
  63107. export * from "babylonjs/Materials/Node/Optimizers/index";
  63108. }
  63109. declare module "babylonjs/Materials/effectRenderer" {
  63110. import { Nullable } from "babylonjs/types";
  63111. import { Texture } from "babylonjs/Materials/Textures/texture";
  63112. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63113. import { Viewport } from "babylonjs/Maths/math.viewport";
  63114. import { Observable } from "babylonjs/Misc/observable";
  63115. import { Effect } from "babylonjs/Materials/effect";
  63116. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63117. import "babylonjs/Shaders/postprocess.vertex";
  63118. /**
  63119. * Effect Render Options
  63120. */
  63121. export interface IEffectRendererOptions {
  63122. /**
  63123. * Defines the vertices positions.
  63124. */
  63125. positions?: number[];
  63126. /**
  63127. * Defines the indices.
  63128. */
  63129. indices?: number[];
  63130. }
  63131. /**
  63132. * Helper class to render one or more effects
  63133. */
  63134. export class EffectRenderer {
  63135. private engine;
  63136. private static _DefaultOptions;
  63137. private _vertexBuffers;
  63138. private _indexBuffer;
  63139. private _ringBufferIndex;
  63140. private _ringScreenBuffer;
  63141. private _fullscreenViewport;
  63142. private _getNextFrameBuffer;
  63143. /**
  63144. * Creates an effect renderer
  63145. * @param engine the engine to use for rendering
  63146. * @param options defines the options of the effect renderer
  63147. */
  63148. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63149. /**
  63150. * Sets the current viewport in normalized coordinates 0-1
  63151. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63152. */
  63153. setViewport(viewport?: Viewport): void;
  63154. /**
  63155. * Binds the embedded attributes buffer to the effect.
  63156. * @param effect Defines the effect to bind the attributes for
  63157. */
  63158. bindBuffers(effect: Effect): void;
  63159. /**
  63160. * Sets the current effect wrapper to use during draw.
  63161. * The effect needs to be ready before calling this api.
  63162. * This also sets the default full screen position attribute.
  63163. * @param effectWrapper Defines the effect to draw with
  63164. */
  63165. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63166. /**
  63167. * Draws a full screen quad.
  63168. */
  63169. draw(): void;
  63170. /**
  63171. * renders one or more effects to a specified texture
  63172. * @param effectWrappers list of effects to renderer
  63173. * @param outputTexture texture to draw to, if null it will render to the screen
  63174. */
  63175. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63176. /**
  63177. * Disposes of the effect renderer
  63178. */
  63179. dispose(): void;
  63180. }
  63181. /**
  63182. * Options to create an EffectWrapper
  63183. */
  63184. interface EffectWrapperCreationOptions {
  63185. /**
  63186. * Engine to use to create the effect
  63187. */
  63188. engine: ThinEngine;
  63189. /**
  63190. * Fragment shader for the effect
  63191. */
  63192. fragmentShader: string;
  63193. /**
  63194. * Vertex shader for the effect
  63195. */
  63196. vertexShader?: string;
  63197. /**
  63198. * Attributes to use in the shader
  63199. */
  63200. attributeNames?: Array<string>;
  63201. /**
  63202. * Uniforms to use in the shader
  63203. */
  63204. uniformNames?: Array<string>;
  63205. /**
  63206. * Texture sampler names to use in the shader
  63207. */
  63208. samplerNames?: Array<string>;
  63209. /**
  63210. * The friendly name of the effect displayed in Spector.
  63211. */
  63212. name?: string;
  63213. }
  63214. /**
  63215. * Wraps an effect to be used for rendering
  63216. */
  63217. export class EffectWrapper {
  63218. /**
  63219. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63220. */
  63221. onApplyObservable: Observable<{}>;
  63222. /**
  63223. * The underlying effect
  63224. */
  63225. effect: Effect;
  63226. /**
  63227. * Creates an effect to be renderer
  63228. * @param creationOptions options to create the effect
  63229. */
  63230. constructor(creationOptions: EffectWrapperCreationOptions);
  63231. /**
  63232. * Disposes of the effect wrapper
  63233. */
  63234. dispose(): void;
  63235. }
  63236. }
  63237. declare module "babylonjs/Materials/index" {
  63238. export * from "babylonjs/Materials/Background/index";
  63239. export * from "babylonjs/Materials/colorCurves";
  63240. export * from "babylonjs/Materials/iEffectFallbacks";
  63241. export * from "babylonjs/Materials/effectFallbacks";
  63242. export * from "babylonjs/Materials/effect";
  63243. export * from "babylonjs/Materials/fresnelParameters";
  63244. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63245. export * from "babylonjs/Materials/material";
  63246. export * from "babylonjs/Materials/materialDefines";
  63247. export * from "babylonjs/Materials/materialHelper";
  63248. export * from "babylonjs/Materials/multiMaterial";
  63249. export * from "babylonjs/Materials/PBR/index";
  63250. export * from "babylonjs/Materials/pushMaterial";
  63251. export * from "babylonjs/Materials/shaderMaterial";
  63252. export * from "babylonjs/Materials/standardMaterial";
  63253. export * from "babylonjs/Materials/Textures/index";
  63254. export * from "babylonjs/Materials/uniformBuffer";
  63255. export * from "babylonjs/Materials/materialFlags";
  63256. export * from "babylonjs/Materials/Node/index";
  63257. export * from "babylonjs/Materials/effectRenderer";
  63258. }
  63259. declare module "babylonjs/Maths/index" {
  63260. export * from "babylonjs/Maths/math.scalar";
  63261. export * from "babylonjs/Maths/math";
  63262. export * from "babylonjs/Maths/sphericalPolynomial";
  63263. }
  63264. declare module "babylonjs/Misc/workerPool" {
  63265. import { IDisposable } from "babylonjs/scene";
  63266. /**
  63267. * Helper class to push actions to a pool of workers.
  63268. */
  63269. export class WorkerPool implements IDisposable {
  63270. private _workerInfos;
  63271. private _pendingActions;
  63272. /**
  63273. * Constructor
  63274. * @param workers Array of workers to use for actions
  63275. */
  63276. constructor(workers: Array<Worker>);
  63277. /**
  63278. * Terminates all workers and clears any pending actions.
  63279. */
  63280. dispose(): void;
  63281. /**
  63282. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63283. * pended until a worker has completed its action.
  63284. * @param action The action to perform. Call onComplete when the action is complete.
  63285. */
  63286. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63287. private _execute;
  63288. }
  63289. }
  63290. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63291. import { IDisposable } from "babylonjs/scene";
  63292. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63293. /**
  63294. * Configuration for Draco compression
  63295. */
  63296. export interface IDracoCompressionConfiguration {
  63297. /**
  63298. * Configuration for the decoder.
  63299. */
  63300. decoder: {
  63301. /**
  63302. * The url to the WebAssembly module.
  63303. */
  63304. wasmUrl?: string;
  63305. /**
  63306. * The url to the WebAssembly binary.
  63307. */
  63308. wasmBinaryUrl?: string;
  63309. /**
  63310. * The url to the fallback JavaScript module.
  63311. */
  63312. fallbackUrl?: string;
  63313. };
  63314. }
  63315. /**
  63316. * Draco compression (https://google.github.io/draco/)
  63317. *
  63318. * This class wraps the Draco module.
  63319. *
  63320. * **Encoder**
  63321. *
  63322. * The encoder is not currently implemented.
  63323. *
  63324. * **Decoder**
  63325. *
  63326. * 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.
  63327. *
  63328. * To update the configuration, use the following code:
  63329. * ```javascript
  63330. * DracoCompression.Configuration = {
  63331. * decoder: {
  63332. * wasmUrl: "<url to the WebAssembly library>",
  63333. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63334. * fallbackUrl: "<url to the fallback JavaScript library>",
  63335. * }
  63336. * };
  63337. * ```
  63338. *
  63339. * 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.
  63340. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63341. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63342. *
  63343. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63344. * ```javascript
  63345. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63346. * ```
  63347. *
  63348. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63349. */
  63350. export class DracoCompression implements IDisposable {
  63351. private _workerPoolPromise?;
  63352. private _decoderModulePromise?;
  63353. /**
  63354. * The configuration. Defaults to the following urls:
  63355. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63356. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63357. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63358. */
  63359. static Configuration: IDracoCompressionConfiguration;
  63360. /**
  63361. * Returns true if the decoder configuration is available.
  63362. */
  63363. static get DecoderAvailable(): boolean;
  63364. /**
  63365. * Default number of workers to create when creating the draco compression object.
  63366. */
  63367. static DefaultNumWorkers: number;
  63368. private static GetDefaultNumWorkers;
  63369. private static _Default;
  63370. /**
  63371. * Default instance for the draco compression object.
  63372. */
  63373. static get Default(): DracoCompression;
  63374. /**
  63375. * Constructor
  63376. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63377. */
  63378. constructor(numWorkers?: number);
  63379. /**
  63380. * Stop all async operations and release resources.
  63381. */
  63382. dispose(): void;
  63383. /**
  63384. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63385. * @returns a promise that resolves when ready
  63386. */
  63387. whenReadyAsync(): Promise<void>;
  63388. /**
  63389. * Decode Draco compressed mesh data to vertex data.
  63390. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63391. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63392. * @returns A promise that resolves with the decoded vertex data
  63393. */
  63394. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63395. [kind: string]: number;
  63396. }): Promise<VertexData>;
  63397. }
  63398. }
  63399. declare module "babylonjs/Meshes/Compression/index" {
  63400. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63401. }
  63402. declare module "babylonjs/Meshes/csg" {
  63403. import { Nullable } from "babylonjs/types";
  63404. import { Scene } from "babylonjs/scene";
  63405. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63406. import { Mesh } from "babylonjs/Meshes/mesh";
  63407. import { Material } from "babylonjs/Materials/material";
  63408. /**
  63409. * Class for building Constructive Solid Geometry
  63410. */
  63411. export class CSG {
  63412. private polygons;
  63413. /**
  63414. * The world matrix
  63415. */
  63416. matrix: Matrix;
  63417. /**
  63418. * Stores the position
  63419. */
  63420. position: Vector3;
  63421. /**
  63422. * Stores the rotation
  63423. */
  63424. rotation: Vector3;
  63425. /**
  63426. * Stores the rotation quaternion
  63427. */
  63428. rotationQuaternion: Nullable<Quaternion>;
  63429. /**
  63430. * Stores the scaling vector
  63431. */
  63432. scaling: Vector3;
  63433. /**
  63434. * Convert the Mesh to CSG
  63435. * @param mesh The Mesh to convert to CSG
  63436. * @returns A new CSG from the Mesh
  63437. */
  63438. static FromMesh(mesh: Mesh): CSG;
  63439. /**
  63440. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63441. * @param polygons Polygons used to construct a CSG solid
  63442. */
  63443. private static FromPolygons;
  63444. /**
  63445. * Clones, or makes a deep copy, of the CSG
  63446. * @returns A new CSG
  63447. */
  63448. clone(): CSG;
  63449. /**
  63450. * Unions this CSG with another CSG
  63451. * @param csg The CSG to union against this CSG
  63452. * @returns The unioned CSG
  63453. */
  63454. union(csg: CSG): CSG;
  63455. /**
  63456. * Unions this CSG with another CSG in place
  63457. * @param csg The CSG to union against this CSG
  63458. */
  63459. unionInPlace(csg: CSG): void;
  63460. /**
  63461. * Subtracts this CSG with another CSG
  63462. * @param csg The CSG to subtract against this CSG
  63463. * @returns A new CSG
  63464. */
  63465. subtract(csg: CSG): CSG;
  63466. /**
  63467. * Subtracts this CSG with another CSG in place
  63468. * @param csg The CSG to subtact against this CSG
  63469. */
  63470. subtractInPlace(csg: CSG): void;
  63471. /**
  63472. * Intersect this CSG with another CSG
  63473. * @param csg The CSG to intersect against this CSG
  63474. * @returns A new CSG
  63475. */
  63476. intersect(csg: CSG): CSG;
  63477. /**
  63478. * Intersects this CSG with another CSG in place
  63479. * @param csg The CSG to intersect against this CSG
  63480. */
  63481. intersectInPlace(csg: CSG): void;
  63482. /**
  63483. * Return a new CSG solid with solid and empty space switched. This solid is
  63484. * not modified.
  63485. * @returns A new CSG solid with solid and empty space switched
  63486. */
  63487. inverse(): CSG;
  63488. /**
  63489. * Inverses the CSG in place
  63490. */
  63491. inverseInPlace(): void;
  63492. /**
  63493. * This is used to keep meshes transformations so they can be restored
  63494. * when we build back a Babylon Mesh
  63495. * NB : All CSG operations are performed in world coordinates
  63496. * @param csg The CSG to copy the transform attributes from
  63497. * @returns This CSG
  63498. */
  63499. copyTransformAttributes(csg: CSG): CSG;
  63500. /**
  63501. * Build Raw mesh from CSG
  63502. * Coordinates here are in world space
  63503. * @param name The name of the mesh geometry
  63504. * @param scene The Scene
  63505. * @param keepSubMeshes Specifies if the submeshes should be kept
  63506. * @returns A new Mesh
  63507. */
  63508. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63509. /**
  63510. * Build Mesh from CSG taking material and transforms into account
  63511. * @param name The name of the Mesh
  63512. * @param material The material of the Mesh
  63513. * @param scene The Scene
  63514. * @param keepSubMeshes Specifies if submeshes should be kept
  63515. * @returns The new Mesh
  63516. */
  63517. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63518. }
  63519. }
  63520. declare module "babylonjs/Meshes/trailMesh" {
  63521. import { Mesh } from "babylonjs/Meshes/mesh";
  63522. import { Scene } from "babylonjs/scene";
  63523. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63524. /**
  63525. * Class used to create a trail following a mesh
  63526. */
  63527. export class TrailMesh extends Mesh {
  63528. private _generator;
  63529. private _autoStart;
  63530. private _running;
  63531. private _diameter;
  63532. private _length;
  63533. private _sectionPolygonPointsCount;
  63534. private _sectionVectors;
  63535. private _sectionNormalVectors;
  63536. private _beforeRenderObserver;
  63537. /**
  63538. * @constructor
  63539. * @param name The value used by scene.getMeshByName() to do a lookup.
  63540. * @param generator The mesh or transform node to generate a trail.
  63541. * @param scene The scene to add this mesh to.
  63542. * @param diameter Diameter of trailing mesh. Default is 1.
  63543. * @param length Length of trailing mesh. Default is 60.
  63544. * @param autoStart Automatically start trailing mesh. Default true.
  63545. */
  63546. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63547. /**
  63548. * "TrailMesh"
  63549. * @returns "TrailMesh"
  63550. */
  63551. getClassName(): string;
  63552. private _createMesh;
  63553. /**
  63554. * Start trailing mesh.
  63555. */
  63556. start(): void;
  63557. /**
  63558. * Stop trailing mesh.
  63559. */
  63560. stop(): void;
  63561. /**
  63562. * Update trailing mesh geometry.
  63563. */
  63564. update(): void;
  63565. /**
  63566. * Returns a new TrailMesh object.
  63567. * @param name is a string, the name given to the new mesh
  63568. * @param newGenerator use new generator object for cloned trail mesh
  63569. * @returns a new mesh
  63570. */
  63571. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63572. /**
  63573. * Serializes this trail mesh
  63574. * @param serializationObject object to write serialization to
  63575. */
  63576. serialize(serializationObject: any): void;
  63577. /**
  63578. * Parses a serialized trail mesh
  63579. * @param parsedMesh the serialized mesh
  63580. * @param scene the scene to create the trail mesh in
  63581. * @returns the created trail mesh
  63582. */
  63583. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63584. }
  63585. }
  63586. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63587. import { Nullable } from "babylonjs/types";
  63588. import { Scene } from "babylonjs/scene";
  63589. import { Vector4 } from "babylonjs/Maths/math.vector";
  63590. import { Color4 } from "babylonjs/Maths/math.color";
  63591. import { Mesh } from "babylonjs/Meshes/mesh";
  63592. /**
  63593. * Class containing static functions to help procedurally build meshes
  63594. */
  63595. export class TiledBoxBuilder {
  63596. /**
  63597. * Creates a box mesh
  63598. * 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)
  63599. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63601. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63603. * @param name defines the name of the mesh
  63604. * @param options defines the options used to create the mesh
  63605. * @param scene defines the hosting scene
  63606. * @returns the box mesh
  63607. */
  63608. static CreateTiledBox(name: string, options: {
  63609. pattern?: number;
  63610. width?: number;
  63611. height?: number;
  63612. depth?: number;
  63613. tileSize?: number;
  63614. tileWidth?: number;
  63615. tileHeight?: number;
  63616. alignHorizontal?: number;
  63617. alignVertical?: number;
  63618. faceUV?: Vector4[];
  63619. faceColors?: Color4[];
  63620. sideOrientation?: number;
  63621. updatable?: boolean;
  63622. }, scene?: Nullable<Scene>): Mesh;
  63623. }
  63624. }
  63625. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63626. import { Vector4 } from "babylonjs/Maths/math.vector";
  63627. import { Mesh } from "babylonjs/Meshes/mesh";
  63628. /**
  63629. * Class containing static functions to help procedurally build meshes
  63630. */
  63631. export class TorusKnotBuilder {
  63632. /**
  63633. * Creates a torus knot mesh
  63634. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63635. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63636. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63637. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63638. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63639. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63641. * @param name defines the name of the mesh
  63642. * @param options defines the options used to create the mesh
  63643. * @param scene defines the hosting scene
  63644. * @returns the torus knot mesh
  63645. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63646. */
  63647. static CreateTorusKnot(name: string, options: {
  63648. radius?: number;
  63649. tube?: number;
  63650. radialSegments?: number;
  63651. tubularSegments?: number;
  63652. p?: number;
  63653. q?: number;
  63654. updatable?: boolean;
  63655. sideOrientation?: number;
  63656. frontUVs?: Vector4;
  63657. backUVs?: Vector4;
  63658. }, scene: any): Mesh;
  63659. }
  63660. }
  63661. declare module "babylonjs/Meshes/polygonMesh" {
  63662. import { Scene } from "babylonjs/scene";
  63663. import { Vector2 } from "babylonjs/Maths/math.vector";
  63664. import { Mesh } from "babylonjs/Meshes/mesh";
  63665. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63666. import { Path2 } from "babylonjs/Maths/math.path";
  63667. /**
  63668. * Polygon
  63669. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63670. */
  63671. export class Polygon {
  63672. /**
  63673. * Creates a rectangle
  63674. * @param xmin bottom X coord
  63675. * @param ymin bottom Y coord
  63676. * @param xmax top X coord
  63677. * @param ymax top Y coord
  63678. * @returns points that make the resulting rectation
  63679. */
  63680. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63681. /**
  63682. * Creates a circle
  63683. * @param radius radius of circle
  63684. * @param cx scale in x
  63685. * @param cy scale in y
  63686. * @param numberOfSides number of sides that make up the circle
  63687. * @returns points that make the resulting circle
  63688. */
  63689. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63690. /**
  63691. * Creates a polygon from input string
  63692. * @param input Input polygon data
  63693. * @returns the parsed points
  63694. */
  63695. static Parse(input: string): Vector2[];
  63696. /**
  63697. * Starts building a polygon from x and y coordinates
  63698. * @param x x coordinate
  63699. * @param y y coordinate
  63700. * @returns the started path2
  63701. */
  63702. static StartingAt(x: number, y: number): Path2;
  63703. }
  63704. /**
  63705. * Builds a polygon
  63706. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63707. */
  63708. export class PolygonMeshBuilder {
  63709. private _points;
  63710. private _outlinepoints;
  63711. private _holes;
  63712. private _name;
  63713. private _scene;
  63714. private _epoints;
  63715. private _eholes;
  63716. private _addToepoint;
  63717. /**
  63718. * Babylon reference to the earcut plugin.
  63719. */
  63720. bjsEarcut: any;
  63721. /**
  63722. * Creates a PolygonMeshBuilder
  63723. * @param name name of the builder
  63724. * @param contours Path of the polygon
  63725. * @param scene scene to add to when creating the mesh
  63726. * @param earcutInjection can be used to inject your own earcut reference
  63727. */
  63728. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63729. /**
  63730. * Adds a whole within the polygon
  63731. * @param hole Array of points defining the hole
  63732. * @returns this
  63733. */
  63734. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63735. /**
  63736. * Creates the polygon
  63737. * @param updatable If the mesh should be updatable
  63738. * @param depth The depth of the mesh created
  63739. * @returns the created mesh
  63740. */
  63741. build(updatable?: boolean, depth?: number): Mesh;
  63742. /**
  63743. * Creates the polygon
  63744. * @param depth The depth of the mesh created
  63745. * @returns the created VertexData
  63746. */
  63747. buildVertexData(depth?: number): VertexData;
  63748. /**
  63749. * Adds a side to the polygon
  63750. * @param positions points that make the polygon
  63751. * @param normals normals of the polygon
  63752. * @param uvs uvs of the polygon
  63753. * @param indices indices of the polygon
  63754. * @param bounds bounds of the polygon
  63755. * @param points points of the polygon
  63756. * @param depth depth of the polygon
  63757. * @param flip flip of the polygon
  63758. */
  63759. private addSide;
  63760. }
  63761. }
  63762. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63763. import { Scene } from "babylonjs/scene";
  63764. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63765. import { Color4 } from "babylonjs/Maths/math.color";
  63766. import { Mesh } from "babylonjs/Meshes/mesh";
  63767. import { Nullable } from "babylonjs/types";
  63768. /**
  63769. * Class containing static functions to help procedurally build meshes
  63770. */
  63771. export class PolygonBuilder {
  63772. /**
  63773. * Creates a polygon mesh
  63774. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63775. * * 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
  63776. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63778. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63779. * * Remember you can only change the shape positions, not their number when updating a polygon
  63780. * @param name defines the name of the mesh
  63781. * @param options defines the options used to create the mesh
  63782. * @param scene defines the hosting scene
  63783. * @param earcutInjection can be used to inject your own earcut reference
  63784. * @returns the polygon mesh
  63785. */
  63786. static CreatePolygon(name: string, options: {
  63787. shape: Vector3[];
  63788. holes?: Vector3[][];
  63789. depth?: number;
  63790. faceUV?: Vector4[];
  63791. faceColors?: Color4[];
  63792. updatable?: boolean;
  63793. sideOrientation?: number;
  63794. frontUVs?: Vector4;
  63795. backUVs?: Vector4;
  63796. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63797. /**
  63798. * Creates an extruded polygon mesh, with depth in the Y direction.
  63799. * * 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)
  63800. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63801. * @param name defines the name of the mesh
  63802. * @param options defines the options used to create the mesh
  63803. * @param scene defines the hosting scene
  63804. * @param earcutInjection can be used to inject your own earcut reference
  63805. * @returns the polygon mesh
  63806. */
  63807. static ExtrudePolygon(name: string, options: {
  63808. shape: Vector3[];
  63809. holes?: Vector3[][];
  63810. depth?: number;
  63811. faceUV?: Vector4[];
  63812. faceColors?: Color4[];
  63813. updatable?: boolean;
  63814. sideOrientation?: number;
  63815. frontUVs?: Vector4;
  63816. backUVs?: Vector4;
  63817. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63818. }
  63819. }
  63820. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63821. import { Scene } from "babylonjs/scene";
  63822. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63823. import { Mesh } from "babylonjs/Meshes/mesh";
  63824. import { Nullable } from "babylonjs/types";
  63825. /**
  63826. * Class containing static functions to help procedurally build meshes
  63827. */
  63828. export class LatheBuilder {
  63829. /**
  63830. * Creates lathe mesh.
  63831. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63832. * * 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
  63833. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63834. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63835. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63836. * * 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
  63837. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63838. * * 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
  63839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63840. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63841. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63843. * @param name defines the name of the mesh
  63844. * @param options defines the options used to create the mesh
  63845. * @param scene defines the hosting scene
  63846. * @returns the lathe mesh
  63847. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63848. */
  63849. static CreateLathe(name: string, options: {
  63850. shape: Vector3[];
  63851. radius?: number;
  63852. tessellation?: number;
  63853. clip?: number;
  63854. arc?: number;
  63855. closed?: boolean;
  63856. updatable?: boolean;
  63857. sideOrientation?: number;
  63858. frontUVs?: Vector4;
  63859. backUVs?: Vector4;
  63860. cap?: number;
  63861. invertUV?: boolean;
  63862. }, scene?: Nullable<Scene>): Mesh;
  63863. }
  63864. }
  63865. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63866. import { Nullable } from "babylonjs/types";
  63867. import { Scene } from "babylonjs/scene";
  63868. import { Vector4 } from "babylonjs/Maths/math.vector";
  63869. import { Mesh } from "babylonjs/Meshes/mesh";
  63870. /**
  63871. * Class containing static functions to help procedurally build meshes
  63872. */
  63873. export class TiledPlaneBuilder {
  63874. /**
  63875. * Creates a tiled plane mesh
  63876. * * The parameter `pattern` will, depending on value, do nothing or
  63877. * * * flip (reflect about central vertical) alternate tiles across and up
  63878. * * * flip every tile on alternate rows
  63879. * * * rotate (180 degs) alternate tiles across and up
  63880. * * * rotate every tile on alternate rows
  63881. * * * flip and rotate alternate tiles across and up
  63882. * * * flip and rotate every tile on alternate rows
  63883. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63884. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63885. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63886. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63887. * * 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)
  63888. * * 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)
  63889. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63890. * @param name defines the name of the mesh
  63891. * @param options defines the options used to create the mesh
  63892. * @param scene defines the hosting scene
  63893. * @returns the box mesh
  63894. */
  63895. static CreateTiledPlane(name: string, options: {
  63896. pattern?: number;
  63897. tileSize?: number;
  63898. tileWidth?: number;
  63899. tileHeight?: number;
  63900. size?: number;
  63901. width?: number;
  63902. height?: number;
  63903. alignHorizontal?: number;
  63904. alignVertical?: number;
  63905. sideOrientation?: number;
  63906. frontUVs?: Vector4;
  63907. backUVs?: Vector4;
  63908. updatable?: boolean;
  63909. }, scene?: Nullable<Scene>): Mesh;
  63910. }
  63911. }
  63912. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  63913. import { Nullable } from "babylonjs/types";
  63914. import { Scene } from "babylonjs/scene";
  63915. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63916. import { Mesh } from "babylonjs/Meshes/mesh";
  63917. /**
  63918. * Class containing static functions to help procedurally build meshes
  63919. */
  63920. export class TubeBuilder {
  63921. /**
  63922. * Creates a tube mesh.
  63923. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63924. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63925. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63926. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63927. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63928. * * 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)
  63929. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63930. * * 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
  63931. * * 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
  63932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63933. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63934. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63936. * @param name defines the name of the mesh
  63937. * @param options defines the options used to create the mesh
  63938. * @param scene defines the hosting scene
  63939. * @returns the tube mesh
  63940. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63941. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63942. */
  63943. static CreateTube(name: string, options: {
  63944. path: Vector3[];
  63945. radius?: number;
  63946. tessellation?: number;
  63947. radiusFunction?: {
  63948. (i: number, distance: number): number;
  63949. };
  63950. cap?: number;
  63951. arc?: number;
  63952. updatable?: boolean;
  63953. sideOrientation?: number;
  63954. frontUVs?: Vector4;
  63955. backUVs?: Vector4;
  63956. instance?: Mesh;
  63957. invertUV?: boolean;
  63958. }, scene?: Nullable<Scene>): Mesh;
  63959. }
  63960. }
  63961. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  63962. import { Scene } from "babylonjs/scene";
  63963. import { Vector4 } from "babylonjs/Maths/math.vector";
  63964. import { Mesh } from "babylonjs/Meshes/mesh";
  63965. import { Nullable } from "babylonjs/types";
  63966. /**
  63967. * Class containing static functions to help procedurally build meshes
  63968. */
  63969. export class IcoSphereBuilder {
  63970. /**
  63971. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63972. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63973. * * 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`)
  63974. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63975. * * 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
  63976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63977. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63979. * @param name defines the name of the mesh
  63980. * @param options defines the options used to create the mesh
  63981. * @param scene defines the hosting scene
  63982. * @returns the icosahedron mesh
  63983. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63984. */
  63985. static CreateIcoSphere(name: string, options: {
  63986. radius?: number;
  63987. radiusX?: number;
  63988. radiusY?: number;
  63989. radiusZ?: number;
  63990. flat?: boolean;
  63991. subdivisions?: number;
  63992. sideOrientation?: number;
  63993. frontUVs?: Vector4;
  63994. backUVs?: Vector4;
  63995. updatable?: boolean;
  63996. }, scene?: Nullable<Scene>): Mesh;
  63997. }
  63998. }
  63999. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64000. import { Vector3 } from "babylonjs/Maths/math.vector";
  64001. import { Mesh } from "babylonjs/Meshes/mesh";
  64002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64003. /**
  64004. * Class containing static functions to help procedurally build meshes
  64005. */
  64006. export class DecalBuilder {
  64007. /**
  64008. * Creates a decal mesh.
  64009. * 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
  64010. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64011. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64012. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64013. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64014. * @param name defines the name of the mesh
  64015. * @param sourceMesh defines the mesh where the decal must be applied
  64016. * @param options defines the options used to create the mesh
  64017. * @param scene defines the hosting scene
  64018. * @returns the decal mesh
  64019. * @see https://doc.babylonjs.com/how_to/decals
  64020. */
  64021. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64022. position?: Vector3;
  64023. normal?: Vector3;
  64024. size?: Vector3;
  64025. angle?: number;
  64026. }): Mesh;
  64027. }
  64028. }
  64029. declare module "babylonjs/Meshes/meshBuilder" {
  64030. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64031. import { Nullable } from "babylonjs/types";
  64032. import { Scene } from "babylonjs/scene";
  64033. import { Mesh } from "babylonjs/Meshes/mesh";
  64034. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64035. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64037. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64038. import { Plane } from "babylonjs/Maths/math.plane";
  64039. /**
  64040. * Class containing static functions to help procedurally build meshes
  64041. */
  64042. export class MeshBuilder {
  64043. /**
  64044. * Creates a box mesh
  64045. * * The parameter `size` sets the size (float) of each box side (default 1)
  64046. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64047. * * 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)
  64048. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64049. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64050. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64052. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64053. * @param name defines the name of the mesh
  64054. * @param options defines the options used to create the mesh
  64055. * @param scene defines the hosting scene
  64056. * @returns the box mesh
  64057. */
  64058. static CreateBox(name: string, options: {
  64059. size?: number;
  64060. width?: number;
  64061. height?: number;
  64062. depth?: number;
  64063. faceUV?: Vector4[];
  64064. faceColors?: Color4[];
  64065. sideOrientation?: number;
  64066. frontUVs?: Vector4;
  64067. backUVs?: Vector4;
  64068. updatable?: boolean;
  64069. }, scene?: Nullable<Scene>): Mesh;
  64070. /**
  64071. * Creates a tiled box mesh
  64072. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64074. * @param name defines the name of the mesh
  64075. * @param options defines the options used to create the mesh
  64076. * @param scene defines the hosting scene
  64077. * @returns the tiled box mesh
  64078. */
  64079. static CreateTiledBox(name: string, options: {
  64080. pattern?: number;
  64081. size?: number;
  64082. width?: number;
  64083. height?: number;
  64084. depth: number;
  64085. tileSize?: number;
  64086. tileWidth?: number;
  64087. tileHeight?: number;
  64088. faceUV?: Vector4[];
  64089. faceColors?: Color4[];
  64090. alignHorizontal?: number;
  64091. alignVertical?: number;
  64092. sideOrientation?: number;
  64093. updatable?: boolean;
  64094. }, scene?: Nullable<Scene>): Mesh;
  64095. /**
  64096. * Creates a sphere mesh
  64097. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64098. * * 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`)
  64099. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64100. * * 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
  64101. * * 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)
  64102. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64103. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64105. * @param name defines the name of the mesh
  64106. * @param options defines the options used to create the mesh
  64107. * @param scene defines the hosting scene
  64108. * @returns the sphere mesh
  64109. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64110. */
  64111. static CreateSphere(name: string, options: {
  64112. segments?: number;
  64113. diameter?: number;
  64114. diameterX?: number;
  64115. diameterY?: number;
  64116. diameterZ?: number;
  64117. arc?: number;
  64118. slice?: number;
  64119. sideOrientation?: number;
  64120. frontUVs?: Vector4;
  64121. backUVs?: Vector4;
  64122. updatable?: boolean;
  64123. }, scene?: Nullable<Scene>): Mesh;
  64124. /**
  64125. * Creates a plane polygonal mesh. By default, this is a disc
  64126. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64127. * * 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
  64128. * * 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
  64129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64130. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64132. * @param name defines the name of the mesh
  64133. * @param options defines the options used to create the mesh
  64134. * @param scene defines the hosting scene
  64135. * @returns the plane polygonal mesh
  64136. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64137. */
  64138. static CreateDisc(name: string, options: {
  64139. radius?: number;
  64140. tessellation?: number;
  64141. arc?: number;
  64142. updatable?: boolean;
  64143. sideOrientation?: number;
  64144. frontUVs?: Vector4;
  64145. backUVs?: Vector4;
  64146. }, scene?: Nullable<Scene>): Mesh;
  64147. /**
  64148. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64149. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64150. * * 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`)
  64151. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64152. * * 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
  64153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64154. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64156. * @param name defines the name of the mesh
  64157. * @param options defines the options used to create the mesh
  64158. * @param scene defines the hosting scene
  64159. * @returns the icosahedron mesh
  64160. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64161. */
  64162. static CreateIcoSphere(name: string, options: {
  64163. radius?: number;
  64164. radiusX?: number;
  64165. radiusY?: number;
  64166. radiusZ?: number;
  64167. flat?: boolean;
  64168. subdivisions?: number;
  64169. sideOrientation?: number;
  64170. frontUVs?: Vector4;
  64171. backUVs?: Vector4;
  64172. updatable?: boolean;
  64173. }, scene?: Nullable<Scene>): Mesh;
  64174. /**
  64175. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64176. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64177. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64178. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64179. * * 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
  64180. * * 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
  64181. * * 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
  64182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64183. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64184. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64185. * * 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
  64186. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64187. * * 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
  64188. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64190. * @param name defines the name of the mesh
  64191. * @param options defines the options used to create the mesh
  64192. * @param scene defines the hosting scene
  64193. * @returns the ribbon mesh
  64194. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64195. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64196. */
  64197. static CreateRibbon(name: string, options: {
  64198. pathArray: Vector3[][];
  64199. closeArray?: boolean;
  64200. closePath?: boolean;
  64201. offset?: number;
  64202. updatable?: boolean;
  64203. sideOrientation?: number;
  64204. frontUVs?: Vector4;
  64205. backUVs?: Vector4;
  64206. instance?: Mesh;
  64207. invertUV?: boolean;
  64208. uvs?: Vector2[];
  64209. colors?: Color4[];
  64210. }, scene?: Nullable<Scene>): Mesh;
  64211. /**
  64212. * Creates a cylinder or a cone mesh
  64213. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64214. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64215. * * 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.
  64216. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64217. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64218. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64219. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64220. * * 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).
  64221. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64222. * * 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).
  64223. * * 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
  64224. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64225. * * 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
  64226. * * 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.
  64227. * * If `enclose` is false, a ring surface is one element.
  64228. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64229. * * 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
  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. * @param name defines the name of the mesh
  64234. * @param options defines the options used to create the mesh
  64235. * @param scene defines the hosting scene
  64236. * @returns the cylinder mesh
  64237. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64238. */
  64239. static CreateCylinder(name: string, options: {
  64240. height?: number;
  64241. diameterTop?: number;
  64242. diameterBottom?: number;
  64243. diameter?: number;
  64244. tessellation?: number;
  64245. subdivisions?: number;
  64246. arc?: number;
  64247. faceColors?: Color4[];
  64248. faceUV?: Vector4[];
  64249. updatable?: boolean;
  64250. hasRings?: boolean;
  64251. enclose?: boolean;
  64252. cap?: number;
  64253. sideOrientation?: number;
  64254. frontUVs?: Vector4;
  64255. backUVs?: Vector4;
  64256. }, scene?: Nullable<Scene>): Mesh;
  64257. /**
  64258. * Creates a torus mesh
  64259. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64260. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64261. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64265. * @param name defines the name of the mesh
  64266. * @param options defines the options used to create the mesh
  64267. * @param scene defines the hosting scene
  64268. * @returns the torus mesh
  64269. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64270. */
  64271. static CreateTorus(name: string, options: {
  64272. diameter?: number;
  64273. thickness?: number;
  64274. tessellation?: number;
  64275. updatable?: boolean;
  64276. sideOrientation?: number;
  64277. frontUVs?: Vector4;
  64278. backUVs?: Vector4;
  64279. }, scene?: Nullable<Scene>): Mesh;
  64280. /**
  64281. * Creates a torus knot mesh
  64282. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64283. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64284. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64285. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64286. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64287. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64289. * @param name defines the name of the mesh
  64290. * @param options defines the options used to create the mesh
  64291. * @param scene defines the hosting scene
  64292. * @returns the torus knot mesh
  64293. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64294. */
  64295. static CreateTorusKnot(name: string, options: {
  64296. radius?: number;
  64297. tube?: number;
  64298. radialSegments?: number;
  64299. tubularSegments?: number;
  64300. p?: number;
  64301. q?: number;
  64302. updatable?: boolean;
  64303. sideOrientation?: number;
  64304. frontUVs?: Vector4;
  64305. backUVs?: Vector4;
  64306. }, scene?: Nullable<Scene>): Mesh;
  64307. /**
  64308. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64309. * * 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
  64310. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64311. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64312. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64313. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64314. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64315. * * 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
  64316. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64318. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64319. * @param name defines the name of the new line system
  64320. * @param options defines the options used to create the line system
  64321. * @param scene defines the hosting scene
  64322. * @returns a new line system mesh
  64323. */
  64324. static CreateLineSystem(name: string, options: {
  64325. lines: Vector3[][];
  64326. updatable?: boolean;
  64327. instance?: Nullable<LinesMesh>;
  64328. colors?: Nullable<Color4[][]>;
  64329. useVertexAlpha?: boolean;
  64330. }, scene: Nullable<Scene>): LinesMesh;
  64331. /**
  64332. * Creates a line mesh
  64333. * 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
  64334. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64335. * * The parameter `points` is an array successive Vector3
  64336. * * 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
  64337. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64338. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64339. * * When updating an instance, remember that only point positions can change, not the number of points
  64340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64341. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64342. * @param name defines the name of the new line system
  64343. * @param options defines the options used to create the line system
  64344. * @param scene defines the hosting scene
  64345. * @returns a new line mesh
  64346. */
  64347. static CreateLines(name: string, options: {
  64348. points: Vector3[];
  64349. updatable?: boolean;
  64350. instance?: Nullable<LinesMesh>;
  64351. colors?: Color4[];
  64352. useVertexAlpha?: boolean;
  64353. }, scene?: Nullable<Scene>): LinesMesh;
  64354. /**
  64355. * Creates a dashed line mesh
  64356. * * 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
  64357. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64358. * * The parameter `points` is an array successive Vector3
  64359. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64360. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64361. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64362. * * 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
  64363. * * When updating an instance, remember that only point positions can change, not the number of points
  64364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64365. * @param name defines the name of the mesh
  64366. * @param options defines the options used to create the mesh
  64367. * @param scene defines the hosting scene
  64368. * @returns the dashed line mesh
  64369. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64370. */
  64371. static CreateDashedLines(name: string, options: {
  64372. points: Vector3[];
  64373. dashSize?: number;
  64374. gapSize?: number;
  64375. dashNb?: number;
  64376. updatable?: boolean;
  64377. instance?: LinesMesh;
  64378. }, scene?: Nullable<Scene>): LinesMesh;
  64379. /**
  64380. * 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.
  64381. * * 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.
  64382. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64383. * * 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.
  64384. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64385. * * 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
  64386. * * 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
  64387. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64390. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64392. * @param name defines the name of the mesh
  64393. * @param options defines the options used to create the mesh
  64394. * @param scene defines the hosting scene
  64395. * @returns the extruded shape mesh
  64396. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64397. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64398. */
  64399. static ExtrudeShape(name: string, options: {
  64400. shape: Vector3[];
  64401. path: Vector3[];
  64402. scale?: number;
  64403. rotation?: number;
  64404. cap?: number;
  64405. updatable?: boolean;
  64406. sideOrientation?: number;
  64407. frontUVs?: Vector4;
  64408. backUVs?: Vector4;
  64409. instance?: Mesh;
  64410. invertUV?: boolean;
  64411. }, scene?: Nullable<Scene>): Mesh;
  64412. /**
  64413. * Creates an custom extruded shape mesh.
  64414. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64415. * * 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.
  64416. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64417. * * 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
  64418. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64419. * * 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
  64420. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64421. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64422. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64423. * * 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
  64424. * * 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
  64425. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64427. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64428. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64430. * @param name defines the name of the mesh
  64431. * @param options defines the options used to create the mesh
  64432. * @param scene defines the hosting scene
  64433. * @returns the custom extruded shape mesh
  64434. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64435. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64436. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64437. */
  64438. static ExtrudeShapeCustom(name: string, options: {
  64439. shape: Vector3[];
  64440. path: Vector3[];
  64441. scaleFunction?: any;
  64442. rotationFunction?: any;
  64443. ribbonCloseArray?: boolean;
  64444. ribbonClosePath?: boolean;
  64445. cap?: number;
  64446. updatable?: boolean;
  64447. sideOrientation?: number;
  64448. frontUVs?: Vector4;
  64449. backUVs?: Vector4;
  64450. instance?: Mesh;
  64451. invertUV?: boolean;
  64452. }, scene?: Nullable<Scene>): Mesh;
  64453. /**
  64454. * Creates lathe mesh.
  64455. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64456. * * 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
  64457. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64458. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64459. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64460. * * 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
  64461. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64462. * * 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
  64463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64464. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64465. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64467. * @param name defines the name of the mesh
  64468. * @param options defines the options used to create the mesh
  64469. * @param scene defines the hosting scene
  64470. * @returns the lathe mesh
  64471. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64472. */
  64473. static CreateLathe(name: string, options: {
  64474. shape: Vector3[];
  64475. radius?: number;
  64476. tessellation?: number;
  64477. clip?: number;
  64478. arc?: number;
  64479. closed?: boolean;
  64480. updatable?: boolean;
  64481. sideOrientation?: number;
  64482. frontUVs?: Vector4;
  64483. backUVs?: Vector4;
  64484. cap?: number;
  64485. invertUV?: boolean;
  64486. }, scene?: Nullable<Scene>): Mesh;
  64487. /**
  64488. * Creates a tiled plane mesh
  64489. * * You can set a limited pattern arrangement with the tiles
  64490. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64491. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64493. * @param name defines the name of the mesh
  64494. * @param options defines the options used to create the mesh
  64495. * @param scene defines the hosting scene
  64496. * @returns the plane mesh
  64497. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64498. */
  64499. static CreateTiledPlane(name: string, options: {
  64500. pattern?: number;
  64501. tileSize?: number;
  64502. tileWidth?: number;
  64503. tileHeight?: number;
  64504. size?: number;
  64505. width?: number;
  64506. height?: number;
  64507. alignHorizontal?: number;
  64508. alignVertical?: number;
  64509. sideOrientation?: number;
  64510. frontUVs?: Vector4;
  64511. backUVs?: Vector4;
  64512. updatable?: boolean;
  64513. }, scene?: Nullable<Scene>): Mesh;
  64514. /**
  64515. * Creates a plane mesh
  64516. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64517. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64518. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64520. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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. * @param name defines the name of the mesh
  64523. * @param options defines the options used to create the mesh
  64524. * @param scene defines the hosting scene
  64525. * @returns the plane mesh
  64526. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64527. */
  64528. static CreatePlane(name: string, options: {
  64529. size?: number;
  64530. width?: number;
  64531. height?: number;
  64532. sideOrientation?: number;
  64533. frontUVs?: Vector4;
  64534. backUVs?: Vector4;
  64535. updatable?: boolean;
  64536. sourcePlane?: Plane;
  64537. }, scene?: Nullable<Scene>): Mesh;
  64538. /**
  64539. * Creates a ground mesh
  64540. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64541. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64543. * @param name defines the name of the mesh
  64544. * @param options defines the options used to create the mesh
  64545. * @param scene defines the hosting scene
  64546. * @returns the ground mesh
  64547. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64548. */
  64549. static CreateGround(name: string, options: {
  64550. width?: number;
  64551. height?: number;
  64552. subdivisions?: number;
  64553. subdivisionsX?: number;
  64554. subdivisionsY?: number;
  64555. updatable?: boolean;
  64556. }, scene?: Nullable<Scene>): Mesh;
  64557. /**
  64558. * Creates a tiled ground mesh
  64559. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64560. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64561. * * 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
  64562. * * 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
  64563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64564. * @param name defines the name of the mesh
  64565. * @param options defines the options used to create the mesh
  64566. * @param scene defines the hosting scene
  64567. * @returns the tiled ground mesh
  64568. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64569. */
  64570. static CreateTiledGround(name: string, options: {
  64571. xmin: number;
  64572. zmin: number;
  64573. xmax: number;
  64574. zmax: number;
  64575. subdivisions?: {
  64576. w: number;
  64577. h: number;
  64578. };
  64579. precision?: {
  64580. w: number;
  64581. h: number;
  64582. };
  64583. updatable?: boolean;
  64584. }, scene?: Nullable<Scene>): Mesh;
  64585. /**
  64586. * Creates a ground mesh from a height map
  64587. * * The parameter `url` sets the URL of the height map image resource.
  64588. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64589. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64590. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64591. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64592. * * 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.
  64593. * * 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).
  64594. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64596. * @param name defines the name of the mesh
  64597. * @param url defines the url to the height map
  64598. * @param options defines the options used to create the mesh
  64599. * @param scene defines the hosting scene
  64600. * @returns the ground mesh
  64601. * @see https://doc.babylonjs.com/babylon101/height_map
  64602. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64603. */
  64604. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64605. width?: number;
  64606. height?: number;
  64607. subdivisions?: number;
  64608. minHeight?: number;
  64609. maxHeight?: number;
  64610. colorFilter?: Color3;
  64611. alphaFilter?: number;
  64612. updatable?: boolean;
  64613. onReady?: (mesh: GroundMesh) => void;
  64614. }, scene?: Nullable<Scene>): GroundMesh;
  64615. /**
  64616. * Creates a polygon mesh
  64617. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64618. * * 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
  64619. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64621. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64622. * * Remember you can only change the shape positions, not their number when updating a polygon
  64623. * @param name defines the name of the mesh
  64624. * @param options defines the options used to create the mesh
  64625. * @param scene defines the hosting scene
  64626. * @param earcutInjection can be used to inject your own earcut reference
  64627. * @returns the polygon mesh
  64628. */
  64629. static CreatePolygon(name: string, options: {
  64630. shape: Vector3[];
  64631. holes?: Vector3[][];
  64632. depth?: number;
  64633. faceUV?: Vector4[];
  64634. faceColors?: Color4[];
  64635. updatable?: boolean;
  64636. sideOrientation?: number;
  64637. frontUVs?: Vector4;
  64638. backUVs?: Vector4;
  64639. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64640. /**
  64641. * Creates an extruded polygon mesh, with depth in the Y direction.
  64642. * * 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)
  64643. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64644. * @param name defines the name of the mesh
  64645. * @param options defines the options used to create the mesh
  64646. * @param scene defines the hosting scene
  64647. * @param earcutInjection can be used to inject your own earcut reference
  64648. * @returns the polygon mesh
  64649. */
  64650. static ExtrudePolygon(name: string, options: {
  64651. shape: Vector3[];
  64652. holes?: Vector3[][];
  64653. depth?: number;
  64654. faceUV?: Vector4[];
  64655. faceColors?: Color4[];
  64656. updatable?: boolean;
  64657. sideOrientation?: number;
  64658. frontUVs?: Vector4;
  64659. backUVs?: Vector4;
  64660. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64661. /**
  64662. * Creates a tube mesh.
  64663. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64664. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64665. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64666. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64667. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64668. * * 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)
  64669. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64670. * * 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
  64671. * * 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
  64672. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64673. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64674. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64676. * @param name defines the name of the mesh
  64677. * @param options defines the options used to create the mesh
  64678. * @param scene defines the hosting scene
  64679. * @returns the tube mesh
  64680. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64681. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64682. */
  64683. static CreateTube(name: string, options: {
  64684. path: Vector3[];
  64685. radius?: number;
  64686. tessellation?: number;
  64687. radiusFunction?: {
  64688. (i: number, distance: number): number;
  64689. };
  64690. cap?: number;
  64691. arc?: number;
  64692. updatable?: boolean;
  64693. sideOrientation?: number;
  64694. frontUVs?: Vector4;
  64695. backUVs?: Vector4;
  64696. instance?: Mesh;
  64697. invertUV?: boolean;
  64698. }, scene?: Nullable<Scene>): Mesh;
  64699. /**
  64700. * Creates a polyhedron mesh
  64701. * * 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
  64702. * * The parameter `size` (positive float, default 1) sets the polygon size
  64703. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64704. * * 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`
  64705. * * 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
  64706. * * 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)`)
  64707. * * 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
  64708. * * 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
  64709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64710. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64712. * @param name defines the name of the mesh
  64713. * @param options defines the options used to create the mesh
  64714. * @param scene defines the hosting scene
  64715. * @returns the polyhedron mesh
  64716. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64717. */
  64718. static CreatePolyhedron(name: string, options: {
  64719. type?: number;
  64720. size?: number;
  64721. sizeX?: number;
  64722. sizeY?: number;
  64723. sizeZ?: number;
  64724. custom?: any;
  64725. faceUV?: Vector4[];
  64726. faceColors?: Color4[];
  64727. flat?: boolean;
  64728. updatable?: boolean;
  64729. sideOrientation?: number;
  64730. frontUVs?: Vector4;
  64731. backUVs?: Vector4;
  64732. }, scene?: Nullable<Scene>): Mesh;
  64733. /**
  64734. * Creates a decal mesh.
  64735. * 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
  64736. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64737. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64738. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64739. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64740. * @param name defines the name of the mesh
  64741. * @param sourceMesh defines the mesh where the decal must be applied
  64742. * @param options defines the options used to create the mesh
  64743. * @param scene defines the hosting scene
  64744. * @returns the decal mesh
  64745. * @see https://doc.babylonjs.com/how_to/decals
  64746. */
  64747. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64748. position?: Vector3;
  64749. normal?: Vector3;
  64750. size?: Vector3;
  64751. angle?: number;
  64752. }): Mesh;
  64753. }
  64754. }
  64755. declare module "babylonjs/Meshes/meshSimplification" {
  64756. import { Mesh } from "babylonjs/Meshes/mesh";
  64757. /**
  64758. * A simplifier interface for future simplification implementations
  64759. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64760. */
  64761. export interface ISimplifier {
  64762. /**
  64763. * Simplification of a given mesh according to the given settings.
  64764. * Since this requires computation, it is assumed that the function runs async.
  64765. * @param settings The settings of the simplification, including quality and distance
  64766. * @param successCallback A callback that will be called after the mesh was simplified.
  64767. * @param errorCallback in case of an error, this callback will be called. optional.
  64768. */
  64769. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64770. }
  64771. /**
  64772. * Expected simplification settings.
  64773. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64774. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64775. */
  64776. export interface ISimplificationSettings {
  64777. /**
  64778. * Gets or sets the expected quality
  64779. */
  64780. quality: number;
  64781. /**
  64782. * Gets or sets the distance when this optimized version should be used
  64783. */
  64784. distance: number;
  64785. /**
  64786. * Gets an already optimized mesh
  64787. */
  64788. optimizeMesh?: boolean;
  64789. }
  64790. /**
  64791. * Class used to specify simplification options
  64792. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64793. */
  64794. export class SimplificationSettings implements ISimplificationSettings {
  64795. /** expected quality */
  64796. quality: number;
  64797. /** distance when this optimized version should be used */
  64798. distance: number;
  64799. /** already optimized mesh */
  64800. optimizeMesh?: boolean | undefined;
  64801. /**
  64802. * Creates a SimplificationSettings
  64803. * @param quality expected quality
  64804. * @param distance distance when this optimized version should be used
  64805. * @param optimizeMesh already optimized mesh
  64806. */
  64807. constructor(
  64808. /** expected quality */
  64809. quality: number,
  64810. /** distance when this optimized version should be used */
  64811. distance: number,
  64812. /** already optimized mesh */
  64813. optimizeMesh?: boolean | undefined);
  64814. }
  64815. /**
  64816. * Interface used to define a simplification task
  64817. */
  64818. export interface ISimplificationTask {
  64819. /**
  64820. * Array of settings
  64821. */
  64822. settings: Array<ISimplificationSettings>;
  64823. /**
  64824. * Simplification type
  64825. */
  64826. simplificationType: SimplificationType;
  64827. /**
  64828. * Mesh to simplify
  64829. */
  64830. mesh: Mesh;
  64831. /**
  64832. * Callback called on success
  64833. */
  64834. successCallback?: () => void;
  64835. /**
  64836. * Defines if parallel processing can be used
  64837. */
  64838. parallelProcessing: boolean;
  64839. }
  64840. /**
  64841. * Queue used to order the simplification tasks
  64842. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64843. */
  64844. export class SimplificationQueue {
  64845. private _simplificationArray;
  64846. /**
  64847. * Gets a boolean indicating that the process is still running
  64848. */
  64849. running: boolean;
  64850. /**
  64851. * Creates a new queue
  64852. */
  64853. constructor();
  64854. /**
  64855. * Adds a new simplification task
  64856. * @param task defines a task to add
  64857. */
  64858. addTask(task: ISimplificationTask): void;
  64859. /**
  64860. * Execute next task
  64861. */
  64862. executeNext(): void;
  64863. /**
  64864. * Execute a simplification task
  64865. * @param task defines the task to run
  64866. */
  64867. runSimplification(task: ISimplificationTask): void;
  64868. private getSimplifier;
  64869. }
  64870. /**
  64871. * The implemented types of simplification
  64872. * At the moment only Quadratic Error Decimation is implemented
  64873. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64874. */
  64875. export enum SimplificationType {
  64876. /** Quadratic error decimation */
  64877. QUADRATIC = 0
  64878. }
  64879. }
  64880. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  64881. import { Scene } from "babylonjs/scene";
  64882. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  64883. import { ISceneComponent } from "babylonjs/sceneComponent";
  64884. module "babylonjs/scene" {
  64885. interface Scene {
  64886. /** @hidden (Backing field) */
  64887. _simplificationQueue: SimplificationQueue;
  64888. /**
  64889. * Gets or sets the simplification queue attached to the scene
  64890. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64891. */
  64892. simplificationQueue: SimplificationQueue;
  64893. }
  64894. }
  64895. module "babylonjs/Meshes/mesh" {
  64896. interface Mesh {
  64897. /**
  64898. * Simplify the mesh according to the given array of settings.
  64899. * Function will return immediately and will simplify async
  64900. * @param settings a collection of simplification settings
  64901. * @param parallelProcessing should all levels calculate parallel or one after the other
  64902. * @param simplificationType the type of simplification to run
  64903. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64904. * @returns the current mesh
  64905. */
  64906. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64907. }
  64908. }
  64909. /**
  64910. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64911. * created in a scene
  64912. */
  64913. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64914. /**
  64915. * The component name helpfull to identify the component in the list of scene components.
  64916. */
  64917. readonly name: string;
  64918. /**
  64919. * The scene the component belongs to.
  64920. */
  64921. scene: Scene;
  64922. /**
  64923. * Creates a new instance of the component for the given scene
  64924. * @param scene Defines the scene to register the component in
  64925. */
  64926. constructor(scene: Scene);
  64927. /**
  64928. * Registers the component in a given scene
  64929. */
  64930. register(): void;
  64931. /**
  64932. * Rebuilds the elements related to this component in case of
  64933. * context lost for instance.
  64934. */
  64935. rebuild(): void;
  64936. /**
  64937. * Disposes the component and the associated ressources
  64938. */
  64939. dispose(): void;
  64940. private _beforeCameraUpdate;
  64941. }
  64942. }
  64943. declare module "babylonjs/Meshes/Builders/index" {
  64944. export * from "babylonjs/Meshes/Builders/boxBuilder";
  64945. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  64946. export * from "babylonjs/Meshes/Builders/discBuilder";
  64947. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  64948. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  64949. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  64950. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  64951. export * from "babylonjs/Meshes/Builders/torusBuilder";
  64952. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  64953. export * from "babylonjs/Meshes/Builders/linesBuilder";
  64954. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  64955. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  64956. export * from "babylonjs/Meshes/Builders/latheBuilder";
  64957. export * from "babylonjs/Meshes/Builders/planeBuilder";
  64958. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  64959. export * from "babylonjs/Meshes/Builders/groundBuilder";
  64960. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  64961. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  64962. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  64963. export * from "babylonjs/Meshes/Builders/decalBuilder";
  64964. }
  64965. declare module "babylonjs/Meshes/index" {
  64966. export * from "babylonjs/Meshes/abstractMesh";
  64967. export * from "babylonjs/Meshes/buffer";
  64968. export * from "babylonjs/Meshes/Compression/index";
  64969. export * from "babylonjs/Meshes/csg";
  64970. export * from "babylonjs/Meshes/geometry";
  64971. export * from "babylonjs/Meshes/groundMesh";
  64972. export * from "babylonjs/Meshes/trailMesh";
  64973. export * from "babylonjs/Meshes/instancedMesh";
  64974. export * from "babylonjs/Meshes/linesMesh";
  64975. export * from "babylonjs/Meshes/mesh";
  64976. export * from "babylonjs/Meshes/mesh.vertexData";
  64977. export * from "babylonjs/Meshes/meshBuilder";
  64978. export * from "babylonjs/Meshes/meshSimplification";
  64979. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  64980. export * from "babylonjs/Meshes/polygonMesh";
  64981. export * from "babylonjs/Meshes/subMesh";
  64982. export * from "babylonjs/Meshes/meshLODLevel";
  64983. export * from "babylonjs/Meshes/transformNode";
  64984. export * from "babylonjs/Meshes/Builders/index";
  64985. export * from "babylonjs/Meshes/dataBuffer";
  64986. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  64987. }
  64988. declare module "babylonjs/Morph/index" {
  64989. export * from "babylonjs/Morph/morphTarget";
  64990. export * from "babylonjs/Morph/morphTargetManager";
  64991. }
  64992. declare module "babylonjs/Navigation/INavigationEngine" {
  64993. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64994. import { Vector3 } from "babylonjs/Maths/math";
  64995. import { Mesh } from "babylonjs/Meshes/mesh";
  64996. import { Scene } from "babylonjs/scene";
  64997. /**
  64998. * Navigation plugin interface to add navigation constrained by a navigation mesh
  64999. */
  65000. export interface INavigationEnginePlugin {
  65001. /**
  65002. * plugin name
  65003. */
  65004. name: string;
  65005. /**
  65006. * Creates a navigation mesh
  65007. * @param meshes array of all the geometry used to compute the navigatio mesh
  65008. * @param parameters bunch of parameters used to filter geometry
  65009. */
  65010. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65011. /**
  65012. * Create a navigation mesh debug mesh
  65013. * @param scene is where the mesh will be added
  65014. * @returns debug display mesh
  65015. */
  65016. createDebugNavMesh(scene: Scene): Mesh;
  65017. /**
  65018. * Get a navigation mesh constrained position, closest to the parameter position
  65019. * @param position world position
  65020. * @returns the closest point to position constrained by the navigation mesh
  65021. */
  65022. getClosestPoint(position: Vector3): Vector3;
  65023. /**
  65024. * Get a navigation mesh constrained position, within a particular radius
  65025. * @param position world position
  65026. * @param maxRadius the maximum distance to the constrained world position
  65027. * @returns the closest point to position constrained by the navigation mesh
  65028. */
  65029. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65030. /**
  65031. * Compute the final position from a segment made of destination-position
  65032. * @param position world position
  65033. * @param destination world position
  65034. * @returns the resulting point along the navmesh
  65035. */
  65036. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65037. /**
  65038. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65039. * @param start world position
  65040. * @param end world position
  65041. * @returns array containing world position composing the path
  65042. */
  65043. computePath(start: Vector3, end: Vector3): Vector3[];
  65044. /**
  65045. * If this plugin is supported
  65046. * @returns true if plugin is supported
  65047. */
  65048. isSupported(): boolean;
  65049. /**
  65050. * Create a new Crowd so you can add agents
  65051. * @param maxAgents the maximum agent count in the crowd
  65052. * @param maxAgentRadius the maximum radius an agent can have
  65053. * @param scene to attach the crowd to
  65054. * @returns the crowd you can add agents to
  65055. */
  65056. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65057. /**
  65058. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65059. * The queries will try to find a solution within those bounds
  65060. * default is (1,1,1)
  65061. * @param extent x,y,z value that define the extent around the queries point of reference
  65062. */
  65063. setDefaultQueryExtent(extent: Vector3): void;
  65064. /**
  65065. * Get the Bounding box extent specified by setDefaultQueryExtent
  65066. * @returns the box extent values
  65067. */
  65068. getDefaultQueryExtent(): Vector3;
  65069. /**
  65070. * Release all resources
  65071. */
  65072. dispose(): void;
  65073. }
  65074. /**
  65075. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65076. */
  65077. export interface ICrowd {
  65078. /**
  65079. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65080. * You can attach anything to that node. The node position is updated in the scene update tick.
  65081. * @param pos world position that will be constrained by the navigation mesh
  65082. * @param parameters agent parameters
  65083. * @param transform hooked to the agent that will be update by the scene
  65084. * @returns agent index
  65085. */
  65086. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65087. /**
  65088. * Returns the agent position in world space
  65089. * @param index agent index returned by addAgent
  65090. * @returns world space position
  65091. */
  65092. getAgentPosition(index: number): Vector3;
  65093. /**
  65094. * Gets the agent velocity in world space
  65095. * @param index agent index returned by addAgent
  65096. * @returns world space velocity
  65097. */
  65098. getAgentVelocity(index: number): Vector3;
  65099. /**
  65100. * remove a particular agent previously created
  65101. * @param index agent index returned by addAgent
  65102. */
  65103. removeAgent(index: number): void;
  65104. /**
  65105. * get the list of all agents attached to this crowd
  65106. * @returns list of agent indices
  65107. */
  65108. getAgents(): number[];
  65109. /**
  65110. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65111. * @param deltaTime in seconds
  65112. */
  65113. update(deltaTime: number): void;
  65114. /**
  65115. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65116. * @param index agent index returned by addAgent
  65117. * @param destination targeted world position
  65118. */
  65119. agentGoto(index: number, destination: Vector3): void;
  65120. /**
  65121. * Teleport the agent to a new position
  65122. * @param index agent index returned by addAgent
  65123. * @param destination targeted world position
  65124. */
  65125. agentTeleport(index: number, destination: Vector3): void;
  65126. /**
  65127. * Update agent parameters
  65128. * @param index agent index returned by addAgent
  65129. * @param parameters agent parameters
  65130. */
  65131. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65132. /**
  65133. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65134. * The queries will try to find a solution within those bounds
  65135. * default is (1,1,1)
  65136. * @param extent x,y,z value that define the extent around the queries point of reference
  65137. */
  65138. setDefaultQueryExtent(extent: Vector3): void;
  65139. /**
  65140. * Get the Bounding box extent specified by setDefaultQueryExtent
  65141. * @returns the box extent values
  65142. */
  65143. getDefaultQueryExtent(): Vector3;
  65144. /**
  65145. * Release all resources
  65146. */
  65147. dispose(): void;
  65148. }
  65149. /**
  65150. * Configures an agent
  65151. */
  65152. export interface IAgentParameters {
  65153. /**
  65154. * Agent radius. [Limit: >= 0]
  65155. */
  65156. radius: number;
  65157. /**
  65158. * Agent height. [Limit: > 0]
  65159. */
  65160. height: number;
  65161. /**
  65162. * Maximum allowed acceleration. [Limit: >= 0]
  65163. */
  65164. maxAcceleration: number;
  65165. /**
  65166. * Maximum allowed speed. [Limit: >= 0]
  65167. */
  65168. maxSpeed: number;
  65169. /**
  65170. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65171. */
  65172. collisionQueryRange: number;
  65173. /**
  65174. * The path visibility optimization range. [Limit: > 0]
  65175. */
  65176. pathOptimizationRange: number;
  65177. /**
  65178. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65179. */
  65180. separationWeight: number;
  65181. }
  65182. /**
  65183. * Configures the navigation mesh creation
  65184. */
  65185. export interface INavMeshParameters {
  65186. /**
  65187. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65188. */
  65189. cs: number;
  65190. /**
  65191. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65192. */
  65193. ch: number;
  65194. /**
  65195. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65196. */
  65197. walkableSlopeAngle: number;
  65198. /**
  65199. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65200. * be considered walkable. [Limit: >= 3] [Units: vx]
  65201. */
  65202. walkableHeight: number;
  65203. /**
  65204. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65205. */
  65206. walkableClimb: number;
  65207. /**
  65208. * The distance to erode/shrink the walkable area of the heightfield away from
  65209. * obstructions. [Limit: >=0] [Units: vx]
  65210. */
  65211. walkableRadius: number;
  65212. /**
  65213. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65214. */
  65215. maxEdgeLen: number;
  65216. /**
  65217. * The maximum distance a simplfied contour's border edges should deviate
  65218. * the original raw contour. [Limit: >=0] [Units: vx]
  65219. */
  65220. maxSimplificationError: number;
  65221. /**
  65222. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65223. */
  65224. minRegionArea: number;
  65225. /**
  65226. * Any regions with a span count smaller than this value will, if possible,
  65227. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65228. */
  65229. mergeRegionArea: number;
  65230. /**
  65231. * The maximum number of vertices allowed for polygons generated during the
  65232. * contour to polygon conversion process. [Limit: >= 3]
  65233. */
  65234. maxVertsPerPoly: number;
  65235. /**
  65236. * Sets the sampling distance to use when generating the detail mesh.
  65237. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65238. */
  65239. detailSampleDist: number;
  65240. /**
  65241. * The maximum distance the detail mesh surface should deviate from heightfield
  65242. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65243. */
  65244. detailSampleMaxError: number;
  65245. }
  65246. }
  65247. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65248. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65249. import { Mesh } from "babylonjs/Meshes/mesh";
  65250. import { Scene } from "babylonjs/scene";
  65251. import { Vector3 } from "babylonjs/Maths/math";
  65252. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65253. /**
  65254. * RecastJS navigation plugin
  65255. */
  65256. export class RecastJSPlugin implements INavigationEnginePlugin {
  65257. /**
  65258. * Reference to the Recast library
  65259. */
  65260. bjsRECAST: any;
  65261. /**
  65262. * plugin name
  65263. */
  65264. name: string;
  65265. /**
  65266. * the first navmesh created. We might extend this to support multiple navmeshes
  65267. */
  65268. navMesh: any;
  65269. /**
  65270. * Initializes the recastJS plugin
  65271. * @param recastInjection can be used to inject your own recast reference
  65272. */
  65273. constructor(recastInjection?: any);
  65274. /**
  65275. * Creates a navigation mesh
  65276. * @param meshes array of all the geometry used to compute the navigatio mesh
  65277. * @param parameters bunch of parameters used to filter geometry
  65278. */
  65279. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65280. /**
  65281. * Create a navigation mesh debug mesh
  65282. * @param scene is where the mesh will be added
  65283. * @returns debug display mesh
  65284. */
  65285. createDebugNavMesh(scene: Scene): Mesh;
  65286. /**
  65287. * Get a navigation mesh constrained position, closest to the parameter position
  65288. * @param position world position
  65289. * @returns the closest point to position constrained by the navigation mesh
  65290. */
  65291. getClosestPoint(position: Vector3): Vector3;
  65292. /**
  65293. * Get a navigation mesh constrained position, within a particular radius
  65294. * @param position world position
  65295. * @param maxRadius the maximum distance to the constrained world position
  65296. * @returns the closest point to position constrained by the navigation mesh
  65297. */
  65298. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65299. /**
  65300. * Compute the final position from a segment made of destination-position
  65301. * @param position world position
  65302. * @param destination world position
  65303. * @returns the resulting point along the navmesh
  65304. */
  65305. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65306. /**
  65307. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65308. * @param start world position
  65309. * @param end world position
  65310. * @returns array containing world position composing the path
  65311. */
  65312. computePath(start: Vector3, end: Vector3): Vector3[];
  65313. /**
  65314. * Create a new Crowd so you can add agents
  65315. * @param maxAgents the maximum agent count in the crowd
  65316. * @param maxAgentRadius the maximum radius an agent can have
  65317. * @param scene to attach the crowd to
  65318. * @returns the crowd you can add agents to
  65319. */
  65320. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65321. /**
  65322. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65323. * The queries will try to find a solution within those bounds
  65324. * default is (1,1,1)
  65325. * @param extent x,y,z value that define the extent around the queries point of reference
  65326. */
  65327. setDefaultQueryExtent(extent: Vector3): void;
  65328. /**
  65329. * Get the Bounding box extent specified by setDefaultQueryExtent
  65330. * @returns the box extent values
  65331. */
  65332. getDefaultQueryExtent(): Vector3;
  65333. /**
  65334. * Disposes
  65335. */
  65336. dispose(): void;
  65337. /**
  65338. * If this plugin is supported
  65339. * @returns true if plugin is supported
  65340. */
  65341. isSupported(): boolean;
  65342. }
  65343. /**
  65344. * Recast detour crowd implementation
  65345. */
  65346. export class RecastJSCrowd implements ICrowd {
  65347. /**
  65348. * Recast/detour plugin
  65349. */
  65350. bjsRECASTPlugin: RecastJSPlugin;
  65351. /**
  65352. * Link to the detour crowd
  65353. */
  65354. recastCrowd: any;
  65355. /**
  65356. * One transform per agent
  65357. */
  65358. transforms: TransformNode[];
  65359. /**
  65360. * All agents created
  65361. */
  65362. agents: number[];
  65363. /**
  65364. * Link to the scene is kept to unregister the crowd from the scene
  65365. */
  65366. private _scene;
  65367. /**
  65368. * Observer for crowd updates
  65369. */
  65370. private _onBeforeAnimationsObserver;
  65371. /**
  65372. * Constructor
  65373. * @param plugin recastJS plugin
  65374. * @param maxAgents the maximum agent count in the crowd
  65375. * @param maxAgentRadius the maximum radius an agent can have
  65376. * @param scene to attach the crowd to
  65377. * @returns the crowd you can add agents to
  65378. */
  65379. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65380. /**
  65381. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65382. * You can attach anything to that node. The node position is updated in the scene update tick.
  65383. * @param pos world position that will be constrained by the navigation mesh
  65384. * @param parameters agent parameters
  65385. * @param transform hooked to the agent that will be update by the scene
  65386. * @returns agent index
  65387. */
  65388. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65389. /**
  65390. * Returns the agent position in world space
  65391. * @param index agent index returned by addAgent
  65392. * @returns world space position
  65393. */
  65394. getAgentPosition(index: number): Vector3;
  65395. /**
  65396. * Returns the agent velocity in world space
  65397. * @param index agent index returned by addAgent
  65398. * @returns world space velocity
  65399. */
  65400. getAgentVelocity(index: number): Vector3;
  65401. /**
  65402. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65403. * @param index agent index returned by addAgent
  65404. * @param destination targeted world position
  65405. */
  65406. agentGoto(index: number, destination: Vector3): void;
  65407. /**
  65408. * Teleport the agent to a new position
  65409. * @param index agent index returned by addAgent
  65410. * @param destination targeted world position
  65411. */
  65412. agentTeleport(index: number, destination: Vector3): void;
  65413. /**
  65414. * Update agent parameters
  65415. * @param index agent index returned by addAgent
  65416. * @param parameters agent parameters
  65417. */
  65418. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65419. /**
  65420. * remove a particular agent previously created
  65421. * @param index agent index returned by addAgent
  65422. */
  65423. removeAgent(index: number): void;
  65424. /**
  65425. * get the list of all agents attached to this crowd
  65426. * @returns list of agent indices
  65427. */
  65428. getAgents(): number[];
  65429. /**
  65430. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65431. * @param deltaTime in seconds
  65432. */
  65433. update(deltaTime: number): void;
  65434. /**
  65435. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65436. * The queries will try to find a solution within those bounds
  65437. * default is (1,1,1)
  65438. * @param extent x,y,z value that define the extent around the queries point of reference
  65439. */
  65440. setDefaultQueryExtent(extent: Vector3): void;
  65441. /**
  65442. * Get the Bounding box extent specified by setDefaultQueryExtent
  65443. * @returns the box extent values
  65444. */
  65445. getDefaultQueryExtent(): Vector3;
  65446. /**
  65447. * Release all resources
  65448. */
  65449. dispose(): void;
  65450. }
  65451. }
  65452. declare module "babylonjs/Navigation/Plugins/index" {
  65453. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65454. }
  65455. declare module "babylonjs/Navigation/index" {
  65456. export * from "babylonjs/Navigation/INavigationEngine";
  65457. export * from "babylonjs/Navigation/Plugins/index";
  65458. }
  65459. declare module "babylonjs/Offline/database" {
  65460. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65461. /**
  65462. * Class used to enable access to IndexedDB
  65463. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65464. */
  65465. export class Database implements IOfflineProvider {
  65466. private _callbackManifestChecked;
  65467. private _currentSceneUrl;
  65468. private _db;
  65469. private _enableSceneOffline;
  65470. private _enableTexturesOffline;
  65471. private _manifestVersionFound;
  65472. private _mustUpdateRessources;
  65473. private _hasReachedQuota;
  65474. private _isSupported;
  65475. private _idbFactory;
  65476. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65477. private static IsUASupportingBlobStorage;
  65478. /**
  65479. * Gets a boolean indicating if Database storate is enabled (off by default)
  65480. */
  65481. static IDBStorageEnabled: boolean;
  65482. /**
  65483. * Gets a boolean indicating if scene must be saved in the database
  65484. */
  65485. get enableSceneOffline(): boolean;
  65486. /**
  65487. * Gets a boolean indicating if textures must be saved in the database
  65488. */
  65489. get enableTexturesOffline(): boolean;
  65490. /**
  65491. * Creates a new Database
  65492. * @param urlToScene defines the url to load the scene
  65493. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65494. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65495. */
  65496. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65497. private static _ParseURL;
  65498. private static _ReturnFullUrlLocation;
  65499. private _checkManifestFile;
  65500. /**
  65501. * Open the database and make it available
  65502. * @param successCallback defines the callback to call on success
  65503. * @param errorCallback defines the callback to call on error
  65504. */
  65505. open(successCallback: () => void, errorCallback: () => void): void;
  65506. /**
  65507. * Loads an image from the database
  65508. * @param url defines the url to load from
  65509. * @param image defines the target DOM image
  65510. */
  65511. loadImage(url: string, image: HTMLImageElement): void;
  65512. private _loadImageFromDBAsync;
  65513. private _saveImageIntoDBAsync;
  65514. private _checkVersionFromDB;
  65515. private _loadVersionFromDBAsync;
  65516. private _saveVersionIntoDBAsync;
  65517. /**
  65518. * Loads a file from database
  65519. * @param url defines the URL to load from
  65520. * @param sceneLoaded defines a callback to call on success
  65521. * @param progressCallBack defines a callback to call when progress changed
  65522. * @param errorCallback defines a callback to call on error
  65523. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65524. */
  65525. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65526. private _loadFileAsync;
  65527. private _saveFileAsync;
  65528. /**
  65529. * Validates if xhr data is correct
  65530. * @param xhr defines the request to validate
  65531. * @param dataType defines the expected data type
  65532. * @returns true if data is correct
  65533. */
  65534. private static _ValidateXHRData;
  65535. }
  65536. }
  65537. declare module "babylonjs/Offline/index" {
  65538. export * from "babylonjs/Offline/database";
  65539. export * from "babylonjs/Offline/IOfflineProvider";
  65540. }
  65541. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65542. /** @hidden */
  65543. export var gpuUpdateParticlesPixelShader: {
  65544. name: string;
  65545. shader: string;
  65546. };
  65547. }
  65548. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65549. /** @hidden */
  65550. export var gpuUpdateParticlesVertexShader: {
  65551. name: string;
  65552. shader: string;
  65553. };
  65554. }
  65555. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65556. /** @hidden */
  65557. export var clipPlaneFragmentDeclaration2: {
  65558. name: string;
  65559. shader: string;
  65560. };
  65561. }
  65562. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65563. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65564. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65565. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65566. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65567. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65568. /** @hidden */
  65569. export var gpuRenderParticlesPixelShader: {
  65570. name: string;
  65571. shader: string;
  65572. };
  65573. }
  65574. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65575. /** @hidden */
  65576. export var clipPlaneVertexDeclaration2: {
  65577. name: string;
  65578. shader: string;
  65579. };
  65580. }
  65581. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65582. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65583. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65584. /** @hidden */
  65585. export var gpuRenderParticlesVertexShader: {
  65586. name: string;
  65587. shader: string;
  65588. };
  65589. }
  65590. declare module "babylonjs/Particles/gpuParticleSystem" {
  65591. import { Nullable } from "babylonjs/types";
  65592. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65593. import { Observable } from "babylonjs/Misc/observable";
  65594. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65595. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65596. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65597. import { Scene, IDisposable } from "babylonjs/scene";
  65598. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65599. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65600. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65601. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65602. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65603. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65604. /**
  65605. * This represents a GPU particle system in Babylon
  65606. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65607. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65608. */
  65609. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65610. /**
  65611. * The layer mask we are rendering the particles through.
  65612. */
  65613. layerMask: number;
  65614. private _capacity;
  65615. private _activeCount;
  65616. private _currentActiveCount;
  65617. private _accumulatedCount;
  65618. private _renderEffect;
  65619. private _updateEffect;
  65620. private _buffer0;
  65621. private _buffer1;
  65622. private _spriteBuffer;
  65623. private _updateVAO;
  65624. private _renderVAO;
  65625. private _targetIndex;
  65626. private _sourceBuffer;
  65627. private _targetBuffer;
  65628. private _engine;
  65629. private _currentRenderId;
  65630. private _started;
  65631. private _stopped;
  65632. private _timeDelta;
  65633. private _randomTexture;
  65634. private _randomTexture2;
  65635. private _attributesStrideSize;
  65636. private _updateEffectOptions;
  65637. private _randomTextureSize;
  65638. private _actualFrame;
  65639. private readonly _rawTextureWidth;
  65640. /**
  65641. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65642. */
  65643. static get IsSupported(): boolean;
  65644. /**
  65645. * An event triggered when the system is disposed.
  65646. */
  65647. onDisposeObservable: Observable<GPUParticleSystem>;
  65648. /**
  65649. * Gets the maximum number of particles active at the same time.
  65650. * @returns The max number of active particles.
  65651. */
  65652. getCapacity(): number;
  65653. /**
  65654. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65655. * to override the particles.
  65656. */
  65657. forceDepthWrite: boolean;
  65658. /**
  65659. * Gets or set the number of active particles
  65660. */
  65661. get activeParticleCount(): number;
  65662. set activeParticleCount(value: number);
  65663. private _preWarmDone;
  65664. /**
  65665. * Specifies if the particles are updated in emitter local space or world space.
  65666. * This is always false for GPU particles
  65667. */
  65668. get isLocal(): boolean;
  65669. set isLocal(value: boolean);
  65670. /**
  65671. * Is this system ready to be used/rendered
  65672. * @return true if the system is ready
  65673. */
  65674. isReady(): boolean;
  65675. /**
  65676. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65677. * @returns True if it has been started, otherwise false.
  65678. */
  65679. isStarted(): boolean;
  65680. /**
  65681. * Starts the particle system and begins to emit
  65682. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65683. */
  65684. start(delay?: number): void;
  65685. /**
  65686. * Stops the particle system.
  65687. */
  65688. stop(): void;
  65689. /**
  65690. * Remove all active particles
  65691. */
  65692. reset(): void;
  65693. /**
  65694. * Returns the string "GPUParticleSystem"
  65695. * @returns a string containing the class name
  65696. */
  65697. getClassName(): string;
  65698. private _colorGradientsTexture;
  65699. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65700. /**
  65701. * Adds a new color gradient
  65702. * @param gradient defines the gradient to use (between 0 and 1)
  65703. * @param color1 defines the color to affect to the specified gradient
  65704. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65705. * @returns the current particle system
  65706. */
  65707. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65708. /**
  65709. * Remove a specific color gradient
  65710. * @param gradient defines the gradient to remove
  65711. * @returns the current particle system
  65712. */
  65713. removeColorGradient(gradient: number): GPUParticleSystem;
  65714. private _angularSpeedGradientsTexture;
  65715. private _sizeGradientsTexture;
  65716. private _velocityGradientsTexture;
  65717. private _limitVelocityGradientsTexture;
  65718. private _dragGradientsTexture;
  65719. private _addFactorGradient;
  65720. /**
  65721. * Adds a new size gradient
  65722. * @param gradient defines the gradient to use (between 0 and 1)
  65723. * @param factor defines the size factor to affect to the specified gradient
  65724. * @returns the current particle system
  65725. */
  65726. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65727. /**
  65728. * Remove a specific size gradient
  65729. * @param gradient defines the gradient to remove
  65730. * @returns the current particle system
  65731. */
  65732. removeSizeGradient(gradient: number): GPUParticleSystem;
  65733. /**
  65734. * Adds a new angular speed gradient
  65735. * @param gradient defines the gradient to use (between 0 and 1)
  65736. * @param factor defines the angular speed to affect to the specified gradient
  65737. * @returns the current particle system
  65738. */
  65739. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65740. /**
  65741. * Remove a specific angular speed gradient
  65742. * @param gradient defines the gradient to remove
  65743. * @returns the current particle system
  65744. */
  65745. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65746. /**
  65747. * Adds a new velocity gradient
  65748. * @param gradient defines the gradient to use (between 0 and 1)
  65749. * @param factor defines the velocity to affect to the specified gradient
  65750. * @returns the current particle system
  65751. */
  65752. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65753. /**
  65754. * Remove a specific velocity gradient
  65755. * @param gradient defines the gradient to remove
  65756. * @returns the current particle system
  65757. */
  65758. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65759. /**
  65760. * Adds a new limit velocity gradient
  65761. * @param gradient defines the gradient to use (between 0 and 1)
  65762. * @param factor defines the limit velocity value to affect to the specified gradient
  65763. * @returns the current particle system
  65764. */
  65765. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65766. /**
  65767. * Remove a specific limit velocity gradient
  65768. * @param gradient defines the gradient to remove
  65769. * @returns the current particle system
  65770. */
  65771. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65772. /**
  65773. * Adds a new drag gradient
  65774. * @param gradient defines the gradient to use (between 0 and 1)
  65775. * @param factor defines the drag value to affect to the specified gradient
  65776. * @returns the current particle system
  65777. */
  65778. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65779. /**
  65780. * Remove a specific drag gradient
  65781. * @param gradient defines the gradient to remove
  65782. * @returns the current particle system
  65783. */
  65784. removeDragGradient(gradient: number): GPUParticleSystem;
  65785. /**
  65786. * Not supported by GPUParticleSystem
  65787. * @param gradient defines the gradient to use (between 0 and 1)
  65788. * @param factor defines the emit rate value to affect to the specified gradient
  65789. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65790. * @returns the current particle system
  65791. */
  65792. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65793. /**
  65794. * Not supported by GPUParticleSystem
  65795. * @param gradient defines the gradient to remove
  65796. * @returns the current particle system
  65797. */
  65798. removeEmitRateGradient(gradient: number): IParticleSystem;
  65799. /**
  65800. * Not supported by GPUParticleSystem
  65801. * @param gradient defines the gradient to use (between 0 and 1)
  65802. * @param factor defines the start size value to affect to the specified gradient
  65803. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65804. * @returns the current particle system
  65805. */
  65806. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65807. /**
  65808. * Not supported by GPUParticleSystem
  65809. * @param gradient defines the gradient to remove
  65810. * @returns the current particle system
  65811. */
  65812. removeStartSizeGradient(gradient: number): IParticleSystem;
  65813. /**
  65814. * Not supported by GPUParticleSystem
  65815. * @param gradient defines the gradient to use (between 0 and 1)
  65816. * @param min defines the color remap minimal range
  65817. * @param max defines the color remap maximal range
  65818. * @returns the current particle system
  65819. */
  65820. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65821. /**
  65822. * Not supported by GPUParticleSystem
  65823. * @param gradient defines the gradient to remove
  65824. * @returns the current particle system
  65825. */
  65826. removeColorRemapGradient(): IParticleSystem;
  65827. /**
  65828. * Not supported by GPUParticleSystem
  65829. * @param gradient defines the gradient to use (between 0 and 1)
  65830. * @param min defines the alpha remap minimal range
  65831. * @param max defines the alpha remap maximal range
  65832. * @returns the current particle system
  65833. */
  65834. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65835. /**
  65836. * Not supported by GPUParticleSystem
  65837. * @param gradient defines the gradient to remove
  65838. * @returns the current particle system
  65839. */
  65840. removeAlphaRemapGradient(): IParticleSystem;
  65841. /**
  65842. * Not supported by GPUParticleSystem
  65843. * @param gradient defines the gradient to use (between 0 and 1)
  65844. * @param color defines the color to affect to the specified gradient
  65845. * @returns the current particle system
  65846. */
  65847. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65848. /**
  65849. * Not supported by GPUParticleSystem
  65850. * @param gradient defines the gradient to remove
  65851. * @returns the current particle system
  65852. */
  65853. removeRampGradient(): IParticleSystem;
  65854. /**
  65855. * Not supported by GPUParticleSystem
  65856. * @returns the list of ramp gradients
  65857. */
  65858. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65859. /**
  65860. * Not supported by GPUParticleSystem
  65861. * Gets or sets a boolean indicating that ramp gradients must be used
  65862. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65863. */
  65864. get useRampGradients(): boolean;
  65865. set useRampGradients(value: boolean);
  65866. /**
  65867. * Not supported by GPUParticleSystem
  65868. * @param gradient defines the gradient to use (between 0 and 1)
  65869. * @param factor defines the life time factor to affect to the specified gradient
  65870. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65871. * @returns the current particle system
  65872. */
  65873. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65874. /**
  65875. * Not supported by GPUParticleSystem
  65876. * @param gradient defines the gradient to remove
  65877. * @returns the current particle system
  65878. */
  65879. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65880. /**
  65881. * Instantiates a GPU particle system.
  65882. * 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.
  65883. * @param name The name of the particle system
  65884. * @param options The options used to create the system
  65885. * @param scene The scene the particle system belongs to
  65886. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65887. */
  65888. constructor(name: string, options: Partial<{
  65889. capacity: number;
  65890. randomTextureSize: number;
  65891. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  65892. protected _reset(): void;
  65893. private _createUpdateVAO;
  65894. private _createRenderVAO;
  65895. private _initialize;
  65896. /** @hidden */
  65897. _recreateUpdateEffect(): void;
  65898. /** @hidden */
  65899. _recreateRenderEffect(): void;
  65900. /**
  65901. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65902. * @param preWarm defines if we are in the pre-warmimg phase
  65903. */
  65904. animate(preWarm?: boolean): void;
  65905. private _createFactorGradientTexture;
  65906. private _createSizeGradientTexture;
  65907. private _createAngularSpeedGradientTexture;
  65908. private _createVelocityGradientTexture;
  65909. private _createLimitVelocityGradientTexture;
  65910. private _createDragGradientTexture;
  65911. private _createColorGradientTexture;
  65912. /**
  65913. * Renders the particle system in its current state
  65914. * @param preWarm defines if the system should only update the particles but not render them
  65915. * @returns the current number of particles
  65916. */
  65917. render(preWarm?: boolean): number;
  65918. /**
  65919. * Rebuilds the particle system
  65920. */
  65921. rebuild(): void;
  65922. private _releaseBuffers;
  65923. private _releaseVAOs;
  65924. /**
  65925. * Disposes the particle system and free the associated resources
  65926. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65927. */
  65928. dispose(disposeTexture?: boolean): void;
  65929. /**
  65930. * Clones the particle system.
  65931. * @param name The name of the cloned object
  65932. * @param newEmitter The new emitter to use
  65933. * @returns the cloned particle system
  65934. */
  65935. clone(name: string, newEmitter: any): GPUParticleSystem;
  65936. /**
  65937. * Serializes the particle system to a JSON object.
  65938. * @returns the JSON object
  65939. */
  65940. serialize(): any;
  65941. /**
  65942. * Parses a JSON object to create a GPU particle system.
  65943. * @param parsedParticleSystem The JSON object to parse
  65944. * @param scene The scene to create the particle system in
  65945. * @param rootUrl The root url to use to load external dependencies like texture
  65946. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65947. * @returns the parsed GPU particle system
  65948. */
  65949. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65950. }
  65951. }
  65952. declare module "babylonjs/Particles/particleSystemSet" {
  65953. import { Nullable } from "babylonjs/types";
  65954. import { Color3 } from "babylonjs/Maths/math.color";
  65955. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65957. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65958. import { Scene, IDisposable } from "babylonjs/scene";
  65959. /**
  65960. * Represents a set of particle systems working together to create a specific effect
  65961. */
  65962. export class ParticleSystemSet implements IDisposable {
  65963. /**
  65964. * Gets or sets base Assets URL
  65965. */
  65966. static BaseAssetsUrl: string;
  65967. private _emitterCreationOptions;
  65968. private _emitterNode;
  65969. /**
  65970. * Gets the particle system list
  65971. */
  65972. systems: IParticleSystem[];
  65973. /**
  65974. * Gets the emitter node used with this set
  65975. */
  65976. get emitterNode(): Nullable<TransformNode>;
  65977. /**
  65978. * Creates a new emitter mesh as a sphere
  65979. * @param options defines the options used to create the sphere
  65980. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65981. * @param scene defines the hosting scene
  65982. */
  65983. setEmitterAsSphere(options: {
  65984. diameter: number;
  65985. segments: number;
  65986. color: Color3;
  65987. }, renderingGroupId: number, scene: Scene): void;
  65988. /**
  65989. * Starts all particle systems of the set
  65990. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65991. */
  65992. start(emitter?: AbstractMesh): void;
  65993. /**
  65994. * Release all associated resources
  65995. */
  65996. dispose(): void;
  65997. /**
  65998. * Serialize the set into a JSON compatible object
  65999. * @returns a JSON compatible representation of the set
  66000. */
  66001. serialize(): any;
  66002. /**
  66003. * Parse a new ParticleSystemSet from a serialized source
  66004. * @param data defines a JSON compatible representation of the set
  66005. * @param scene defines the hosting scene
  66006. * @param gpu defines if we want GPU particles or CPU particles
  66007. * @returns a new ParticleSystemSet
  66008. */
  66009. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66010. }
  66011. }
  66012. declare module "babylonjs/Particles/particleHelper" {
  66013. import { Nullable } from "babylonjs/types";
  66014. import { Scene } from "babylonjs/scene";
  66015. import { Vector3 } from "babylonjs/Maths/math.vector";
  66016. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66017. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66018. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66019. /**
  66020. * This class is made for on one-liner static method to help creating particle system set.
  66021. */
  66022. export class ParticleHelper {
  66023. /**
  66024. * Gets or sets base Assets URL
  66025. */
  66026. static BaseAssetsUrl: string;
  66027. /**
  66028. * Create a default particle system that you can tweak
  66029. * @param emitter defines the emitter to use
  66030. * @param capacity defines the system capacity (default is 500 particles)
  66031. * @param scene defines the hosting scene
  66032. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66033. * @returns the new Particle system
  66034. */
  66035. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66036. /**
  66037. * This is the main static method (one-liner) of this helper to create different particle systems
  66038. * @param type This string represents the type to the particle system to create
  66039. * @param scene The scene where the particle system should live
  66040. * @param gpu If the system will use gpu
  66041. * @returns the ParticleSystemSet created
  66042. */
  66043. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66044. /**
  66045. * Static function used to export a particle system to a ParticleSystemSet variable.
  66046. * Please note that the emitter shape is not exported
  66047. * @param systems defines the particle systems to export
  66048. * @returns the created particle system set
  66049. */
  66050. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66051. }
  66052. }
  66053. declare module "babylonjs/Particles/particleSystemComponent" {
  66054. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66055. import { Effect } from "babylonjs/Materials/effect";
  66056. import "babylonjs/Shaders/particles.vertex";
  66057. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66058. module "babylonjs/Engines/engine" {
  66059. interface Engine {
  66060. /**
  66061. * Create an effect to use with particle systems.
  66062. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66063. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66064. * @param uniformsNames defines a list of attribute names
  66065. * @param samplers defines an array of string used to represent textures
  66066. * @param defines defines the string containing the defines to use to compile the shaders
  66067. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66068. * @param onCompiled defines a function to call when the effect creation is successful
  66069. * @param onError defines a function to call when the effect creation has failed
  66070. * @returns the new Effect
  66071. */
  66072. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66073. }
  66074. }
  66075. module "babylonjs/Meshes/mesh" {
  66076. interface Mesh {
  66077. /**
  66078. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66079. * @returns an array of IParticleSystem
  66080. */
  66081. getEmittedParticleSystems(): IParticleSystem[];
  66082. /**
  66083. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66084. * @returns an array of IParticleSystem
  66085. */
  66086. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66087. }
  66088. }
  66089. /**
  66090. * @hidden
  66091. */
  66092. export var _IDoNeedToBeInTheBuild: number;
  66093. }
  66094. declare module "babylonjs/Particles/pointsCloudSystem" {
  66095. import { Color4 } from "babylonjs/Maths/math";
  66096. import { Mesh } from "babylonjs/Meshes/mesh";
  66097. import { Scene, IDisposable } from "babylonjs/scene";
  66098. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66099. /** Defines the 4 color options */
  66100. export enum PointColor {
  66101. /** color value */
  66102. Color = 2,
  66103. /** uv value */
  66104. UV = 1,
  66105. /** random value */
  66106. Random = 0,
  66107. /** stated value */
  66108. Stated = 3
  66109. }
  66110. /**
  66111. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66112. * 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.
  66113. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66114. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66115. *
  66116. * Full documentation here : TO BE ENTERED
  66117. */
  66118. export class PointsCloudSystem implements IDisposable {
  66119. /**
  66120. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66121. * Example : var p = SPS.particles[i];
  66122. */
  66123. particles: CloudPoint[];
  66124. /**
  66125. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66126. */
  66127. nbParticles: number;
  66128. /**
  66129. * This a counter for your own usage. It's not set by any SPS functions.
  66130. */
  66131. counter: number;
  66132. /**
  66133. * The PCS name. This name is also given to the underlying mesh.
  66134. */
  66135. name: string;
  66136. /**
  66137. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66138. */
  66139. mesh: Mesh;
  66140. /**
  66141. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66142. * Please read :
  66143. */
  66144. vars: any;
  66145. /**
  66146. * @hidden
  66147. */
  66148. _size: number;
  66149. private _scene;
  66150. private _promises;
  66151. private _positions;
  66152. private _indices;
  66153. private _normals;
  66154. private _colors;
  66155. private _uvs;
  66156. private _indices32;
  66157. private _positions32;
  66158. private _colors32;
  66159. private _uvs32;
  66160. private _updatable;
  66161. private _isVisibilityBoxLocked;
  66162. private _alwaysVisible;
  66163. private _groups;
  66164. private _groupCounter;
  66165. private _computeParticleColor;
  66166. private _computeParticleTexture;
  66167. private _computeParticleRotation;
  66168. private _computeBoundingBox;
  66169. private _isReady;
  66170. /**
  66171. * Creates a PCS (Points Cloud System) object
  66172. * @param name (String) is the PCS name, this will be the underlying mesh name
  66173. * @param pointSize (number) is the size for each point
  66174. * @param scene (Scene) is the scene in which the PCS is added
  66175. * @param options defines the options of the PCS e.g.
  66176. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66177. */
  66178. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66179. updatable?: boolean;
  66180. });
  66181. /**
  66182. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66183. * If no points were added to the PCS, the returned mesh is just a single point.
  66184. * @returns a promise for the created mesh
  66185. */
  66186. buildMeshAsync(): Promise<Mesh>;
  66187. /**
  66188. * @hidden
  66189. */
  66190. private _buildMesh;
  66191. private _addParticle;
  66192. private _randomUnitVector;
  66193. private _getColorIndicesForCoord;
  66194. private _setPointsColorOrUV;
  66195. private _colorFromTexture;
  66196. private _calculateDensity;
  66197. /**
  66198. * Adds points to the PCS in random positions within a unit sphere
  66199. * @param nb (positive integer) the number of particles to be created from this model
  66200. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66201. * @returns the number of groups in the system
  66202. */
  66203. addPoints(nb: number, pointFunction?: any): number;
  66204. /**
  66205. * Adds points to the PCS from the surface of the model shape
  66206. * @param mesh is any Mesh object that will be used as a surface model for the points
  66207. * @param nb (positive integer) the number of particles to be created from this model
  66208. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66209. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66210. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66211. * @returns the number of groups in the system
  66212. */
  66213. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66214. /**
  66215. * Adds points to the PCS inside the model shape
  66216. * @param mesh is any Mesh object that will be used as a surface model for the points
  66217. * @param nb (positive integer) the number of particles to be created from this model
  66218. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66219. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66220. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66221. * @returns the number of groups in the system
  66222. */
  66223. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66224. /**
  66225. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66226. * This method calls `updateParticle()` for each particle of the SPS.
  66227. * For an animated SPS, it is usually called within the render loop.
  66228. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66229. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66230. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66231. * @returns the PCS.
  66232. */
  66233. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66234. /**
  66235. * Disposes the PCS.
  66236. */
  66237. dispose(): void;
  66238. /**
  66239. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66240. * doc :
  66241. * @returns the PCS.
  66242. */
  66243. refreshVisibleSize(): PointsCloudSystem;
  66244. /**
  66245. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66246. * @param size the size (float) of the visibility box
  66247. * note : this doesn't lock the PCS mesh bounding box.
  66248. * doc :
  66249. */
  66250. setVisibilityBox(size: number): void;
  66251. /**
  66252. * Gets whether the PCS is always visible or not
  66253. * doc :
  66254. */
  66255. get isAlwaysVisible(): boolean;
  66256. /**
  66257. * Sets the PCS as always visible or not
  66258. * doc :
  66259. */
  66260. set isAlwaysVisible(val: boolean);
  66261. /**
  66262. * Tells to `setParticles()` to compute the particle rotations or not
  66263. * Default value : false. The PCS is faster when it's set to false
  66264. * Note : particle rotations are only applied to parent particles
  66265. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66266. */
  66267. set computeParticleRotation(val: boolean);
  66268. /**
  66269. * Tells to `setParticles()` to compute the particle colors or not.
  66270. * Default value : true. The PCS is faster when it's set to false.
  66271. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66272. */
  66273. set computeParticleColor(val: boolean);
  66274. set computeParticleTexture(val: boolean);
  66275. /**
  66276. * Gets if `setParticles()` computes the particle colors or not.
  66277. * Default value : false. The PCS is faster when it's set to false.
  66278. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66279. */
  66280. get computeParticleColor(): boolean;
  66281. /**
  66282. * Gets if `setParticles()` computes the particle textures or not.
  66283. * Default value : false. The PCS is faster when it's set to false.
  66284. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66285. */
  66286. get computeParticleTexture(): boolean;
  66287. /**
  66288. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66289. */
  66290. set computeBoundingBox(val: boolean);
  66291. /**
  66292. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66293. */
  66294. get computeBoundingBox(): boolean;
  66295. /**
  66296. * This function does nothing. It may be overwritten to set all the particle first values.
  66297. * The PCS doesn't call this function, you may have to call it by your own.
  66298. * doc :
  66299. */
  66300. initParticles(): void;
  66301. /**
  66302. * This function does nothing. It may be overwritten to recycle a particle
  66303. * The PCS doesn't call this function, you can to call it
  66304. * doc :
  66305. * @param particle The particle to recycle
  66306. * @returns the recycled particle
  66307. */
  66308. recycleParticle(particle: CloudPoint): CloudPoint;
  66309. /**
  66310. * Updates a particle : this function should be overwritten by the user.
  66311. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66312. * doc :
  66313. * @example : just set a particle position or velocity and recycle conditions
  66314. * @param particle The particle to update
  66315. * @returns the updated particle
  66316. */
  66317. updateParticle(particle: CloudPoint): CloudPoint;
  66318. /**
  66319. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66320. * This does nothing and may be overwritten by the user.
  66321. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66322. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66323. * @param update the boolean update value actually passed to setParticles()
  66324. */
  66325. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66326. /**
  66327. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66328. * This will be passed three parameters.
  66329. * This does nothing and may be overwritten by the user.
  66330. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66331. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66332. * @param update the boolean update value actually passed to setParticles()
  66333. */
  66334. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66335. }
  66336. }
  66337. declare module "babylonjs/Particles/cloudPoint" {
  66338. import { Nullable } from "babylonjs/types";
  66339. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66340. import { Mesh } from "babylonjs/Meshes/mesh";
  66341. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66342. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66343. /**
  66344. * Represents one particle of a points cloud system.
  66345. */
  66346. export class CloudPoint {
  66347. /**
  66348. * particle global index
  66349. */
  66350. idx: number;
  66351. /**
  66352. * The color of the particle
  66353. */
  66354. color: Nullable<Color4>;
  66355. /**
  66356. * The world space position of the particle.
  66357. */
  66358. position: Vector3;
  66359. /**
  66360. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66361. */
  66362. rotation: Vector3;
  66363. /**
  66364. * The world space rotation quaternion of the particle.
  66365. */
  66366. rotationQuaternion: Nullable<Quaternion>;
  66367. /**
  66368. * The uv of the particle.
  66369. */
  66370. uv: Nullable<Vector2>;
  66371. /**
  66372. * The current speed of the particle.
  66373. */
  66374. velocity: Vector3;
  66375. /**
  66376. * The pivot point in the particle local space.
  66377. */
  66378. pivot: Vector3;
  66379. /**
  66380. * Must the particle be translated from its pivot point in its local space ?
  66381. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66382. * Default : false
  66383. */
  66384. translateFromPivot: boolean;
  66385. /**
  66386. * Index of this particle in the global "positions" array (Internal use)
  66387. * @hidden
  66388. */
  66389. _pos: number;
  66390. /**
  66391. * @hidden Index of this particle in the global "indices" array (Internal use)
  66392. */
  66393. _ind: number;
  66394. /**
  66395. * Group this particle belongs to
  66396. */
  66397. _group: PointsGroup;
  66398. /**
  66399. * Group id of this particle
  66400. */
  66401. groupId: number;
  66402. /**
  66403. * Index of the particle in its group id (Internal use)
  66404. */
  66405. idxInGroup: number;
  66406. /**
  66407. * @hidden Particle BoundingInfo object (Internal use)
  66408. */
  66409. _boundingInfo: BoundingInfo;
  66410. /**
  66411. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66412. */
  66413. _pcs: PointsCloudSystem;
  66414. /**
  66415. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66416. */
  66417. _stillInvisible: boolean;
  66418. /**
  66419. * @hidden Last computed particle rotation matrix
  66420. */
  66421. _rotationMatrix: number[];
  66422. /**
  66423. * Parent particle Id, if any.
  66424. * Default null.
  66425. */
  66426. parentId: Nullable<number>;
  66427. /**
  66428. * @hidden Internal global position in the PCS.
  66429. */
  66430. _globalPosition: Vector3;
  66431. /**
  66432. * Creates a Point Cloud object.
  66433. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66434. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66435. * @param group (PointsGroup) is the group the particle belongs to
  66436. * @param groupId (integer) is the group identifier in the PCS.
  66437. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66438. * @param pcs defines the PCS it is associated to
  66439. */
  66440. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66441. /**
  66442. * get point size
  66443. */
  66444. get size(): Vector3;
  66445. /**
  66446. * Set point size
  66447. */
  66448. set size(scale: Vector3);
  66449. /**
  66450. * Legacy support, changed quaternion to rotationQuaternion
  66451. */
  66452. get quaternion(): Nullable<Quaternion>;
  66453. /**
  66454. * Legacy support, changed quaternion to rotationQuaternion
  66455. */
  66456. set quaternion(q: Nullable<Quaternion>);
  66457. /**
  66458. * Returns a boolean. True if the particle intersects a mesh, else false
  66459. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66460. * @param target is the object (point or mesh) what the intersection is computed against
  66461. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66462. * @returns true if it intersects
  66463. */
  66464. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66465. /**
  66466. * get the rotation matrix of the particle
  66467. * @hidden
  66468. */
  66469. getRotationMatrix(m: Matrix): void;
  66470. }
  66471. /**
  66472. * Represents a group of points in a points cloud system
  66473. * * PCS internal tool, don't use it manually.
  66474. */
  66475. export class PointsGroup {
  66476. /**
  66477. * The group id
  66478. * @hidden
  66479. */
  66480. groupID: number;
  66481. /**
  66482. * image data for group (internal use)
  66483. * @hidden
  66484. */
  66485. _groupImageData: Nullable<ArrayBufferView>;
  66486. /**
  66487. * Image Width (internal use)
  66488. * @hidden
  66489. */
  66490. _groupImgWidth: number;
  66491. /**
  66492. * Image Height (internal use)
  66493. * @hidden
  66494. */
  66495. _groupImgHeight: number;
  66496. /**
  66497. * Custom position function (internal use)
  66498. * @hidden
  66499. */
  66500. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66501. /**
  66502. * density per facet for surface points
  66503. * @hidden
  66504. */
  66505. _groupDensity: number[];
  66506. /**
  66507. * Only when points are colored by texture carries pointer to texture list array
  66508. * @hidden
  66509. */
  66510. _textureNb: number;
  66511. /**
  66512. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66513. * PCS internal tool, don't use it manually.
  66514. * @hidden
  66515. */
  66516. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66517. }
  66518. }
  66519. declare module "babylonjs/Particles/index" {
  66520. export * from "babylonjs/Particles/baseParticleSystem";
  66521. export * from "babylonjs/Particles/EmitterTypes/index";
  66522. export * from "babylonjs/Particles/gpuParticleSystem";
  66523. export * from "babylonjs/Particles/IParticleSystem";
  66524. export * from "babylonjs/Particles/particle";
  66525. export * from "babylonjs/Particles/particleHelper";
  66526. export * from "babylonjs/Particles/particleSystem";
  66527. export * from "babylonjs/Particles/particleSystemComponent";
  66528. export * from "babylonjs/Particles/particleSystemSet";
  66529. export * from "babylonjs/Particles/solidParticle";
  66530. export * from "babylonjs/Particles/solidParticleSystem";
  66531. export * from "babylonjs/Particles/cloudPoint";
  66532. export * from "babylonjs/Particles/pointsCloudSystem";
  66533. export * from "babylonjs/Particles/subEmitter";
  66534. }
  66535. declare module "babylonjs/Physics/physicsEngineComponent" {
  66536. import { Nullable } from "babylonjs/types";
  66537. import { Observable, Observer } from "babylonjs/Misc/observable";
  66538. import { Vector3 } from "babylonjs/Maths/math.vector";
  66539. import { Mesh } from "babylonjs/Meshes/mesh";
  66540. import { ISceneComponent } from "babylonjs/sceneComponent";
  66541. import { Scene } from "babylonjs/scene";
  66542. import { Node } from "babylonjs/node";
  66543. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66544. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66545. module "babylonjs/scene" {
  66546. interface Scene {
  66547. /** @hidden (Backing field) */
  66548. _physicsEngine: Nullable<IPhysicsEngine>;
  66549. /** @hidden */
  66550. _physicsTimeAccumulator: number;
  66551. /**
  66552. * Gets the current physics engine
  66553. * @returns a IPhysicsEngine or null if none attached
  66554. */
  66555. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66556. /**
  66557. * Enables physics to the current scene
  66558. * @param gravity defines the scene's gravity for the physics engine
  66559. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66560. * @return a boolean indicating if the physics engine was initialized
  66561. */
  66562. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66563. /**
  66564. * Disables and disposes the physics engine associated with the scene
  66565. */
  66566. disablePhysicsEngine(): void;
  66567. /**
  66568. * Gets a boolean indicating if there is an active physics engine
  66569. * @returns a boolean indicating if there is an active physics engine
  66570. */
  66571. isPhysicsEnabled(): boolean;
  66572. /**
  66573. * Deletes a physics compound impostor
  66574. * @param compound defines the compound to delete
  66575. */
  66576. deleteCompoundImpostor(compound: any): void;
  66577. /**
  66578. * An event triggered when physic simulation is about to be run
  66579. */
  66580. onBeforePhysicsObservable: Observable<Scene>;
  66581. /**
  66582. * An event triggered when physic simulation has been done
  66583. */
  66584. onAfterPhysicsObservable: Observable<Scene>;
  66585. }
  66586. }
  66587. module "babylonjs/Meshes/abstractMesh" {
  66588. interface AbstractMesh {
  66589. /** @hidden */
  66590. _physicsImpostor: Nullable<PhysicsImpostor>;
  66591. /**
  66592. * Gets or sets impostor used for physic simulation
  66593. * @see http://doc.babylonjs.com/features/physics_engine
  66594. */
  66595. physicsImpostor: Nullable<PhysicsImpostor>;
  66596. /**
  66597. * Gets the current physics impostor
  66598. * @see http://doc.babylonjs.com/features/physics_engine
  66599. * @returns a physics impostor or null
  66600. */
  66601. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66602. /** Apply a physic impulse to the mesh
  66603. * @param force defines the force to apply
  66604. * @param contactPoint defines where to apply the force
  66605. * @returns the current mesh
  66606. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66607. */
  66608. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66609. /**
  66610. * Creates a physic joint between two meshes
  66611. * @param otherMesh defines the other mesh to use
  66612. * @param pivot1 defines the pivot to use on this mesh
  66613. * @param pivot2 defines the pivot to use on the other mesh
  66614. * @param options defines additional options (can be plugin dependent)
  66615. * @returns the current mesh
  66616. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66617. */
  66618. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66619. /** @hidden */
  66620. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66621. }
  66622. }
  66623. /**
  66624. * Defines the physics engine scene component responsible to manage a physics engine
  66625. */
  66626. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66627. /**
  66628. * The component name helpful to identify the component in the list of scene components.
  66629. */
  66630. readonly name: string;
  66631. /**
  66632. * The scene the component belongs to.
  66633. */
  66634. scene: Scene;
  66635. /**
  66636. * Creates a new instance of the component for the given scene
  66637. * @param scene Defines the scene to register the component in
  66638. */
  66639. constructor(scene: Scene);
  66640. /**
  66641. * Registers the component in a given scene
  66642. */
  66643. register(): void;
  66644. /**
  66645. * Rebuilds the elements related to this component in case of
  66646. * context lost for instance.
  66647. */
  66648. rebuild(): void;
  66649. /**
  66650. * Disposes the component and the associated ressources
  66651. */
  66652. dispose(): void;
  66653. }
  66654. }
  66655. declare module "babylonjs/Physics/physicsHelper" {
  66656. import { Nullable } from "babylonjs/types";
  66657. import { Vector3 } from "babylonjs/Maths/math.vector";
  66658. import { Mesh } from "babylonjs/Meshes/mesh";
  66659. import { Scene } from "babylonjs/scene";
  66660. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66661. /**
  66662. * A helper for physics simulations
  66663. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66664. */
  66665. export class PhysicsHelper {
  66666. private _scene;
  66667. private _physicsEngine;
  66668. /**
  66669. * Initializes the Physics helper
  66670. * @param scene Babylon.js scene
  66671. */
  66672. constructor(scene: Scene);
  66673. /**
  66674. * Applies a radial explosion impulse
  66675. * @param origin the origin of the explosion
  66676. * @param radiusOrEventOptions the radius or the options of radial explosion
  66677. * @param strength the explosion strength
  66678. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66679. * @returns A physics radial explosion event, or null
  66680. */
  66681. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66682. /**
  66683. * Applies a radial explosion force
  66684. * @param origin the origin of the explosion
  66685. * @param radiusOrEventOptions the radius or the options of radial explosion
  66686. * @param strength the explosion strength
  66687. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66688. * @returns A physics radial explosion event, or null
  66689. */
  66690. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66691. /**
  66692. * Creates a gravitational field
  66693. * @param origin the origin of the explosion
  66694. * @param radiusOrEventOptions the radius or the options of radial explosion
  66695. * @param strength the explosion strength
  66696. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66697. * @returns A physics gravitational field event, or null
  66698. */
  66699. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66700. /**
  66701. * Creates a physics updraft event
  66702. * @param origin the origin of the updraft
  66703. * @param radiusOrEventOptions the radius or the options of the updraft
  66704. * @param strength the strength of the updraft
  66705. * @param height the height of the updraft
  66706. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66707. * @returns A physics updraft event, or null
  66708. */
  66709. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66710. /**
  66711. * Creates a physics vortex event
  66712. * @param origin the of the vortex
  66713. * @param radiusOrEventOptions the radius or the options of the vortex
  66714. * @param strength the strength of the vortex
  66715. * @param height the height of the vortex
  66716. * @returns a Physics vortex event, or null
  66717. * A physics vortex event or null
  66718. */
  66719. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66720. }
  66721. /**
  66722. * Represents a physics radial explosion event
  66723. */
  66724. class PhysicsRadialExplosionEvent {
  66725. private _scene;
  66726. private _options;
  66727. private _sphere;
  66728. private _dataFetched;
  66729. /**
  66730. * Initializes a radial explosioin event
  66731. * @param _scene BabylonJS scene
  66732. * @param _options The options for the vortex event
  66733. */
  66734. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66735. /**
  66736. * Returns the data related to the radial explosion event (sphere).
  66737. * @returns The radial explosion event data
  66738. */
  66739. getData(): PhysicsRadialExplosionEventData;
  66740. /**
  66741. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66742. * @param impostor A physics imposter
  66743. * @param origin the origin of the explosion
  66744. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66745. */
  66746. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66747. /**
  66748. * Triggers affecterd impostors callbacks
  66749. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66750. */
  66751. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66752. /**
  66753. * Disposes the sphere.
  66754. * @param force Specifies if the sphere should be disposed by force
  66755. */
  66756. dispose(force?: boolean): void;
  66757. /*** Helpers ***/
  66758. private _prepareSphere;
  66759. private _intersectsWithSphere;
  66760. }
  66761. /**
  66762. * Represents a gravitational field event
  66763. */
  66764. class PhysicsGravitationalFieldEvent {
  66765. private _physicsHelper;
  66766. private _scene;
  66767. private _origin;
  66768. private _options;
  66769. private _tickCallback;
  66770. private _sphere;
  66771. private _dataFetched;
  66772. /**
  66773. * Initializes the physics gravitational field event
  66774. * @param _physicsHelper A physics helper
  66775. * @param _scene BabylonJS scene
  66776. * @param _origin The origin position of the gravitational field event
  66777. * @param _options The options for the vortex event
  66778. */
  66779. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66780. /**
  66781. * Returns the data related to the gravitational field event (sphere).
  66782. * @returns A gravitational field event
  66783. */
  66784. getData(): PhysicsGravitationalFieldEventData;
  66785. /**
  66786. * Enables the gravitational field.
  66787. */
  66788. enable(): void;
  66789. /**
  66790. * Disables the gravitational field.
  66791. */
  66792. disable(): void;
  66793. /**
  66794. * Disposes the sphere.
  66795. * @param force The force to dispose from the gravitational field event
  66796. */
  66797. dispose(force?: boolean): void;
  66798. private _tick;
  66799. }
  66800. /**
  66801. * Represents a physics updraft event
  66802. */
  66803. class PhysicsUpdraftEvent {
  66804. private _scene;
  66805. private _origin;
  66806. private _options;
  66807. private _physicsEngine;
  66808. private _originTop;
  66809. private _originDirection;
  66810. private _tickCallback;
  66811. private _cylinder;
  66812. private _cylinderPosition;
  66813. private _dataFetched;
  66814. /**
  66815. * Initializes the physics updraft event
  66816. * @param _scene BabylonJS scene
  66817. * @param _origin The origin position of the updraft
  66818. * @param _options The options for the updraft event
  66819. */
  66820. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66821. /**
  66822. * Returns the data related to the updraft event (cylinder).
  66823. * @returns A physics updraft event
  66824. */
  66825. getData(): PhysicsUpdraftEventData;
  66826. /**
  66827. * Enables the updraft.
  66828. */
  66829. enable(): void;
  66830. /**
  66831. * Disables the updraft.
  66832. */
  66833. disable(): void;
  66834. /**
  66835. * Disposes the cylinder.
  66836. * @param force Specifies if the updraft should be disposed by force
  66837. */
  66838. dispose(force?: boolean): void;
  66839. private getImpostorHitData;
  66840. private _tick;
  66841. /*** Helpers ***/
  66842. private _prepareCylinder;
  66843. private _intersectsWithCylinder;
  66844. }
  66845. /**
  66846. * Represents a physics vortex event
  66847. */
  66848. class PhysicsVortexEvent {
  66849. private _scene;
  66850. private _origin;
  66851. private _options;
  66852. private _physicsEngine;
  66853. private _originTop;
  66854. private _tickCallback;
  66855. private _cylinder;
  66856. private _cylinderPosition;
  66857. private _dataFetched;
  66858. /**
  66859. * Initializes the physics vortex event
  66860. * @param _scene The BabylonJS scene
  66861. * @param _origin The origin position of the vortex
  66862. * @param _options The options for the vortex event
  66863. */
  66864. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66865. /**
  66866. * Returns the data related to the vortex event (cylinder).
  66867. * @returns The physics vortex event data
  66868. */
  66869. getData(): PhysicsVortexEventData;
  66870. /**
  66871. * Enables the vortex.
  66872. */
  66873. enable(): void;
  66874. /**
  66875. * Disables the cortex.
  66876. */
  66877. disable(): void;
  66878. /**
  66879. * Disposes the sphere.
  66880. * @param force
  66881. */
  66882. dispose(force?: boolean): void;
  66883. private getImpostorHitData;
  66884. private _tick;
  66885. /*** Helpers ***/
  66886. private _prepareCylinder;
  66887. private _intersectsWithCylinder;
  66888. }
  66889. /**
  66890. * Options fot the radial explosion event
  66891. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66892. */
  66893. export class PhysicsRadialExplosionEventOptions {
  66894. /**
  66895. * The radius of the sphere for the radial explosion.
  66896. */
  66897. radius: number;
  66898. /**
  66899. * The strenth of the explosion.
  66900. */
  66901. strength: number;
  66902. /**
  66903. * The strenght of the force in correspondence to the distance of the affected object
  66904. */
  66905. falloff: PhysicsRadialImpulseFalloff;
  66906. /**
  66907. * Sphere options for the radial explosion.
  66908. */
  66909. sphere: {
  66910. segments: number;
  66911. diameter: number;
  66912. };
  66913. /**
  66914. * Sphere options for the radial explosion.
  66915. */
  66916. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66917. }
  66918. /**
  66919. * Options fot the updraft event
  66920. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66921. */
  66922. export class PhysicsUpdraftEventOptions {
  66923. /**
  66924. * The radius of the cylinder for the vortex
  66925. */
  66926. radius: number;
  66927. /**
  66928. * The strenth of the updraft.
  66929. */
  66930. strength: number;
  66931. /**
  66932. * The height of the cylinder for the updraft.
  66933. */
  66934. height: number;
  66935. /**
  66936. * The mode for the the updraft.
  66937. */
  66938. updraftMode: PhysicsUpdraftMode;
  66939. }
  66940. /**
  66941. * Options fot the vortex event
  66942. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66943. */
  66944. export class PhysicsVortexEventOptions {
  66945. /**
  66946. * The radius of the cylinder for the vortex
  66947. */
  66948. radius: number;
  66949. /**
  66950. * The strenth of the vortex.
  66951. */
  66952. strength: number;
  66953. /**
  66954. * The height of the cylinder for the vortex.
  66955. */
  66956. height: number;
  66957. /**
  66958. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66959. */
  66960. centripetalForceThreshold: number;
  66961. /**
  66962. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66963. */
  66964. centripetalForceMultiplier: number;
  66965. /**
  66966. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66967. */
  66968. centrifugalForceMultiplier: number;
  66969. /**
  66970. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66971. */
  66972. updraftForceMultiplier: number;
  66973. }
  66974. /**
  66975. * The strenght of the force in correspondence to the distance of the affected object
  66976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66977. */
  66978. export enum PhysicsRadialImpulseFalloff {
  66979. /** Defines that impulse is constant in strength across it's whole radius */
  66980. Constant = 0,
  66981. /** Defines that impulse gets weaker if it's further from the origin */
  66982. Linear = 1
  66983. }
  66984. /**
  66985. * The strength of the force in correspondence to the distance of the affected object
  66986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66987. */
  66988. export enum PhysicsUpdraftMode {
  66989. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66990. Center = 0,
  66991. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66992. Perpendicular = 1
  66993. }
  66994. /**
  66995. * Interface for a physics hit data
  66996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66997. */
  66998. export interface PhysicsHitData {
  66999. /**
  67000. * The force applied at the contact point
  67001. */
  67002. force: Vector3;
  67003. /**
  67004. * The contact point
  67005. */
  67006. contactPoint: Vector3;
  67007. /**
  67008. * The distance from the origin to the contact point
  67009. */
  67010. distanceFromOrigin: number;
  67011. }
  67012. /**
  67013. * Interface for radial explosion event data
  67014. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67015. */
  67016. export interface PhysicsRadialExplosionEventData {
  67017. /**
  67018. * A sphere used for the radial explosion event
  67019. */
  67020. sphere: Mesh;
  67021. }
  67022. /**
  67023. * Interface for gravitational field event data
  67024. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67025. */
  67026. export interface PhysicsGravitationalFieldEventData {
  67027. /**
  67028. * A sphere mesh used for the gravitational field event
  67029. */
  67030. sphere: Mesh;
  67031. }
  67032. /**
  67033. * Interface for updraft event data
  67034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67035. */
  67036. export interface PhysicsUpdraftEventData {
  67037. /**
  67038. * A cylinder used for the updraft event
  67039. */
  67040. cylinder: Mesh;
  67041. }
  67042. /**
  67043. * Interface for vortex event data
  67044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67045. */
  67046. export interface PhysicsVortexEventData {
  67047. /**
  67048. * A cylinder used for the vortex event
  67049. */
  67050. cylinder: Mesh;
  67051. }
  67052. /**
  67053. * Interface for an affected physics impostor
  67054. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67055. */
  67056. export interface PhysicsAffectedImpostorWithData {
  67057. /**
  67058. * The impostor affected by the effect
  67059. */
  67060. impostor: PhysicsImpostor;
  67061. /**
  67062. * The data about the hit/horce from the explosion
  67063. */
  67064. hitData: PhysicsHitData;
  67065. }
  67066. }
  67067. declare module "babylonjs/Physics/Plugins/index" {
  67068. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67069. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67070. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67071. }
  67072. declare module "babylonjs/Physics/index" {
  67073. export * from "babylonjs/Physics/IPhysicsEngine";
  67074. export * from "babylonjs/Physics/physicsEngine";
  67075. export * from "babylonjs/Physics/physicsEngineComponent";
  67076. export * from "babylonjs/Physics/physicsHelper";
  67077. export * from "babylonjs/Physics/physicsImpostor";
  67078. export * from "babylonjs/Physics/physicsJoint";
  67079. export * from "babylonjs/Physics/Plugins/index";
  67080. }
  67081. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67082. /** @hidden */
  67083. export var blackAndWhitePixelShader: {
  67084. name: string;
  67085. shader: string;
  67086. };
  67087. }
  67088. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67089. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67090. import { Camera } from "babylonjs/Cameras/camera";
  67091. import { Engine } from "babylonjs/Engines/engine";
  67092. import "babylonjs/Shaders/blackAndWhite.fragment";
  67093. /**
  67094. * Post process used to render in black and white
  67095. */
  67096. export class BlackAndWhitePostProcess extends PostProcess {
  67097. /**
  67098. * Linear about to convert he result to black and white (default: 1)
  67099. */
  67100. degree: number;
  67101. /**
  67102. * Creates a black and white post process
  67103. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67104. * @param name The name of the effect.
  67105. * @param options The required width/height ratio to downsize to before computing the render pass.
  67106. * @param camera The camera to apply the render pass to.
  67107. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67108. * @param engine The engine which the post process will be applied. (default: current engine)
  67109. * @param reusable If the post process can be reused on the same frame. (default: false)
  67110. */
  67111. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67112. }
  67113. }
  67114. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67115. import { Nullable } from "babylonjs/types";
  67116. import { Camera } from "babylonjs/Cameras/camera";
  67117. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67118. import { Engine } from "babylonjs/Engines/engine";
  67119. /**
  67120. * This represents a set of one or more post processes in Babylon.
  67121. * A post process can be used to apply a shader to a texture after it is rendered.
  67122. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67123. */
  67124. export class PostProcessRenderEffect {
  67125. private _postProcesses;
  67126. private _getPostProcesses;
  67127. private _singleInstance;
  67128. private _cameras;
  67129. private _indicesForCamera;
  67130. /**
  67131. * Name of the effect
  67132. * @hidden
  67133. */
  67134. _name: string;
  67135. /**
  67136. * Instantiates a post process render effect.
  67137. * A post process can be used to apply a shader to a texture after it is rendered.
  67138. * @param engine The engine the effect is tied to
  67139. * @param name The name of the effect
  67140. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67141. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67142. */
  67143. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67144. /**
  67145. * Checks if all the post processes in the effect are supported.
  67146. */
  67147. get isSupported(): boolean;
  67148. /**
  67149. * Updates the current state of the effect
  67150. * @hidden
  67151. */
  67152. _update(): void;
  67153. /**
  67154. * Attaches the effect on cameras
  67155. * @param cameras The camera to attach to.
  67156. * @hidden
  67157. */
  67158. _attachCameras(cameras: Camera): void;
  67159. /**
  67160. * Attaches the effect on cameras
  67161. * @param cameras The camera to attach to.
  67162. * @hidden
  67163. */
  67164. _attachCameras(cameras: Camera[]): void;
  67165. /**
  67166. * Detaches the effect on cameras
  67167. * @param cameras The camera to detatch from.
  67168. * @hidden
  67169. */
  67170. _detachCameras(cameras: Camera): void;
  67171. /**
  67172. * Detatches the effect on cameras
  67173. * @param cameras The camera to detatch from.
  67174. * @hidden
  67175. */
  67176. _detachCameras(cameras: Camera[]): void;
  67177. /**
  67178. * Enables the effect on given cameras
  67179. * @param cameras The camera to enable.
  67180. * @hidden
  67181. */
  67182. _enable(cameras: Camera): void;
  67183. /**
  67184. * Enables the effect on given cameras
  67185. * @param cameras The camera to enable.
  67186. * @hidden
  67187. */
  67188. _enable(cameras: Nullable<Camera[]>): void;
  67189. /**
  67190. * Disables the effect on the given cameras
  67191. * @param cameras The camera to disable.
  67192. * @hidden
  67193. */
  67194. _disable(cameras: Camera): void;
  67195. /**
  67196. * Disables the effect on the given cameras
  67197. * @param cameras The camera to disable.
  67198. * @hidden
  67199. */
  67200. _disable(cameras: Nullable<Camera[]>): void;
  67201. /**
  67202. * Gets a list of the post processes contained in the effect.
  67203. * @param camera The camera to get the post processes on.
  67204. * @returns The list of the post processes in the effect.
  67205. */
  67206. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67207. }
  67208. }
  67209. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67210. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67211. /** @hidden */
  67212. export var extractHighlightsPixelShader: {
  67213. name: string;
  67214. shader: string;
  67215. };
  67216. }
  67217. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67218. import { Nullable } from "babylonjs/types";
  67219. import { Camera } from "babylonjs/Cameras/camera";
  67220. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67221. import { Engine } from "babylonjs/Engines/engine";
  67222. import "babylonjs/Shaders/extractHighlights.fragment";
  67223. /**
  67224. * 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.
  67225. */
  67226. export class ExtractHighlightsPostProcess extends PostProcess {
  67227. /**
  67228. * The luminance threshold, pixels below this value will be set to black.
  67229. */
  67230. threshold: number;
  67231. /** @hidden */
  67232. _exposure: number;
  67233. /**
  67234. * Post process which has the input texture to be used when performing highlight extraction
  67235. * @hidden
  67236. */
  67237. _inputPostProcess: Nullable<PostProcess>;
  67238. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67239. }
  67240. }
  67241. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67242. /** @hidden */
  67243. export var bloomMergePixelShader: {
  67244. name: string;
  67245. shader: string;
  67246. };
  67247. }
  67248. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67249. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67250. import { Nullable } from "babylonjs/types";
  67251. import { Engine } from "babylonjs/Engines/engine";
  67252. import { Camera } from "babylonjs/Cameras/camera";
  67253. import "babylonjs/Shaders/bloomMerge.fragment";
  67254. /**
  67255. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67256. */
  67257. export class BloomMergePostProcess extends PostProcess {
  67258. /** Weight of the bloom to be added to the original input. */
  67259. weight: number;
  67260. /**
  67261. * Creates a new instance of @see BloomMergePostProcess
  67262. * @param name The name of the effect.
  67263. * @param originalFromInput Post process which's input will be used for the merge.
  67264. * @param blurred Blurred highlights post process which's output will be used.
  67265. * @param weight Weight of the bloom to be added to the original input.
  67266. * @param options The required width/height ratio to downsize to before computing the render pass.
  67267. * @param camera The camera to apply the render pass to.
  67268. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67269. * @param engine The engine which the post process will be applied. (default: current engine)
  67270. * @param reusable If the post process can be reused on the same frame. (default: false)
  67271. * @param textureType Type of textures used when performing the post process. (default: 0)
  67272. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  67273. */
  67274. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67275. /** Weight of the bloom to be added to the original input. */
  67276. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67277. }
  67278. }
  67279. declare module "babylonjs/PostProcesses/bloomEffect" {
  67280. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67281. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67282. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67283. import { Camera } from "babylonjs/Cameras/camera";
  67284. import { Scene } from "babylonjs/scene";
  67285. /**
  67286. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67287. */
  67288. export class BloomEffect extends PostProcessRenderEffect {
  67289. private bloomScale;
  67290. /**
  67291. * @hidden Internal
  67292. */
  67293. _effects: Array<PostProcess>;
  67294. /**
  67295. * @hidden Internal
  67296. */
  67297. _downscale: ExtractHighlightsPostProcess;
  67298. private _blurX;
  67299. private _blurY;
  67300. private _merge;
  67301. /**
  67302. * The luminance threshold to find bright areas of the image to bloom.
  67303. */
  67304. get threshold(): number;
  67305. set threshold(value: number);
  67306. /**
  67307. * The strength of the bloom.
  67308. */
  67309. get weight(): number;
  67310. set weight(value: number);
  67311. /**
  67312. * Specifies the size of the bloom blur kernel, relative to the final output size
  67313. */
  67314. get kernel(): number;
  67315. set kernel(value: number);
  67316. /**
  67317. * Creates a new instance of @see BloomEffect
  67318. * @param scene The scene the effect belongs to.
  67319. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67320. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67321. * @param bloomWeight The the strength of bloom.
  67322. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67323. * @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)
  67324. */
  67325. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67326. /**
  67327. * Disposes each of the internal effects for a given camera.
  67328. * @param camera The camera to dispose the effect on.
  67329. */
  67330. disposeEffects(camera: Camera): void;
  67331. /**
  67332. * @hidden Internal
  67333. */
  67334. _updateEffects(): void;
  67335. /**
  67336. * Internal
  67337. * @returns if all the contained post processes are ready.
  67338. * @hidden
  67339. */
  67340. _isReady(): boolean;
  67341. }
  67342. }
  67343. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67344. /** @hidden */
  67345. export var chromaticAberrationPixelShader: {
  67346. name: string;
  67347. shader: string;
  67348. };
  67349. }
  67350. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67351. import { Vector2 } from "babylonjs/Maths/math.vector";
  67352. import { Nullable } from "babylonjs/types";
  67353. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67354. import { Camera } from "babylonjs/Cameras/camera";
  67355. import { Engine } from "babylonjs/Engines/engine";
  67356. import "babylonjs/Shaders/chromaticAberration.fragment";
  67357. /**
  67358. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67359. */
  67360. export class ChromaticAberrationPostProcess extends PostProcess {
  67361. /**
  67362. * The amount of seperation of rgb channels (default: 30)
  67363. */
  67364. aberrationAmount: number;
  67365. /**
  67366. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67367. */
  67368. radialIntensity: number;
  67369. /**
  67370. * 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))
  67371. */
  67372. direction: Vector2;
  67373. /**
  67374. * 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))
  67375. */
  67376. centerPosition: Vector2;
  67377. /**
  67378. * Creates a new instance ChromaticAberrationPostProcess
  67379. * @param name The name of the effect.
  67380. * @param screenWidth The width of the screen to apply the effect on.
  67381. * @param screenHeight The height of the screen to apply the effect on.
  67382. * @param options The required width/height ratio to downsize to before computing the render pass.
  67383. * @param camera The camera to apply the render pass to.
  67384. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67385. * @param engine The engine which the post process will be applied. (default: current engine)
  67386. * @param reusable If the post process can be reused on the same frame. (default: false)
  67387. * @param textureType Type of textures used when performing the post process. (default: 0)
  67388. * @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)
  67389. */
  67390. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67391. }
  67392. }
  67393. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67394. /** @hidden */
  67395. export var circleOfConfusionPixelShader: {
  67396. name: string;
  67397. shader: string;
  67398. };
  67399. }
  67400. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67401. import { Nullable } from "babylonjs/types";
  67402. import { Engine } from "babylonjs/Engines/engine";
  67403. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67404. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67405. import { Camera } from "babylonjs/Cameras/camera";
  67406. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67407. /**
  67408. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67409. */
  67410. export class CircleOfConfusionPostProcess extends PostProcess {
  67411. /**
  67412. * 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.
  67413. */
  67414. lensSize: number;
  67415. /**
  67416. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67417. */
  67418. fStop: number;
  67419. /**
  67420. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67421. */
  67422. focusDistance: number;
  67423. /**
  67424. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67425. */
  67426. focalLength: number;
  67427. private _depthTexture;
  67428. /**
  67429. * Creates a new instance CircleOfConfusionPostProcess
  67430. * @param name The name of the effect.
  67431. * @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.
  67432. * @param options The required width/height ratio to downsize to before computing the render pass.
  67433. * @param camera The camera to apply the render pass to.
  67434. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67435. * @param engine The engine which the post process will be applied. (default: current engine)
  67436. * @param reusable If the post process can be reused on the same frame. (default: false)
  67437. * @param textureType Type of textures used when performing the post process. (default: 0)
  67438. * @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)
  67439. */
  67440. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67441. /**
  67442. * 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.
  67443. */
  67444. set depthTexture(value: RenderTargetTexture);
  67445. }
  67446. }
  67447. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67448. /** @hidden */
  67449. export var colorCorrectionPixelShader: {
  67450. name: string;
  67451. shader: string;
  67452. };
  67453. }
  67454. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67455. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67456. import { Engine } from "babylonjs/Engines/engine";
  67457. import { Camera } from "babylonjs/Cameras/camera";
  67458. import "babylonjs/Shaders/colorCorrection.fragment";
  67459. /**
  67460. *
  67461. * This post-process allows the modification of rendered colors by using
  67462. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67463. *
  67464. * The object needs to be provided an url to a texture containing the color
  67465. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67466. * Use an image editing software to tweak the LUT to match your needs.
  67467. *
  67468. * For an example of a color LUT, see here:
  67469. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67470. * For explanations on color grading, see here:
  67471. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67472. *
  67473. */
  67474. export class ColorCorrectionPostProcess extends PostProcess {
  67475. private _colorTableTexture;
  67476. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67477. }
  67478. }
  67479. declare module "babylonjs/Shaders/convolution.fragment" {
  67480. /** @hidden */
  67481. export var convolutionPixelShader: {
  67482. name: string;
  67483. shader: string;
  67484. };
  67485. }
  67486. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67487. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67488. import { Nullable } from "babylonjs/types";
  67489. import { Camera } from "babylonjs/Cameras/camera";
  67490. import { Engine } from "babylonjs/Engines/engine";
  67491. import "babylonjs/Shaders/convolution.fragment";
  67492. /**
  67493. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67494. * input texture to perform effects such as edge detection or sharpening
  67495. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67496. */
  67497. export class ConvolutionPostProcess extends PostProcess {
  67498. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67499. kernel: number[];
  67500. /**
  67501. * Creates a new instance ConvolutionPostProcess
  67502. * @param name The name of the effect.
  67503. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67504. * @param options The required width/height ratio to downsize to before computing the render pass.
  67505. * @param camera The camera to apply the render pass to.
  67506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67507. * @param engine The engine which the post process will be applied. (default: current engine)
  67508. * @param reusable If the post process can be reused on the same frame. (default: false)
  67509. * @param textureType Type of textures used when performing the post process. (default: 0)
  67510. */
  67511. constructor(name: string,
  67512. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67513. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67514. /**
  67515. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67516. */
  67517. static EdgeDetect0Kernel: number[];
  67518. /**
  67519. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67520. */
  67521. static EdgeDetect1Kernel: number[];
  67522. /**
  67523. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67524. */
  67525. static EdgeDetect2Kernel: number[];
  67526. /**
  67527. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67528. */
  67529. static SharpenKernel: number[];
  67530. /**
  67531. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67532. */
  67533. static EmbossKernel: number[];
  67534. /**
  67535. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67536. */
  67537. static GaussianKernel: number[];
  67538. }
  67539. }
  67540. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67541. import { Nullable } from "babylonjs/types";
  67542. import { Vector2 } from "babylonjs/Maths/math.vector";
  67543. import { Camera } from "babylonjs/Cameras/camera";
  67544. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67545. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67546. import { Engine } from "babylonjs/Engines/engine";
  67547. import { Scene } from "babylonjs/scene";
  67548. /**
  67549. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67550. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67551. * based on samples that have a large difference in distance than the center pixel.
  67552. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67553. */
  67554. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67555. direction: Vector2;
  67556. /**
  67557. * Creates a new instance CircleOfConfusionPostProcess
  67558. * @param name The name of the effect.
  67559. * @param scene The scene the effect belongs to.
  67560. * @param direction The direction the blur should be applied.
  67561. * @param kernel The size of the kernel used to blur.
  67562. * @param options The required width/height ratio to downsize to before computing the render pass.
  67563. * @param camera The camera to apply the render pass to.
  67564. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67565. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67566. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67567. * @param engine The engine which the post process will be applied. (default: current engine)
  67568. * @param reusable If the post process can be reused on the same frame. (default: false)
  67569. * @param textureType Type of textures used when performing the post process. (default: 0)
  67570. * @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)
  67571. */
  67572. 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);
  67573. }
  67574. }
  67575. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67576. /** @hidden */
  67577. export var depthOfFieldMergePixelShader: {
  67578. name: string;
  67579. shader: string;
  67580. };
  67581. }
  67582. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67583. import { Nullable } from "babylonjs/types";
  67584. import { Camera } from "babylonjs/Cameras/camera";
  67585. import { Effect } from "babylonjs/Materials/effect";
  67586. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67587. import { Engine } from "babylonjs/Engines/engine";
  67588. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67589. /**
  67590. * Options to be set when merging outputs from the default pipeline.
  67591. */
  67592. export class DepthOfFieldMergePostProcessOptions {
  67593. /**
  67594. * The original image to merge on top of
  67595. */
  67596. originalFromInput: PostProcess;
  67597. /**
  67598. * Parameters to perform the merge of the depth of field effect
  67599. */
  67600. depthOfField?: {
  67601. circleOfConfusion: PostProcess;
  67602. blurSteps: Array<PostProcess>;
  67603. };
  67604. /**
  67605. * Parameters to perform the merge of bloom effect
  67606. */
  67607. bloom?: {
  67608. blurred: PostProcess;
  67609. weight: number;
  67610. };
  67611. }
  67612. /**
  67613. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67614. */
  67615. export class DepthOfFieldMergePostProcess extends PostProcess {
  67616. private blurSteps;
  67617. /**
  67618. * Creates a new instance of DepthOfFieldMergePostProcess
  67619. * @param name The name of the effect.
  67620. * @param originalFromInput Post process which's input will be used for the merge.
  67621. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67622. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67623. * @param options The required width/height ratio to downsize to before computing the render pass.
  67624. * @param camera The camera to apply the render pass to.
  67625. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67626. * @param engine The engine which the post process will be applied. (default: current engine)
  67627. * @param reusable If the post process can be reused on the same frame. (default: false)
  67628. * @param textureType Type of textures used when performing the post process. (default: 0)
  67629. * @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)
  67630. */
  67631. 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);
  67632. /**
  67633. * Updates the effect with the current post process compile time values and recompiles the shader.
  67634. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67635. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67636. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67637. * @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
  67638. * @param onCompiled Called when the shader has been compiled.
  67639. * @param onError Called if there is an error when compiling a shader.
  67640. */
  67641. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67642. }
  67643. }
  67644. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67645. import { Nullable } from "babylonjs/types";
  67646. import { Camera } from "babylonjs/Cameras/camera";
  67647. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67648. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67649. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67650. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67651. import { Scene } from "babylonjs/scene";
  67652. /**
  67653. * Specifies the level of max blur that should be applied when using the depth of field effect
  67654. */
  67655. export enum DepthOfFieldEffectBlurLevel {
  67656. /**
  67657. * Subtle blur
  67658. */
  67659. Low = 0,
  67660. /**
  67661. * Medium blur
  67662. */
  67663. Medium = 1,
  67664. /**
  67665. * Large blur
  67666. */
  67667. High = 2
  67668. }
  67669. /**
  67670. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67671. */
  67672. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67673. private _circleOfConfusion;
  67674. /**
  67675. * @hidden Internal, blurs from high to low
  67676. */
  67677. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67678. private _depthOfFieldBlurY;
  67679. private _dofMerge;
  67680. /**
  67681. * @hidden Internal post processes in depth of field effect
  67682. */
  67683. _effects: Array<PostProcess>;
  67684. /**
  67685. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67686. */
  67687. set focalLength(value: number);
  67688. get focalLength(): number;
  67689. /**
  67690. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67691. */
  67692. set fStop(value: number);
  67693. get fStop(): number;
  67694. /**
  67695. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67696. */
  67697. set focusDistance(value: number);
  67698. get focusDistance(): number;
  67699. /**
  67700. * 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.
  67701. */
  67702. set lensSize(value: number);
  67703. get lensSize(): number;
  67704. /**
  67705. * Creates a new instance DepthOfFieldEffect
  67706. * @param scene The scene the effect belongs to.
  67707. * @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.
  67708. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67709. * @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)
  67710. */
  67711. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67712. /**
  67713. * Get the current class name of the current effet
  67714. * @returns "DepthOfFieldEffect"
  67715. */
  67716. getClassName(): string;
  67717. /**
  67718. * 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.
  67719. */
  67720. set depthTexture(value: RenderTargetTexture);
  67721. /**
  67722. * Disposes each of the internal effects for a given camera.
  67723. * @param camera The camera to dispose the effect on.
  67724. */
  67725. disposeEffects(camera: Camera): void;
  67726. /**
  67727. * @hidden Internal
  67728. */
  67729. _updateEffects(): void;
  67730. /**
  67731. * Internal
  67732. * @returns if all the contained post processes are ready.
  67733. * @hidden
  67734. */
  67735. _isReady(): boolean;
  67736. }
  67737. }
  67738. declare module "babylonjs/Shaders/displayPass.fragment" {
  67739. /** @hidden */
  67740. export var displayPassPixelShader: {
  67741. name: string;
  67742. shader: string;
  67743. };
  67744. }
  67745. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67746. import { Nullable } from "babylonjs/types";
  67747. import { Camera } from "babylonjs/Cameras/camera";
  67748. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67749. import { Engine } from "babylonjs/Engines/engine";
  67750. import "babylonjs/Shaders/displayPass.fragment";
  67751. /**
  67752. * DisplayPassPostProcess which produces an output the same as it's input
  67753. */
  67754. export class DisplayPassPostProcess extends PostProcess {
  67755. /**
  67756. * Creates the DisplayPassPostProcess
  67757. * @param name The name of the effect.
  67758. * @param options The required width/height ratio to downsize to before computing the render pass.
  67759. * @param camera The camera to apply the render pass to.
  67760. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67761. * @param engine The engine which the post process will be applied. (default: current engine)
  67762. * @param reusable If the post process can be reused on the same frame. (default: false)
  67763. */
  67764. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67765. }
  67766. }
  67767. declare module "babylonjs/Shaders/filter.fragment" {
  67768. /** @hidden */
  67769. export var filterPixelShader: {
  67770. name: string;
  67771. shader: string;
  67772. };
  67773. }
  67774. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67775. import { Nullable } from "babylonjs/types";
  67776. import { Matrix } from "babylonjs/Maths/math.vector";
  67777. import { Camera } from "babylonjs/Cameras/camera";
  67778. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67779. import { Engine } from "babylonjs/Engines/engine";
  67780. import "babylonjs/Shaders/filter.fragment";
  67781. /**
  67782. * Applies a kernel filter to the image
  67783. */
  67784. export class FilterPostProcess extends PostProcess {
  67785. /** The matrix to be applied to the image */
  67786. kernelMatrix: Matrix;
  67787. /**
  67788. *
  67789. * @param name The name of the effect.
  67790. * @param kernelMatrix The matrix to be applied to the image
  67791. * @param options The required width/height ratio to downsize to before computing the render pass.
  67792. * @param camera The camera to apply the render pass to.
  67793. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67794. * @param engine The engine which the post process will be applied. (default: current engine)
  67795. * @param reusable If the post process can be reused on the same frame. (default: false)
  67796. */
  67797. constructor(name: string,
  67798. /** The matrix to be applied to the image */
  67799. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67800. }
  67801. }
  67802. declare module "babylonjs/Shaders/fxaa.fragment" {
  67803. /** @hidden */
  67804. export var fxaaPixelShader: {
  67805. name: string;
  67806. shader: string;
  67807. };
  67808. }
  67809. declare module "babylonjs/Shaders/fxaa.vertex" {
  67810. /** @hidden */
  67811. export var fxaaVertexShader: {
  67812. name: string;
  67813. shader: string;
  67814. };
  67815. }
  67816. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67817. import { Nullable } from "babylonjs/types";
  67818. import { Camera } from "babylonjs/Cameras/camera";
  67819. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67820. import { Engine } from "babylonjs/Engines/engine";
  67821. import "babylonjs/Shaders/fxaa.fragment";
  67822. import "babylonjs/Shaders/fxaa.vertex";
  67823. /**
  67824. * Fxaa post process
  67825. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67826. */
  67827. export class FxaaPostProcess extends PostProcess {
  67828. /** @hidden */
  67829. texelWidth: number;
  67830. /** @hidden */
  67831. texelHeight: number;
  67832. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67833. private _getDefines;
  67834. }
  67835. }
  67836. declare module "babylonjs/Shaders/grain.fragment" {
  67837. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67838. /** @hidden */
  67839. export var grainPixelShader: {
  67840. name: string;
  67841. shader: string;
  67842. };
  67843. }
  67844. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67845. import { Nullable } from "babylonjs/types";
  67846. import { Camera } from "babylonjs/Cameras/camera";
  67847. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67848. import { Engine } from "babylonjs/Engines/engine";
  67849. import "babylonjs/Shaders/grain.fragment";
  67850. /**
  67851. * The GrainPostProcess adds noise to the image at mid luminance levels
  67852. */
  67853. export class GrainPostProcess extends PostProcess {
  67854. /**
  67855. * The intensity of the grain added (default: 30)
  67856. */
  67857. intensity: number;
  67858. /**
  67859. * If the grain should be randomized on every frame
  67860. */
  67861. animated: boolean;
  67862. /**
  67863. * Creates a new instance of @see GrainPostProcess
  67864. * @param name The name of the effect.
  67865. * @param options The required width/height ratio to downsize to before computing the render pass.
  67866. * @param camera The camera to apply the render pass to.
  67867. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67868. * @param engine The engine which the post process will be applied. (default: current engine)
  67869. * @param reusable If the post process can be reused on the same frame. (default: false)
  67870. * @param textureType Type of textures used when performing the post process. (default: 0)
  67871. * @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)
  67872. */
  67873. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67874. }
  67875. }
  67876. declare module "babylonjs/Shaders/highlights.fragment" {
  67877. /** @hidden */
  67878. export var highlightsPixelShader: {
  67879. name: string;
  67880. shader: string;
  67881. };
  67882. }
  67883. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  67884. import { Nullable } from "babylonjs/types";
  67885. import { Camera } from "babylonjs/Cameras/camera";
  67886. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67887. import { Engine } from "babylonjs/Engines/engine";
  67888. import "babylonjs/Shaders/highlights.fragment";
  67889. /**
  67890. * Extracts highlights from the image
  67891. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67892. */
  67893. export class HighlightsPostProcess extends PostProcess {
  67894. /**
  67895. * Extracts highlights from the image
  67896. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67897. * @param name The name of the effect.
  67898. * @param options The required width/height ratio to downsize to before computing the render pass.
  67899. * @param camera The camera to apply the render pass to.
  67900. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67901. * @param engine The engine which the post process will be applied. (default: current engine)
  67902. * @param reusable If the post process can be reused on the same frame. (default: false)
  67903. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67904. */
  67905. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67906. }
  67907. }
  67908. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  67909. /** @hidden */
  67910. export var mrtFragmentDeclaration: {
  67911. name: string;
  67912. shader: string;
  67913. };
  67914. }
  67915. declare module "babylonjs/Shaders/geometry.fragment" {
  67916. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  67917. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67918. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67919. /** @hidden */
  67920. export var geometryPixelShader: {
  67921. name: string;
  67922. shader: string;
  67923. };
  67924. }
  67925. declare module "babylonjs/Shaders/geometry.vertex" {
  67926. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67927. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67928. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67929. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67930. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67931. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67932. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67933. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  67934. /** @hidden */
  67935. export var geometryVertexShader: {
  67936. name: string;
  67937. shader: string;
  67938. };
  67939. }
  67940. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  67941. import { Matrix } from "babylonjs/Maths/math.vector";
  67942. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67943. import { Mesh } from "babylonjs/Meshes/mesh";
  67944. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  67945. import { Effect } from "babylonjs/Materials/effect";
  67946. import { Scene } from "babylonjs/scene";
  67947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67948. import "babylonjs/Shaders/geometry.fragment";
  67949. import "babylonjs/Shaders/geometry.vertex";
  67950. /** @hidden */
  67951. interface ISavedTransformationMatrix {
  67952. world: Matrix;
  67953. viewProjection: Matrix;
  67954. }
  67955. /**
  67956. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67957. */
  67958. export class GeometryBufferRenderer {
  67959. /**
  67960. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67961. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67962. */
  67963. static readonly POSITION_TEXTURE_TYPE: number;
  67964. /**
  67965. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67966. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67967. */
  67968. static readonly VELOCITY_TEXTURE_TYPE: number;
  67969. /**
  67970. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67971. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67972. */
  67973. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67974. /**
  67975. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67976. * in order to compute objects velocities when enableVelocity is set to "true"
  67977. * @hidden
  67978. */
  67979. _previousTransformationMatrices: {
  67980. [index: number]: ISavedTransformationMatrix;
  67981. };
  67982. /**
  67983. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67984. * in order to compute objects velocities when enableVelocity is set to "true"
  67985. * @hidden
  67986. */
  67987. _previousBonesTransformationMatrices: {
  67988. [index: number]: Float32Array;
  67989. };
  67990. /**
  67991. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67992. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67993. */
  67994. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67995. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67996. renderTransparentMeshes: boolean;
  67997. private _scene;
  67998. private _multiRenderTarget;
  67999. private _ratio;
  68000. private _enablePosition;
  68001. private _enableVelocity;
  68002. private _enableReflectivity;
  68003. private _positionIndex;
  68004. private _velocityIndex;
  68005. private _reflectivityIndex;
  68006. protected _effect: Effect;
  68007. protected _cachedDefines: string;
  68008. /**
  68009. * Set the render list (meshes to be rendered) used in the G buffer.
  68010. */
  68011. set renderList(meshes: Mesh[]);
  68012. /**
  68013. * Gets wether or not G buffer are supported by the running hardware.
  68014. * This requires draw buffer supports
  68015. */
  68016. get isSupported(): boolean;
  68017. /**
  68018. * Returns the index of the given texture type in the G-Buffer textures array
  68019. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68020. * @returns the index of the given texture type in the G-Buffer textures array
  68021. */
  68022. getTextureIndex(textureType: number): number;
  68023. /**
  68024. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68025. */
  68026. get enablePosition(): boolean;
  68027. /**
  68028. * Sets whether or not objects positions are enabled for the G buffer.
  68029. */
  68030. set enablePosition(enable: boolean);
  68031. /**
  68032. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68033. */
  68034. get enableVelocity(): boolean;
  68035. /**
  68036. * Sets wether or not objects velocities are enabled for the G buffer.
  68037. */
  68038. set enableVelocity(enable: boolean);
  68039. /**
  68040. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68041. */
  68042. get enableReflectivity(): boolean;
  68043. /**
  68044. * Sets wether or not objects roughness are enabled for the G buffer.
  68045. */
  68046. set enableReflectivity(enable: boolean);
  68047. /**
  68048. * Gets the scene associated with the buffer.
  68049. */
  68050. get scene(): Scene;
  68051. /**
  68052. * Gets the ratio used by the buffer during its creation.
  68053. * How big is the buffer related to the main canvas.
  68054. */
  68055. get ratio(): number;
  68056. /** @hidden */
  68057. static _SceneComponentInitialization: (scene: Scene) => void;
  68058. /**
  68059. * Creates a new G Buffer for the scene
  68060. * @param scene The scene the buffer belongs to
  68061. * @param ratio How big is the buffer related to the main canvas.
  68062. */
  68063. constructor(scene: Scene, ratio?: number);
  68064. /**
  68065. * Checks wether everything is ready to render a submesh to the G buffer.
  68066. * @param subMesh the submesh to check readiness for
  68067. * @param useInstances is the mesh drawn using instance or not
  68068. * @returns true if ready otherwise false
  68069. */
  68070. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68071. /**
  68072. * Gets the current underlying G Buffer.
  68073. * @returns the buffer
  68074. */
  68075. getGBuffer(): MultiRenderTarget;
  68076. /**
  68077. * Gets the number of samples used to render the buffer (anti aliasing).
  68078. */
  68079. get samples(): number;
  68080. /**
  68081. * Sets the number of samples used to render the buffer (anti aliasing).
  68082. */
  68083. set samples(value: number);
  68084. /**
  68085. * Disposes the renderer and frees up associated resources.
  68086. */
  68087. dispose(): void;
  68088. protected _createRenderTargets(): void;
  68089. private _copyBonesTransformationMatrices;
  68090. }
  68091. }
  68092. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68093. import { Nullable } from "babylonjs/types";
  68094. import { Scene } from "babylonjs/scene";
  68095. import { ISceneComponent } from "babylonjs/sceneComponent";
  68096. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68097. module "babylonjs/scene" {
  68098. interface Scene {
  68099. /** @hidden (Backing field) */
  68100. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68101. /**
  68102. * Gets or Sets the current geometry buffer associated to the scene.
  68103. */
  68104. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68105. /**
  68106. * Enables a GeometryBufferRender and associates it with the scene
  68107. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68108. * @returns the GeometryBufferRenderer
  68109. */
  68110. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68111. /**
  68112. * Disables the GeometryBufferRender associated with the scene
  68113. */
  68114. disableGeometryBufferRenderer(): void;
  68115. }
  68116. }
  68117. /**
  68118. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68119. * in several rendering techniques.
  68120. */
  68121. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68122. /**
  68123. * The component name helpful to identify the component in the list of scene components.
  68124. */
  68125. readonly name: string;
  68126. /**
  68127. * The scene the component belongs to.
  68128. */
  68129. scene: Scene;
  68130. /**
  68131. * Creates a new instance of the component for the given scene
  68132. * @param scene Defines the scene to register the component in
  68133. */
  68134. constructor(scene: Scene);
  68135. /**
  68136. * Registers the component in a given scene
  68137. */
  68138. register(): void;
  68139. /**
  68140. * Rebuilds the elements related to this component in case of
  68141. * context lost for instance.
  68142. */
  68143. rebuild(): void;
  68144. /**
  68145. * Disposes the component and the associated ressources
  68146. */
  68147. dispose(): void;
  68148. private _gatherRenderTargets;
  68149. }
  68150. }
  68151. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68152. /** @hidden */
  68153. export var motionBlurPixelShader: {
  68154. name: string;
  68155. shader: string;
  68156. };
  68157. }
  68158. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68159. import { Nullable } from "babylonjs/types";
  68160. import { Camera } from "babylonjs/Cameras/camera";
  68161. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68162. import { Scene } from "babylonjs/scene";
  68163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68164. import "babylonjs/Animations/animatable";
  68165. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68166. import "babylonjs/Shaders/motionBlur.fragment";
  68167. import { Engine } from "babylonjs/Engines/engine";
  68168. /**
  68169. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68170. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68171. * As an example, all you have to do is to create the post-process:
  68172. * var mb = new BABYLON.MotionBlurPostProcess(
  68173. * 'mb', // The name of the effect.
  68174. * scene, // The scene containing the objects to blur according to their velocity.
  68175. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68176. * camera // The camera to apply the render pass to.
  68177. * );
  68178. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68179. */
  68180. export class MotionBlurPostProcess extends PostProcess {
  68181. /**
  68182. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68183. */
  68184. motionStrength: number;
  68185. /**
  68186. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68187. */
  68188. get motionBlurSamples(): number;
  68189. /**
  68190. * Sets the number of iterations to be used for motion blur quality
  68191. */
  68192. set motionBlurSamples(samples: number);
  68193. private _motionBlurSamples;
  68194. private _geometryBufferRenderer;
  68195. /**
  68196. * Creates a new instance MotionBlurPostProcess
  68197. * @param name The name of the effect.
  68198. * @param scene The scene containing the objects to blur according to their velocity.
  68199. * @param options The required width/height ratio to downsize to before computing the render pass.
  68200. * @param camera The camera to apply the render pass to.
  68201. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68202. * @param engine The engine which the post process will be applied. (default: current engine)
  68203. * @param reusable If the post process can be reused on the same frame. (default: false)
  68204. * @param textureType Type of textures used when performing the post process. (default: 0)
  68205. * @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)
  68206. */
  68207. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68208. /**
  68209. * Excludes the given skinned mesh from computing bones velocities.
  68210. * 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.
  68211. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68212. */
  68213. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68214. /**
  68215. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68216. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68217. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68218. */
  68219. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68220. /**
  68221. * Disposes the post process.
  68222. * @param camera The camera to dispose the post process on.
  68223. */
  68224. dispose(camera?: Camera): void;
  68225. }
  68226. }
  68227. declare module "babylonjs/Shaders/refraction.fragment" {
  68228. /** @hidden */
  68229. export var refractionPixelShader: {
  68230. name: string;
  68231. shader: string;
  68232. };
  68233. }
  68234. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68235. import { Color3 } from "babylonjs/Maths/math.color";
  68236. import { Camera } from "babylonjs/Cameras/camera";
  68237. import { Texture } from "babylonjs/Materials/Textures/texture";
  68238. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68239. import { Engine } from "babylonjs/Engines/engine";
  68240. import "babylonjs/Shaders/refraction.fragment";
  68241. /**
  68242. * Post process which applies a refractin texture
  68243. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68244. */
  68245. export class RefractionPostProcess extends PostProcess {
  68246. /** the base color of the refraction (used to taint the rendering) */
  68247. color: Color3;
  68248. /** simulated refraction depth */
  68249. depth: number;
  68250. /** the coefficient of the base color (0 to remove base color tainting) */
  68251. colorLevel: number;
  68252. private _refTexture;
  68253. private _ownRefractionTexture;
  68254. /**
  68255. * Gets or sets the refraction texture
  68256. * Please note that you are responsible for disposing the texture if you set it manually
  68257. */
  68258. get refractionTexture(): Texture;
  68259. set refractionTexture(value: Texture);
  68260. /**
  68261. * Initializes the RefractionPostProcess
  68262. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68263. * @param name The name of the effect.
  68264. * @param refractionTextureUrl Url of the refraction texture to use
  68265. * @param color the base color of the refraction (used to taint the rendering)
  68266. * @param depth simulated refraction depth
  68267. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68268. * @param camera The camera to apply the render pass to.
  68269. * @param options The required width/height ratio to downsize to before computing the render pass.
  68270. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68271. * @param engine The engine which the post process will be applied. (default: current engine)
  68272. * @param reusable If the post process can be reused on the same frame. (default: false)
  68273. */
  68274. constructor(name: string, refractionTextureUrl: string,
  68275. /** the base color of the refraction (used to taint the rendering) */
  68276. color: Color3,
  68277. /** simulated refraction depth */
  68278. depth: number,
  68279. /** the coefficient of the base color (0 to remove base color tainting) */
  68280. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68281. /**
  68282. * Disposes of the post process
  68283. * @param camera Camera to dispose post process on
  68284. */
  68285. dispose(camera: Camera): void;
  68286. }
  68287. }
  68288. declare module "babylonjs/Shaders/sharpen.fragment" {
  68289. /** @hidden */
  68290. export var sharpenPixelShader: {
  68291. name: string;
  68292. shader: string;
  68293. };
  68294. }
  68295. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68296. import { Nullable } from "babylonjs/types";
  68297. import { Camera } from "babylonjs/Cameras/camera";
  68298. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68299. import "babylonjs/Shaders/sharpen.fragment";
  68300. import { Engine } from "babylonjs/Engines/engine";
  68301. /**
  68302. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68303. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68304. */
  68305. export class SharpenPostProcess extends PostProcess {
  68306. /**
  68307. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68308. */
  68309. colorAmount: number;
  68310. /**
  68311. * How much sharpness should be applied (default: 0.3)
  68312. */
  68313. edgeAmount: number;
  68314. /**
  68315. * Creates a new instance ConvolutionPostProcess
  68316. * @param name The name of the effect.
  68317. * @param options The required width/height ratio to downsize to before computing the render pass.
  68318. * @param camera The camera to apply the render pass to.
  68319. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68320. * @param engine The engine which the post process will be applied. (default: current engine)
  68321. * @param reusable If the post process can be reused on the same frame. (default: false)
  68322. * @param textureType Type of textures used when performing the post process. (default: 0)
  68323. * @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)
  68324. */
  68325. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68326. }
  68327. }
  68328. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68329. import { Nullable } from "babylonjs/types";
  68330. import { Camera } from "babylonjs/Cameras/camera";
  68331. import { Engine } from "babylonjs/Engines/engine";
  68332. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68333. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68334. /**
  68335. * PostProcessRenderPipeline
  68336. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68337. */
  68338. export class PostProcessRenderPipeline {
  68339. private engine;
  68340. private _renderEffects;
  68341. private _renderEffectsForIsolatedPass;
  68342. /**
  68343. * List of inspectable custom properties (used by the Inspector)
  68344. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68345. */
  68346. inspectableCustomProperties: IInspectable[];
  68347. /**
  68348. * @hidden
  68349. */
  68350. protected _cameras: Camera[];
  68351. /** @hidden */
  68352. _name: string;
  68353. /**
  68354. * Gets pipeline name
  68355. */
  68356. get name(): string;
  68357. /** Gets the list of attached cameras */
  68358. get cameras(): Camera[];
  68359. /**
  68360. * Initializes a PostProcessRenderPipeline
  68361. * @param engine engine to add the pipeline to
  68362. * @param name name of the pipeline
  68363. */
  68364. constructor(engine: Engine, name: string);
  68365. /**
  68366. * Gets the class name
  68367. * @returns "PostProcessRenderPipeline"
  68368. */
  68369. getClassName(): string;
  68370. /**
  68371. * If all the render effects in the pipeline are supported
  68372. */
  68373. get isSupported(): boolean;
  68374. /**
  68375. * Adds an effect to the pipeline
  68376. * @param renderEffect the effect to add
  68377. */
  68378. addEffect(renderEffect: PostProcessRenderEffect): void;
  68379. /** @hidden */
  68380. _rebuild(): void;
  68381. /** @hidden */
  68382. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68383. /** @hidden */
  68384. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68385. /** @hidden */
  68386. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68387. /** @hidden */
  68388. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68389. /** @hidden */
  68390. _attachCameras(cameras: Camera, unique: boolean): void;
  68391. /** @hidden */
  68392. _attachCameras(cameras: Camera[], unique: boolean): void;
  68393. /** @hidden */
  68394. _detachCameras(cameras: Camera): void;
  68395. /** @hidden */
  68396. _detachCameras(cameras: Nullable<Camera[]>): void;
  68397. /** @hidden */
  68398. _update(): void;
  68399. /** @hidden */
  68400. _reset(): void;
  68401. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68402. /**
  68403. * Disposes of the pipeline
  68404. */
  68405. dispose(): void;
  68406. }
  68407. }
  68408. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68409. import { Camera } from "babylonjs/Cameras/camera";
  68410. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68411. /**
  68412. * PostProcessRenderPipelineManager class
  68413. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68414. */
  68415. export class PostProcessRenderPipelineManager {
  68416. private _renderPipelines;
  68417. /**
  68418. * Initializes a PostProcessRenderPipelineManager
  68419. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68420. */
  68421. constructor();
  68422. /**
  68423. * Gets the list of supported render pipelines
  68424. */
  68425. get supportedPipelines(): PostProcessRenderPipeline[];
  68426. /**
  68427. * Adds a pipeline to the manager
  68428. * @param renderPipeline The pipeline to add
  68429. */
  68430. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68431. /**
  68432. * Attaches a camera to the pipeline
  68433. * @param renderPipelineName The name of the pipeline to attach to
  68434. * @param cameras the camera to attach
  68435. * @param unique if the camera can be attached multiple times to the pipeline
  68436. */
  68437. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68438. /**
  68439. * Detaches a camera from the pipeline
  68440. * @param renderPipelineName The name of the pipeline to detach from
  68441. * @param cameras the camera to detach
  68442. */
  68443. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68444. /**
  68445. * Enables an effect by name on a pipeline
  68446. * @param renderPipelineName the name of the pipeline to enable the effect in
  68447. * @param renderEffectName the name of the effect to enable
  68448. * @param cameras the cameras that the effect should be enabled on
  68449. */
  68450. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68451. /**
  68452. * Disables an effect by name on a pipeline
  68453. * @param renderPipelineName the name of the pipeline to disable the effect in
  68454. * @param renderEffectName the name of the effect to disable
  68455. * @param cameras the cameras that the effect should be disabled on
  68456. */
  68457. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68458. /**
  68459. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68460. */
  68461. update(): void;
  68462. /** @hidden */
  68463. _rebuild(): void;
  68464. /**
  68465. * Disposes of the manager and pipelines
  68466. */
  68467. dispose(): void;
  68468. }
  68469. }
  68470. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68471. import { ISceneComponent } from "babylonjs/sceneComponent";
  68472. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68473. import { Scene } from "babylonjs/scene";
  68474. module "babylonjs/scene" {
  68475. interface Scene {
  68476. /** @hidden (Backing field) */
  68477. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68478. /**
  68479. * Gets the postprocess render pipeline manager
  68480. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68481. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68482. */
  68483. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68484. }
  68485. }
  68486. /**
  68487. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68488. */
  68489. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68490. /**
  68491. * The component name helpfull to identify the component in the list of scene components.
  68492. */
  68493. readonly name: string;
  68494. /**
  68495. * The scene the component belongs to.
  68496. */
  68497. scene: Scene;
  68498. /**
  68499. * Creates a new instance of the component for the given scene
  68500. * @param scene Defines the scene to register the component in
  68501. */
  68502. constructor(scene: Scene);
  68503. /**
  68504. * Registers the component in a given scene
  68505. */
  68506. register(): void;
  68507. /**
  68508. * Rebuilds the elements related to this component in case of
  68509. * context lost for instance.
  68510. */
  68511. rebuild(): void;
  68512. /**
  68513. * Disposes the component and the associated ressources
  68514. */
  68515. dispose(): void;
  68516. private _gatherRenderTargets;
  68517. }
  68518. }
  68519. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68520. import { Nullable } from "babylonjs/types";
  68521. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68522. import { Camera } from "babylonjs/Cameras/camera";
  68523. import { IDisposable } from "babylonjs/scene";
  68524. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68525. import { Scene } from "babylonjs/scene";
  68526. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68527. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68528. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68529. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68530. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68531. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68532. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68533. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68534. import { Animation } from "babylonjs/Animations/animation";
  68535. /**
  68536. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68537. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68538. */
  68539. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68540. private _scene;
  68541. private _camerasToBeAttached;
  68542. /**
  68543. * ID of the sharpen post process,
  68544. */
  68545. private readonly SharpenPostProcessId;
  68546. /**
  68547. * @ignore
  68548. * ID of the image processing post process;
  68549. */
  68550. readonly ImageProcessingPostProcessId: string;
  68551. /**
  68552. * @ignore
  68553. * ID of the Fast Approximate Anti-Aliasing post process;
  68554. */
  68555. readonly FxaaPostProcessId: string;
  68556. /**
  68557. * ID of the chromatic aberration post process,
  68558. */
  68559. private readonly ChromaticAberrationPostProcessId;
  68560. /**
  68561. * ID of the grain post process
  68562. */
  68563. private readonly GrainPostProcessId;
  68564. /**
  68565. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68566. */
  68567. sharpen: SharpenPostProcess;
  68568. private _sharpenEffect;
  68569. private bloom;
  68570. /**
  68571. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68572. */
  68573. depthOfField: DepthOfFieldEffect;
  68574. /**
  68575. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68576. */
  68577. fxaa: FxaaPostProcess;
  68578. /**
  68579. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68580. */
  68581. imageProcessing: ImageProcessingPostProcess;
  68582. /**
  68583. * Chromatic aberration post process which will shift rgb colors in the image
  68584. */
  68585. chromaticAberration: ChromaticAberrationPostProcess;
  68586. private _chromaticAberrationEffect;
  68587. /**
  68588. * Grain post process which add noise to the image
  68589. */
  68590. grain: GrainPostProcess;
  68591. private _grainEffect;
  68592. /**
  68593. * Glow post process which adds a glow to emissive areas of the image
  68594. */
  68595. private _glowLayer;
  68596. /**
  68597. * Animations which can be used to tweak settings over a period of time
  68598. */
  68599. animations: Animation[];
  68600. private _imageProcessingConfigurationObserver;
  68601. private _sharpenEnabled;
  68602. private _bloomEnabled;
  68603. private _depthOfFieldEnabled;
  68604. private _depthOfFieldBlurLevel;
  68605. private _fxaaEnabled;
  68606. private _imageProcessingEnabled;
  68607. private _defaultPipelineTextureType;
  68608. private _bloomScale;
  68609. private _chromaticAberrationEnabled;
  68610. private _grainEnabled;
  68611. private _buildAllowed;
  68612. /**
  68613. * Gets active scene
  68614. */
  68615. get scene(): Scene;
  68616. /**
  68617. * Enable or disable the sharpen process from the pipeline
  68618. */
  68619. set sharpenEnabled(enabled: boolean);
  68620. get sharpenEnabled(): boolean;
  68621. private _resizeObserver;
  68622. private _hardwareScaleLevel;
  68623. private _bloomKernel;
  68624. /**
  68625. * Specifies the size of the bloom blur kernel, relative to the final output size
  68626. */
  68627. get bloomKernel(): number;
  68628. set bloomKernel(value: number);
  68629. /**
  68630. * Specifies the weight of the bloom in the final rendering
  68631. */
  68632. private _bloomWeight;
  68633. /**
  68634. * Specifies the luma threshold for the area that will be blurred by the bloom
  68635. */
  68636. private _bloomThreshold;
  68637. private _hdr;
  68638. /**
  68639. * The strength of the bloom.
  68640. */
  68641. set bloomWeight(value: number);
  68642. get bloomWeight(): number;
  68643. /**
  68644. * The strength of the bloom.
  68645. */
  68646. set bloomThreshold(value: number);
  68647. get bloomThreshold(): number;
  68648. /**
  68649. * The scale of the bloom, lower value will provide better performance.
  68650. */
  68651. set bloomScale(value: number);
  68652. get bloomScale(): number;
  68653. /**
  68654. * Enable or disable the bloom from the pipeline
  68655. */
  68656. set bloomEnabled(enabled: boolean);
  68657. get bloomEnabled(): boolean;
  68658. private _rebuildBloom;
  68659. /**
  68660. * If the depth of field is enabled.
  68661. */
  68662. get depthOfFieldEnabled(): boolean;
  68663. set depthOfFieldEnabled(enabled: boolean);
  68664. /**
  68665. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68666. */
  68667. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68668. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68669. /**
  68670. * If the anti aliasing is enabled.
  68671. */
  68672. set fxaaEnabled(enabled: boolean);
  68673. get fxaaEnabled(): boolean;
  68674. private _samples;
  68675. /**
  68676. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68677. */
  68678. set samples(sampleCount: number);
  68679. get samples(): number;
  68680. /**
  68681. * If image processing is enabled.
  68682. */
  68683. set imageProcessingEnabled(enabled: boolean);
  68684. get imageProcessingEnabled(): boolean;
  68685. /**
  68686. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68687. */
  68688. set glowLayerEnabled(enabled: boolean);
  68689. get glowLayerEnabled(): boolean;
  68690. /**
  68691. * Gets the glow layer (or null if not defined)
  68692. */
  68693. get glowLayer(): Nullable<GlowLayer>;
  68694. /**
  68695. * Enable or disable the chromaticAberration process from the pipeline
  68696. */
  68697. set chromaticAberrationEnabled(enabled: boolean);
  68698. get chromaticAberrationEnabled(): boolean;
  68699. /**
  68700. * Enable or disable the grain process from the pipeline
  68701. */
  68702. set grainEnabled(enabled: boolean);
  68703. get grainEnabled(): boolean;
  68704. /**
  68705. * @constructor
  68706. * @param name - The rendering pipeline name (default: "")
  68707. * @param hdr - If high dynamic range textures should be used (default: true)
  68708. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68709. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68710. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68711. */
  68712. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68713. /**
  68714. * Get the class name
  68715. * @returns "DefaultRenderingPipeline"
  68716. */
  68717. getClassName(): string;
  68718. /**
  68719. * Force the compilation of the entire pipeline.
  68720. */
  68721. prepare(): void;
  68722. private _hasCleared;
  68723. private _prevPostProcess;
  68724. private _prevPrevPostProcess;
  68725. private _setAutoClearAndTextureSharing;
  68726. private _depthOfFieldSceneObserver;
  68727. private _buildPipeline;
  68728. private _disposePostProcesses;
  68729. /**
  68730. * Adds a camera to the pipeline
  68731. * @param camera the camera to be added
  68732. */
  68733. addCamera(camera: Camera): void;
  68734. /**
  68735. * Removes a camera from the pipeline
  68736. * @param camera the camera to remove
  68737. */
  68738. removeCamera(camera: Camera): void;
  68739. /**
  68740. * Dispose of the pipeline and stop all post processes
  68741. */
  68742. dispose(): void;
  68743. /**
  68744. * Serialize the rendering pipeline (Used when exporting)
  68745. * @returns the serialized object
  68746. */
  68747. serialize(): any;
  68748. /**
  68749. * Parse the serialized pipeline
  68750. * @param source Source pipeline.
  68751. * @param scene The scene to load the pipeline to.
  68752. * @param rootUrl The URL of the serialized pipeline.
  68753. * @returns An instantiated pipeline from the serialized object.
  68754. */
  68755. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68756. }
  68757. }
  68758. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68759. /** @hidden */
  68760. export var lensHighlightsPixelShader: {
  68761. name: string;
  68762. shader: string;
  68763. };
  68764. }
  68765. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68766. /** @hidden */
  68767. export var depthOfFieldPixelShader: {
  68768. name: string;
  68769. shader: string;
  68770. };
  68771. }
  68772. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68773. import { Camera } from "babylonjs/Cameras/camera";
  68774. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68775. import { Scene } from "babylonjs/scene";
  68776. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68777. import "babylonjs/Shaders/chromaticAberration.fragment";
  68778. import "babylonjs/Shaders/lensHighlights.fragment";
  68779. import "babylonjs/Shaders/depthOfField.fragment";
  68780. /**
  68781. * BABYLON.JS Chromatic Aberration GLSL Shader
  68782. * Author: Olivier Guyot
  68783. * Separates very slightly R, G and B colors on the edges of the screen
  68784. * Inspired by Francois Tarlier & Martins Upitis
  68785. */
  68786. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68787. /**
  68788. * @ignore
  68789. * The chromatic aberration PostProcess id in the pipeline
  68790. */
  68791. LensChromaticAberrationEffect: string;
  68792. /**
  68793. * @ignore
  68794. * The highlights enhancing PostProcess id in the pipeline
  68795. */
  68796. HighlightsEnhancingEffect: string;
  68797. /**
  68798. * @ignore
  68799. * The depth-of-field PostProcess id in the pipeline
  68800. */
  68801. LensDepthOfFieldEffect: string;
  68802. private _scene;
  68803. private _depthTexture;
  68804. private _grainTexture;
  68805. private _chromaticAberrationPostProcess;
  68806. private _highlightsPostProcess;
  68807. private _depthOfFieldPostProcess;
  68808. private _edgeBlur;
  68809. private _grainAmount;
  68810. private _chromaticAberration;
  68811. private _distortion;
  68812. private _highlightsGain;
  68813. private _highlightsThreshold;
  68814. private _dofDistance;
  68815. private _dofAperture;
  68816. private _dofDarken;
  68817. private _dofPentagon;
  68818. private _blurNoise;
  68819. /**
  68820. * @constructor
  68821. *
  68822. * Effect parameters are as follow:
  68823. * {
  68824. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68825. * edge_blur: number; // from 0 to x (1 for realism)
  68826. * distortion: number; // from 0 to x (1 for realism)
  68827. * grain_amount: number; // from 0 to 1
  68828. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68829. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68830. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68831. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68832. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68833. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68834. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68835. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68836. * }
  68837. * Note: if an effect parameter is unset, effect is disabled
  68838. *
  68839. * @param name The rendering pipeline name
  68840. * @param parameters - An object containing all parameters (see above)
  68841. * @param scene The scene linked to this pipeline
  68842. * @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)
  68843. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68844. */
  68845. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68846. /**
  68847. * Get the class name
  68848. * @returns "LensRenderingPipeline"
  68849. */
  68850. getClassName(): string;
  68851. /**
  68852. * Gets associated scene
  68853. */
  68854. get scene(): Scene;
  68855. /**
  68856. * Gets or sets the edge blur
  68857. */
  68858. get edgeBlur(): number;
  68859. set edgeBlur(value: number);
  68860. /**
  68861. * Gets or sets the grain amount
  68862. */
  68863. get grainAmount(): number;
  68864. set grainAmount(value: number);
  68865. /**
  68866. * Gets or sets the chromatic aberration amount
  68867. */
  68868. get chromaticAberration(): number;
  68869. set chromaticAberration(value: number);
  68870. /**
  68871. * Gets or sets the depth of field aperture
  68872. */
  68873. get dofAperture(): number;
  68874. set dofAperture(value: number);
  68875. /**
  68876. * Gets or sets the edge distortion
  68877. */
  68878. get edgeDistortion(): number;
  68879. set edgeDistortion(value: number);
  68880. /**
  68881. * Gets or sets the depth of field distortion
  68882. */
  68883. get dofDistortion(): number;
  68884. set dofDistortion(value: number);
  68885. /**
  68886. * Gets or sets the darken out of focus amount
  68887. */
  68888. get darkenOutOfFocus(): number;
  68889. set darkenOutOfFocus(value: number);
  68890. /**
  68891. * Gets or sets a boolean indicating if blur noise is enabled
  68892. */
  68893. get blurNoise(): boolean;
  68894. set blurNoise(value: boolean);
  68895. /**
  68896. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68897. */
  68898. get pentagonBokeh(): boolean;
  68899. set pentagonBokeh(value: boolean);
  68900. /**
  68901. * Gets or sets the highlight grain amount
  68902. */
  68903. get highlightsGain(): number;
  68904. set highlightsGain(value: number);
  68905. /**
  68906. * Gets or sets the highlight threshold
  68907. */
  68908. get highlightsThreshold(): number;
  68909. set highlightsThreshold(value: number);
  68910. /**
  68911. * Sets the amount of blur at the edges
  68912. * @param amount blur amount
  68913. */
  68914. setEdgeBlur(amount: number): void;
  68915. /**
  68916. * Sets edge blur to 0
  68917. */
  68918. disableEdgeBlur(): void;
  68919. /**
  68920. * Sets the amout of grain
  68921. * @param amount Amount of grain
  68922. */
  68923. setGrainAmount(amount: number): void;
  68924. /**
  68925. * Set grain amount to 0
  68926. */
  68927. disableGrain(): void;
  68928. /**
  68929. * Sets the chromatic aberration amount
  68930. * @param amount amount of chromatic aberration
  68931. */
  68932. setChromaticAberration(amount: number): void;
  68933. /**
  68934. * Sets chromatic aberration amount to 0
  68935. */
  68936. disableChromaticAberration(): void;
  68937. /**
  68938. * Sets the EdgeDistortion amount
  68939. * @param amount amount of EdgeDistortion
  68940. */
  68941. setEdgeDistortion(amount: number): void;
  68942. /**
  68943. * Sets edge distortion to 0
  68944. */
  68945. disableEdgeDistortion(): void;
  68946. /**
  68947. * Sets the FocusDistance amount
  68948. * @param amount amount of FocusDistance
  68949. */
  68950. setFocusDistance(amount: number): void;
  68951. /**
  68952. * Disables depth of field
  68953. */
  68954. disableDepthOfField(): void;
  68955. /**
  68956. * Sets the Aperture amount
  68957. * @param amount amount of Aperture
  68958. */
  68959. setAperture(amount: number): void;
  68960. /**
  68961. * Sets the DarkenOutOfFocus amount
  68962. * @param amount amount of DarkenOutOfFocus
  68963. */
  68964. setDarkenOutOfFocus(amount: number): void;
  68965. private _pentagonBokehIsEnabled;
  68966. /**
  68967. * Creates a pentagon bokeh effect
  68968. */
  68969. enablePentagonBokeh(): void;
  68970. /**
  68971. * Disables the pentagon bokeh effect
  68972. */
  68973. disablePentagonBokeh(): void;
  68974. /**
  68975. * Enables noise blur
  68976. */
  68977. enableNoiseBlur(): void;
  68978. /**
  68979. * Disables noise blur
  68980. */
  68981. disableNoiseBlur(): void;
  68982. /**
  68983. * Sets the HighlightsGain amount
  68984. * @param amount amount of HighlightsGain
  68985. */
  68986. setHighlightsGain(amount: number): void;
  68987. /**
  68988. * Sets the HighlightsThreshold amount
  68989. * @param amount amount of HighlightsThreshold
  68990. */
  68991. setHighlightsThreshold(amount: number): void;
  68992. /**
  68993. * Disables highlights
  68994. */
  68995. disableHighlights(): void;
  68996. /**
  68997. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68998. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68999. */
  69000. dispose(disableDepthRender?: boolean): void;
  69001. private _createChromaticAberrationPostProcess;
  69002. private _createHighlightsPostProcess;
  69003. private _createDepthOfFieldPostProcess;
  69004. private _createGrainTexture;
  69005. }
  69006. }
  69007. declare module "babylonjs/Shaders/ssao2.fragment" {
  69008. /** @hidden */
  69009. export var ssao2PixelShader: {
  69010. name: string;
  69011. shader: string;
  69012. };
  69013. }
  69014. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69015. /** @hidden */
  69016. export var ssaoCombinePixelShader: {
  69017. name: string;
  69018. shader: string;
  69019. };
  69020. }
  69021. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69022. import { Camera } from "babylonjs/Cameras/camera";
  69023. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69024. import { Scene } from "babylonjs/scene";
  69025. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69026. import "babylonjs/Shaders/ssao2.fragment";
  69027. import "babylonjs/Shaders/ssaoCombine.fragment";
  69028. /**
  69029. * Render pipeline to produce ssao effect
  69030. */
  69031. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69032. /**
  69033. * @ignore
  69034. * The PassPostProcess id in the pipeline that contains the original scene color
  69035. */
  69036. SSAOOriginalSceneColorEffect: string;
  69037. /**
  69038. * @ignore
  69039. * The SSAO PostProcess id in the pipeline
  69040. */
  69041. SSAORenderEffect: string;
  69042. /**
  69043. * @ignore
  69044. * The horizontal blur PostProcess id in the pipeline
  69045. */
  69046. SSAOBlurHRenderEffect: string;
  69047. /**
  69048. * @ignore
  69049. * The vertical blur PostProcess id in the pipeline
  69050. */
  69051. SSAOBlurVRenderEffect: string;
  69052. /**
  69053. * @ignore
  69054. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69055. */
  69056. SSAOCombineRenderEffect: string;
  69057. /**
  69058. * The output strength of the SSAO post-process. Default value is 1.0.
  69059. */
  69060. totalStrength: number;
  69061. /**
  69062. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69063. */
  69064. maxZ: number;
  69065. /**
  69066. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69067. */
  69068. minZAspect: number;
  69069. private _samples;
  69070. /**
  69071. * Number of samples used for the SSAO calculations. Default value is 8
  69072. */
  69073. set samples(n: number);
  69074. get samples(): number;
  69075. private _textureSamples;
  69076. /**
  69077. * Number of samples to use for antialiasing
  69078. */
  69079. set textureSamples(n: number);
  69080. get textureSamples(): number;
  69081. /**
  69082. * Ratio object used for SSAO ratio and blur ratio
  69083. */
  69084. private _ratio;
  69085. /**
  69086. * Dynamically generated sphere sampler.
  69087. */
  69088. private _sampleSphere;
  69089. /**
  69090. * Blur filter offsets
  69091. */
  69092. private _samplerOffsets;
  69093. private _expensiveBlur;
  69094. /**
  69095. * If bilateral blur should be used
  69096. */
  69097. set expensiveBlur(b: boolean);
  69098. get expensiveBlur(): boolean;
  69099. /**
  69100. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69101. */
  69102. radius: number;
  69103. /**
  69104. * The base color of the SSAO post-process
  69105. * The final result is "base + ssao" between [0, 1]
  69106. */
  69107. base: number;
  69108. /**
  69109. * Support test.
  69110. */
  69111. static get IsSupported(): boolean;
  69112. private _scene;
  69113. private _depthTexture;
  69114. private _normalTexture;
  69115. private _randomTexture;
  69116. private _originalColorPostProcess;
  69117. private _ssaoPostProcess;
  69118. private _blurHPostProcess;
  69119. private _blurVPostProcess;
  69120. private _ssaoCombinePostProcess;
  69121. /**
  69122. * Gets active scene
  69123. */
  69124. get scene(): Scene;
  69125. /**
  69126. * @constructor
  69127. * @param name The rendering pipeline name
  69128. * @param scene The scene linked to this pipeline
  69129. * @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 }
  69130. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69131. */
  69132. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69133. /**
  69134. * Get the class name
  69135. * @returns "SSAO2RenderingPipeline"
  69136. */
  69137. getClassName(): string;
  69138. /**
  69139. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69140. */
  69141. dispose(disableGeometryBufferRenderer?: boolean): void;
  69142. private _createBlurPostProcess;
  69143. /** @hidden */
  69144. _rebuild(): void;
  69145. private _bits;
  69146. private _radicalInverse_VdC;
  69147. private _hammersley;
  69148. private _hemisphereSample_uniform;
  69149. private _generateHemisphere;
  69150. private _createSSAOPostProcess;
  69151. private _createSSAOCombinePostProcess;
  69152. private _createRandomTexture;
  69153. /**
  69154. * Serialize the rendering pipeline (Used when exporting)
  69155. * @returns the serialized object
  69156. */
  69157. serialize(): any;
  69158. /**
  69159. * Parse the serialized pipeline
  69160. * @param source Source pipeline.
  69161. * @param scene The scene to load the pipeline to.
  69162. * @param rootUrl The URL of the serialized pipeline.
  69163. * @returns An instantiated pipeline from the serialized object.
  69164. */
  69165. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69166. }
  69167. }
  69168. declare module "babylonjs/Shaders/ssao.fragment" {
  69169. /** @hidden */
  69170. export var ssaoPixelShader: {
  69171. name: string;
  69172. shader: string;
  69173. };
  69174. }
  69175. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69176. import { Camera } from "babylonjs/Cameras/camera";
  69177. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69178. import { Scene } from "babylonjs/scene";
  69179. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69180. import "babylonjs/Shaders/ssao.fragment";
  69181. import "babylonjs/Shaders/ssaoCombine.fragment";
  69182. /**
  69183. * Render pipeline to produce ssao effect
  69184. */
  69185. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69186. /**
  69187. * @ignore
  69188. * The PassPostProcess id in the pipeline that contains the original scene color
  69189. */
  69190. SSAOOriginalSceneColorEffect: string;
  69191. /**
  69192. * @ignore
  69193. * The SSAO PostProcess id in the pipeline
  69194. */
  69195. SSAORenderEffect: string;
  69196. /**
  69197. * @ignore
  69198. * The horizontal blur PostProcess id in the pipeline
  69199. */
  69200. SSAOBlurHRenderEffect: string;
  69201. /**
  69202. * @ignore
  69203. * The vertical blur PostProcess id in the pipeline
  69204. */
  69205. SSAOBlurVRenderEffect: string;
  69206. /**
  69207. * @ignore
  69208. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69209. */
  69210. SSAOCombineRenderEffect: string;
  69211. /**
  69212. * The output strength of the SSAO post-process. Default value is 1.0.
  69213. */
  69214. totalStrength: number;
  69215. /**
  69216. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69217. */
  69218. radius: number;
  69219. /**
  69220. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69221. * Must not be equal to fallOff and superior to fallOff.
  69222. * Default value is 0.0075
  69223. */
  69224. area: number;
  69225. /**
  69226. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69227. * Must not be equal to area and inferior to area.
  69228. * Default value is 0.000001
  69229. */
  69230. fallOff: number;
  69231. /**
  69232. * The base color of the SSAO post-process
  69233. * The final result is "base + ssao" between [0, 1]
  69234. */
  69235. base: number;
  69236. private _scene;
  69237. private _depthTexture;
  69238. private _randomTexture;
  69239. private _originalColorPostProcess;
  69240. private _ssaoPostProcess;
  69241. private _blurHPostProcess;
  69242. private _blurVPostProcess;
  69243. private _ssaoCombinePostProcess;
  69244. private _firstUpdate;
  69245. /**
  69246. * Gets active scene
  69247. */
  69248. get scene(): Scene;
  69249. /**
  69250. * @constructor
  69251. * @param name - The rendering pipeline name
  69252. * @param scene - The scene linked to this pipeline
  69253. * @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 }
  69254. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69255. */
  69256. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69257. /**
  69258. * Get the class name
  69259. * @returns "SSAORenderingPipeline"
  69260. */
  69261. getClassName(): string;
  69262. /**
  69263. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69264. */
  69265. dispose(disableDepthRender?: boolean): void;
  69266. private _createBlurPostProcess;
  69267. /** @hidden */
  69268. _rebuild(): void;
  69269. private _createSSAOPostProcess;
  69270. private _createSSAOCombinePostProcess;
  69271. private _createRandomTexture;
  69272. }
  69273. }
  69274. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69275. /** @hidden */
  69276. export var screenSpaceReflectionPixelShader: {
  69277. name: string;
  69278. shader: string;
  69279. };
  69280. }
  69281. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69282. import { Nullable } from "babylonjs/types";
  69283. import { Camera } from "babylonjs/Cameras/camera";
  69284. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69285. import { Scene } from "babylonjs/scene";
  69286. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69287. import { Engine } from "babylonjs/Engines/engine";
  69288. /**
  69289. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69290. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69291. */
  69292. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69293. /**
  69294. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69295. */
  69296. threshold: number;
  69297. /**
  69298. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69299. */
  69300. strength: number;
  69301. /**
  69302. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69303. */
  69304. reflectionSpecularFalloffExponent: number;
  69305. /**
  69306. * 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]
  69307. */
  69308. step: number;
  69309. /**
  69310. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69311. */
  69312. roughnessFactor: number;
  69313. private _geometryBufferRenderer;
  69314. private _enableSmoothReflections;
  69315. private _reflectionSamples;
  69316. private _smoothSteps;
  69317. /**
  69318. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69319. * @param name The name of the effect.
  69320. * @param scene The scene containing the objects to calculate reflections.
  69321. * @param options The required width/height ratio to downsize to before computing the render pass.
  69322. * @param camera The camera to apply the render pass to.
  69323. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69324. * @param engine The engine which the post process will be applied. (default: current engine)
  69325. * @param reusable If the post process can be reused on the same frame. (default: false)
  69326. * @param textureType Type of textures used when performing the post process. (default: 0)
  69327. * @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)
  69328. */
  69329. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69330. /**
  69331. * Gets wether or not smoothing reflections is enabled.
  69332. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69333. */
  69334. get enableSmoothReflections(): boolean;
  69335. /**
  69336. * Sets wether or not smoothing reflections is enabled.
  69337. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69338. */
  69339. set enableSmoothReflections(enabled: boolean);
  69340. /**
  69341. * Gets the number of samples taken while computing reflections. More samples count is high,
  69342. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69343. */
  69344. get reflectionSamples(): number;
  69345. /**
  69346. * Sets the number of samples taken while computing reflections. More samples count is high,
  69347. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69348. */
  69349. set reflectionSamples(samples: number);
  69350. /**
  69351. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69352. * more the post-process will require GPU power and can generate a drop in FPS.
  69353. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69354. */
  69355. get smoothSteps(): number;
  69356. set smoothSteps(steps: number);
  69357. private _updateEffectDefines;
  69358. }
  69359. }
  69360. declare module "babylonjs/Shaders/standard.fragment" {
  69361. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69362. /** @hidden */
  69363. export var standardPixelShader: {
  69364. name: string;
  69365. shader: string;
  69366. };
  69367. }
  69368. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69369. import { Nullable } from "babylonjs/types";
  69370. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69371. import { Camera } from "babylonjs/Cameras/camera";
  69372. import { Texture } from "babylonjs/Materials/Textures/texture";
  69373. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69374. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69375. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69376. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69377. import { IDisposable } from "babylonjs/scene";
  69378. import { SpotLight } from "babylonjs/Lights/spotLight";
  69379. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69380. import { Scene } from "babylonjs/scene";
  69381. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69382. import { Animation } from "babylonjs/Animations/animation";
  69383. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69384. import "babylonjs/Shaders/standard.fragment";
  69385. /**
  69386. * Standard rendering pipeline
  69387. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69388. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69389. */
  69390. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69391. /**
  69392. * Public members
  69393. */
  69394. /**
  69395. * Post-process which contains the original scene color before the pipeline applies all the effects
  69396. */
  69397. originalPostProcess: Nullable<PostProcess>;
  69398. /**
  69399. * Post-process used to down scale an image x4
  69400. */
  69401. downSampleX4PostProcess: Nullable<PostProcess>;
  69402. /**
  69403. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69404. */
  69405. brightPassPostProcess: Nullable<PostProcess>;
  69406. /**
  69407. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69408. */
  69409. blurHPostProcesses: PostProcess[];
  69410. /**
  69411. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69412. */
  69413. blurVPostProcesses: PostProcess[];
  69414. /**
  69415. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69416. */
  69417. textureAdderPostProcess: Nullable<PostProcess>;
  69418. /**
  69419. * Post-process used to create volumetric lighting effect
  69420. */
  69421. volumetricLightPostProcess: Nullable<PostProcess>;
  69422. /**
  69423. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69424. */
  69425. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69426. /**
  69427. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69428. */
  69429. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69430. /**
  69431. * Post-process used to merge the volumetric light effect and the real scene color
  69432. */
  69433. volumetricLightMergePostProces: Nullable<PostProcess>;
  69434. /**
  69435. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69436. */
  69437. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69438. /**
  69439. * Base post-process used to calculate the average luminance of the final image for HDR
  69440. */
  69441. luminancePostProcess: Nullable<PostProcess>;
  69442. /**
  69443. * Post-processes used to create down sample post-processes in order to get
  69444. * the average luminance of the final image for HDR
  69445. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69446. */
  69447. luminanceDownSamplePostProcesses: PostProcess[];
  69448. /**
  69449. * Post-process used to create a HDR effect (light adaptation)
  69450. */
  69451. hdrPostProcess: Nullable<PostProcess>;
  69452. /**
  69453. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69454. */
  69455. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69456. /**
  69457. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69458. */
  69459. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69460. /**
  69461. * Post-process used to merge the final HDR post-process and the real scene color
  69462. */
  69463. hdrFinalPostProcess: Nullable<PostProcess>;
  69464. /**
  69465. * Post-process used to create a lens flare effect
  69466. */
  69467. lensFlarePostProcess: Nullable<PostProcess>;
  69468. /**
  69469. * Post-process that merges the result of the lens flare post-process and the real scene color
  69470. */
  69471. lensFlareComposePostProcess: Nullable<PostProcess>;
  69472. /**
  69473. * Post-process used to create a motion blur effect
  69474. */
  69475. motionBlurPostProcess: Nullable<PostProcess>;
  69476. /**
  69477. * Post-process used to create a depth of field effect
  69478. */
  69479. depthOfFieldPostProcess: Nullable<PostProcess>;
  69480. /**
  69481. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69482. */
  69483. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69484. /**
  69485. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69486. */
  69487. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69488. /**
  69489. * Represents the brightness threshold in order to configure the illuminated surfaces
  69490. */
  69491. brightThreshold: number;
  69492. /**
  69493. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69494. */
  69495. blurWidth: number;
  69496. /**
  69497. * Sets if the blur for highlighted surfaces must be only horizontal
  69498. */
  69499. horizontalBlur: boolean;
  69500. /**
  69501. * Gets the overall exposure used by the pipeline
  69502. */
  69503. get exposure(): number;
  69504. /**
  69505. * Sets the overall exposure used by the pipeline
  69506. */
  69507. set exposure(value: number);
  69508. /**
  69509. * Texture used typically to simulate "dirty" on camera lens
  69510. */
  69511. lensTexture: Nullable<Texture>;
  69512. /**
  69513. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69514. */
  69515. volumetricLightCoefficient: number;
  69516. /**
  69517. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69518. */
  69519. volumetricLightPower: number;
  69520. /**
  69521. * Used the set the blur intensity to smooth the volumetric lights
  69522. */
  69523. volumetricLightBlurScale: number;
  69524. /**
  69525. * Light (spot or directional) used to generate the volumetric lights rays
  69526. * The source light must have a shadow generate so the pipeline can get its
  69527. * depth map
  69528. */
  69529. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69530. /**
  69531. * For eye adaptation, represents the minimum luminance the eye can see
  69532. */
  69533. hdrMinimumLuminance: number;
  69534. /**
  69535. * For eye adaptation, represents the decrease luminance speed
  69536. */
  69537. hdrDecreaseRate: number;
  69538. /**
  69539. * For eye adaptation, represents the increase luminance speed
  69540. */
  69541. hdrIncreaseRate: number;
  69542. /**
  69543. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69544. */
  69545. get hdrAutoExposure(): boolean;
  69546. /**
  69547. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69548. */
  69549. set hdrAutoExposure(value: boolean);
  69550. /**
  69551. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69552. */
  69553. lensColorTexture: Nullable<Texture>;
  69554. /**
  69555. * The overall strengh for the lens flare effect
  69556. */
  69557. lensFlareStrength: number;
  69558. /**
  69559. * Dispersion coefficient for lens flare ghosts
  69560. */
  69561. lensFlareGhostDispersal: number;
  69562. /**
  69563. * Main lens flare halo width
  69564. */
  69565. lensFlareHaloWidth: number;
  69566. /**
  69567. * Based on the lens distortion effect, defines how much the lens flare result
  69568. * is distorted
  69569. */
  69570. lensFlareDistortionStrength: number;
  69571. /**
  69572. * Configures the blur intensity used for for lens flare (halo)
  69573. */
  69574. lensFlareBlurWidth: number;
  69575. /**
  69576. * Lens star texture must be used to simulate rays on the flares and is available
  69577. * in the documentation
  69578. */
  69579. lensStarTexture: Nullable<Texture>;
  69580. /**
  69581. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69582. * flare effect by taking account of the dirt texture
  69583. */
  69584. lensFlareDirtTexture: Nullable<Texture>;
  69585. /**
  69586. * Represents the focal length for the depth of field effect
  69587. */
  69588. depthOfFieldDistance: number;
  69589. /**
  69590. * Represents the blur intensity for the blurred part of the depth of field effect
  69591. */
  69592. depthOfFieldBlurWidth: number;
  69593. /**
  69594. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69595. */
  69596. get motionStrength(): number;
  69597. /**
  69598. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69599. */
  69600. set motionStrength(strength: number);
  69601. /**
  69602. * Gets wether or not the motion blur post-process is object based or screen based.
  69603. */
  69604. get objectBasedMotionBlur(): boolean;
  69605. /**
  69606. * Sets wether or not the motion blur post-process should be object based or screen based
  69607. */
  69608. set objectBasedMotionBlur(value: boolean);
  69609. /**
  69610. * List of animations for the pipeline (IAnimatable implementation)
  69611. */
  69612. animations: Animation[];
  69613. /**
  69614. * Private members
  69615. */
  69616. private _scene;
  69617. private _currentDepthOfFieldSource;
  69618. private _basePostProcess;
  69619. private _fixedExposure;
  69620. private _currentExposure;
  69621. private _hdrAutoExposure;
  69622. private _hdrCurrentLuminance;
  69623. private _motionStrength;
  69624. private _isObjectBasedMotionBlur;
  69625. private _floatTextureType;
  69626. private _camerasToBeAttached;
  69627. private _ratio;
  69628. private _bloomEnabled;
  69629. private _depthOfFieldEnabled;
  69630. private _vlsEnabled;
  69631. private _lensFlareEnabled;
  69632. private _hdrEnabled;
  69633. private _motionBlurEnabled;
  69634. private _fxaaEnabled;
  69635. private _screenSpaceReflectionsEnabled;
  69636. private _motionBlurSamples;
  69637. private _volumetricLightStepsCount;
  69638. private _samples;
  69639. /**
  69640. * @ignore
  69641. * Specifies if the bloom pipeline is enabled
  69642. */
  69643. get BloomEnabled(): boolean;
  69644. set BloomEnabled(enabled: boolean);
  69645. /**
  69646. * @ignore
  69647. * Specifies if the depth of field pipeline is enabed
  69648. */
  69649. get DepthOfFieldEnabled(): boolean;
  69650. set DepthOfFieldEnabled(enabled: boolean);
  69651. /**
  69652. * @ignore
  69653. * Specifies if the lens flare pipeline is enabed
  69654. */
  69655. get LensFlareEnabled(): boolean;
  69656. set LensFlareEnabled(enabled: boolean);
  69657. /**
  69658. * @ignore
  69659. * Specifies if the HDR pipeline is enabled
  69660. */
  69661. get HDREnabled(): boolean;
  69662. set HDREnabled(enabled: boolean);
  69663. /**
  69664. * @ignore
  69665. * Specifies if the volumetric lights scattering effect is enabled
  69666. */
  69667. get VLSEnabled(): boolean;
  69668. set VLSEnabled(enabled: boolean);
  69669. /**
  69670. * @ignore
  69671. * Specifies if the motion blur effect is enabled
  69672. */
  69673. get MotionBlurEnabled(): boolean;
  69674. set MotionBlurEnabled(enabled: boolean);
  69675. /**
  69676. * Specifies if anti-aliasing is enabled
  69677. */
  69678. get fxaaEnabled(): boolean;
  69679. set fxaaEnabled(enabled: boolean);
  69680. /**
  69681. * Specifies if screen space reflections are enabled.
  69682. */
  69683. get screenSpaceReflectionsEnabled(): boolean;
  69684. set screenSpaceReflectionsEnabled(enabled: boolean);
  69685. /**
  69686. * Specifies the number of steps used to calculate the volumetric lights
  69687. * Typically in interval [50, 200]
  69688. */
  69689. get volumetricLightStepsCount(): number;
  69690. set volumetricLightStepsCount(count: number);
  69691. /**
  69692. * Specifies the number of samples used for the motion blur effect
  69693. * Typically in interval [16, 64]
  69694. */
  69695. get motionBlurSamples(): number;
  69696. set motionBlurSamples(samples: number);
  69697. /**
  69698. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69699. */
  69700. get samples(): number;
  69701. set samples(sampleCount: number);
  69702. /**
  69703. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69704. * @constructor
  69705. * @param name The rendering pipeline name
  69706. * @param scene The scene linked to this pipeline
  69707. * @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)
  69708. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69709. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69710. */
  69711. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69712. private _buildPipeline;
  69713. private _createDownSampleX4PostProcess;
  69714. private _createBrightPassPostProcess;
  69715. private _createBlurPostProcesses;
  69716. private _createTextureAdderPostProcess;
  69717. private _createVolumetricLightPostProcess;
  69718. private _createLuminancePostProcesses;
  69719. private _createHdrPostProcess;
  69720. private _createLensFlarePostProcess;
  69721. private _createDepthOfFieldPostProcess;
  69722. private _createMotionBlurPostProcess;
  69723. private _getDepthTexture;
  69724. private _disposePostProcesses;
  69725. /**
  69726. * Dispose of the pipeline and stop all post processes
  69727. */
  69728. dispose(): void;
  69729. /**
  69730. * Serialize the rendering pipeline (Used when exporting)
  69731. * @returns the serialized object
  69732. */
  69733. serialize(): any;
  69734. /**
  69735. * Parse the serialized pipeline
  69736. * @param source Source pipeline.
  69737. * @param scene The scene to load the pipeline to.
  69738. * @param rootUrl The URL of the serialized pipeline.
  69739. * @returns An instantiated pipeline from the serialized object.
  69740. */
  69741. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69742. /**
  69743. * Luminance steps
  69744. */
  69745. static LuminanceSteps: number;
  69746. }
  69747. }
  69748. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69749. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69750. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69751. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69752. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69753. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69754. }
  69755. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69756. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69757. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69758. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69759. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69760. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69761. }
  69762. declare module "babylonjs/Shaders/tonemap.fragment" {
  69763. /** @hidden */
  69764. export var tonemapPixelShader: {
  69765. name: string;
  69766. shader: string;
  69767. };
  69768. }
  69769. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69770. import { Camera } from "babylonjs/Cameras/camera";
  69771. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69772. import "babylonjs/Shaders/tonemap.fragment";
  69773. import { Engine } from "babylonjs/Engines/engine";
  69774. /** Defines operator used for tonemapping */
  69775. export enum TonemappingOperator {
  69776. /** Hable */
  69777. Hable = 0,
  69778. /** Reinhard */
  69779. Reinhard = 1,
  69780. /** HejiDawson */
  69781. HejiDawson = 2,
  69782. /** Photographic */
  69783. Photographic = 3
  69784. }
  69785. /**
  69786. * Defines a post process to apply tone mapping
  69787. */
  69788. export class TonemapPostProcess extends PostProcess {
  69789. private _operator;
  69790. /** Defines the required exposure adjustement */
  69791. exposureAdjustment: number;
  69792. /**
  69793. * Creates a new TonemapPostProcess
  69794. * @param name defines the name of the postprocess
  69795. * @param _operator defines the operator to use
  69796. * @param exposureAdjustment defines the required exposure adjustement
  69797. * @param camera defines the camera to use (can be null)
  69798. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69799. * @param engine defines the hosting engine (can be ignore if camera is set)
  69800. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69801. */
  69802. constructor(name: string, _operator: TonemappingOperator,
  69803. /** Defines the required exposure adjustement */
  69804. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69805. }
  69806. }
  69807. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69808. /** @hidden */
  69809. export var volumetricLightScatteringPixelShader: {
  69810. name: string;
  69811. shader: string;
  69812. };
  69813. }
  69814. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69815. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69816. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69817. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69818. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69819. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69820. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69821. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69822. /** @hidden */
  69823. export var volumetricLightScatteringPassVertexShader: {
  69824. name: string;
  69825. shader: string;
  69826. };
  69827. }
  69828. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69829. /** @hidden */
  69830. export var volumetricLightScatteringPassPixelShader: {
  69831. name: string;
  69832. shader: string;
  69833. };
  69834. }
  69835. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69836. import { Vector3 } from "babylonjs/Maths/math.vector";
  69837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69838. import { Mesh } from "babylonjs/Meshes/mesh";
  69839. import { Camera } from "babylonjs/Cameras/camera";
  69840. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69841. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69842. import { Scene } from "babylonjs/scene";
  69843. import "babylonjs/Meshes/Builders/planeBuilder";
  69844. import "babylonjs/Shaders/depth.vertex";
  69845. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69846. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69847. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69848. import { Engine } from "babylonjs/Engines/engine";
  69849. /**
  69850. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69851. */
  69852. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69853. private _volumetricLightScatteringPass;
  69854. private _volumetricLightScatteringRTT;
  69855. private _viewPort;
  69856. private _screenCoordinates;
  69857. private _cachedDefines;
  69858. /**
  69859. * If not undefined, the mesh position is computed from the attached node position
  69860. */
  69861. attachedNode: {
  69862. position: Vector3;
  69863. };
  69864. /**
  69865. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69866. */
  69867. customMeshPosition: Vector3;
  69868. /**
  69869. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69870. */
  69871. useCustomMeshPosition: boolean;
  69872. /**
  69873. * If the post-process should inverse the light scattering direction
  69874. */
  69875. invert: boolean;
  69876. /**
  69877. * The internal mesh used by the post-process
  69878. */
  69879. mesh: Mesh;
  69880. /**
  69881. * @hidden
  69882. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69883. */
  69884. get useDiffuseColor(): boolean;
  69885. set useDiffuseColor(useDiffuseColor: boolean);
  69886. /**
  69887. * Array containing the excluded meshes not rendered in the internal pass
  69888. */
  69889. excludedMeshes: AbstractMesh[];
  69890. /**
  69891. * Controls the overall intensity of the post-process
  69892. */
  69893. exposure: number;
  69894. /**
  69895. * Dissipates each sample's contribution in range [0, 1]
  69896. */
  69897. decay: number;
  69898. /**
  69899. * Controls the overall intensity of each sample
  69900. */
  69901. weight: number;
  69902. /**
  69903. * Controls the density of each sample
  69904. */
  69905. density: number;
  69906. /**
  69907. * @constructor
  69908. * @param name The post-process name
  69909. * @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)
  69910. * @param camera The camera that the post-process will be attached to
  69911. * @param mesh The mesh used to create the light scattering
  69912. * @param samples The post-process quality, default 100
  69913. * @param samplingModeThe post-process filtering mode
  69914. * @param engine The babylon engine
  69915. * @param reusable If the post-process is reusable
  69916. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69917. */
  69918. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69919. /**
  69920. * Returns the string "VolumetricLightScatteringPostProcess"
  69921. * @returns "VolumetricLightScatteringPostProcess"
  69922. */
  69923. getClassName(): string;
  69924. private _isReady;
  69925. /**
  69926. * Sets the new light position for light scattering effect
  69927. * @param position The new custom light position
  69928. */
  69929. setCustomMeshPosition(position: Vector3): void;
  69930. /**
  69931. * Returns the light position for light scattering effect
  69932. * @return Vector3 The custom light position
  69933. */
  69934. getCustomMeshPosition(): Vector3;
  69935. /**
  69936. * Disposes the internal assets and detaches the post-process from the camera
  69937. */
  69938. dispose(camera: Camera): void;
  69939. /**
  69940. * Returns the render target texture used by the post-process
  69941. * @return the render target texture used by the post-process
  69942. */
  69943. getPass(): RenderTargetTexture;
  69944. private _meshExcluded;
  69945. private _createPass;
  69946. private _updateMeshScreenCoordinates;
  69947. /**
  69948. * Creates a default mesh for the Volumeric Light Scattering post-process
  69949. * @param name The mesh name
  69950. * @param scene The scene where to create the mesh
  69951. * @return the default mesh
  69952. */
  69953. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69954. }
  69955. }
  69956. declare module "babylonjs/PostProcesses/index" {
  69957. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  69958. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  69959. export * from "babylonjs/PostProcesses/bloomEffect";
  69960. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  69961. export * from "babylonjs/PostProcesses/blurPostProcess";
  69962. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69963. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  69964. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  69965. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  69966. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  69967. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  69968. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  69969. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  69970. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69971. export * from "babylonjs/PostProcesses/filterPostProcess";
  69972. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  69973. export * from "babylonjs/PostProcesses/grainPostProcess";
  69974. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  69975. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69976. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  69977. export * from "babylonjs/PostProcesses/passPostProcess";
  69978. export * from "babylonjs/PostProcesses/postProcess";
  69979. export * from "babylonjs/PostProcesses/postProcessManager";
  69980. export * from "babylonjs/PostProcesses/refractionPostProcess";
  69981. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  69982. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  69983. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  69984. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  69985. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  69986. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  69987. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  69988. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69989. }
  69990. declare module "babylonjs/Probes/index" {
  69991. export * from "babylonjs/Probes/reflectionProbe";
  69992. }
  69993. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  69994. import { Scene } from "babylonjs/scene";
  69995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69996. import { SmartArray } from "babylonjs/Misc/smartArray";
  69997. import { ISceneComponent } from "babylonjs/sceneComponent";
  69998. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  69999. import "babylonjs/Meshes/Builders/boxBuilder";
  70000. import "babylonjs/Shaders/color.fragment";
  70001. import "babylonjs/Shaders/color.vertex";
  70002. import { Color3 } from "babylonjs/Maths/math.color";
  70003. module "babylonjs/scene" {
  70004. interface Scene {
  70005. /** @hidden (Backing field) */
  70006. _boundingBoxRenderer: BoundingBoxRenderer;
  70007. /** @hidden (Backing field) */
  70008. _forceShowBoundingBoxes: boolean;
  70009. /**
  70010. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70011. */
  70012. forceShowBoundingBoxes: boolean;
  70013. /**
  70014. * Gets the bounding box renderer associated with the scene
  70015. * @returns a BoundingBoxRenderer
  70016. */
  70017. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70018. }
  70019. }
  70020. module "babylonjs/Meshes/abstractMesh" {
  70021. interface AbstractMesh {
  70022. /** @hidden (Backing field) */
  70023. _showBoundingBox: boolean;
  70024. /**
  70025. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70026. */
  70027. showBoundingBox: boolean;
  70028. }
  70029. }
  70030. /**
  70031. * Component responsible of rendering the bounding box of the meshes in a scene.
  70032. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70033. */
  70034. export class BoundingBoxRenderer implements ISceneComponent {
  70035. /**
  70036. * The component name helpfull to identify the component in the list of scene components.
  70037. */
  70038. readonly name: string;
  70039. /**
  70040. * The scene the component belongs to.
  70041. */
  70042. scene: Scene;
  70043. /**
  70044. * Color of the bounding box lines placed in front of an object
  70045. */
  70046. frontColor: Color3;
  70047. /**
  70048. * Color of the bounding box lines placed behind an object
  70049. */
  70050. backColor: Color3;
  70051. /**
  70052. * Defines if the renderer should show the back lines or not
  70053. */
  70054. showBackLines: boolean;
  70055. /**
  70056. * @hidden
  70057. */
  70058. renderList: SmartArray<BoundingBox>;
  70059. private _colorShader;
  70060. private _vertexBuffers;
  70061. private _indexBuffer;
  70062. private _fillIndexBuffer;
  70063. private _fillIndexData;
  70064. /**
  70065. * Instantiates a new bounding box renderer in a scene.
  70066. * @param scene the scene the renderer renders in
  70067. */
  70068. constructor(scene: Scene);
  70069. /**
  70070. * Registers the component in a given scene
  70071. */
  70072. register(): void;
  70073. private _evaluateSubMesh;
  70074. private _activeMesh;
  70075. private _prepareRessources;
  70076. private _createIndexBuffer;
  70077. /**
  70078. * Rebuilds the elements related to this component in case of
  70079. * context lost for instance.
  70080. */
  70081. rebuild(): void;
  70082. /**
  70083. * @hidden
  70084. */
  70085. reset(): void;
  70086. /**
  70087. * Render the bounding boxes of a specific rendering group
  70088. * @param renderingGroupId defines the rendering group to render
  70089. */
  70090. render(renderingGroupId: number): void;
  70091. /**
  70092. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70093. * @param mesh Define the mesh to render the occlusion bounding box for
  70094. */
  70095. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70096. /**
  70097. * Dispose and release the resources attached to this renderer.
  70098. */
  70099. dispose(): void;
  70100. }
  70101. }
  70102. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70103. import { Nullable } from "babylonjs/types";
  70104. import { Scene } from "babylonjs/scene";
  70105. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70106. import { Camera } from "babylonjs/Cameras/camera";
  70107. import { ISceneComponent } from "babylonjs/sceneComponent";
  70108. module "babylonjs/scene" {
  70109. interface Scene {
  70110. /** @hidden (Backing field) */
  70111. _depthRenderer: {
  70112. [id: string]: DepthRenderer;
  70113. };
  70114. /**
  70115. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70116. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70117. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70118. * @returns the created depth renderer
  70119. */
  70120. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70121. /**
  70122. * Disables a depth renderer for a given camera
  70123. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70124. */
  70125. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70126. }
  70127. }
  70128. /**
  70129. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70130. * in several rendering techniques.
  70131. */
  70132. export class DepthRendererSceneComponent implements ISceneComponent {
  70133. /**
  70134. * The component name helpfull to identify the component in the list of scene components.
  70135. */
  70136. readonly name: string;
  70137. /**
  70138. * The scene the component belongs to.
  70139. */
  70140. scene: Scene;
  70141. /**
  70142. * Creates a new instance of the component for the given scene
  70143. * @param scene Defines the scene to register the component in
  70144. */
  70145. constructor(scene: Scene);
  70146. /**
  70147. * Registers the component in a given scene
  70148. */
  70149. register(): void;
  70150. /**
  70151. * Rebuilds the elements related to this component in case of
  70152. * context lost for instance.
  70153. */
  70154. rebuild(): void;
  70155. /**
  70156. * Disposes the component and the associated ressources
  70157. */
  70158. dispose(): void;
  70159. private _gatherRenderTargets;
  70160. private _gatherActiveCameraRenderTargets;
  70161. }
  70162. }
  70163. declare module "babylonjs/Shaders/outline.fragment" {
  70164. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70165. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70166. /** @hidden */
  70167. export var outlinePixelShader: {
  70168. name: string;
  70169. shader: string;
  70170. };
  70171. }
  70172. declare module "babylonjs/Shaders/outline.vertex" {
  70173. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70174. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70175. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70176. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70177. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70178. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70179. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70180. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70181. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70182. /** @hidden */
  70183. export var outlineVertexShader: {
  70184. name: string;
  70185. shader: string;
  70186. };
  70187. }
  70188. declare module "babylonjs/Rendering/outlineRenderer" {
  70189. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70190. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70191. import { Scene } from "babylonjs/scene";
  70192. import { ISceneComponent } from "babylonjs/sceneComponent";
  70193. import "babylonjs/Shaders/outline.fragment";
  70194. import "babylonjs/Shaders/outline.vertex";
  70195. module "babylonjs/scene" {
  70196. interface Scene {
  70197. /** @hidden */
  70198. _outlineRenderer: OutlineRenderer;
  70199. /**
  70200. * Gets the outline renderer associated with the scene
  70201. * @returns a OutlineRenderer
  70202. */
  70203. getOutlineRenderer(): OutlineRenderer;
  70204. }
  70205. }
  70206. module "babylonjs/Meshes/abstractMesh" {
  70207. interface AbstractMesh {
  70208. /** @hidden (Backing field) */
  70209. _renderOutline: boolean;
  70210. /**
  70211. * Gets or sets a boolean indicating if the outline must be rendered as well
  70212. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70213. */
  70214. renderOutline: boolean;
  70215. /** @hidden (Backing field) */
  70216. _renderOverlay: boolean;
  70217. /**
  70218. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70219. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70220. */
  70221. renderOverlay: boolean;
  70222. }
  70223. }
  70224. /**
  70225. * This class is responsible to draw bothe outline/overlay of meshes.
  70226. * It should not be used directly but through the available method on mesh.
  70227. */
  70228. export class OutlineRenderer implements ISceneComponent {
  70229. /**
  70230. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70231. */
  70232. private static _StencilReference;
  70233. /**
  70234. * The name of the component. Each component must have a unique name.
  70235. */
  70236. name: string;
  70237. /**
  70238. * The scene the component belongs to.
  70239. */
  70240. scene: Scene;
  70241. /**
  70242. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70243. */
  70244. zOffset: number;
  70245. private _engine;
  70246. private _effect;
  70247. private _cachedDefines;
  70248. private _savedDepthWrite;
  70249. /**
  70250. * Instantiates a new outline renderer. (There could be only one per scene).
  70251. * @param scene Defines the scene it belongs to
  70252. */
  70253. constructor(scene: Scene);
  70254. /**
  70255. * Register the component to one instance of a scene.
  70256. */
  70257. register(): void;
  70258. /**
  70259. * Rebuilds the elements related to this component in case of
  70260. * context lost for instance.
  70261. */
  70262. rebuild(): void;
  70263. /**
  70264. * Disposes the component and the associated ressources.
  70265. */
  70266. dispose(): void;
  70267. /**
  70268. * Renders the outline in the canvas.
  70269. * @param subMesh Defines the sumesh to render
  70270. * @param batch Defines the batch of meshes in case of instances
  70271. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70272. */
  70273. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70274. /**
  70275. * Returns whether or not the outline renderer is ready for a given submesh.
  70276. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70277. * @param subMesh Defines the submesh to check readyness for
  70278. * @param useInstances Defines wheter wee are trying to render instances or not
  70279. * @returns true if ready otherwise false
  70280. */
  70281. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70282. private _beforeRenderingMesh;
  70283. private _afterRenderingMesh;
  70284. }
  70285. }
  70286. declare module "babylonjs/Rendering/index" {
  70287. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70288. export * from "babylonjs/Rendering/depthRenderer";
  70289. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70290. export * from "babylonjs/Rendering/edgesRenderer";
  70291. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70292. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70293. export * from "babylonjs/Rendering/outlineRenderer";
  70294. export * from "babylonjs/Rendering/renderingGroup";
  70295. export * from "babylonjs/Rendering/renderingManager";
  70296. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70297. }
  70298. declare module "babylonjs/Sprites/ISprites" {
  70299. /**
  70300. * Defines the basic options interface of a Sprite Frame Source Size.
  70301. */
  70302. export interface ISpriteJSONSpriteSourceSize {
  70303. /**
  70304. * number of the original width of the Frame
  70305. */
  70306. w: number;
  70307. /**
  70308. * number of the original height of the Frame
  70309. */
  70310. h: number;
  70311. }
  70312. /**
  70313. * Defines the basic options interface of a Sprite Frame Data.
  70314. */
  70315. export interface ISpriteJSONSpriteFrameData {
  70316. /**
  70317. * number of the x offset of the Frame
  70318. */
  70319. x: number;
  70320. /**
  70321. * number of the y offset of the Frame
  70322. */
  70323. y: number;
  70324. /**
  70325. * number of the width of the Frame
  70326. */
  70327. w: number;
  70328. /**
  70329. * number of the height of the Frame
  70330. */
  70331. h: number;
  70332. }
  70333. /**
  70334. * Defines the basic options interface of a JSON Sprite.
  70335. */
  70336. export interface ISpriteJSONSprite {
  70337. /**
  70338. * string name of the Frame
  70339. */
  70340. filename: string;
  70341. /**
  70342. * ISpriteJSONSpriteFrame basic object of the frame data
  70343. */
  70344. frame: ISpriteJSONSpriteFrameData;
  70345. /**
  70346. * boolean to flag is the frame was rotated.
  70347. */
  70348. rotated: boolean;
  70349. /**
  70350. * boolean to flag is the frame was trimmed.
  70351. */
  70352. trimmed: boolean;
  70353. /**
  70354. * ISpriteJSONSpriteFrame basic object of the source data
  70355. */
  70356. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70357. /**
  70358. * ISpriteJSONSpriteFrame basic object of the source data
  70359. */
  70360. sourceSize: ISpriteJSONSpriteSourceSize;
  70361. }
  70362. /**
  70363. * Defines the basic options interface of a JSON atlas.
  70364. */
  70365. export interface ISpriteJSONAtlas {
  70366. /**
  70367. * Array of objects that contain the frame data.
  70368. */
  70369. frames: Array<ISpriteJSONSprite>;
  70370. /**
  70371. * object basic object containing the sprite meta data.
  70372. */
  70373. meta?: object;
  70374. }
  70375. }
  70376. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70377. /** @hidden */
  70378. export var spriteMapPixelShader: {
  70379. name: string;
  70380. shader: string;
  70381. };
  70382. }
  70383. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70384. /** @hidden */
  70385. export var spriteMapVertexShader: {
  70386. name: string;
  70387. shader: string;
  70388. };
  70389. }
  70390. declare module "babylonjs/Sprites/spriteMap" {
  70391. import { IDisposable, Scene } from "babylonjs/scene";
  70392. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70393. import { Texture } from "babylonjs/Materials/Textures/texture";
  70394. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70395. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70396. import "babylonjs/Meshes/Builders/planeBuilder";
  70397. import "babylonjs/Shaders/spriteMap.fragment";
  70398. import "babylonjs/Shaders/spriteMap.vertex";
  70399. /**
  70400. * Defines the basic options interface of a SpriteMap
  70401. */
  70402. export interface ISpriteMapOptions {
  70403. /**
  70404. * Vector2 of the number of cells in the grid.
  70405. */
  70406. stageSize?: Vector2;
  70407. /**
  70408. * Vector2 of the size of the output plane in World Units.
  70409. */
  70410. outputSize?: Vector2;
  70411. /**
  70412. * Vector3 of the position of the output plane in World Units.
  70413. */
  70414. outputPosition?: Vector3;
  70415. /**
  70416. * Vector3 of the rotation of the output plane.
  70417. */
  70418. outputRotation?: Vector3;
  70419. /**
  70420. * number of layers that the system will reserve in resources.
  70421. */
  70422. layerCount?: number;
  70423. /**
  70424. * number of max animation frames a single cell will reserve in resources.
  70425. */
  70426. maxAnimationFrames?: number;
  70427. /**
  70428. * number cell index of the base tile when the system compiles.
  70429. */
  70430. baseTile?: number;
  70431. /**
  70432. * boolean flip the sprite after its been repositioned by the framing data.
  70433. */
  70434. flipU?: boolean;
  70435. /**
  70436. * Vector3 scalar of the global RGB values of the SpriteMap.
  70437. */
  70438. colorMultiply?: Vector3;
  70439. }
  70440. /**
  70441. * Defines the IDisposable interface in order to be cleanable from resources.
  70442. */
  70443. export interface ISpriteMap extends IDisposable {
  70444. /**
  70445. * String name of the SpriteMap.
  70446. */
  70447. name: string;
  70448. /**
  70449. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70450. */
  70451. atlasJSON: ISpriteJSONAtlas;
  70452. /**
  70453. * Texture of the SpriteMap.
  70454. */
  70455. spriteSheet: Texture;
  70456. /**
  70457. * The parameters to initialize the SpriteMap with.
  70458. */
  70459. options: ISpriteMapOptions;
  70460. }
  70461. /**
  70462. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70463. */
  70464. export class SpriteMap implements ISpriteMap {
  70465. /** The Name of the spriteMap */
  70466. name: string;
  70467. /** The JSON file with the frame and meta data */
  70468. atlasJSON: ISpriteJSONAtlas;
  70469. /** The systems Sprite Sheet Texture */
  70470. spriteSheet: Texture;
  70471. /** Arguments passed with the Constructor */
  70472. options: ISpriteMapOptions;
  70473. /** Public Sprite Storage array, parsed from atlasJSON */
  70474. sprites: Array<ISpriteJSONSprite>;
  70475. /** Returns the Number of Sprites in the System */
  70476. get spriteCount(): number;
  70477. /** Returns the Position of Output Plane*/
  70478. get position(): Vector3;
  70479. /** Returns the Position of Output Plane*/
  70480. set position(v: Vector3);
  70481. /** Returns the Rotation of Output Plane*/
  70482. get rotation(): Vector3;
  70483. /** Returns the Rotation of Output Plane*/
  70484. set rotation(v: Vector3);
  70485. /** Sets the AnimationMap*/
  70486. get animationMap(): RawTexture;
  70487. /** Sets the AnimationMap*/
  70488. set animationMap(v: RawTexture);
  70489. /** Scene that the SpriteMap was created in */
  70490. private _scene;
  70491. /** Texture Buffer of Float32 that holds tile frame data*/
  70492. private _frameMap;
  70493. /** Texture Buffers of Float32 that holds tileMap data*/
  70494. private _tileMaps;
  70495. /** Texture Buffer of Float32 that holds Animation Data*/
  70496. private _animationMap;
  70497. /** Custom ShaderMaterial Central to the System*/
  70498. private _material;
  70499. /** Custom ShaderMaterial Central to the System*/
  70500. private _output;
  70501. /** Systems Time Ticker*/
  70502. private _time;
  70503. /**
  70504. * Creates a new SpriteMap
  70505. * @param name defines the SpriteMaps Name
  70506. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70507. * @param spriteSheet is the Texture that the Sprites are on.
  70508. * @param options a basic deployment configuration
  70509. * @param scene The Scene that the map is deployed on
  70510. */
  70511. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70512. /**
  70513. * Returns tileID location
  70514. * @returns Vector2 the cell position ID
  70515. */
  70516. getTileID(): Vector2;
  70517. /**
  70518. * Gets the UV location of the mouse over the SpriteMap.
  70519. * @returns Vector2 the UV position of the mouse interaction
  70520. */
  70521. getMousePosition(): Vector2;
  70522. /**
  70523. * Creates the "frame" texture Buffer
  70524. * -------------------------------------
  70525. * Structure of frames
  70526. * "filename": "Falling-Water-2.png",
  70527. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70528. * "rotated": true,
  70529. * "trimmed": true,
  70530. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70531. * "sourceSize": {"w":32,"h":32}
  70532. * @returns RawTexture of the frameMap
  70533. */
  70534. private _createFrameBuffer;
  70535. /**
  70536. * Creates the tileMap texture Buffer
  70537. * @param buffer normally and array of numbers, or a false to generate from scratch
  70538. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70539. * @returns RawTexture of the tileMap
  70540. */
  70541. private _createTileBuffer;
  70542. /**
  70543. * Modifies the data of the tileMaps
  70544. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70545. * @param pos is the iVector2 Coordinates of the Tile
  70546. * @param tile The SpriteIndex of the new Tile
  70547. */
  70548. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70549. /**
  70550. * Creates the animationMap texture Buffer
  70551. * @param buffer normally and array of numbers, or a false to generate from scratch
  70552. * @returns RawTexture of the animationMap
  70553. */
  70554. private _createTileAnimationBuffer;
  70555. /**
  70556. * Modifies the data of the animationMap
  70557. * @param cellID is the Index of the Sprite
  70558. * @param _frame is the target Animation frame
  70559. * @param toCell is the Target Index of the next frame of the animation
  70560. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70561. * @param speed is a global scalar of the time variable on the map.
  70562. */
  70563. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70564. /**
  70565. * Exports the .tilemaps file
  70566. */
  70567. saveTileMaps(): void;
  70568. /**
  70569. * Imports the .tilemaps file
  70570. * @param url of the .tilemaps file
  70571. */
  70572. loadTileMaps(url: string): void;
  70573. /**
  70574. * Release associated resources
  70575. */
  70576. dispose(): void;
  70577. }
  70578. }
  70579. declare module "babylonjs/Sprites/spritePackedManager" {
  70580. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70581. import { Scene } from "babylonjs/scene";
  70582. /**
  70583. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70584. * @see http://doc.babylonjs.com/babylon101/sprites
  70585. */
  70586. export class SpritePackedManager extends SpriteManager {
  70587. /** defines the packed manager's name */
  70588. name: string;
  70589. /**
  70590. * Creates a new sprite manager from a packed sprite sheet
  70591. * @param name defines the manager's name
  70592. * @param imgUrl defines the sprite sheet url
  70593. * @param capacity defines the maximum allowed number of sprites
  70594. * @param scene defines the hosting scene
  70595. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70596. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70597. * @param samplingMode defines the smapling mode to use with spritesheet
  70598. * @param fromPacked set to true; do not alter
  70599. */
  70600. constructor(
  70601. /** defines the packed manager's name */
  70602. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70603. }
  70604. }
  70605. declare module "babylonjs/Sprites/index" {
  70606. export * from "babylonjs/Sprites/sprite";
  70607. export * from "babylonjs/Sprites/ISprites";
  70608. export * from "babylonjs/Sprites/spriteManager";
  70609. export * from "babylonjs/Sprites/spriteMap";
  70610. export * from "babylonjs/Sprites/spritePackedManager";
  70611. export * from "babylonjs/Sprites/spriteSceneComponent";
  70612. }
  70613. declare module "babylonjs/States/index" {
  70614. export * from "babylonjs/States/alphaCullingState";
  70615. export * from "babylonjs/States/depthCullingState";
  70616. export * from "babylonjs/States/stencilState";
  70617. }
  70618. declare module "babylonjs/Misc/assetsManager" {
  70619. import { Scene } from "babylonjs/scene";
  70620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70621. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70622. import { Skeleton } from "babylonjs/Bones/skeleton";
  70623. import { Observable } from "babylonjs/Misc/observable";
  70624. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70625. import { Texture } from "babylonjs/Materials/Textures/texture";
  70626. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70627. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70628. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70629. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70630. /**
  70631. * Defines the list of states available for a task inside a AssetsManager
  70632. */
  70633. export enum AssetTaskState {
  70634. /**
  70635. * Initialization
  70636. */
  70637. INIT = 0,
  70638. /**
  70639. * Running
  70640. */
  70641. RUNNING = 1,
  70642. /**
  70643. * Done
  70644. */
  70645. DONE = 2,
  70646. /**
  70647. * Error
  70648. */
  70649. ERROR = 3
  70650. }
  70651. /**
  70652. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70653. */
  70654. export abstract class AbstractAssetTask {
  70655. /**
  70656. * Task name
  70657. */ name: string;
  70658. /**
  70659. * Callback called when the task is successful
  70660. */
  70661. onSuccess: (task: any) => void;
  70662. /**
  70663. * Callback called when the task is not successful
  70664. */
  70665. onError: (task: any, message?: string, exception?: any) => void;
  70666. /**
  70667. * Creates a new AssetsManager
  70668. * @param name defines the name of the task
  70669. */
  70670. constructor(
  70671. /**
  70672. * Task name
  70673. */ name: string);
  70674. private _isCompleted;
  70675. private _taskState;
  70676. private _errorObject;
  70677. /**
  70678. * Get if the task is completed
  70679. */
  70680. get isCompleted(): boolean;
  70681. /**
  70682. * Gets the current state of the task
  70683. */
  70684. get taskState(): AssetTaskState;
  70685. /**
  70686. * Gets the current error object (if task is in error)
  70687. */
  70688. get errorObject(): {
  70689. message?: string;
  70690. exception?: any;
  70691. };
  70692. /**
  70693. * Internal only
  70694. * @hidden
  70695. */
  70696. _setErrorObject(message?: string, exception?: any): void;
  70697. /**
  70698. * Execute the current task
  70699. * @param scene defines the scene where you want your assets to be loaded
  70700. * @param onSuccess is a callback called when the task is successfully executed
  70701. * @param onError is a callback called if an error occurs
  70702. */
  70703. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70704. /**
  70705. * Execute the current task
  70706. * @param scene defines the scene where you want your assets to be loaded
  70707. * @param onSuccess is a callback called when the task is successfully executed
  70708. * @param onError is a callback called if an error occurs
  70709. */
  70710. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70711. /**
  70712. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70713. * This can be used with failed tasks that have the reason for failure fixed.
  70714. */
  70715. reset(): void;
  70716. private onErrorCallback;
  70717. private onDoneCallback;
  70718. }
  70719. /**
  70720. * Define the interface used by progress events raised during assets loading
  70721. */
  70722. export interface IAssetsProgressEvent {
  70723. /**
  70724. * Defines the number of remaining tasks to process
  70725. */
  70726. remainingCount: number;
  70727. /**
  70728. * Defines the total number of tasks
  70729. */
  70730. totalCount: number;
  70731. /**
  70732. * Defines the task that was just processed
  70733. */
  70734. task: AbstractAssetTask;
  70735. }
  70736. /**
  70737. * Class used to share progress information about assets loading
  70738. */
  70739. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70740. /**
  70741. * Defines the number of remaining tasks to process
  70742. */
  70743. remainingCount: number;
  70744. /**
  70745. * Defines the total number of tasks
  70746. */
  70747. totalCount: number;
  70748. /**
  70749. * Defines the task that was just processed
  70750. */
  70751. task: AbstractAssetTask;
  70752. /**
  70753. * Creates a AssetsProgressEvent
  70754. * @param remainingCount defines the number of remaining tasks to process
  70755. * @param totalCount defines the total number of tasks
  70756. * @param task defines the task that was just processed
  70757. */
  70758. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70759. }
  70760. /**
  70761. * Define a task used by AssetsManager to load meshes
  70762. */
  70763. export class MeshAssetTask extends AbstractAssetTask {
  70764. /**
  70765. * Defines the name of the task
  70766. */
  70767. name: string;
  70768. /**
  70769. * Defines the list of mesh's names you want to load
  70770. */
  70771. meshesNames: any;
  70772. /**
  70773. * Defines the root url to use as a base to load your meshes and associated resources
  70774. */
  70775. rootUrl: string;
  70776. /**
  70777. * Defines the filename of the scene to load from
  70778. */
  70779. sceneFilename: string;
  70780. /**
  70781. * Gets the list of loaded meshes
  70782. */
  70783. loadedMeshes: Array<AbstractMesh>;
  70784. /**
  70785. * Gets the list of loaded particle systems
  70786. */
  70787. loadedParticleSystems: Array<IParticleSystem>;
  70788. /**
  70789. * Gets the list of loaded skeletons
  70790. */
  70791. loadedSkeletons: Array<Skeleton>;
  70792. /**
  70793. * Gets the list of loaded animation groups
  70794. */
  70795. loadedAnimationGroups: Array<AnimationGroup>;
  70796. /**
  70797. * Callback called when the task is successful
  70798. */
  70799. onSuccess: (task: MeshAssetTask) => void;
  70800. /**
  70801. * Callback called when the task is successful
  70802. */
  70803. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70804. /**
  70805. * Creates a new MeshAssetTask
  70806. * @param name defines the name of the task
  70807. * @param meshesNames defines the list of mesh's names you want to load
  70808. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70809. * @param sceneFilename defines the filename of the scene to load from
  70810. */
  70811. constructor(
  70812. /**
  70813. * Defines the name of the task
  70814. */
  70815. name: string,
  70816. /**
  70817. * Defines the list of mesh's names you want to load
  70818. */
  70819. meshesNames: any,
  70820. /**
  70821. * Defines the root url to use as a base to load your meshes and associated resources
  70822. */
  70823. rootUrl: string,
  70824. /**
  70825. * Defines the filename of the scene to load from
  70826. */
  70827. sceneFilename: string);
  70828. /**
  70829. * Execute the current task
  70830. * @param scene defines the scene where you want your assets to be loaded
  70831. * @param onSuccess is a callback called when the task is successfully executed
  70832. * @param onError is a callback called if an error occurs
  70833. */
  70834. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70835. }
  70836. /**
  70837. * Define a task used by AssetsManager to load text content
  70838. */
  70839. export class TextFileAssetTask extends AbstractAssetTask {
  70840. /**
  70841. * Defines the name of the task
  70842. */
  70843. name: string;
  70844. /**
  70845. * Defines the location of the file to load
  70846. */
  70847. url: string;
  70848. /**
  70849. * Gets the loaded text string
  70850. */
  70851. text: string;
  70852. /**
  70853. * Callback called when the task is successful
  70854. */
  70855. onSuccess: (task: TextFileAssetTask) => void;
  70856. /**
  70857. * Callback called when the task is successful
  70858. */
  70859. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70860. /**
  70861. * Creates a new TextFileAssetTask object
  70862. * @param name defines the name of the task
  70863. * @param url defines the location of the file to load
  70864. */
  70865. constructor(
  70866. /**
  70867. * Defines the name of the task
  70868. */
  70869. name: string,
  70870. /**
  70871. * Defines the location of the file to load
  70872. */
  70873. url: string);
  70874. /**
  70875. * Execute the current task
  70876. * @param scene defines the scene where you want your assets to be loaded
  70877. * @param onSuccess is a callback called when the task is successfully executed
  70878. * @param onError is a callback called if an error occurs
  70879. */
  70880. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70881. }
  70882. /**
  70883. * Define a task used by AssetsManager to load binary data
  70884. */
  70885. export class BinaryFileAssetTask extends AbstractAssetTask {
  70886. /**
  70887. * Defines the name of the task
  70888. */
  70889. name: string;
  70890. /**
  70891. * Defines the location of the file to load
  70892. */
  70893. url: string;
  70894. /**
  70895. * Gets the lodaded data (as an array buffer)
  70896. */
  70897. data: ArrayBuffer;
  70898. /**
  70899. * Callback called when the task is successful
  70900. */
  70901. onSuccess: (task: BinaryFileAssetTask) => void;
  70902. /**
  70903. * Callback called when the task is successful
  70904. */
  70905. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70906. /**
  70907. * Creates a new BinaryFileAssetTask object
  70908. * @param name defines the name of the new task
  70909. * @param url defines the location of the file to load
  70910. */
  70911. constructor(
  70912. /**
  70913. * Defines the name of the task
  70914. */
  70915. name: string,
  70916. /**
  70917. * Defines the location of the file to load
  70918. */
  70919. url: string);
  70920. /**
  70921. * Execute the current task
  70922. * @param scene defines the scene where you want your assets to be loaded
  70923. * @param onSuccess is a callback called when the task is successfully executed
  70924. * @param onError is a callback called if an error occurs
  70925. */
  70926. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70927. }
  70928. /**
  70929. * Define a task used by AssetsManager to load images
  70930. */
  70931. export class ImageAssetTask extends AbstractAssetTask {
  70932. /**
  70933. * Defines the name of the task
  70934. */
  70935. name: string;
  70936. /**
  70937. * Defines the location of the image to load
  70938. */
  70939. url: string;
  70940. /**
  70941. * Gets the loaded images
  70942. */
  70943. image: HTMLImageElement;
  70944. /**
  70945. * Callback called when the task is successful
  70946. */
  70947. onSuccess: (task: ImageAssetTask) => void;
  70948. /**
  70949. * Callback called when the task is successful
  70950. */
  70951. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70952. /**
  70953. * Creates a new ImageAssetTask
  70954. * @param name defines the name of the task
  70955. * @param url defines the location of the image to load
  70956. */
  70957. constructor(
  70958. /**
  70959. * Defines the name of the task
  70960. */
  70961. name: string,
  70962. /**
  70963. * Defines the location of the image to load
  70964. */
  70965. url: string);
  70966. /**
  70967. * Execute the current task
  70968. * @param scene defines the scene where you want your assets to be loaded
  70969. * @param onSuccess is a callback called when the task is successfully executed
  70970. * @param onError is a callback called if an error occurs
  70971. */
  70972. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70973. }
  70974. /**
  70975. * Defines the interface used by texture loading tasks
  70976. */
  70977. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70978. /**
  70979. * Gets the loaded texture
  70980. */
  70981. texture: TEX;
  70982. }
  70983. /**
  70984. * Define a task used by AssetsManager to load 2D textures
  70985. */
  70986. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70987. /**
  70988. * Defines the name of the task
  70989. */
  70990. name: string;
  70991. /**
  70992. * Defines the location of the file to load
  70993. */
  70994. url: string;
  70995. /**
  70996. * Defines if mipmap should not be generated (default is false)
  70997. */
  70998. noMipmap?: boolean | undefined;
  70999. /**
  71000. * Defines if texture must be inverted on Y axis (default is false)
  71001. */
  71002. invertY?: boolean | undefined;
  71003. /**
  71004. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71005. */
  71006. samplingMode: number;
  71007. /**
  71008. * Gets the loaded texture
  71009. */
  71010. texture: Texture;
  71011. /**
  71012. * Callback called when the task is successful
  71013. */
  71014. onSuccess: (task: TextureAssetTask) => void;
  71015. /**
  71016. * Callback called when the task is successful
  71017. */
  71018. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71019. /**
  71020. * Creates a new TextureAssetTask object
  71021. * @param name defines the name of the task
  71022. * @param url defines the location of the file to load
  71023. * @param noMipmap defines if mipmap should not be generated (default is false)
  71024. * @param invertY defines if texture must be inverted on Y axis (default is false)
  71025. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71026. */
  71027. constructor(
  71028. /**
  71029. * Defines the name of the task
  71030. */
  71031. name: string,
  71032. /**
  71033. * Defines the location of the file to load
  71034. */
  71035. url: string,
  71036. /**
  71037. * Defines if mipmap should not be generated (default is false)
  71038. */
  71039. noMipmap?: boolean | undefined,
  71040. /**
  71041. * Defines if texture must be inverted on Y axis (default is false)
  71042. */
  71043. invertY?: boolean | undefined,
  71044. /**
  71045. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71046. */
  71047. samplingMode?: number);
  71048. /**
  71049. * Execute the current task
  71050. * @param scene defines the scene where you want your assets to be loaded
  71051. * @param onSuccess is a callback called when the task is successfully executed
  71052. * @param onError is a callback called if an error occurs
  71053. */
  71054. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71055. }
  71056. /**
  71057. * Define a task used by AssetsManager to load cube textures
  71058. */
  71059. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71060. /**
  71061. * Defines the name of the task
  71062. */
  71063. name: string;
  71064. /**
  71065. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71066. */
  71067. url: string;
  71068. /**
  71069. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71070. */
  71071. extensions?: string[] | undefined;
  71072. /**
  71073. * Defines if mipmaps should not be generated (default is false)
  71074. */
  71075. noMipmap?: boolean | undefined;
  71076. /**
  71077. * Defines the explicit list of files (undefined by default)
  71078. */
  71079. files?: string[] | undefined;
  71080. /**
  71081. * Gets the loaded texture
  71082. */
  71083. texture: CubeTexture;
  71084. /**
  71085. * Callback called when the task is successful
  71086. */
  71087. onSuccess: (task: CubeTextureAssetTask) => void;
  71088. /**
  71089. * Callback called when the task is successful
  71090. */
  71091. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71092. /**
  71093. * Creates a new CubeTextureAssetTask
  71094. * @param name defines the name of the task
  71095. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71096. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71097. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71098. * @param files defines the explicit list of files (undefined by default)
  71099. */
  71100. constructor(
  71101. /**
  71102. * Defines the name of the task
  71103. */
  71104. name: string,
  71105. /**
  71106. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71107. */
  71108. url: string,
  71109. /**
  71110. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71111. */
  71112. extensions?: string[] | undefined,
  71113. /**
  71114. * Defines if mipmaps should not be generated (default is false)
  71115. */
  71116. noMipmap?: boolean | undefined,
  71117. /**
  71118. * Defines the explicit list of files (undefined by default)
  71119. */
  71120. files?: string[] | undefined);
  71121. /**
  71122. * Execute the current task
  71123. * @param scene defines the scene where you want your assets to be loaded
  71124. * @param onSuccess is a callback called when the task is successfully executed
  71125. * @param onError is a callback called if an error occurs
  71126. */
  71127. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71128. }
  71129. /**
  71130. * Define a task used by AssetsManager to load HDR cube textures
  71131. */
  71132. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71133. /**
  71134. * Defines the name of the task
  71135. */
  71136. name: string;
  71137. /**
  71138. * Defines the location of the file to load
  71139. */
  71140. url: string;
  71141. /**
  71142. * Defines the desired size (the more it increases the longer the generation will be)
  71143. */
  71144. size: number;
  71145. /**
  71146. * Defines if mipmaps should not be generated (default is false)
  71147. */
  71148. noMipmap: boolean;
  71149. /**
  71150. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71151. */
  71152. generateHarmonics: boolean;
  71153. /**
  71154. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  71155. */
  71156. gammaSpace: boolean;
  71157. /**
  71158. * Internal Use Only
  71159. */
  71160. reserved: boolean;
  71161. /**
  71162. * Gets the loaded texture
  71163. */
  71164. texture: HDRCubeTexture;
  71165. /**
  71166. * Callback called when the task is successful
  71167. */
  71168. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71169. /**
  71170. * Callback called when the task is successful
  71171. */
  71172. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71173. /**
  71174. * Creates a new HDRCubeTextureAssetTask object
  71175. * @param name defines the name of the task
  71176. * @param url defines the location of the file to load
  71177. * @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.
  71178. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71179. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71180. * @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)
  71181. * @param reserved Internal use only
  71182. */
  71183. constructor(
  71184. /**
  71185. * Defines the name of the task
  71186. */
  71187. name: string,
  71188. /**
  71189. * Defines the location of the file to load
  71190. */
  71191. url: string,
  71192. /**
  71193. * Defines the desired size (the more it increases the longer the generation will be)
  71194. */
  71195. size: number,
  71196. /**
  71197. * Defines if mipmaps should not be generated (default is false)
  71198. */
  71199. noMipmap?: boolean,
  71200. /**
  71201. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71202. */
  71203. generateHarmonics?: boolean,
  71204. /**
  71205. * 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)
  71206. */
  71207. gammaSpace?: boolean,
  71208. /**
  71209. * Internal Use Only
  71210. */
  71211. reserved?: boolean);
  71212. /**
  71213. * Execute the current task
  71214. * @param scene defines the scene where you want your assets to be loaded
  71215. * @param onSuccess is a callback called when the task is successfully executed
  71216. * @param onError is a callback called if an error occurs
  71217. */
  71218. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71219. }
  71220. /**
  71221. * Define a task used by AssetsManager to load Equirectangular cube textures
  71222. */
  71223. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71224. /**
  71225. * Defines the name of the task
  71226. */
  71227. name: string;
  71228. /**
  71229. * Defines the location of the file to load
  71230. */
  71231. url: string;
  71232. /**
  71233. * Defines the desired size (the more it increases the longer the generation will be)
  71234. */
  71235. size: number;
  71236. /**
  71237. * Defines if mipmaps should not be generated (default is false)
  71238. */
  71239. noMipmap: boolean;
  71240. /**
  71241. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71242. * but the standard material would require them in Gamma space) (default is true)
  71243. */
  71244. gammaSpace: boolean;
  71245. /**
  71246. * Gets the loaded texture
  71247. */
  71248. texture: EquiRectangularCubeTexture;
  71249. /**
  71250. * Callback called when the task is successful
  71251. */
  71252. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71253. /**
  71254. * Callback called when the task is successful
  71255. */
  71256. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71257. /**
  71258. * Creates a new EquiRectangularCubeTextureAssetTask object
  71259. * @param name defines the name of the task
  71260. * @param url defines the location of the file to load
  71261. * @param size defines the desired size (the more it increases the longer the generation will be)
  71262. * If the size is omitted this implies you are using a preprocessed cubemap.
  71263. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71264. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71265. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71266. * (default is true)
  71267. */
  71268. constructor(
  71269. /**
  71270. * Defines the name of the task
  71271. */
  71272. name: string,
  71273. /**
  71274. * Defines the location of the file to load
  71275. */
  71276. url: string,
  71277. /**
  71278. * Defines the desired size (the more it increases the longer the generation will be)
  71279. */
  71280. size: number,
  71281. /**
  71282. * Defines if mipmaps should not be generated (default is false)
  71283. */
  71284. noMipmap?: boolean,
  71285. /**
  71286. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71287. * but the standard material would require them in Gamma space) (default is true)
  71288. */
  71289. gammaSpace?: boolean);
  71290. /**
  71291. * Execute the current task
  71292. * @param scene defines the scene where you want your assets to be loaded
  71293. * @param onSuccess is a callback called when the task is successfully executed
  71294. * @param onError is a callback called if an error occurs
  71295. */
  71296. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71297. }
  71298. /**
  71299. * This class can be used to easily import assets into a scene
  71300. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71301. */
  71302. export class AssetsManager {
  71303. private _scene;
  71304. private _isLoading;
  71305. protected _tasks: AbstractAssetTask[];
  71306. protected _waitingTasksCount: number;
  71307. protected _totalTasksCount: number;
  71308. /**
  71309. * Callback called when all tasks are processed
  71310. */
  71311. onFinish: (tasks: AbstractAssetTask[]) => void;
  71312. /**
  71313. * Callback called when a task is successful
  71314. */
  71315. onTaskSuccess: (task: AbstractAssetTask) => void;
  71316. /**
  71317. * Callback called when a task had an error
  71318. */
  71319. onTaskError: (task: AbstractAssetTask) => void;
  71320. /**
  71321. * Callback called when a task is done (whatever the result is)
  71322. */
  71323. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71324. /**
  71325. * Observable called when all tasks are processed
  71326. */
  71327. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71328. /**
  71329. * Observable called when a task had an error
  71330. */
  71331. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71332. /**
  71333. * Observable called when all tasks were executed
  71334. */
  71335. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71336. /**
  71337. * Observable called when a task is done (whatever the result is)
  71338. */
  71339. onProgressObservable: Observable<IAssetsProgressEvent>;
  71340. /**
  71341. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71342. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71343. */
  71344. useDefaultLoadingScreen: boolean;
  71345. /**
  71346. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71347. * when all assets have been downloaded.
  71348. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71349. */
  71350. autoHideLoadingUI: boolean;
  71351. /**
  71352. * Creates a new AssetsManager
  71353. * @param scene defines the scene to work on
  71354. */
  71355. constructor(scene: Scene);
  71356. /**
  71357. * Add a MeshAssetTask to the list of active tasks
  71358. * @param taskName defines the name of the new task
  71359. * @param meshesNames defines the name of meshes to load
  71360. * @param rootUrl defines the root url to use to locate files
  71361. * @param sceneFilename defines the filename of the scene file
  71362. * @returns a new MeshAssetTask object
  71363. */
  71364. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71365. /**
  71366. * Add a TextFileAssetTask to the list of active tasks
  71367. * @param taskName defines the name of the new task
  71368. * @param url defines the url of the file to load
  71369. * @returns a new TextFileAssetTask object
  71370. */
  71371. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71372. /**
  71373. * Add a BinaryFileAssetTask to the list of active tasks
  71374. * @param taskName defines the name of the new task
  71375. * @param url defines the url of the file to load
  71376. * @returns a new BinaryFileAssetTask object
  71377. */
  71378. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71379. /**
  71380. * Add a ImageAssetTask to the list of active tasks
  71381. * @param taskName defines the name of the new task
  71382. * @param url defines the url of the file to load
  71383. * @returns a new ImageAssetTask object
  71384. */
  71385. addImageTask(taskName: string, url: string): ImageAssetTask;
  71386. /**
  71387. * Add a TextureAssetTask to the list of active tasks
  71388. * @param taskName defines the name of the new task
  71389. * @param url defines the url of the file to load
  71390. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71391. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71392. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71393. * @returns a new TextureAssetTask object
  71394. */
  71395. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71396. /**
  71397. * Add a CubeTextureAssetTask to the list of active tasks
  71398. * @param taskName defines the name of the new task
  71399. * @param url defines the url of the file to load
  71400. * @param extensions defines the extension to use to load the cube map (can be null)
  71401. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71402. * @param files defines the list of files to load (can be null)
  71403. * @returns a new CubeTextureAssetTask object
  71404. */
  71405. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71406. /**
  71407. *
  71408. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71409. * @param taskName defines the name of the new task
  71410. * @param url defines the url of the file to load
  71411. * @param size defines the size you want for the cubemap (can be null)
  71412. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71413. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71414. * @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)
  71415. * @param reserved Internal use only
  71416. * @returns a new HDRCubeTextureAssetTask object
  71417. */
  71418. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71419. /**
  71420. *
  71421. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71422. * @param taskName defines the name of the new task
  71423. * @param url defines the url of the file to load
  71424. * @param size defines the size you want for the cubemap (can be null)
  71425. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71426. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71427. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71428. * @returns a new EquiRectangularCubeTextureAssetTask object
  71429. */
  71430. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71431. /**
  71432. * Remove a task from the assets manager.
  71433. * @param task the task to remove
  71434. */
  71435. removeTask(task: AbstractAssetTask): void;
  71436. private _decreaseWaitingTasksCount;
  71437. private _runTask;
  71438. /**
  71439. * Reset the AssetsManager and remove all tasks
  71440. * @return the current instance of the AssetsManager
  71441. */
  71442. reset(): AssetsManager;
  71443. /**
  71444. * Start the loading process
  71445. * @return the current instance of the AssetsManager
  71446. */
  71447. load(): AssetsManager;
  71448. /**
  71449. * Start the loading process as an async operation
  71450. * @return a promise returning the list of failed tasks
  71451. */
  71452. loadAsync(): Promise<void>;
  71453. }
  71454. }
  71455. declare module "babylonjs/Misc/deferred" {
  71456. /**
  71457. * Wrapper class for promise with external resolve and reject.
  71458. */
  71459. export class Deferred<T> {
  71460. /**
  71461. * The promise associated with this deferred object.
  71462. */
  71463. readonly promise: Promise<T>;
  71464. private _resolve;
  71465. private _reject;
  71466. /**
  71467. * The resolve method of the promise associated with this deferred object.
  71468. */
  71469. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71470. /**
  71471. * The reject method of the promise associated with this deferred object.
  71472. */
  71473. get reject(): (reason?: any) => void;
  71474. /**
  71475. * Constructor for this deferred object.
  71476. */
  71477. constructor();
  71478. }
  71479. }
  71480. declare module "babylonjs/Misc/meshExploder" {
  71481. import { Mesh } from "babylonjs/Meshes/mesh";
  71482. /**
  71483. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71484. */
  71485. export class MeshExploder {
  71486. private _centerMesh;
  71487. private _meshes;
  71488. private _meshesOrigins;
  71489. private _toCenterVectors;
  71490. private _scaledDirection;
  71491. private _newPosition;
  71492. private _centerPosition;
  71493. /**
  71494. * Explodes meshes from a center mesh.
  71495. * @param meshes The meshes to explode.
  71496. * @param centerMesh The mesh to be center of explosion.
  71497. */
  71498. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71499. private _setCenterMesh;
  71500. /**
  71501. * Get class name
  71502. * @returns "MeshExploder"
  71503. */
  71504. getClassName(): string;
  71505. /**
  71506. * "Exploded meshes"
  71507. * @returns Array of meshes with the centerMesh at index 0.
  71508. */
  71509. getMeshes(): Array<Mesh>;
  71510. /**
  71511. * Explodes meshes giving a specific direction
  71512. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71513. */
  71514. explode(direction?: number): void;
  71515. }
  71516. }
  71517. declare module "babylonjs/Misc/filesInput" {
  71518. import { Engine } from "babylonjs/Engines/engine";
  71519. import { Scene } from "babylonjs/scene";
  71520. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71521. /**
  71522. * Class used to help managing file picking and drag'n'drop
  71523. */
  71524. export class FilesInput {
  71525. /**
  71526. * List of files ready to be loaded
  71527. */
  71528. static get FilesToLoad(): {
  71529. [key: string]: File;
  71530. };
  71531. /**
  71532. * Callback called when a file is processed
  71533. */
  71534. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71535. private _engine;
  71536. private _currentScene;
  71537. private _sceneLoadedCallback;
  71538. private _progressCallback;
  71539. private _additionalRenderLoopLogicCallback;
  71540. private _textureLoadingCallback;
  71541. private _startingProcessingFilesCallback;
  71542. private _onReloadCallback;
  71543. private _errorCallback;
  71544. private _elementToMonitor;
  71545. private _sceneFileToLoad;
  71546. private _filesToLoad;
  71547. /**
  71548. * Creates a new FilesInput
  71549. * @param engine defines the rendering engine
  71550. * @param scene defines the hosting scene
  71551. * @param sceneLoadedCallback callback called when scene is loaded
  71552. * @param progressCallback callback called to track progress
  71553. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71554. * @param textureLoadingCallback callback called when a texture is loading
  71555. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71556. * @param onReloadCallback callback called when a reload is requested
  71557. * @param errorCallback callback call if an error occurs
  71558. */
  71559. 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);
  71560. private _dragEnterHandler;
  71561. private _dragOverHandler;
  71562. private _dropHandler;
  71563. /**
  71564. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71565. * @param elementToMonitor defines the DOM element to track
  71566. */
  71567. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71568. /**
  71569. * Release all associated resources
  71570. */
  71571. dispose(): void;
  71572. private renderFunction;
  71573. private drag;
  71574. private drop;
  71575. private _traverseFolder;
  71576. private _processFiles;
  71577. /**
  71578. * Load files from a drop event
  71579. * @param event defines the drop event to use as source
  71580. */
  71581. loadFiles(event: any): void;
  71582. private _processReload;
  71583. /**
  71584. * Reload the current scene from the loaded files
  71585. */
  71586. reload(): void;
  71587. }
  71588. }
  71589. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71590. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71591. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71592. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71593. }
  71594. declare module "babylonjs/Misc/sceneOptimizer" {
  71595. import { Scene, IDisposable } from "babylonjs/scene";
  71596. import { Observable } from "babylonjs/Misc/observable";
  71597. /**
  71598. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71599. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71600. */
  71601. export class SceneOptimization {
  71602. /**
  71603. * Defines the priority of this optimization (0 by default which means first in the list)
  71604. */
  71605. priority: number;
  71606. /**
  71607. * Gets a string describing the action executed by the current optimization
  71608. * @returns description string
  71609. */
  71610. getDescription(): string;
  71611. /**
  71612. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71613. * @param scene defines the current scene where to apply this optimization
  71614. * @param optimizer defines the current optimizer
  71615. * @returns true if everything that can be done was applied
  71616. */
  71617. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71618. /**
  71619. * Creates the SceneOptimization object
  71620. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71621. * @param desc defines the description associated with the optimization
  71622. */
  71623. constructor(
  71624. /**
  71625. * Defines the priority of this optimization (0 by default which means first in the list)
  71626. */
  71627. priority?: number);
  71628. }
  71629. /**
  71630. * Defines an optimization used to reduce the size of render target textures
  71631. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71632. */
  71633. export class TextureOptimization extends SceneOptimization {
  71634. /**
  71635. * Defines the priority of this optimization (0 by default which means first in the list)
  71636. */
  71637. priority: number;
  71638. /**
  71639. * 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
  71640. */
  71641. maximumSize: number;
  71642. /**
  71643. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71644. */
  71645. step: number;
  71646. /**
  71647. * Gets a string describing the action executed by the current optimization
  71648. * @returns description string
  71649. */
  71650. getDescription(): string;
  71651. /**
  71652. * Creates the TextureOptimization object
  71653. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71654. * @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
  71655. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71656. */
  71657. constructor(
  71658. /**
  71659. * Defines the priority of this optimization (0 by default which means first in the list)
  71660. */
  71661. priority?: number,
  71662. /**
  71663. * Defines the maximum 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
  71664. */
  71665. maximumSize?: number,
  71666. /**
  71667. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71668. */
  71669. step?: number);
  71670. /**
  71671. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71672. * @param scene defines the current scene where to apply this optimization
  71673. * @param optimizer defines the current optimizer
  71674. * @returns true if everything that can be done was applied
  71675. */
  71676. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71677. }
  71678. /**
  71679. * Defines an optimization used to increase or decrease the rendering resolution
  71680. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71681. */
  71682. export class HardwareScalingOptimization extends SceneOptimization {
  71683. /**
  71684. * Defines the priority of this optimization (0 by default which means first in the list)
  71685. */
  71686. priority: number;
  71687. /**
  71688. * Defines the maximum scale to use (2 by default)
  71689. */
  71690. maximumScale: number;
  71691. /**
  71692. * Defines the step to use between two passes (0.5 by default)
  71693. */
  71694. step: number;
  71695. private _currentScale;
  71696. private _directionOffset;
  71697. /**
  71698. * Gets a string describing the action executed by the current optimization
  71699. * @return description string
  71700. */
  71701. getDescription(): string;
  71702. /**
  71703. * Creates the HardwareScalingOptimization object
  71704. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71705. * @param maximumScale defines the maximum scale to use (2 by default)
  71706. * @param step defines the step to use between two passes (0.5 by default)
  71707. */
  71708. constructor(
  71709. /**
  71710. * Defines the priority of this optimization (0 by default which means first in the list)
  71711. */
  71712. priority?: number,
  71713. /**
  71714. * Defines the maximum scale to use (2 by default)
  71715. */
  71716. maximumScale?: number,
  71717. /**
  71718. * Defines the step to use between two passes (0.5 by default)
  71719. */
  71720. step?: number);
  71721. /**
  71722. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71723. * @param scene defines the current scene where to apply this optimization
  71724. * @param optimizer defines the current optimizer
  71725. * @returns true if everything that can be done was applied
  71726. */
  71727. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71728. }
  71729. /**
  71730. * Defines an optimization used to remove shadows
  71731. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71732. */
  71733. export class ShadowsOptimization extends SceneOptimization {
  71734. /**
  71735. * Gets a string describing the action executed by the current optimization
  71736. * @return description string
  71737. */
  71738. getDescription(): string;
  71739. /**
  71740. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71741. * @param scene defines the current scene where to apply this optimization
  71742. * @param optimizer defines the current optimizer
  71743. * @returns true if everything that can be done was applied
  71744. */
  71745. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71746. }
  71747. /**
  71748. * Defines an optimization used to turn post-processes off
  71749. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71750. */
  71751. export class PostProcessesOptimization extends SceneOptimization {
  71752. /**
  71753. * Gets a string describing the action executed by the current optimization
  71754. * @return description string
  71755. */
  71756. getDescription(): string;
  71757. /**
  71758. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71759. * @param scene defines the current scene where to apply this optimization
  71760. * @param optimizer defines the current optimizer
  71761. * @returns true if everything that can be done was applied
  71762. */
  71763. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71764. }
  71765. /**
  71766. * Defines an optimization used to turn lens flares off
  71767. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71768. */
  71769. export class LensFlaresOptimization extends SceneOptimization {
  71770. /**
  71771. * Gets a string describing the action executed by the current optimization
  71772. * @return description string
  71773. */
  71774. getDescription(): string;
  71775. /**
  71776. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71777. * @param scene defines the current scene where to apply this optimization
  71778. * @param optimizer defines the current optimizer
  71779. * @returns true if everything that can be done was applied
  71780. */
  71781. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71782. }
  71783. /**
  71784. * Defines an optimization based on user defined callback.
  71785. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71786. */
  71787. export class CustomOptimization extends SceneOptimization {
  71788. /**
  71789. * Callback called to apply the custom optimization.
  71790. */
  71791. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71792. /**
  71793. * Callback called to get custom description
  71794. */
  71795. onGetDescription: () => string;
  71796. /**
  71797. * Gets a string describing the action executed by the current optimization
  71798. * @returns description string
  71799. */
  71800. getDescription(): string;
  71801. /**
  71802. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71803. * @param scene defines the current scene where to apply this optimization
  71804. * @param optimizer defines the current optimizer
  71805. * @returns true if everything that can be done was applied
  71806. */
  71807. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71808. }
  71809. /**
  71810. * Defines an optimization used to turn particles off
  71811. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71812. */
  71813. export class ParticlesOptimization extends SceneOptimization {
  71814. /**
  71815. * Gets a string describing the action executed by the current optimization
  71816. * @return description string
  71817. */
  71818. getDescription(): string;
  71819. /**
  71820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71821. * @param scene defines the current scene where to apply this optimization
  71822. * @param optimizer defines the current optimizer
  71823. * @returns true if everything that can be done was applied
  71824. */
  71825. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71826. }
  71827. /**
  71828. * Defines an optimization used to turn render targets off
  71829. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71830. */
  71831. export class RenderTargetsOptimization extends SceneOptimization {
  71832. /**
  71833. * Gets a string describing the action executed by the current optimization
  71834. * @return description string
  71835. */
  71836. getDescription(): string;
  71837. /**
  71838. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71839. * @param scene defines the current scene where to apply this optimization
  71840. * @param optimizer defines the current optimizer
  71841. * @returns true if everything that can be done was applied
  71842. */
  71843. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71844. }
  71845. /**
  71846. * Defines an optimization used to merge meshes with compatible materials
  71847. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71848. */
  71849. export class MergeMeshesOptimization extends SceneOptimization {
  71850. private static _UpdateSelectionTree;
  71851. /**
  71852. * Gets or sets a boolean which defines if optimization octree has to be updated
  71853. */
  71854. static get UpdateSelectionTree(): boolean;
  71855. /**
  71856. * Gets or sets a boolean which defines if optimization octree has to be updated
  71857. */
  71858. static set UpdateSelectionTree(value: boolean);
  71859. /**
  71860. * Gets a string describing the action executed by the current optimization
  71861. * @return description string
  71862. */
  71863. getDescription(): string;
  71864. private _canBeMerged;
  71865. /**
  71866. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71867. * @param scene defines the current scene where to apply this optimization
  71868. * @param optimizer defines the current optimizer
  71869. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71870. * @returns true if everything that can be done was applied
  71871. */
  71872. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71873. }
  71874. /**
  71875. * Defines a list of options used by SceneOptimizer
  71876. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71877. */
  71878. export class SceneOptimizerOptions {
  71879. /**
  71880. * Defines the target frame rate to reach (60 by default)
  71881. */
  71882. targetFrameRate: number;
  71883. /**
  71884. * Defines the interval between two checkes (2000ms by default)
  71885. */
  71886. trackerDuration: number;
  71887. /**
  71888. * Gets the list of optimizations to apply
  71889. */
  71890. optimizations: SceneOptimization[];
  71891. /**
  71892. * Creates a new list of options used by SceneOptimizer
  71893. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71894. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71895. */
  71896. constructor(
  71897. /**
  71898. * Defines the target frame rate to reach (60 by default)
  71899. */
  71900. targetFrameRate?: number,
  71901. /**
  71902. * Defines the interval between two checkes (2000ms by default)
  71903. */
  71904. trackerDuration?: number);
  71905. /**
  71906. * Add a new optimization
  71907. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71908. * @returns the current SceneOptimizerOptions
  71909. */
  71910. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71911. /**
  71912. * Add a new custom optimization
  71913. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71914. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71915. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71916. * @returns the current SceneOptimizerOptions
  71917. */
  71918. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71919. /**
  71920. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71921. * @param targetFrameRate defines the target frame rate (60 by default)
  71922. * @returns a SceneOptimizerOptions object
  71923. */
  71924. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71925. /**
  71926. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71927. * @param targetFrameRate defines the target frame rate (60 by default)
  71928. * @returns a SceneOptimizerOptions object
  71929. */
  71930. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71931. /**
  71932. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71933. * @param targetFrameRate defines the target frame rate (60 by default)
  71934. * @returns a SceneOptimizerOptions object
  71935. */
  71936. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71937. }
  71938. /**
  71939. * Class used to run optimizations in order to reach a target frame rate
  71940. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71941. */
  71942. export class SceneOptimizer implements IDisposable {
  71943. private _isRunning;
  71944. private _options;
  71945. private _scene;
  71946. private _currentPriorityLevel;
  71947. private _targetFrameRate;
  71948. private _trackerDuration;
  71949. private _currentFrameRate;
  71950. private _sceneDisposeObserver;
  71951. private _improvementMode;
  71952. /**
  71953. * Defines an observable called when the optimizer reaches the target frame rate
  71954. */
  71955. onSuccessObservable: Observable<SceneOptimizer>;
  71956. /**
  71957. * Defines an observable called when the optimizer enables an optimization
  71958. */
  71959. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71960. /**
  71961. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71962. */
  71963. onFailureObservable: Observable<SceneOptimizer>;
  71964. /**
  71965. * Gets a boolean indicating if the optimizer is in improvement mode
  71966. */
  71967. get isInImprovementMode(): boolean;
  71968. /**
  71969. * Gets the current priority level (0 at start)
  71970. */
  71971. get currentPriorityLevel(): number;
  71972. /**
  71973. * Gets the current frame rate checked by the SceneOptimizer
  71974. */
  71975. get currentFrameRate(): number;
  71976. /**
  71977. * Gets or sets the current target frame rate (60 by default)
  71978. */
  71979. get targetFrameRate(): number;
  71980. /**
  71981. * Gets or sets the current target frame rate (60 by default)
  71982. */
  71983. set targetFrameRate(value: number);
  71984. /**
  71985. * Gets or sets the current interval between two checks (every 2000ms by default)
  71986. */
  71987. get trackerDuration(): number;
  71988. /**
  71989. * Gets or sets the current interval between two checks (every 2000ms by default)
  71990. */
  71991. set trackerDuration(value: number);
  71992. /**
  71993. * Gets the list of active optimizations
  71994. */
  71995. get optimizations(): SceneOptimization[];
  71996. /**
  71997. * Creates a new SceneOptimizer
  71998. * @param scene defines the scene to work on
  71999. * @param options defines the options to use with the SceneOptimizer
  72000. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72001. * @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)
  72002. */
  72003. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72004. /**
  72005. * Stops the current optimizer
  72006. */
  72007. stop(): void;
  72008. /**
  72009. * Reset the optimizer to initial step (current priority level = 0)
  72010. */
  72011. reset(): void;
  72012. /**
  72013. * Start the optimizer. By default it will try to reach a specific framerate
  72014. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72015. */
  72016. start(): void;
  72017. private _checkCurrentState;
  72018. /**
  72019. * Release all resources
  72020. */
  72021. dispose(): void;
  72022. /**
  72023. * Helper function to create a SceneOptimizer with one single line of code
  72024. * @param scene defines the scene to work on
  72025. * @param options defines the options to use with the SceneOptimizer
  72026. * @param onSuccess defines a callback to call on success
  72027. * @param onFailure defines a callback to call on failure
  72028. * @returns the new SceneOptimizer object
  72029. */
  72030. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72031. }
  72032. }
  72033. declare module "babylonjs/Misc/sceneSerializer" {
  72034. import { Scene } from "babylonjs/scene";
  72035. /**
  72036. * Class used to serialize a scene into a string
  72037. */
  72038. export class SceneSerializer {
  72039. /**
  72040. * Clear cache used by a previous serialization
  72041. */
  72042. static ClearCache(): void;
  72043. /**
  72044. * Serialize a scene into a JSON compatible object
  72045. * @param scene defines the scene to serialize
  72046. * @returns a JSON compatible object
  72047. */
  72048. static Serialize(scene: Scene): any;
  72049. /**
  72050. * Serialize a mesh into a JSON compatible object
  72051. * @param toSerialize defines the mesh to serialize
  72052. * @param withParents defines if parents must be serialized as well
  72053. * @param withChildren defines if children must be serialized as well
  72054. * @returns a JSON compatible object
  72055. */
  72056. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72057. }
  72058. }
  72059. declare module "babylonjs/Misc/textureTools" {
  72060. import { Texture } from "babylonjs/Materials/Textures/texture";
  72061. /**
  72062. * Class used to host texture specific utilities
  72063. */
  72064. export class TextureTools {
  72065. /**
  72066. * Uses the GPU to create a copy texture rescaled at a given size
  72067. * @param texture Texture to copy from
  72068. * @param width defines the desired width
  72069. * @param height defines the desired height
  72070. * @param useBilinearMode defines if bilinear mode has to be used
  72071. * @return the generated texture
  72072. */
  72073. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72074. }
  72075. }
  72076. declare module "babylonjs/Misc/videoRecorder" {
  72077. import { Nullable } from "babylonjs/types";
  72078. import { Engine } from "babylonjs/Engines/engine";
  72079. /**
  72080. * This represents the different options available for the video capture.
  72081. */
  72082. export interface VideoRecorderOptions {
  72083. /** Defines the mime type of the video. */
  72084. mimeType: string;
  72085. /** Defines the FPS the video should be recorded at. */
  72086. fps: number;
  72087. /** Defines the chunk size for the recording data. */
  72088. recordChunckSize: number;
  72089. /** The audio tracks to attach to the recording. */
  72090. audioTracks?: MediaStreamTrack[];
  72091. }
  72092. /**
  72093. * This can help with recording videos from BabylonJS.
  72094. * This is based on the available WebRTC functionalities of the browser.
  72095. *
  72096. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72097. */
  72098. export class VideoRecorder {
  72099. private static readonly _defaultOptions;
  72100. /**
  72101. * Returns whether or not the VideoRecorder is available in your browser.
  72102. * @param engine Defines the Babylon Engine.
  72103. * @returns true if supported otherwise false.
  72104. */
  72105. static IsSupported(engine: Engine): boolean;
  72106. private readonly _options;
  72107. private _canvas;
  72108. private _mediaRecorder;
  72109. private _recordedChunks;
  72110. private _fileName;
  72111. private _resolve;
  72112. private _reject;
  72113. /**
  72114. * True when a recording is already in progress.
  72115. */
  72116. get isRecording(): boolean;
  72117. /**
  72118. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72119. * @param engine Defines the BabylonJS Engine you wish to record.
  72120. * @param options Defines options that can be used to customize the capture.
  72121. */
  72122. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72123. /**
  72124. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72125. */
  72126. stopRecording(): void;
  72127. /**
  72128. * Starts recording the canvas for a max duration specified in parameters.
  72129. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72130. * If null no automatic download will start and you can rely on the promise to get the data back.
  72131. * @param maxDuration Defines the maximum recording time in seconds.
  72132. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72133. * @return A promise callback at the end of the recording with the video data in Blob.
  72134. */
  72135. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72136. /**
  72137. * Releases internal resources used during the recording.
  72138. */
  72139. dispose(): void;
  72140. private _handleDataAvailable;
  72141. private _handleError;
  72142. private _handleStop;
  72143. }
  72144. }
  72145. declare module "babylonjs/Misc/screenshotTools" {
  72146. import { Camera } from "babylonjs/Cameras/camera";
  72147. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72148. import { Engine } from "babylonjs/Engines/engine";
  72149. /**
  72150. * Class containing a set of static utilities functions for screenshots
  72151. */
  72152. export class ScreenshotTools {
  72153. /**
  72154. * Captures a screenshot of the current rendering
  72155. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72156. * @param engine defines the rendering engine
  72157. * @param camera defines the source camera
  72158. * @param size This parameter can be set to a single number or to an object with the
  72159. * following (optional) properties: precision, width, height. If a single number is passed,
  72160. * it will be used for both width and height. If an object is passed, the screenshot size
  72161. * will be derived from the parameters. The precision property is a multiplier allowing
  72162. * rendering at a higher or lower resolution
  72163. * @param successCallback defines the callback receives a single parameter which contains the
  72164. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72165. * src parameter of an <img> to display it
  72166. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72167. * Check your browser for supported MIME types
  72168. */
  72169. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72170. /**
  72171. * Captures a screenshot of the current rendering
  72172. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72173. * @param engine defines the rendering engine
  72174. * @param camera defines the source camera
  72175. * @param size This parameter can be set to a single number or to an object with the
  72176. * following (optional) properties: precision, width, height. If a single number is passed,
  72177. * it will be used for both width and height. If an object is passed, the screenshot size
  72178. * will be derived from the parameters. The precision property is a multiplier allowing
  72179. * rendering at a higher or lower resolution
  72180. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72181. * Check your browser for supported MIME types
  72182. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72183. * to the src parameter of an <img> to display it
  72184. */
  72185. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72186. /**
  72187. * Generates an image screenshot from the specified camera.
  72188. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72189. * @param engine The engine to use for rendering
  72190. * @param camera The camera to use for rendering
  72191. * @param size This parameter can be set to a single number or to an object with the
  72192. * following (optional) properties: precision, width, height. If a single number is passed,
  72193. * it will be used for both width and height. If an object is passed, the screenshot size
  72194. * will be derived from the parameters. The precision property is a multiplier allowing
  72195. * rendering at a higher or lower resolution
  72196. * @param successCallback The callback receives a single parameter which contains the
  72197. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72198. * src parameter of an <img> to display it
  72199. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72200. * Check your browser for supported MIME types
  72201. * @param samples Texture samples (default: 1)
  72202. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72203. * @param fileName A name for for the downloaded file.
  72204. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72205. */
  72206. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72207. /**
  72208. * Generates an image screenshot from the specified camera.
  72209. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72210. * @param engine The engine to use for rendering
  72211. * @param camera The camera to use for rendering
  72212. * @param size This parameter can be set to a single number or to an object with the
  72213. * following (optional) properties: precision, width, height. If a single number is passed,
  72214. * it will be used for both width and height. If an object is passed, the screenshot size
  72215. * will be derived from the parameters. The precision property is a multiplier allowing
  72216. * rendering at a higher or lower resolution
  72217. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72218. * Check your browser for supported MIME types
  72219. * @param samples Texture samples (default: 1)
  72220. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72221. * @param fileName A name for for the downloaded file.
  72222. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72223. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72224. * to the src parameter of an <img> to display it
  72225. */
  72226. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72227. /**
  72228. * Gets height and width for screenshot size
  72229. * @private
  72230. */
  72231. private static _getScreenshotSize;
  72232. }
  72233. }
  72234. declare module "babylonjs/Misc/dataReader" {
  72235. /**
  72236. * Interface for a data buffer
  72237. */
  72238. export interface IDataBuffer {
  72239. /**
  72240. * Reads bytes from the data buffer.
  72241. * @param byteOffset The byte offset to read
  72242. * @param byteLength The byte length to read
  72243. * @returns A promise that resolves when the bytes are read
  72244. */
  72245. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72246. /**
  72247. * The byte length of the buffer.
  72248. */
  72249. readonly byteLength: number;
  72250. }
  72251. /**
  72252. * Utility class for reading from a data buffer
  72253. */
  72254. export class DataReader {
  72255. /**
  72256. * The data buffer associated with this data reader.
  72257. */
  72258. readonly buffer: IDataBuffer;
  72259. /**
  72260. * The current byte offset from the beginning of the data buffer.
  72261. */
  72262. byteOffset: number;
  72263. private _dataView;
  72264. private _dataByteOffset;
  72265. /**
  72266. * Constructor
  72267. * @param buffer The buffer to read
  72268. */
  72269. constructor(buffer: IDataBuffer);
  72270. /**
  72271. * Loads the given byte length.
  72272. * @param byteLength The byte length to load
  72273. * @returns A promise that resolves when the load is complete
  72274. */
  72275. loadAsync(byteLength: number): Promise<void>;
  72276. /**
  72277. * Read a unsigned 32-bit integer from the currently loaded data range.
  72278. * @returns The 32-bit integer read
  72279. */
  72280. readUint32(): number;
  72281. /**
  72282. * Read a byte array from the currently loaded data range.
  72283. * @param byteLength The byte length to read
  72284. * @returns The byte array read
  72285. */
  72286. readUint8Array(byteLength: number): Uint8Array;
  72287. /**
  72288. * Read a string from the currently loaded data range.
  72289. * @param byteLength The byte length to read
  72290. * @returns The string read
  72291. */
  72292. readString(byteLength: number): string;
  72293. /**
  72294. * Skips the given byte length the currently loaded data range.
  72295. * @param byteLength The byte length to skip
  72296. */
  72297. skipBytes(byteLength: number): void;
  72298. }
  72299. }
  72300. declare module "babylonjs/Misc/index" {
  72301. export * from "babylonjs/Misc/andOrNotEvaluator";
  72302. export * from "babylonjs/Misc/assetsManager";
  72303. export * from "babylonjs/Misc/basis";
  72304. export * from "babylonjs/Misc/dds";
  72305. export * from "babylonjs/Misc/decorators";
  72306. export * from "babylonjs/Misc/deferred";
  72307. export * from "babylonjs/Misc/environmentTextureTools";
  72308. export * from "babylonjs/Misc/meshExploder";
  72309. export * from "babylonjs/Misc/filesInput";
  72310. export * from "babylonjs/Misc/HighDynamicRange/index";
  72311. export * from "babylonjs/Misc/khronosTextureContainer";
  72312. export * from "babylonjs/Misc/observable";
  72313. export * from "babylonjs/Misc/performanceMonitor";
  72314. export * from "babylonjs/Misc/promise";
  72315. export * from "babylonjs/Misc/sceneOptimizer";
  72316. export * from "babylonjs/Misc/sceneSerializer";
  72317. export * from "babylonjs/Misc/smartArray";
  72318. export * from "babylonjs/Misc/stringDictionary";
  72319. export * from "babylonjs/Misc/tags";
  72320. export * from "babylonjs/Misc/textureTools";
  72321. export * from "babylonjs/Misc/tga";
  72322. export * from "babylonjs/Misc/tools";
  72323. export * from "babylonjs/Misc/videoRecorder";
  72324. export * from "babylonjs/Misc/virtualJoystick";
  72325. export * from "babylonjs/Misc/workerPool";
  72326. export * from "babylonjs/Misc/logger";
  72327. export * from "babylonjs/Misc/typeStore";
  72328. export * from "babylonjs/Misc/filesInputStore";
  72329. export * from "babylonjs/Misc/deepCopier";
  72330. export * from "babylonjs/Misc/pivotTools";
  72331. export * from "babylonjs/Misc/precisionDate";
  72332. export * from "babylonjs/Misc/screenshotTools";
  72333. export * from "babylonjs/Misc/typeStore";
  72334. export * from "babylonjs/Misc/webRequest";
  72335. export * from "babylonjs/Misc/iInspectable";
  72336. export * from "babylonjs/Misc/brdfTextureTools";
  72337. export * from "babylonjs/Misc/rgbdTextureTools";
  72338. export * from "babylonjs/Misc/gradients";
  72339. export * from "babylonjs/Misc/perfCounter";
  72340. export * from "babylonjs/Misc/fileRequest";
  72341. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72342. export * from "babylonjs/Misc/retryStrategy";
  72343. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72344. export * from "babylonjs/Misc/canvasGenerator";
  72345. export * from "babylonjs/Misc/fileTools";
  72346. export * from "babylonjs/Misc/stringTools";
  72347. export * from "babylonjs/Misc/dataReader";
  72348. export * from "babylonjs/Misc/minMaxReducer";
  72349. export * from "babylonjs/Misc/depthReducer";
  72350. }
  72351. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  72352. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72353. import { Observable } from "babylonjs/Misc/observable";
  72354. import { Matrix } from "babylonjs/Maths/math.vector";
  72355. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72356. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72357. /**
  72358. * Options used for hit testing
  72359. */
  72360. export interface IWebXRHitTestOptions {
  72361. /**
  72362. * Only test when user interacted with the scene. Default - hit test every frame
  72363. */
  72364. testOnPointerDownOnly?: boolean;
  72365. /**
  72366. * The node to use to transform the local results to world coordinates
  72367. */
  72368. worldParentNode?: TransformNode;
  72369. }
  72370. /**
  72371. * Interface defining the babylon result of raycasting/hit-test
  72372. */
  72373. export interface IWebXRHitResult {
  72374. /**
  72375. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72376. */
  72377. transformationMatrix: Matrix;
  72378. /**
  72379. * The native hit test result
  72380. */
  72381. xrHitResult: XRHitResult;
  72382. }
  72383. /**
  72384. * The currently-working hit-test module.
  72385. * Hit test (or Ray-casting) is used to interact with the real world.
  72386. * For further information read here - https://github.com/immersive-web/hit-test
  72387. */
  72388. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72389. /**
  72390. * options to use when constructing this feature
  72391. */
  72392. readonly options: IWebXRHitTestOptions;
  72393. private _direction;
  72394. private _mat;
  72395. private _onSelectEnabled;
  72396. private _origin;
  72397. /**
  72398. * The module's name
  72399. */
  72400. static readonly Name: string;
  72401. /**
  72402. * The (Babylon) version of this module.
  72403. * This is an integer representing the implementation version.
  72404. * This number does not correspond to the WebXR specs version
  72405. */
  72406. static readonly Version: number;
  72407. /**
  72408. * Populated with the last native XR Hit Results
  72409. */
  72410. lastNativeXRHitResults: XRHitResult[];
  72411. /**
  72412. * Triggered when new babylon (transformed) hit test results are available
  72413. */
  72414. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72415. /**
  72416. * Creates a new instance of the (legacy version) hit test feature
  72417. * @param _xrSessionManager an instance of WebXRSessionManager
  72418. * @param options options to use when constructing this feature
  72419. */
  72420. constructor(_xrSessionManager: WebXRSessionManager,
  72421. /**
  72422. * options to use when constructing this feature
  72423. */
  72424. options?: IWebXRHitTestOptions);
  72425. /**
  72426. * execute a hit test with an XR Ray
  72427. *
  72428. * @param xrSession a native xrSession that will execute this hit test
  72429. * @param xrRay the ray (position and direction) to use for ray-casting
  72430. * @param referenceSpace native XR reference space to use for the hit-test
  72431. * @param filter filter function that will filter the results
  72432. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72433. */
  72434. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72435. /**
  72436. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72437. * @param event the (select) event to use to select with
  72438. * @param referenceSpace the reference space to use for this hit test
  72439. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72440. */
  72441. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72442. /**
  72443. * attach this feature
  72444. * Will usually be called by the features manager
  72445. *
  72446. * @returns true if successful.
  72447. */
  72448. attach(): boolean;
  72449. /**
  72450. * detach this feature.
  72451. * Will usually be called by the features manager
  72452. *
  72453. * @returns true if successful.
  72454. */
  72455. detach(): boolean;
  72456. /**
  72457. * Dispose this feature and all of the resources attached
  72458. */
  72459. dispose(): void;
  72460. protected _onXRFrame(frame: XRFrame): void;
  72461. private _onHitTestResults;
  72462. private _onSelect;
  72463. }
  72464. }
  72465. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72466. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72467. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72468. import { Observable } from "babylonjs/Misc/observable";
  72469. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72470. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72471. /**
  72472. * Options used in the plane detector module
  72473. */
  72474. export interface IWebXRPlaneDetectorOptions {
  72475. /**
  72476. * The node to use to transform the local results to world coordinates
  72477. */
  72478. worldParentNode?: TransformNode;
  72479. }
  72480. /**
  72481. * A babylon interface for a WebXR plane.
  72482. * A Plane is actually a polygon, built from N points in space
  72483. *
  72484. * Supported in chrome 79, not supported in canary 81 ATM
  72485. */
  72486. export interface IWebXRPlane {
  72487. /**
  72488. * a babylon-assigned ID for this polygon
  72489. */
  72490. id: number;
  72491. /**
  72492. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72493. */
  72494. polygonDefinition: Array<Vector3>;
  72495. /**
  72496. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72497. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72498. */
  72499. transformationMatrix: Matrix;
  72500. /**
  72501. * the native xr-plane object
  72502. */
  72503. xrPlane: XRPlane;
  72504. }
  72505. /**
  72506. * The plane detector is used to detect planes in the real world when in AR
  72507. * For more information see https://github.com/immersive-web/real-world-geometry/
  72508. */
  72509. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72510. private _options;
  72511. private _detectedPlanes;
  72512. private _enabled;
  72513. private _lastFrameDetected;
  72514. /**
  72515. * The module's name
  72516. */
  72517. static readonly Name: string;
  72518. /**
  72519. * The (Babylon) version of this module.
  72520. * This is an integer representing the implementation version.
  72521. * This number does not correspond to the WebXR specs version
  72522. */
  72523. static readonly Version: number;
  72524. /**
  72525. * Observers registered here will be executed when a new plane was added to the session
  72526. */
  72527. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72528. /**
  72529. * Observers registered here will be executed when a plane is no longer detected in the session
  72530. */
  72531. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72532. /**
  72533. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72534. * This can execute N times every frame
  72535. */
  72536. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72537. /**
  72538. * construct a new Plane Detector
  72539. * @param _xrSessionManager an instance of xr Session manager
  72540. * @param _options configuration to use when constructing this feature
  72541. */
  72542. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72543. /**
  72544. * Dispose this feature and all of the resources attached
  72545. */
  72546. dispose(): void;
  72547. protected _onXRFrame(frame: XRFrame): void;
  72548. private _init;
  72549. private _updatePlaneWithXRPlane;
  72550. /**
  72551. * avoiding using Array.find for global support.
  72552. * @param xrPlane the plane to find in the array
  72553. */
  72554. private findIndexInPlaneArray;
  72555. }
  72556. }
  72557. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72558. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72559. import { Observable } from "babylonjs/Misc/observable";
  72560. import { Matrix } from "babylonjs/Maths/math.vector";
  72561. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72562. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72563. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72564. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72565. /**
  72566. * Configuration options of the anchor system
  72567. */
  72568. export interface IWebXRAnchorSystemOptions {
  72569. /**
  72570. * Should a new anchor be added every time a select event is triggered
  72571. */
  72572. addAnchorOnSelect?: boolean;
  72573. /**
  72574. * should the anchor system use plane detection.
  72575. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72576. */
  72577. usePlaneDetection?: boolean;
  72578. /**
  72579. * a node that will be used to convert local to world coordinates
  72580. */
  72581. worldParentNode?: TransformNode;
  72582. }
  72583. /**
  72584. * A babylon container for an XR Anchor
  72585. */
  72586. export interface IWebXRAnchor {
  72587. /**
  72588. * A babylon-assigned ID for this anchor
  72589. */
  72590. id: number;
  72591. /**
  72592. * Transformation matrix to apply to an object attached to this anchor
  72593. */
  72594. transformationMatrix: Matrix;
  72595. /**
  72596. * The native anchor object
  72597. */
  72598. xrAnchor: XRAnchor;
  72599. }
  72600. /**
  72601. * An implementation of the anchor system of WebXR.
  72602. * Note that the current documented implementation is not available in any browser. Future implementations
  72603. * will use the frame to create an anchor and not the session or a detected plane
  72604. * For further information see https://github.com/immersive-web/anchors/
  72605. */
  72606. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72607. private _options;
  72608. private _enabled;
  72609. private _hitTestModule;
  72610. private _lastFrameDetected;
  72611. private _onSelect;
  72612. private _planeDetector;
  72613. private _trackedAnchors;
  72614. /**
  72615. * The module's name
  72616. */
  72617. static readonly Name: string;
  72618. /**
  72619. * The (Babylon) version of this module.
  72620. * This is an integer representing the implementation version.
  72621. * This number does not correspond to the WebXR specs version
  72622. */
  72623. static readonly Version: number;
  72624. /**
  72625. * Observers registered here will be executed when a new anchor was added to the session
  72626. */
  72627. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72628. /**
  72629. * Observers registered here will be executed when an anchor was removed from the session
  72630. */
  72631. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72632. /**
  72633. * Observers registered here will be executed when an existing anchor updates
  72634. * This can execute N times every frame
  72635. */
  72636. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72637. /**
  72638. * constructs a new anchor system
  72639. * @param _xrSessionManager an instance of WebXRSessionManager
  72640. * @param _options configuration object for this feature
  72641. */
  72642. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72643. /**
  72644. * Add anchor at a specific XR point.
  72645. *
  72646. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72647. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72648. * @returns a promise the fulfills when the anchor was created
  72649. */
  72650. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72651. /**
  72652. * attach this feature
  72653. * Will usually be called by the features manager
  72654. *
  72655. * @returns true if successful.
  72656. */
  72657. attach(): boolean;
  72658. /**
  72659. * detach this feature.
  72660. * Will usually be called by the features manager
  72661. *
  72662. * @returns true if successful.
  72663. */
  72664. detach(): boolean;
  72665. /**
  72666. * Dispose this feature and all of the resources attached
  72667. */
  72668. dispose(): void;
  72669. /**
  72670. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72671. * @param hitTestModule the hit-test module to use.
  72672. */
  72673. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72674. /**
  72675. * set the plane detector to use in order to create anchors from frames
  72676. * @param planeDetector the plane-detector module to use
  72677. * @param enable enable plane-anchors. default is true
  72678. */
  72679. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72680. protected _onXRFrame(frame: XRFrame): void;
  72681. /**
  72682. * avoiding using Array.find for global support.
  72683. * @param xrAnchor the plane to find in the array
  72684. */
  72685. private _findIndexInAnchorArray;
  72686. private _updateAnchorWithXRFrame;
  72687. }
  72688. }
  72689. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  72690. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72692. import { Observable } from "babylonjs/Misc/observable";
  72693. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72694. /**
  72695. * Options interface for the background remover plugin
  72696. */
  72697. export interface IWebXRBackgroundRemoverOptions {
  72698. /**
  72699. * Further background meshes to disable when entering AR
  72700. */
  72701. backgroundMeshes?: AbstractMesh[];
  72702. /**
  72703. * flags to configure the removal of the environment helper.
  72704. * If not set, the entire background will be removed. If set, flags should be set as well.
  72705. */
  72706. environmentHelperRemovalFlags?: {
  72707. /**
  72708. * Should the skybox be removed (default false)
  72709. */
  72710. skyBox?: boolean;
  72711. /**
  72712. * Should the ground be removed (default false)
  72713. */
  72714. ground?: boolean;
  72715. };
  72716. /**
  72717. * don't disable the environment helper
  72718. */
  72719. ignoreEnvironmentHelper?: boolean;
  72720. }
  72721. /**
  72722. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72723. */
  72724. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72725. /**
  72726. * read-only options to be used in this module
  72727. */
  72728. readonly options: IWebXRBackgroundRemoverOptions;
  72729. /**
  72730. * The module's name
  72731. */
  72732. static readonly Name: string;
  72733. /**
  72734. * The (Babylon) version of this module.
  72735. * This is an integer representing the implementation version.
  72736. * This number does not correspond to the WebXR specs version
  72737. */
  72738. static readonly Version: number;
  72739. /**
  72740. * registered observers will be triggered when the background state changes
  72741. */
  72742. onBackgroundStateChangedObservable: Observable<boolean>;
  72743. /**
  72744. * constructs a new background remover module
  72745. * @param _xrSessionManager the session manager for this module
  72746. * @param options read-only options to be used in this module
  72747. */
  72748. constructor(_xrSessionManager: WebXRSessionManager,
  72749. /**
  72750. * read-only options to be used in this module
  72751. */
  72752. options?: IWebXRBackgroundRemoverOptions);
  72753. /**
  72754. * attach this feature
  72755. * Will usually be called by the features manager
  72756. *
  72757. * @returns true if successful.
  72758. */
  72759. attach(): boolean;
  72760. /**
  72761. * detach this feature.
  72762. * Will usually be called by the features manager
  72763. *
  72764. * @returns true if successful.
  72765. */
  72766. detach(): boolean;
  72767. /**
  72768. * Dispose this feature and all of the resources attached
  72769. */
  72770. dispose(): void;
  72771. protected _onXRFrame(_xrFrame: XRFrame): void;
  72772. private _setBackgroundState;
  72773. }
  72774. }
  72775. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  72776. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72777. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  72778. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72779. import { WebXRInput } from "babylonjs/XR/webXRInput";
  72780. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72781. import { Nullable } from "babylonjs/types";
  72782. /**
  72783. * Options for the controller physics feature
  72784. */
  72785. export class IWebXRControllerPhysicsOptions {
  72786. /**
  72787. * Should the headset get its own impostor
  72788. */
  72789. enableHeadsetImpostor?: boolean;
  72790. /**
  72791. * Optional parameters for the headset impostor
  72792. */
  72793. headsetImpostorParams?: {
  72794. /**
  72795. * The type of impostor to create. Default is sphere
  72796. */
  72797. impostorType: number;
  72798. /**
  72799. * the size of the impostor. Defaults to 10cm
  72800. */
  72801. impostorSize?: number | {
  72802. width: number;
  72803. height: number;
  72804. depth: number;
  72805. };
  72806. /**
  72807. * Friction definitions
  72808. */
  72809. friction?: number;
  72810. /**
  72811. * Restitution
  72812. */
  72813. restitution?: number;
  72814. };
  72815. /**
  72816. * The physics properties of the future impostors
  72817. */
  72818. physicsProperties?: {
  72819. /**
  72820. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72821. * Note that this requires a physics engine that supports mesh impostors!
  72822. */
  72823. useControllerMesh?: boolean;
  72824. /**
  72825. * The type of impostor to create. Default is sphere
  72826. */
  72827. impostorType?: number;
  72828. /**
  72829. * the size of the impostor. Defaults to 10cm
  72830. */
  72831. impostorSize?: number | {
  72832. width: number;
  72833. height: number;
  72834. depth: number;
  72835. };
  72836. /**
  72837. * Friction definitions
  72838. */
  72839. friction?: number;
  72840. /**
  72841. * Restitution
  72842. */
  72843. restitution?: number;
  72844. };
  72845. /**
  72846. * the xr input to use with this pointer selection
  72847. */
  72848. xrInput: WebXRInput;
  72849. }
  72850. /**
  72851. * Add physics impostor to your webxr controllers,
  72852. * including naive calculation of their linear and angular velocity
  72853. */
  72854. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72855. private readonly _options;
  72856. private _attachController;
  72857. private _controllers;
  72858. private _debugMode;
  72859. private _delta;
  72860. private _headsetImpostor?;
  72861. private _headsetMesh?;
  72862. private _lastTimestamp;
  72863. private _tmpQuaternion;
  72864. private _tmpVector;
  72865. /**
  72866. * The module's name
  72867. */
  72868. static readonly Name: string;
  72869. /**
  72870. * The (Babylon) version of this module.
  72871. * This is an integer representing the implementation version.
  72872. * This number does not correspond to the webxr specs version
  72873. */
  72874. static readonly Version: number;
  72875. /**
  72876. * Construct a new Controller Physics Feature
  72877. * @param _xrSessionManager the corresponding xr session manager
  72878. * @param _options options to create this feature with
  72879. */
  72880. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72881. /**
  72882. * @hidden
  72883. * enable debugging - will show console outputs and the impostor mesh
  72884. */
  72885. _enablePhysicsDebug(): void;
  72886. /**
  72887. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72888. * @param xrController the controller to add
  72889. */
  72890. addController(xrController: WebXRInputSource): void;
  72891. /**
  72892. * attach this feature
  72893. * Will usually be called by the features manager
  72894. *
  72895. * @returns true if successful.
  72896. */
  72897. attach(): boolean;
  72898. /**
  72899. * detach this feature.
  72900. * Will usually be called by the features manager
  72901. *
  72902. * @returns true if successful.
  72903. */
  72904. detach(): boolean;
  72905. /**
  72906. * Get the headset impostor, if enabled
  72907. * @returns the impostor
  72908. */
  72909. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72910. /**
  72911. * Get the physics impostor of a specific controller.
  72912. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72913. * @param controller the controller or the controller id of which to get the impostor
  72914. * @returns the impostor or null
  72915. */
  72916. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72917. /**
  72918. * Update the physics properties provided in the constructor
  72919. * @param newProperties the new properties object
  72920. */
  72921. setPhysicsProperties(newProperties: {
  72922. impostorType?: number;
  72923. impostorSize?: number | {
  72924. width: number;
  72925. height: number;
  72926. depth: number;
  72927. };
  72928. friction?: number;
  72929. restitution?: number;
  72930. }): void;
  72931. protected _onXRFrame(_xrFrame: any): void;
  72932. private _detachController;
  72933. }
  72934. }
  72935. declare module "babylonjs/XR/features/index" {
  72936. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  72937. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  72938. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  72939. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  72940. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  72941. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  72942. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  72943. }
  72944. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  72945. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  72946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72947. import { Scene } from "babylonjs/scene";
  72948. /**
  72949. * The motion controller class for all microsoft mixed reality controllers
  72950. */
  72951. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72952. protected readonly _mapping: {
  72953. defaultButton: {
  72954. "valueNodeName": string;
  72955. "unpressedNodeName": string;
  72956. "pressedNodeName": string;
  72957. };
  72958. defaultAxis: {
  72959. "valueNodeName": string;
  72960. "minNodeName": string;
  72961. "maxNodeName": string;
  72962. };
  72963. buttons: {
  72964. "xr-standard-trigger": {
  72965. "rootNodeName": string;
  72966. "componentProperty": string;
  72967. "states": string[];
  72968. };
  72969. "xr-standard-squeeze": {
  72970. "rootNodeName": string;
  72971. "componentProperty": string;
  72972. "states": string[];
  72973. };
  72974. "xr-standard-touchpad": {
  72975. "rootNodeName": string;
  72976. "labelAnchorNodeName": string;
  72977. "touchPointNodeName": string;
  72978. };
  72979. "xr-standard-thumbstick": {
  72980. "rootNodeName": string;
  72981. "componentProperty": string;
  72982. "states": string[];
  72983. };
  72984. };
  72985. axes: {
  72986. "xr-standard-touchpad": {
  72987. "x-axis": {
  72988. "rootNodeName": string;
  72989. };
  72990. "y-axis": {
  72991. "rootNodeName": string;
  72992. };
  72993. };
  72994. "xr-standard-thumbstick": {
  72995. "x-axis": {
  72996. "rootNodeName": string;
  72997. };
  72998. "y-axis": {
  72999. "rootNodeName": string;
  73000. };
  73001. };
  73002. };
  73003. };
  73004. /**
  73005. * The base url used to load the left and right controller models
  73006. */
  73007. static MODEL_BASE_URL: string;
  73008. /**
  73009. * The name of the left controller model file
  73010. */
  73011. static MODEL_LEFT_FILENAME: string;
  73012. /**
  73013. * The name of the right controller model file
  73014. */
  73015. static MODEL_RIGHT_FILENAME: string;
  73016. profileId: string;
  73017. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73018. protected _getFilenameAndPath(): {
  73019. filename: string;
  73020. path: string;
  73021. };
  73022. protected _getModelLoadingConstraints(): boolean;
  73023. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73024. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73025. protected _updateModel(): void;
  73026. }
  73027. }
  73028. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  73029. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73031. import { Scene } from "babylonjs/scene";
  73032. /**
  73033. * The motion controller class for oculus touch (quest, rift).
  73034. * This class supports legacy mapping as well the standard xr mapping
  73035. */
  73036. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73037. private _forceLegacyControllers;
  73038. private _modelRootNode;
  73039. /**
  73040. * The base url used to load the left and right controller models
  73041. */
  73042. static MODEL_BASE_URL: string;
  73043. /**
  73044. * The name of the left controller model file
  73045. */
  73046. static MODEL_LEFT_FILENAME: string;
  73047. /**
  73048. * The name of the right controller model file
  73049. */
  73050. static MODEL_RIGHT_FILENAME: string;
  73051. /**
  73052. * Base Url for the Quest controller model.
  73053. */
  73054. static QUEST_MODEL_BASE_URL: string;
  73055. profileId: string;
  73056. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73057. protected _getFilenameAndPath(): {
  73058. filename: string;
  73059. path: string;
  73060. };
  73061. protected _getModelLoadingConstraints(): boolean;
  73062. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73063. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73064. protected _updateModel(): void;
  73065. /**
  73066. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73067. * between the touch and touch 2.
  73068. */
  73069. private _isQuest;
  73070. }
  73071. }
  73072. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  73073. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73074. import { Scene } from "babylonjs/scene";
  73075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73076. /**
  73077. * The motion controller class for the standard HTC-Vive controllers
  73078. */
  73079. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73080. private _modelRootNode;
  73081. /**
  73082. * The base url used to load the left and right controller models
  73083. */
  73084. static MODEL_BASE_URL: string;
  73085. /**
  73086. * File name for the controller model.
  73087. */
  73088. static MODEL_FILENAME: string;
  73089. profileId: string;
  73090. /**
  73091. * Create a new Vive motion controller object
  73092. * @param scene the scene to use to create this controller
  73093. * @param gamepadObject the corresponding gamepad object
  73094. * @param handness the handness of the controller
  73095. */
  73096. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73097. protected _getFilenameAndPath(): {
  73098. filename: string;
  73099. path: string;
  73100. };
  73101. protected _getModelLoadingConstraints(): boolean;
  73102. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73103. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73104. protected _updateModel(): void;
  73105. }
  73106. }
  73107. declare module "babylonjs/XR/motionController/index" {
  73108. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73109. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  73110. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  73111. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  73112. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  73113. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  73114. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  73115. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  73116. }
  73117. declare module "babylonjs/XR/index" {
  73118. export * from "babylonjs/XR/webXRCamera";
  73119. export * from "babylonjs/XR/webXREnterExitUI";
  73120. export * from "babylonjs/XR/webXRExperienceHelper";
  73121. export * from "babylonjs/XR/webXRInput";
  73122. export * from "babylonjs/XR/webXRInputSource";
  73123. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  73124. export * from "babylonjs/XR/webXRTypes";
  73125. export * from "babylonjs/XR/webXRSessionManager";
  73126. export * from "babylonjs/XR/webXRDefaultExperience";
  73127. export * from "babylonjs/XR/webXRFeaturesManager";
  73128. export * from "babylonjs/XR/features/index";
  73129. export * from "babylonjs/XR/motionController/index";
  73130. }
  73131. declare module "babylonjs/index" {
  73132. export * from "babylonjs/abstractScene";
  73133. export * from "babylonjs/Actions/index";
  73134. export * from "babylonjs/Animations/index";
  73135. export * from "babylonjs/assetContainer";
  73136. export * from "babylonjs/Audio/index";
  73137. export * from "babylonjs/Behaviors/index";
  73138. export * from "babylonjs/Bones/index";
  73139. export * from "babylonjs/Cameras/index";
  73140. export * from "babylonjs/Collisions/index";
  73141. export * from "babylonjs/Culling/index";
  73142. export * from "babylonjs/Debug/index";
  73143. export * from "babylonjs/Engines/index";
  73144. export * from "babylonjs/Events/index";
  73145. export * from "babylonjs/Gamepads/index";
  73146. export * from "babylonjs/Gizmos/index";
  73147. export * from "babylonjs/Helpers/index";
  73148. export * from "babylonjs/Instrumentation/index";
  73149. export * from "babylonjs/Layers/index";
  73150. export * from "babylonjs/LensFlares/index";
  73151. export * from "babylonjs/Lights/index";
  73152. export * from "babylonjs/Loading/index";
  73153. export * from "babylonjs/Materials/index";
  73154. export * from "babylonjs/Maths/index";
  73155. export * from "babylonjs/Meshes/index";
  73156. export * from "babylonjs/Morph/index";
  73157. export * from "babylonjs/Navigation/index";
  73158. export * from "babylonjs/node";
  73159. export * from "babylonjs/Offline/index";
  73160. export * from "babylonjs/Particles/index";
  73161. export * from "babylonjs/Physics/index";
  73162. export * from "babylonjs/PostProcesses/index";
  73163. export * from "babylonjs/Probes/index";
  73164. export * from "babylonjs/Rendering/index";
  73165. export * from "babylonjs/scene";
  73166. export * from "babylonjs/sceneComponent";
  73167. export * from "babylonjs/Sprites/index";
  73168. export * from "babylonjs/States/index";
  73169. export * from "babylonjs/Misc/index";
  73170. export * from "babylonjs/XR/index";
  73171. export * from "babylonjs/types";
  73172. }
  73173. declare module "babylonjs/Animations/pathCursor" {
  73174. import { Vector3 } from "babylonjs/Maths/math.vector";
  73175. import { Path2 } from "babylonjs/Maths/math.path";
  73176. /**
  73177. * A cursor which tracks a point on a path
  73178. */
  73179. export class PathCursor {
  73180. private path;
  73181. /**
  73182. * Stores path cursor callbacks for when an onchange event is triggered
  73183. */
  73184. private _onchange;
  73185. /**
  73186. * The value of the path cursor
  73187. */
  73188. value: number;
  73189. /**
  73190. * The animation array of the path cursor
  73191. */
  73192. animations: Animation[];
  73193. /**
  73194. * Initializes the path cursor
  73195. * @param path The path to track
  73196. */
  73197. constructor(path: Path2);
  73198. /**
  73199. * Gets the cursor point on the path
  73200. * @returns A point on the path cursor at the cursor location
  73201. */
  73202. getPoint(): Vector3;
  73203. /**
  73204. * Moves the cursor ahead by the step amount
  73205. * @param step The amount to move the cursor forward
  73206. * @returns This path cursor
  73207. */
  73208. moveAhead(step?: number): PathCursor;
  73209. /**
  73210. * Moves the cursor behind by the step amount
  73211. * @param step The amount to move the cursor back
  73212. * @returns This path cursor
  73213. */
  73214. moveBack(step?: number): PathCursor;
  73215. /**
  73216. * Moves the cursor by the step amount
  73217. * If the step amount is greater than one, an exception is thrown
  73218. * @param step The amount to move the cursor
  73219. * @returns This path cursor
  73220. */
  73221. move(step: number): PathCursor;
  73222. /**
  73223. * Ensures that the value is limited between zero and one
  73224. * @returns This path cursor
  73225. */
  73226. private ensureLimits;
  73227. /**
  73228. * Runs onchange callbacks on change (used by the animation engine)
  73229. * @returns This path cursor
  73230. */
  73231. private raiseOnChange;
  73232. /**
  73233. * Executes a function on change
  73234. * @param f A path cursor onchange callback
  73235. * @returns This path cursor
  73236. */
  73237. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73238. }
  73239. }
  73240. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  73241. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  73242. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  73243. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  73244. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  73245. }
  73246. declare module "babylonjs/Engines/Processors/Expressions/index" {
  73247. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  73248. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  73249. }
  73250. declare module "babylonjs/Engines/Processors/index" {
  73251. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  73252. export * from "babylonjs/Engines/Processors/Expressions/index";
  73253. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  73254. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  73255. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  73256. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  73257. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  73258. export * from "babylonjs/Engines/Processors/shaderProcessor";
  73259. }
  73260. declare module "babylonjs/Legacy/legacy" {
  73261. import * as Babylon from "babylonjs/index";
  73262. export * from "babylonjs/index";
  73263. }
  73264. declare module "babylonjs/Shaders/blur.fragment" {
  73265. /** @hidden */
  73266. export var blurPixelShader: {
  73267. name: string;
  73268. shader: string;
  73269. };
  73270. }
  73271. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  73272. /** @hidden */
  73273. export var pointCloudVertexDeclaration: {
  73274. name: string;
  73275. shader: string;
  73276. };
  73277. }
  73278. declare module "babylonjs" {
  73279. export * from "babylonjs/Legacy/legacy";
  73280. }
  73281. declare module BABYLON {
  73282. /** Alias type for value that can be null */
  73283. export type Nullable<T> = T | null;
  73284. /**
  73285. * Alias type for number that are floats
  73286. * @ignorenaming
  73287. */
  73288. export type float = number;
  73289. /**
  73290. * Alias type for number that are doubles.
  73291. * @ignorenaming
  73292. */
  73293. export type double = number;
  73294. /**
  73295. * Alias type for number that are integer
  73296. * @ignorenaming
  73297. */
  73298. export type int = number;
  73299. /** Alias type for number array or Float32Array */
  73300. export type FloatArray = number[] | Float32Array;
  73301. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  73302. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  73303. /**
  73304. * Alias for types that can be used by a Buffer or VertexBuffer.
  73305. */
  73306. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  73307. /**
  73308. * Alias type for primitive types
  73309. * @ignorenaming
  73310. */
  73311. type Primitive = undefined | null | boolean | string | number | Function;
  73312. /**
  73313. * Type modifier to make all the properties of an object Readonly
  73314. */
  73315. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  73316. /**
  73317. * Type modifier to make all the properties of an object Readonly recursively
  73318. */
  73319. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  73320. /**
  73321. * Type modifier to make object properties readonly.
  73322. */
  73323. export type DeepImmutableObject<T> = {
  73324. readonly [K in keyof T]: DeepImmutable<T[K]>;
  73325. };
  73326. /** @hidden */
  73327. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  73328. }
  73329. }
  73330. declare module BABYLON {
  73331. /**
  73332. * A class serves as a medium between the observable and its observers
  73333. */
  73334. export class EventState {
  73335. /**
  73336. * Create a new EventState
  73337. * @param mask defines the mask associated with this state
  73338. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73339. * @param target defines the original target of the state
  73340. * @param currentTarget defines the current target of the state
  73341. */
  73342. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  73343. /**
  73344. * Initialize the current event state
  73345. * @param mask defines the mask associated with this state
  73346. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73347. * @param target defines the original target of the state
  73348. * @param currentTarget defines the current target of the state
  73349. * @returns the current event state
  73350. */
  73351. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73352. /**
  73353. * An Observer can set this property to true to prevent subsequent observers of being notified
  73354. */
  73355. skipNextObservers: boolean;
  73356. /**
  73357. * Get the mask value that were used to trigger the event corresponding to this EventState object
  73358. */
  73359. mask: number;
  73360. /**
  73361. * The object that originally notified the event
  73362. */
  73363. target?: any;
  73364. /**
  73365. * The current object in the bubbling phase
  73366. */
  73367. currentTarget?: any;
  73368. /**
  73369. * This will be populated with the return value of the last function that was executed.
  73370. * If it is the first function in the callback chain it will be the event data.
  73371. */
  73372. lastReturnValue?: any;
  73373. }
  73374. /**
  73375. * Represent an Observer registered to a given Observable object.
  73376. */
  73377. export class Observer<T> {
  73378. /**
  73379. * Defines the callback to call when the observer is notified
  73380. */
  73381. callback: (eventData: T, eventState: EventState) => void;
  73382. /**
  73383. * Defines the mask of the observer (used to filter notifications)
  73384. */
  73385. mask: number;
  73386. /**
  73387. * Defines the current scope used to restore the JS context
  73388. */
  73389. scope: any;
  73390. /** @hidden */
  73391. _willBeUnregistered: boolean;
  73392. /**
  73393. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  73394. */
  73395. unregisterOnNextCall: boolean;
  73396. /**
  73397. * Creates a new observer
  73398. * @param callback defines the callback to call when the observer is notified
  73399. * @param mask defines the mask of the observer (used to filter notifications)
  73400. * @param scope defines the current scope used to restore the JS context
  73401. */
  73402. constructor(
  73403. /**
  73404. * Defines the callback to call when the observer is notified
  73405. */
  73406. callback: (eventData: T, eventState: EventState) => void,
  73407. /**
  73408. * Defines the mask of the observer (used to filter notifications)
  73409. */
  73410. mask: number,
  73411. /**
  73412. * Defines the current scope used to restore the JS context
  73413. */
  73414. scope?: any);
  73415. }
  73416. /**
  73417. * Represent a list of observers registered to multiple Observables object.
  73418. */
  73419. export class MultiObserver<T> {
  73420. private _observers;
  73421. private _observables;
  73422. /**
  73423. * Release associated resources
  73424. */
  73425. dispose(): void;
  73426. /**
  73427. * Raise a callback when one of the observable will notify
  73428. * @param observables defines a list of observables to watch
  73429. * @param callback defines the callback to call on notification
  73430. * @param mask defines the mask used to filter notifications
  73431. * @param scope defines the current scope used to restore the JS context
  73432. * @returns the new MultiObserver
  73433. */
  73434. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73435. }
  73436. /**
  73437. * The Observable class is a simple implementation of the Observable pattern.
  73438. *
  73439. * 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.
  73440. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73441. * 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).
  73442. * 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.
  73443. */
  73444. export class Observable<T> {
  73445. private _observers;
  73446. private _eventState;
  73447. private _onObserverAdded;
  73448. /**
  73449. * Gets the list of observers
  73450. */
  73451. get observers(): Array<Observer<T>>;
  73452. /**
  73453. * Creates a new observable
  73454. * @param onObserverAdded defines a callback to call when a new observer is added
  73455. */
  73456. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73457. /**
  73458. * Create a new Observer with the specified callback
  73459. * @param callback the callback that will be executed for that Observer
  73460. * @param mask the mask used to filter observers
  73461. * @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.
  73462. * @param scope optional scope for the callback to be called from
  73463. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73464. * @returns the new observer created for the callback
  73465. */
  73466. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73467. /**
  73468. * Create a new Observer with the specified callback and unregisters after the next notification
  73469. * @param callback the callback that will be executed for that Observer
  73470. * @returns the new observer created for the callback
  73471. */
  73472. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73473. /**
  73474. * Remove an Observer from the Observable object
  73475. * @param observer the instance of the Observer to remove
  73476. * @returns false if it doesn't belong to this Observable
  73477. */
  73478. remove(observer: Nullable<Observer<T>>): boolean;
  73479. /**
  73480. * Remove a callback from the Observable object
  73481. * @param callback the callback to remove
  73482. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73483. * @returns false if it doesn't belong to this Observable
  73484. */
  73485. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73486. private _deferUnregister;
  73487. private _remove;
  73488. /**
  73489. * Moves the observable to the top of the observer list making it get called first when notified
  73490. * @param observer the observer to move
  73491. */
  73492. makeObserverTopPriority(observer: Observer<T>): void;
  73493. /**
  73494. * Moves the observable to the bottom of the observer list making it get called last when notified
  73495. * @param observer the observer to move
  73496. */
  73497. makeObserverBottomPriority(observer: Observer<T>): void;
  73498. /**
  73499. * Notify all Observers by calling their respective callback with the given data
  73500. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73501. * @param eventData defines the data to send to all observers
  73502. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73503. * @param target defines the original target of the state
  73504. * @param currentTarget defines the current target of the state
  73505. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73506. */
  73507. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73508. /**
  73509. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73510. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73511. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73512. * and it is crucial that all callbacks will be executed.
  73513. * The order of the callbacks is kept, callbacks are not executed parallel.
  73514. *
  73515. * @param eventData The data to be sent to each callback
  73516. * @param mask is used to filter observers defaults to -1
  73517. * @param target defines the callback target (see EventState)
  73518. * @param currentTarget defines he current object in the bubbling phase
  73519. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73520. */
  73521. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73522. /**
  73523. * Notify a specific observer
  73524. * @param observer defines the observer to notify
  73525. * @param eventData defines the data to be sent to each callback
  73526. * @param mask is used to filter observers defaults to -1
  73527. */
  73528. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73529. /**
  73530. * Gets a boolean indicating if the observable has at least one observer
  73531. * @returns true is the Observable has at least one Observer registered
  73532. */
  73533. hasObservers(): boolean;
  73534. /**
  73535. * Clear the list of observers
  73536. */
  73537. clear(): void;
  73538. /**
  73539. * Clone the current observable
  73540. * @returns a new observable
  73541. */
  73542. clone(): Observable<T>;
  73543. /**
  73544. * Does this observable handles observer registered with a given mask
  73545. * @param mask defines the mask to be tested
  73546. * @return whether or not one observer registered with the given mask is handeled
  73547. **/
  73548. hasSpecificMask(mask?: number): boolean;
  73549. }
  73550. }
  73551. declare module BABYLON {
  73552. /**
  73553. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73554. * Babylon.js
  73555. */
  73556. export class DomManagement {
  73557. /**
  73558. * Checks if the window object exists
  73559. * @returns true if the window object exists
  73560. */
  73561. static IsWindowObjectExist(): boolean;
  73562. /**
  73563. * Checks if the navigator object exists
  73564. * @returns true if the navigator object exists
  73565. */
  73566. static IsNavigatorAvailable(): boolean;
  73567. /**
  73568. * Extracts text content from a DOM element hierarchy
  73569. * @param element defines the root element
  73570. * @returns a string
  73571. */
  73572. static GetDOMTextContent(element: HTMLElement): string;
  73573. }
  73574. }
  73575. declare module BABYLON {
  73576. /**
  73577. * Logger used througouht the application to allow configuration of
  73578. * the log level required for the messages.
  73579. */
  73580. export class Logger {
  73581. /**
  73582. * No log
  73583. */
  73584. static readonly NoneLogLevel: number;
  73585. /**
  73586. * Only message logs
  73587. */
  73588. static readonly MessageLogLevel: number;
  73589. /**
  73590. * Only warning logs
  73591. */
  73592. static readonly WarningLogLevel: number;
  73593. /**
  73594. * Only error logs
  73595. */
  73596. static readonly ErrorLogLevel: number;
  73597. /**
  73598. * All logs
  73599. */
  73600. static readonly AllLogLevel: number;
  73601. private static _LogCache;
  73602. /**
  73603. * Gets a value indicating the number of loading errors
  73604. * @ignorenaming
  73605. */
  73606. static errorsCount: number;
  73607. /**
  73608. * Callback called when a new log is added
  73609. */
  73610. static OnNewCacheEntry: (entry: string) => void;
  73611. private static _AddLogEntry;
  73612. private static _FormatMessage;
  73613. private static _LogDisabled;
  73614. private static _LogEnabled;
  73615. private static _WarnDisabled;
  73616. private static _WarnEnabled;
  73617. private static _ErrorDisabled;
  73618. private static _ErrorEnabled;
  73619. /**
  73620. * Log a message to the console
  73621. */
  73622. static Log: (message: string) => void;
  73623. /**
  73624. * Write a warning message to the console
  73625. */
  73626. static Warn: (message: string) => void;
  73627. /**
  73628. * Write an error message to the console
  73629. */
  73630. static Error: (message: string) => void;
  73631. /**
  73632. * Gets current log cache (list of logs)
  73633. */
  73634. static get LogCache(): string;
  73635. /**
  73636. * Clears the log cache
  73637. */
  73638. static ClearLogCache(): void;
  73639. /**
  73640. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73641. */
  73642. static set LogLevels(level: number);
  73643. }
  73644. }
  73645. declare module BABYLON {
  73646. /** @hidden */
  73647. export class _TypeStore {
  73648. /** @hidden */
  73649. static RegisteredTypes: {
  73650. [key: string]: Object;
  73651. };
  73652. /** @hidden */
  73653. static GetClass(fqdn: string): any;
  73654. }
  73655. }
  73656. declare module BABYLON {
  73657. /**
  73658. * Helper to manipulate strings
  73659. */
  73660. export class StringTools {
  73661. /**
  73662. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73663. * @param str Source string
  73664. * @param suffix Suffix to search for in the source string
  73665. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73666. */
  73667. static EndsWith(str: string, suffix: string): boolean;
  73668. /**
  73669. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73670. * @param str Source string
  73671. * @param suffix Suffix to search for in the source string
  73672. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73673. */
  73674. static StartsWith(str: string, suffix: string): boolean;
  73675. /**
  73676. * Decodes a buffer into a string
  73677. * @param buffer The buffer to decode
  73678. * @returns The decoded string
  73679. */
  73680. static Decode(buffer: Uint8Array | Uint16Array): string;
  73681. /**
  73682. * Encode a buffer to a base64 string
  73683. * @param buffer defines the buffer to encode
  73684. * @returns the encoded string
  73685. */
  73686. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73687. }
  73688. }
  73689. declare module BABYLON {
  73690. /**
  73691. * Class containing a set of static utilities functions for deep copy.
  73692. */
  73693. export class DeepCopier {
  73694. /**
  73695. * Tries to copy an object by duplicating every property
  73696. * @param source defines the source object
  73697. * @param destination defines the target object
  73698. * @param doNotCopyList defines a list of properties to avoid
  73699. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  73700. */
  73701. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  73702. }
  73703. }
  73704. declare module BABYLON {
  73705. /**
  73706. * Class containing a set of static utilities functions for precision date
  73707. */
  73708. export class PrecisionDate {
  73709. /**
  73710. * Gets either window.performance.now() if supported or Date.now() else
  73711. */
  73712. static get Now(): number;
  73713. }
  73714. }
  73715. declare module BABYLON {
  73716. /** @hidden */
  73717. export class _DevTools {
  73718. static WarnImport(name: string): string;
  73719. }
  73720. }
  73721. declare module BABYLON {
  73722. /**
  73723. * Interface used to define the mechanism to get data from the network
  73724. */
  73725. export interface IWebRequest {
  73726. /**
  73727. * Returns client's response url
  73728. */
  73729. responseURL: string;
  73730. /**
  73731. * Returns client's status
  73732. */
  73733. status: number;
  73734. /**
  73735. * Returns client's status as a text
  73736. */
  73737. statusText: string;
  73738. }
  73739. }
  73740. declare module BABYLON {
  73741. /**
  73742. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  73743. */
  73744. export class WebRequest implements IWebRequest {
  73745. private _xhr;
  73746. /**
  73747. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  73748. * i.e. when loading files, where the server/service expects an Authorization header
  73749. */
  73750. static CustomRequestHeaders: {
  73751. [key: string]: string;
  73752. };
  73753. /**
  73754. * Add callback functions in this array to update all the requests before they get sent to the network
  73755. */
  73756. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  73757. private _injectCustomRequestHeaders;
  73758. /**
  73759. * Gets or sets a function to be called when loading progress changes
  73760. */
  73761. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  73762. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  73763. /**
  73764. * Returns client's state
  73765. */
  73766. get readyState(): number;
  73767. /**
  73768. * Returns client's status
  73769. */
  73770. get status(): number;
  73771. /**
  73772. * Returns client's status as a text
  73773. */
  73774. get statusText(): string;
  73775. /**
  73776. * Returns client's response
  73777. */
  73778. get response(): any;
  73779. /**
  73780. * Returns client's response url
  73781. */
  73782. get responseURL(): string;
  73783. /**
  73784. * Returns client's response as text
  73785. */
  73786. get responseText(): string;
  73787. /**
  73788. * Gets or sets the expected response type
  73789. */
  73790. get responseType(): XMLHttpRequestResponseType;
  73791. set responseType(value: XMLHttpRequestResponseType);
  73792. /** @hidden */
  73793. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  73794. /** @hidden */
  73795. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  73796. /**
  73797. * Cancels any network activity
  73798. */
  73799. abort(): void;
  73800. /**
  73801. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  73802. * @param body defines an optional request body
  73803. */
  73804. send(body?: Document | BodyInit | null): void;
  73805. /**
  73806. * Sets the request method, request URL
  73807. * @param method defines the method to use (GET, POST, etc..)
  73808. * @param url defines the url to connect with
  73809. */
  73810. open(method: string, url: string): void;
  73811. /**
  73812. * Sets the value of a request header.
  73813. * @param name The name of the header whose value is to be set
  73814. * @param value The value to set as the body of the header
  73815. */
  73816. setRequestHeader(name: string, value: string): void;
  73817. /**
  73818. * Get the string containing the text of a particular header's value.
  73819. * @param name The name of the header
  73820. * @returns The string containing the text of the given header name
  73821. */
  73822. getResponseHeader(name: string): Nullable<string>;
  73823. }
  73824. }
  73825. declare module BABYLON {
  73826. /**
  73827. * File request interface
  73828. */
  73829. export interface IFileRequest {
  73830. /**
  73831. * Raised when the request is complete (success or error).
  73832. */
  73833. onCompleteObservable: Observable<IFileRequest>;
  73834. /**
  73835. * Aborts the request for a file.
  73836. */
  73837. abort: () => void;
  73838. }
  73839. }
  73840. declare module BABYLON {
  73841. /**
  73842. * Define options used to create a render target texture
  73843. */
  73844. export class RenderTargetCreationOptions {
  73845. /**
  73846. * Specifies is mipmaps must be generated
  73847. */
  73848. generateMipMaps?: boolean;
  73849. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  73850. generateDepthBuffer?: boolean;
  73851. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  73852. generateStencilBuffer?: boolean;
  73853. /** Defines texture type (int by default) */
  73854. type?: number;
  73855. /** Defines sampling mode (trilinear by default) */
  73856. samplingMode?: number;
  73857. /** Defines format (RGBA by default) */
  73858. format?: number;
  73859. }
  73860. }
  73861. declare module BABYLON {
  73862. /** Defines the cross module used constants to avoid circular dependncies */
  73863. export class Constants {
  73864. /** Defines that alpha blending is disabled */
  73865. static readonly ALPHA_DISABLE: number;
  73866. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  73867. static readonly ALPHA_ADD: number;
  73868. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  73869. static readonly ALPHA_COMBINE: number;
  73870. /** Defines that alpha blending is DEST - SRC * DEST */
  73871. static readonly ALPHA_SUBTRACT: number;
  73872. /** Defines that alpha blending is SRC * DEST */
  73873. static readonly ALPHA_MULTIPLY: number;
  73874. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  73875. static readonly ALPHA_MAXIMIZED: number;
  73876. /** Defines that alpha blending is SRC + DEST */
  73877. static readonly ALPHA_ONEONE: number;
  73878. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  73879. static readonly ALPHA_PREMULTIPLIED: number;
  73880. /**
  73881. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  73882. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  73883. */
  73884. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  73885. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  73886. static readonly ALPHA_INTERPOLATE: number;
  73887. /**
  73888. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  73889. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  73890. */
  73891. static readonly ALPHA_SCREENMODE: number;
  73892. /**
  73893. * Defines that alpha blending is SRC + DST
  73894. * Alpha will be set to SRC ALPHA + DST ALPHA
  73895. */
  73896. static readonly ALPHA_ONEONE_ONEONE: number;
  73897. /**
  73898. * Defines that alpha blending is SRC * DST ALPHA + DST
  73899. * Alpha will be set to 0
  73900. */
  73901. static readonly ALPHA_ALPHATOCOLOR: number;
  73902. /**
  73903. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73904. */
  73905. static readonly ALPHA_REVERSEONEMINUS: number;
  73906. /**
  73907. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  73908. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  73909. */
  73910. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  73911. /**
  73912. * Defines that alpha blending is SRC + DST
  73913. * Alpha will be set to SRC ALPHA
  73914. */
  73915. static readonly ALPHA_ONEONE_ONEZERO: number;
  73916. /**
  73917. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73918. * Alpha will be set to DST ALPHA
  73919. */
  73920. static readonly ALPHA_EXCLUSION: number;
  73921. /** Defines that alpha blending equation a SUM */
  73922. static readonly ALPHA_EQUATION_ADD: number;
  73923. /** Defines that alpha blending equation a SUBSTRACTION */
  73924. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  73925. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  73926. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  73927. /** Defines that alpha blending equation a MAX operation */
  73928. static readonly ALPHA_EQUATION_MAX: number;
  73929. /** Defines that alpha blending equation a MIN operation */
  73930. static readonly ALPHA_EQUATION_MIN: number;
  73931. /**
  73932. * Defines that alpha blending equation a DARKEN operation:
  73933. * It takes the min of the src and sums the alpha channels.
  73934. */
  73935. static readonly ALPHA_EQUATION_DARKEN: number;
  73936. /** Defines that the ressource is not delayed*/
  73937. static readonly DELAYLOADSTATE_NONE: number;
  73938. /** Defines that the ressource was successfully delay loaded */
  73939. static readonly DELAYLOADSTATE_LOADED: number;
  73940. /** Defines that the ressource is currently delay loading */
  73941. static readonly DELAYLOADSTATE_LOADING: number;
  73942. /** Defines that the ressource is delayed and has not started loading */
  73943. static readonly DELAYLOADSTATE_NOTLOADED: number;
  73944. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  73945. static readonly NEVER: number;
  73946. /** 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 */
  73947. static readonly ALWAYS: number;
  73948. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  73949. static readonly LESS: number;
  73950. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  73951. static readonly EQUAL: number;
  73952. /** 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 */
  73953. static readonly LEQUAL: number;
  73954. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  73955. static readonly GREATER: number;
  73956. /** 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 */
  73957. static readonly GEQUAL: number;
  73958. /** 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 */
  73959. static readonly NOTEQUAL: number;
  73960. /** Passed to stencilOperation to specify that stencil value must be kept */
  73961. static readonly KEEP: number;
  73962. /** Passed to stencilOperation to specify that stencil value must be replaced */
  73963. static readonly REPLACE: number;
  73964. /** Passed to stencilOperation to specify that stencil value must be incremented */
  73965. static readonly INCR: number;
  73966. /** Passed to stencilOperation to specify that stencil value must be decremented */
  73967. static readonly DECR: number;
  73968. /** Passed to stencilOperation to specify that stencil value must be inverted */
  73969. static readonly INVERT: number;
  73970. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  73971. static readonly INCR_WRAP: number;
  73972. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  73973. static readonly DECR_WRAP: number;
  73974. /** Texture is not repeating outside of 0..1 UVs */
  73975. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  73976. /** Texture is repeating outside of 0..1 UVs */
  73977. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  73978. /** Texture is repeating and mirrored */
  73979. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  73980. /** ALPHA */
  73981. static readonly TEXTUREFORMAT_ALPHA: number;
  73982. /** LUMINANCE */
  73983. static readonly TEXTUREFORMAT_LUMINANCE: number;
  73984. /** LUMINANCE_ALPHA */
  73985. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  73986. /** RGB */
  73987. static readonly TEXTUREFORMAT_RGB: number;
  73988. /** RGBA */
  73989. static readonly TEXTUREFORMAT_RGBA: number;
  73990. /** RED */
  73991. static readonly TEXTUREFORMAT_RED: number;
  73992. /** RED (2nd reference) */
  73993. static readonly TEXTUREFORMAT_R: number;
  73994. /** RG */
  73995. static readonly TEXTUREFORMAT_RG: number;
  73996. /** RED_INTEGER */
  73997. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  73998. /** RED_INTEGER (2nd reference) */
  73999. static readonly TEXTUREFORMAT_R_INTEGER: number;
  74000. /** RG_INTEGER */
  74001. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  74002. /** RGB_INTEGER */
  74003. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  74004. /** RGBA_INTEGER */
  74005. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  74006. /** UNSIGNED_BYTE */
  74007. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  74008. /** UNSIGNED_BYTE (2nd reference) */
  74009. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  74010. /** FLOAT */
  74011. static readonly TEXTURETYPE_FLOAT: number;
  74012. /** HALF_FLOAT */
  74013. static readonly TEXTURETYPE_HALF_FLOAT: number;
  74014. /** BYTE */
  74015. static readonly TEXTURETYPE_BYTE: number;
  74016. /** SHORT */
  74017. static readonly TEXTURETYPE_SHORT: number;
  74018. /** UNSIGNED_SHORT */
  74019. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  74020. /** INT */
  74021. static readonly TEXTURETYPE_INT: number;
  74022. /** UNSIGNED_INT */
  74023. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  74024. /** UNSIGNED_SHORT_4_4_4_4 */
  74025. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  74026. /** UNSIGNED_SHORT_5_5_5_1 */
  74027. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  74028. /** UNSIGNED_SHORT_5_6_5 */
  74029. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  74030. /** UNSIGNED_INT_2_10_10_10_REV */
  74031. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  74032. /** UNSIGNED_INT_24_8 */
  74033. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  74034. /** UNSIGNED_INT_10F_11F_11F_REV */
  74035. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  74036. /** UNSIGNED_INT_5_9_9_9_REV */
  74037. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  74038. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  74039. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74040. /** nearest is mag = nearest and min = nearest and no mip */
  74041. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  74042. /** mag = nearest and min = nearest and mip = none */
  74043. static readonly TEXTURE_NEAREST_NEAREST: number;
  74044. /** Bilinear is mag = linear and min = linear and no mip */
  74045. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  74046. /** mag = linear and min = linear and mip = none */
  74047. static readonly TEXTURE_LINEAR_LINEAR: number;
  74048. /** Trilinear is mag = linear and min = linear and mip = linear */
  74049. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  74050. /** Trilinear is mag = linear and min = linear and mip = linear */
  74051. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  74052. /** mag = nearest and min = nearest and mip = nearest */
  74053. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  74054. /** mag = nearest and min = linear and mip = nearest */
  74055. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  74056. /** mag = nearest and min = linear and mip = linear */
  74057. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  74058. /** mag = nearest and min = linear and mip = none */
  74059. static readonly TEXTURE_NEAREST_LINEAR: number;
  74060. /** nearest is mag = nearest and min = nearest and mip = linear */
  74061. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  74062. /** mag = linear and min = nearest and mip = nearest */
  74063. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  74064. /** mag = linear and min = nearest and mip = linear */
  74065. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  74066. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74067. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  74068. /** mag = linear and min = nearest and mip = none */
  74069. static readonly TEXTURE_LINEAR_NEAREST: number;
  74070. /** Explicit coordinates mode */
  74071. static readonly TEXTURE_EXPLICIT_MODE: number;
  74072. /** Spherical coordinates mode */
  74073. static readonly TEXTURE_SPHERICAL_MODE: number;
  74074. /** Planar coordinates mode */
  74075. static readonly TEXTURE_PLANAR_MODE: number;
  74076. /** Cubic coordinates mode */
  74077. static readonly TEXTURE_CUBIC_MODE: number;
  74078. /** Projection coordinates mode */
  74079. static readonly TEXTURE_PROJECTION_MODE: number;
  74080. /** Skybox coordinates mode */
  74081. static readonly TEXTURE_SKYBOX_MODE: number;
  74082. /** Inverse Cubic coordinates mode */
  74083. static readonly TEXTURE_INVCUBIC_MODE: number;
  74084. /** Equirectangular coordinates mode */
  74085. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  74086. /** Equirectangular Fixed coordinates mode */
  74087. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  74088. /** Equirectangular Fixed Mirrored coordinates mode */
  74089. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74090. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  74091. static readonly SCALEMODE_FLOOR: number;
  74092. /** Defines that texture rescaling will look for the nearest power of 2 size */
  74093. static readonly SCALEMODE_NEAREST: number;
  74094. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  74095. static readonly SCALEMODE_CEILING: number;
  74096. /**
  74097. * The dirty texture flag value
  74098. */
  74099. static readonly MATERIAL_TextureDirtyFlag: number;
  74100. /**
  74101. * The dirty light flag value
  74102. */
  74103. static readonly MATERIAL_LightDirtyFlag: number;
  74104. /**
  74105. * The dirty fresnel flag value
  74106. */
  74107. static readonly MATERIAL_FresnelDirtyFlag: number;
  74108. /**
  74109. * The dirty attribute flag value
  74110. */
  74111. static readonly MATERIAL_AttributesDirtyFlag: number;
  74112. /**
  74113. * The dirty misc flag value
  74114. */
  74115. static readonly MATERIAL_MiscDirtyFlag: number;
  74116. /**
  74117. * The all dirty flag value
  74118. */
  74119. static readonly MATERIAL_AllDirtyFlag: number;
  74120. /**
  74121. * Returns the triangle fill mode
  74122. */
  74123. static readonly MATERIAL_TriangleFillMode: number;
  74124. /**
  74125. * Returns the wireframe mode
  74126. */
  74127. static readonly MATERIAL_WireFrameFillMode: number;
  74128. /**
  74129. * Returns the point fill mode
  74130. */
  74131. static readonly MATERIAL_PointFillMode: number;
  74132. /**
  74133. * Returns the point list draw mode
  74134. */
  74135. static readonly MATERIAL_PointListDrawMode: number;
  74136. /**
  74137. * Returns the line list draw mode
  74138. */
  74139. static readonly MATERIAL_LineListDrawMode: number;
  74140. /**
  74141. * Returns the line loop draw mode
  74142. */
  74143. static readonly MATERIAL_LineLoopDrawMode: number;
  74144. /**
  74145. * Returns the line strip draw mode
  74146. */
  74147. static readonly MATERIAL_LineStripDrawMode: number;
  74148. /**
  74149. * Returns the triangle strip draw mode
  74150. */
  74151. static readonly MATERIAL_TriangleStripDrawMode: number;
  74152. /**
  74153. * Returns the triangle fan draw mode
  74154. */
  74155. static readonly MATERIAL_TriangleFanDrawMode: number;
  74156. /**
  74157. * Stores the clock-wise side orientation
  74158. */
  74159. static readonly MATERIAL_ClockWiseSideOrientation: number;
  74160. /**
  74161. * Stores the counter clock-wise side orientation
  74162. */
  74163. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  74164. /**
  74165. * Nothing
  74166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74167. */
  74168. static readonly ACTION_NothingTrigger: number;
  74169. /**
  74170. * On pick
  74171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74172. */
  74173. static readonly ACTION_OnPickTrigger: number;
  74174. /**
  74175. * On left pick
  74176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74177. */
  74178. static readonly ACTION_OnLeftPickTrigger: number;
  74179. /**
  74180. * On right pick
  74181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74182. */
  74183. static readonly ACTION_OnRightPickTrigger: number;
  74184. /**
  74185. * On center pick
  74186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74187. */
  74188. static readonly ACTION_OnCenterPickTrigger: number;
  74189. /**
  74190. * On pick down
  74191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74192. */
  74193. static readonly ACTION_OnPickDownTrigger: number;
  74194. /**
  74195. * On double pick
  74196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74197. */
  74198. static readonly ACTION_OnDoublePickTrigger: number;
  74199. /**
  74200. * On pick up
  74201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74202. */
  74203. static readonly ACTION_OnPickUpTrigger: number;
  74204. /**
  74205. * On pick out.
  74206. * This trigger will only be raised if you also declared a OnPickDown
  74207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74208. */
  74209. static readonly ACTION_OnPickOutTrigger: number;
  74210. /**
  74211. * On long press
  74212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74213. */
  74214. static readonly ACTION_OnLongPressTrigger: number;
  74215. /**
  74216. * On pointer over
  74217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74218. */
  74219. static readonly ACTION_OnPointerOverTrigger: number;
  74220. /**
  74221. * On pointer out
  74222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74223. */
  74224. static readonly ACTION_OnPointerOutTrigger: number;
  74225. /**
  74226. * On every frame
  74227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74228. */
  74229. static readonly ACTION_OnEveryFrameTrigger: number;
  74230. /**
  74231. * On intersection enter
  74232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74233. */
  74234. static readonly ACTION_OnIntersectionEnterTrigger: number;
  74235. /**
  74236. * On intersection exit
  74237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74238. */
  74239. static readonly ACTION_OnIntersectionExitTrigger: number;
  74240. /**
  74241. * On key down
  74242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74243. */
  74244. static readonly ACTION_OnKeyDownTrigger: number;
  74245. /**
  74246. * On key up
  74247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74248. */
  74249. static readonly ACTION_OnKeyUpTrigger: number;
  74250. /**
  74251. * Billboard mode will only apply to Y axis
  74252. */
  74253. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  74254. /**
  74255. * Billboard mode will apply to all axes
  74256. */
  74257. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  74258. /**
  74259. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74260. */
  74261. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  74262. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  74263. * Test order :
  74264. * Is the bounding sphere outside the frustum ?
  74265. * If not, are the bounding box vertices outside the frustum ?
  74266. * It not, then the cullable object is in the frustum.
  74267. */
  74268. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  74269. /** Culling strategy : Bounding Sphere Only.
  74270. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  74271. * It's also less accurate than the standard because some not visible objects can still be selected.
  74272. * Test : is the bounding sphere outside the frustum ?
  74273. * If not, then the cullable object is in the frustum.
  74274. */
  74275. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  74276. /** Culling strategy : Optimistic Inclusion.
  74277. * This in an inclusion test first, then the standard exclusion test.
  74278. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  74279. * 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.
  74280. * Anyway, it's as accurate as the standard strategy.
  74281. * Test :
  74282. * Is the cullable object bounding sphere center in the frustum ?
  74283. * If not, apply the default culling strategy.
  74284. */
  74285. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  74286. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  74287. * This in an inclusion test first, then the bounding sphere only exclusion test.
  74288. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  74289. * 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.
  74290. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  74291. * Test :
  74292. * Is the cullable object bounding sphere center in the frustum ?
  74293. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  74294. */
  74295. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  74296. /**
  74297. * No logging while loading
  74298. */
  74299. static readonly SCENELOADER_NO_LOGGING: number;
  74300. /**
  74301. * Minimal logging while loading
  74302. */
  74303. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  74304. /**
  74305. * Summary logging while loading
  74306. */
  74307. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  74308. /**
  74309. * Detailled logging while loading
  74310. */
  74311. static readonly SCENELOADER_DETAILED_LOGGING: number;
  74312. }
  74313. }
  74314. declare module BABYLON {
  74315. /**
  74316. * This represents the required contract to create a new type of texture loader.
  74317. */
  74318. export interface IInternalTextureLoader {
  74319. /**
  74320. * Defines wether the loader supports cascade loading the different faces.
  74321. */
  74322. supportCascades: boolean;
  74323. /**
  74324. * This returns if the loader support the current file information.
  74325. * @param extension defines the file extension of the file being loaded
  74326. * @returns true if the loader can load the specified file
  74327. */
  74328. canLoad(extension: string): boolean;
  74329. /**
  74330. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  74331. * @param data contains the texture data
  74332. * @param texture defines the BabylonJS internal texture
  74333. * @param createPolynomials will be true if polynomials have been requested
  74334. * @param onLoad defines the callback to trigger once the texture is ready
  74335. * @param onError defines the callback to trigger in case of error
  74336. */
  74337. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  74338. /**
  74339. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  74340. * @param data contains the texture data
  74341. * @param texture defines the BabylonJS internal texture
  74342. * @param callback defines the method to call once ready to upload
  74343. */
  74344. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  74345. }
  74346. }
  74347. declare module BABYLON {
  74348. /**
  74349. * Class used to store and describe the pipeline context associated with an effect
  74350. */
  74351. export interface IPipelineContext {
  74352. /**
  74353. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  74354. */
  74355. isAsync: boolean;
  74356. /**
  74357. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  74358. */
  74359. isReady: boolean;
  74360. /** @hidden */
  74361. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  74362. }
  74363. }
  74364. declare module BABYLON {
  74365. /**
  74366. * Class used to store gfx data (like WebGLBuffer)
  74367. */
  74368. export class DataBuffer {
  74369. /**
  74370. * Gets or sets the number of objects referencing this buffer
  74371. */
  74372. references: number;
  74373. /** Gets or sets the size of the underlying buffer */
  74374. capacity: number;
  74375. /**
  74376. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  74377. */
  74378. is32Bits: boolean;
  74379. /**
  74380. * Gets the underlying buffer
  74381. */
  74382. get underlyingResource(): any;
  74383. }
  74384. }
  74385. declare module BABYLON {
  74386. /** @hidden */
  74387. export interface IShaderProcessor {
  74388. attributeProcessor?: (attribute: string) => string;
  74389. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  74390. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  74391. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  74392. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  74393. lineProcessor?: (line: string, isFragment: boolean) => string;
  74394. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74395. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74396. }
  74397. }
  74398. declare module BABYLON {
  74399. /** @hidden */
  74400. export interface ProcessingOptions {
  74401. defines: string[];
  74402. indexParameters: any;
  74403. isFragment: boolean;
  74404. shouldUseHighPrecisionShader: boolean;
  74405. supportsUniformBuffers: boolean;
  74406. shadersRepository: string;
  74407. includesShadersStore: {
  74408. [key: string]: string;
  74409. };
  74410. processor?: IShaderProcessor;
  74411. version: string;
  74412. platformName: string;
  74413. lookForClosingBracketForUniformBuffer?: boolean;
  74414. }
  74415. }
  74416. declare module BABYLON {
  74417. /** @hidden */
  74418. export class ShaderCodeNode {
  74419. line: string;
  74420. children: ShaderCodeNode[];
  74421. additionalDefineKey?: string;
  74422. additionalDefineValue?: string;
  74423. isValid(preprocessors: {
  74424. [key: string]: string;
  74425. }): boolean;
  74426. process(preprocessors: {
  74427. [key: string]: string;
  74428. }, options: ProcessingOptions): string;
  74429. }
  74430. }
  74431. declare module BABYLON {
  74432. /** @hidden */
  74433. export class ShaderCodeCursor {
  74434. private _lines;
  74435. lineIndex: number;
  74436. get currentLine(): string;
  74437. get canRead(): boolean;
  74438. set lines(value: string[]);
  74439. }
  74440. }
  74441. declare module BABYLON {
  74442. /** @hidden */
  74443. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74444. process(preprocessors: {
  74445. [key: string]: string;
  74446. }, options: ProcessingOptions): string;
  74447. }
  74448. }
  74449. declare module BABYLON {
  74450. /** @hidden */
  74451. export class ShaderDefineExpression {
  74452. isTrue(preprocessors: {
  74453. [key: string]: string;
  74454. }): boolean;
  74455. }
  74456. }
  74457. declare module BABYLON {
  74458. /** @hidden */
  74459. export class ShaderCodeTestNode extends ShaderCodeNode {
  74460. testExpression: ShaderDefineExpression;
  74461. isValid(preprocessors: {
  74462. [key: string]: string;
  74463. }): boolean;
  74464. }
  74465. }
  74466. declare module BABYLON {
  74467. /** @hidden */
  74468. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74469. define: string;
  74470. not: boolean;
  74471. constructor(define: string, not?: boolean);
  74472. isTrue(preprocessors: {
  74473. [key: string]: string;
  74474. }): boolean;
  74475. }
  74476. }
  74477. declare module BABYLON {
  74478. /** @hidden */
  74479. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74480. leftOperand: ShaderDefineExpression;
  74481. rightOperand: ShaderDefineExpression;
  74482. isTrue(preprocessors: {
  74483. [key: string]: string;
  74484. }): boolean;
  74485. }
  74486. }
  74487. declare module BABYLON {
  74488. /** @hidden */
  74489. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74490. leftOperand: ShaderDefineExpression;
  74491. rightOperand: ShaderDefineExpression;
  74492. isTrue(preprocessors: {
  74493. [key: string]: string;
  74494. }): boolean;
  74495. }
  74496. }
  74497. declare module BABYLON {
  74498. /** @hidden */
  74499. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74500. define: string;
  74501. operand: string;
  74502. testValue: string;
  74503. constructor(define: string, operand: string, testValue: string);
  74504. isTrue(preprocessors: {
  74505. [key: string]: string;
  74506. }): boolean;
  74507. }
  74508. }
  74509. declare module BABYLON {
  74510. /**
  74511. * Class used to enable access to offline support
  74512. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74513. */
  74514. export interface IOfflineProvider {
  74515. /**
  74516. * Gets a boolean indicating if scene must be saved in the database
  74517. */
  74518. enableSceneOffline: boolean;
  74519. /**
  74520. * Gets a boolean indicating if textures must be saved in the database
  74521. */
  74522. enableTexturesOffline: boolean;
  74523. /**
  74524. * Open the offline support and make it available
  74525. * @param successCallback defines the callback to call on success
  74526. * @param errorCallback defines the callback to call on error
  74527. */
  74528. open(successCallback: () => void, errorCallback: () => void): void;
  74529. /**
  74530. * Loads an image from the offline support
  74531. * @param url defines the url to load from
  74532. * @param image defines the target DOM image
  74533. */
  74534. loadImage(url: string, image: HTMLImageElement): void;
  74535. /**
  74536. * Loads a file from offline support
  74537. * @param url defines the URL to load from
  74538. * @param sceneLoaded defines a callback to call on success
  74539. * @param progressCallBack defines a callback to call when progress changed
  74540. * @param errorCallback defines a callback to call on error
  74541. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74542. */
  74543. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74544. }
  74545. }
  74546. declare module BABYLON {
  74547. /**
  74548. * Class used to help managing file picking and drag'n'drop
  74549. * File Storage
  74550. */
  74551. export class FilesInputStore {
  74552. /**
  74553. * List of files ready to be loaded
  74554. */
  74555. static FilesToLoad: {
  74556. [key: string]: File;
  74557. };
  74558. }
  74559. }
  74560. declare module BABYLON {
  74561. /**
  74562. * Class used to define a retry strategy when error happens while loading assets
  74563. */
  74564. export class RetryStrategy {
  74565. /**
  74566. * Function used to defines an exponential back off strategy
  74567. * @param maxRetries defines the maximum number of retries (3 by default)
  74568. * @param baseInterval defines the interval between retries
  74569. * @returns the strategy function to use
  74570. */
  74571. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74572. }
  74573. }
  74574. declare module BABYLON {
  74575. /**
  74576. * @ignore
  74577. * Application error to support additional information when loading a file
  74578. */
  74579. export abstract class BaseError extends Error {
  74580. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74581. }
  74582. }
  74583. declare module BABYLON {
  74584. /** @ignore */
  74585. export class LoadFileError extends BaseError {
  74586. request?: WebRequest;
  74587. file?: File;
  74588. /**
  74589. * Creates a new LoadFileError
  74590. * @param message defines the message of the error
  74591. * @param request defines the optional web request
  74592. * @param file defines the optional file
  74593. */
  74594. constructor(message: string, object?: WebRequest | File);
  74595. }
  74596. /** @ignore */
  74597. export class RequestFileError extends BaseError {
  74598. request: WebRequest;
  74599. /**
  74600. * Creates a new LoadFileError
  74601. * @param message defines the message of the error
  74602. * @param request defines the optional web request
  74603. */
  74604. constructor(message: string, request: WebRequest);
  74605. }
  74606. /** @ignore */
  74607. export class ReadFileError extends BaseError {
  74608. file: File;
  74609. /**
  74610. * Creates a new ReadFileError
  74611. * @param message defines the message of the error
  74612. * @param file defines the optional file
  74613. */
  74614. constructor(message: string, file: File);
  74615. }
  74616. /**
  74617. * @hidden
  74618. */
  74619. export class FileTools {
  74620. /**
  74621. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74622. */
  74623. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74624. /**
  74625. * Gets or sets the base URL to use to load assets
  74626. */
  74627. static BaseUrl: string;
  74628. /**
  74629. * Default behaviour for cors in the application.
  74630. * It can be a string if the expected behavior is identical in the entire app.
  74631. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74632. */
  74633. static CorsBehavior: string | ((url: string | string[]) => string);
  74634. /**
  74635. * Gets or sets a function used to pre-process url before using them to load assets
  74636. */
  74637. static PreprocessUrl: (url: string) => string;
  74638. /**
  74639. * Removes unwanted characters from an url
  74640. * @param url defines the url to clean
  74641. * @returns the cleaned url
  74642. */
  74643. private static _CleanUrl;
  74644. /**
  74645. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74646. * @param url define the url we are trying
  74647. * @param element define the dom element where to configure the cors policy
  74648. */
  74649. static SetCorsBehavior(url: string | string[], element: {
  74650. crossOrigin: string | null;
  74651. }): void;
  74652. /**
  74653. * Loads an image as an HTMLImageElement.
  74654. * @param input url string, ArrayBuffer, or Blob to load
  74655. * @param onLoad callback called when the image successfully loads
  74656. * @param onError callback called when the image fails to load
  74657. * @param offlineProvider offline provider for caching
  74658. * @param mimeType optional mime type
  74659. * @returns the HTMLImageElement of the loaded image
  74660. */
  74661. 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>;
  74662. /**
  74663. * Reads a file from a File object
  74664. * @param file defines the file to load
  74665. * @param onSuccess defines the callback to call when data is loaded
  74666. * @param onProgress defines the callback to call during loading process
  74667. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74668. * @param onError defines the callback to call when an error occurs
  74669. * @returns a file request object
  74670. */
  74671. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74672. /**
  74673. * Loads a file from a url
  74674. * @param url url to load
  74675. * @param onSuccess callback called when the file successfully loads
  74676. * @param onProgress callback called while file is loading (if the server supports this mode)
  74677. * @param offlineProvider defines the offline provider for caching
  74678. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74679. * @param onError callback called when the file fails to load
  74680. * @returns a file request object
  74681. */
  74682. 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;
  74683. /**
  74684. * Loads a file
  74685. * @param url url to load
  74686. * @param onSuccess callback called when the file successfully loads
  74687. * @param onProgress callback called while file is loading (if the server supports this mode)
  74688. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74689. * @param onError callback called when the file fails to load
  74690. * @param onOpened callback called when the web request is opened
  74691. * @returns a file request object
  74692. */
  74693. 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;
  74694. /**
  74695. * Checks if the loaded document was accessed via `file:`-Protocol.
  74696. * @returns boolean
  74697. */
  74698. static IsFileURL(): boolean;
  74699. }
  74700. }
  74701. declare module BABYLON {
  74702. /** @hidden */
  74703. export class ShaderProcessor {
  74704. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  74705. private static _ProcessPrecision;
  74706. private static _ExtractOperation;
  74707. private static _BuildSubExpression;
  74708. private static _BuildExpression;
  74709. private static _MoveCursorWithinIf;
  74710. private static _MoveCursor;
  74711. private static _EvaluatePreProcessors;
  74712. private static _PreparePreProcessors;
  74713. private static _ProcessShaderConversion;
  74714. private static _ProcessIncludes;
  74715. /**
  74716. * Loads a file from a url
  74717. * @param url url to load
  74718. * @param onSuccess callback called when the file successfully loads
  74719. * @param onProgress callback called while file is loading (if the server supports this mode)
  74720. * @param offlineProvider defines the offline provider for caching
  74721. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74722. * @param onError callback called when the file fails to load
  74723. * @returns a file request object
  74724. * @hidden
  74725. */
  74726. 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;
  74727. }
  74728. }
  74729. declare module BABYLON {
  74730. /**
  74731. * @hidden
  74732. */
  74733. export interface IColor4Like {
  74734. r: float;
  74735. g: float;
  74736. b: float;
  74737. a: float;
  74738. }
  74739. /**
  74740. * @hidden
  74741. */
  74742. export interface IColor3Like {
  74743. r: float;
  74744. g: float;
  74745. b: float;
  74746. }
  74747. /**
  74748. * @hidden
  74749. */
  74750. export interface IVector4Like {
  74751. x: float;
  74752. y: float;
  74753. z: float;
  74754. w: float;
  74755. }
  74756. /**
  74757. * @hidden
  74758. */
  74759. export interface IVector3Like {
  74760. x: float;
  74761. y: float;
  74762. z: float;
  74763. }
  74764. /**
  74765. * @hidden
  74766. */
  74767. export interface IVector2Like {
  74768. x: float;
  74769. y: float;
  74770. }
  74771. /**
  74772. * @hidden
  74773. */
  74774. export interface IMatrixLike {
  74775. toArray(): DeepImmutable<Float32Array>;
  74776. updateFlag: int;
  74777. }
  74778. /**
  74779. * @hidden
  74780. */
  74781. export interface IViewportLike {
  74782. x: float;
  74783. y: float;
  74784. width: float;
  74785. height: float;
  74786. }
  74787. /**
  74788. * @hidden
  74789. */
  74790. export interface IPlaneLike {
  74791. normal: IVector3Like;
  74792. d: float;
  74793. normalize(): void;
  74794. }
  74795. }
  74796. declare module BABYLON {
  74797. /**
  74798. * Interface used to define common properties for effect fallbacks
  74799. */
  74800. export interface IEffectFallbacks {
  74801. /**
  74802. * Removes the defines that should be removed when falling back.
  74803. * @param currentDefines defines the current define statements for the shader.
  74804. * @param effect defines the current effect we try to compile
  74805. * @returns The resulting defines with defines of the current rank removed.
  74806. */
  74807. reduce(currentDefines: string, effect: Effect): string;
  74808. /**
  74809. * Removes the fallback from the bound mesh.
  74810. */
  74811. unBindMesh(): void;
  74812. /**
  74813. * Checks to see if more fallbacks are still availible.
  74814. */
  74815. hasMoreFallbacks: boolean;
  74816. }
  74817. }
  74818. declare module BABYLON {
  74819. /**
  74820. * Class used to evalaute queries containing `and` and `or` operators
  74821. */
  74822. export class AndOrNotEvaluator {
  74823. /**
  74824. * Evaluate a query
  74825. * @param query defines the query to evaluate
  74826. * @param evaluateCallback defines the callback used to filter result
  74827. * @returns true if the query matches
  74828. */
  74829. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  74830. private static _HandleParenthesisContent;
  74831. private static _SimplifyNegation;
  74832. }
  74833. }
  74834. declare module BABYLON {
  74835. /**
  74836. * Class used to store custom tags
  74837. */
  74838. export class Tags {
  74839. /**
  74840. * Adds support for tags on the given object
  74841. * @param obj defines the object to use
  74842. */
  74843. static EnableFor(obj: any): void;
  74844. /**
  74845. * Removes tags support
  74846. * @param obj defines the object to use
  74847. */
  74848. static DisableFor(obj: any): void;
  74849. /**
  74850. * Gets a boolean indicating if the given object has tags
  74851. * @param obj defines the object to use
  74852. * @returns a boolean
  74853. */
  74854. static HasTags(obj: any): boolean;
  74855. /**
  74856. * Gets the tags available on a given object
  74857. * @param obj defines the object to use
  74858. * @param asString defines if the tags must be returned as a string instead of an array of strings
  74859. * @returns the tags
  74860. */
  74861. static GetTags(obj: any, asString?: boolean): any;
  74862. /**
  74863. * Adds tags to an object
  74864. * @param obj defines the object to use
  74865. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  74866. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  74867. */
  74868. static AddTagsTo(obj: any, tagsString: string): void;
  74869. /**
  74870. * @hidden
  74871. */
  74872. static _AddTagTo(obj: any, tag: string): void;
  74873. /**
  74874. * Removes specific tags from a specific object
  74875. * @param obj defines the object to use
  74876. * @param tagsString defines the tags to remove
  74877. */
  74878. static RemoveTagsFrom(obj: any, tagsString: string): void;
  74879. /**
  74880. * @hidden
  74881. */
  74882. static _RemoveTagFrom(obj: any, tag: string): void;
  74883. /**
  74884. * Defines if tags hosted on an object match a given query
  74885. * @param obj defines the object to use
  74886. * @param tagsQuery defines the tag query
  74887. * @returns a boolean
  74888. */
  74889. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  74890. }
  74891. }
  74892. declare module BABYLON {
  74893. /**
  74894. * Scalar computation library
  74895. */
  74896. export class Scalar {
  74897. /**
  74898. * Two pi constants convenient for computation.
  74899. */
  74900. static TwoPi: number;
  74901. /**
  74902. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74903. * @param a number
  74904. * @param b number
  74905. * @param epsilon (default = 1.401298E-45)
  74906. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74907. */
  74908. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  74909. /**
  74910. * Returns a string : the upper case translation of the number i to hexadecimal.
  74911. * @param i number
  74912. * @returns the upper case translation of the number i to hexadecimal.
  74913. */
  74914. static ToHex(i: number): string;
  74915. /**
  74916. * Returns -1 if value is negative and +1 is value is positive.
  74917. * @param value the value
  74918. * @returns the value itself if it's equal to zero.
  74919. */
  74920. static Sign(value: number): number;
  74921. /**
  74922. * Returns the value itself if it's between min and max.
  74923. * Returns min if the value is lower than min.
  74924. * Returns max if the value is greater than max.
  74925. * @param value the value to clmap
  74926. * @param min the min value to clamp to (default: 0)
  74927. * @param max the max value to clamp to (default: 1)
  74928. * @returns the clamped value
  74929. */
  74930. static Clamp(value: number, min?: number, max?: number): number;
  74931. /**
  74932. * the log2 of value.
  74933. * @param value the value to compute log2 of
  74934. * @returns the log2 of value.
  74935. */
  74936. static Log2(value: number): number;
  74937. /**
  74938. * Loops the value, so that it is never larger than length and never smaller than 0.
  74939. *
  74940. * This is similar to the modulo operator but it works with floating point numbers.
  74941. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  74942. * With t = 5 and length = 2.5, the result would be 0.0.
  74943. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  74944. * @param value the value
  74945. * @param length the length
  74946. * @returns the looped value
  74947. */
  74948. static Repeat(value: number, length: number): number;
  74949. /**
  74950. * Normalize the value between 0.0 and 1.0 using min and max values
  74951. * @param value value to normalize
  74952. * @param min max to normalize between
  74953. * @param max min to normalize between
  74954. * @returns the normalized value
  74955. */
  74956. static Normalize(value: number, min: number, max: number): number;
  74957. /**
  74958. * Denormalize the value from 0.0 and 1.0 using min and max values
  74959. * @param normalized value to denormalize
  74960. * @param min max to denormalize between
  74961. * @param max min to denormalize between
  74962. * @returns the denormalized value
  74963. */
  74964. static Denormalize(normalized: number, min: number, max: number): number;
  74965. /**
  74966. * Calculates the shortest difference between two given angles given in degrees.
  74967. * @param current current angle in degrees
  74968. * @param target target angle in degrees
  74969. * @returns the delta
  74970. */
  74971. static DeltaAngle(current: number, target: number): number;
  74972. /**
  74973. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  74974. * @param tx value
  74975. * @param length length
  74976. * @returns The returned value will move back and forth between 0 and length
  74977. */
  74978. static PingPong(tx: number, length: number): number;
  74979. /**
  74980. * Interpolates between min and max with smoothing at the limits.
  74981. *
  74982. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  74983. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  74984. * @param from from
  74985. * @param to to
  74986. * @param tx value
  74987. * @returns the smooth stepped value
  74988. */
  74989. static SmoothStep(from: number, to: number, tx: number): number;
  74990. /**
  74991. * Moves a value current towards target.
  74992. *
  74993. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  74994. * Negative values of maxDelta pushes the value away from target.
  74995. * @param current current value
  74996. * @param target target value
  74997. * @param maxDelta max distance to move
  74998. * @returns resulting value
  74999. */
  75000. static MoveTowards(current: number, target: number, maxDelta: number): number;
  75001. /**
  75002. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75003. *
  75004. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  75005. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  75006. * @param current current value
  75007. * @param target target value
  75008. * @param maxDelta max distance to move
  75009. * @returns resulting angle
  75010. */
  75011. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  75012. /**
  75013. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  75014. * @param start start value
  75015. * @param end target value
  75016. * @param amount amount to lerp between
  75017. * @returns the lerped value
  75018. */
  75019. static Lerp(start: number, end: number, amount: number): number;
  75020. /**
  75021. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75022. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  75023. * @param start start value
  75024. * @param end target value
  75025. * @param amount amount to lerp between
  75026. * @returns the lerped value
  75027. */
  75028. static LerpAngle(start: number, end: number, amount: number): number;
  75029. /**
  75030. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  75031. * @param a start value
  75032. * @param b target value
  75033. * @param value value between a and b
  75034. * @returns the inverseLerp value
  75035. */
  75036. static InverseLerp(a: number, b: number, value: number): number;
  75037. /**
  75038. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  75039. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  75040. * @param value1 spline value
  75041. * @param tangent1 spline value
  75042. * @param value2 spline value
  75043. * @param tangent2 spline value
  75044. * @param amount input value
  75045. * @returns hermite result
  75046. */
  75047. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  75048. /**
  75049. * Returns a random float number between and min and max values
  75050. * @param min min value of random
  75051. * @param max max value of random
  75052. * @returns random value
  75053. */
  75054. static RandomRange(min: number, max: number): number;
  75055. /**
  75056. * This function returns percentage of a number in a given range.
  75057. *
  75058. * RangeToPercent(40,20,60) will return 0.5 (50%)
  75059. * RangeToPercent(34,0,100) will return 0.34 (34%)
  75060. * @param number to convert to percentage
  75061. * @param min min range
  75062. * @param max max range
  75063. * @returns the percentage
  75064. */
  75065. static RangeToPercent(number: number, min: number, max: number): number;
  75066. /**
  75067. * This function returns number that corresponds to the percentage in a given range.
  75068. *
  75069. * PercentToRange(0.34,0,100) will return 34.
  75070. * @param percent to convert to number
  75071. * @param min min range
  75072. * @param max max range
  75073. * @returns the number
  75074. */
  75075. static PercentToRange(percent: number, min: number, max: number): number;
  75076. /**
  75077. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  75078. * @param angle The angle to normalize in radian.
  75079. * @return The converted angle.
  75080. */
  75081. static NormalizeRadians(angle: number): number;
  75082. }
  75083. }
  75084. declare module BABYLON {
  75085. /**
  75086. * Constant used to convert a value to gamma space
  75087. * @ignorenaming
  75088. */
  75089. export const ToGammaSpace: number;
  75090. /**
  75091. * Constant used to convert a value to linear space
  75092. * @ignorenaming
  75093. */
  75094. export const ToLinearSpace = 2.2;
  75095. /**
  75096. * Constant used to define the minimal number value in Babylon.js
  75097. * @ignorenaming
  75098. */
  75099. let Epsilon: number;
  75100. }
  75101. declare module BABYLON {
  75102. /**
  75103. * Class used to represent a viewport on screen
  75104. */
  75105. export class Viewport {
  75106. /** viewport left coordinate */
  75107. x: number;
  75108. /** viewport top coordinate */
  75109. y: number;
  75110. /**viewport width */
  75111. width: number;
  75112. /** viewport height */
  75113. height: number;
  75114. /**
  75115. * Creates a Viewport object located at (x, y) and sized (width, height)
  75116. * @param x defines viewport left coordinate
  75117. * @param y defines viewport top coordinate
  75118. * @param width defines the viewport width
  75119. * @param height defines the viewport height
  75120. */
  75121. constructor(
  75122. /** viewport left coordinate */
  75123. x: number,
  75124. /** viewport top coordinate */
  75125. y: number,
  75126. /**viewport width */
  75127. width: number,
  75128. /** viewport height */
  75129. height: number);
  75130. /**
  75131. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75132. * @param renderWidth defines the rendering width
  75133. * @param renderHeight defines the rendering height
  75134. * @returns a new Viewport
  75135. */
  75136. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  75137. /**
  75138. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75139. * @param renderWidth defines the rendering width
  75140. * @param renderHeight defines the rendering height
  75141. * @param ref defines the target viewport
  75142. * @returns the current viewport
  75143. */
  75144. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  75145. /**
  75146. * Returns a new Viewport copied from the current one
  75147. * @returns a new Viewport
  75148. */
  75149. clone(): Viewport;
  75150. }
  75151. }
  75152. declare module BABYLON {
  75153. /**
  75154. * Class containing a set of static utilities functions for arrays.
  75155. */
  75156. export class ArrayTools {
  75157. /**
  75158. * Returns an array of the given size filled with element built from the given constructor and the paramters
  75159. * @param size the number of element to construct and put in the array
  75160. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  75161. * @returns a new array filled with new objects
  75162. */
  75163. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  75164. }
  75165. }
  75166. declare module BABYLON {
  75167. /**
  75168. * Class representing a vector containing 2 coordinates
  75169. */
  75170. export class Vector2 {
  75171. /** defines the first coordinate */
  75172. x: number;
  75173. /** defines the second coordinate */
  75174. y: number;
  75175. /**
  75176. * Creates a new Vector2 from the given x and y coordinates
  75177. * @param x defines the first coordinate
  75178. * @param y defines the second coordinate
  75179. */
  75180. constructor(
  75181. /** defines the first coordinate */
  75182. x?: number,
  75183. /** defines the second coordinate */
  75184. y?: number);
  75185. /**
  75186. * Gets a string with the Vector2 coordinates
  75187. * @returns a string with the Vector2 coordinates
  75188. */
  75189. toString(): string;
  75190. /**
  75191. * Gets class name
  75192. * @returns the string "Vector2"
  75193. */
  75194. getClassName(): string;
  75195. /**
  75196. * Gets current vector hash code
  75197. * @returns the Vector2 hash code as a number
  75198. */
  75199. getHashCode(): number;
  75200. /**
  75201. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  75202. * @param array defines the source array
  75203. * @param index defines the offset in source array
  75204. * @returns the current Vector2
  75205. */
  75206. toArray(array: FloatArray, index?: number): Vector2;
  75207. /**
  75208. * Copy the current vector to an array
  75209. * @returns a new array with 2 elements: the Vector2 coordinates.
  75210. */
  75211. asArray(): number[];
  75212. /**
  75213. * Sets the Vector2 coordinates with the given Vector2 coordinates
  75214. * @param source defines the source Vector2
  75215. * @returns the current updated Vector2
  75216. */
  75217. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  75218. /**
  75219. * Sets the Vector2 coordinates with the given floats
  75220. * @param x defines the first coordinate
  75221. * @param y defines the second coordinate
  75222. * @returns the current updated Vector2
  75223. */
  75224. copyFromFloats(x: number, y: number): Vector2;
  75225. /**
  75226. * Sets the Vector2 coordinates with the given floats
  75227. * @param x defines the first coordinate
  75228. * @param y defines the second coordinate
  75229. * @returns the current updated Vector2
  75230. */
  75231. set(x: number, y: number): Vector2;
  75232. /**
  75233. * Add another vector with the current one
  75234. * @param otherVector defines the other vector
  75235. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  75236. */
  75237. add(otherVector: DeepImmutable<Vector2>): Vector2;
  75238. /**
  75239. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  75240. * @param otherVector defines the other vector
  75241. * @param result defines the target vector
  75242. * @returns the unmodified current Vector2
  75243. */
  75244. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75245. /**
  75246. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  75247. * @param otherVector defines the other vector
  75248. * @returns the current updated Vector2
  75249. */
  75250. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75251. /**
  75252. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  75253. * @param otherVector defines the other vector
  75254. * @returns a new Vector2
  75255. */
  75256. addVector3(otherVector: Vector3): Vector2;
  75257. /**
  75258. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  75259. * @param otherVector defines the other vector
  75260. * @returns a new Vector2
  75261. */
  75262. subtract(otherVector: Vector2): Vector2;
  75263. /**
  75264. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  75265. * @param otherVector defines the other vector
  75266. * @param result defines the target vector
  75267. * @returns the unmodified current Vector2
  75268. */
  75269. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75270. /**
  75271. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  75272. * @param otherVector defines the other vector
  75273. * @returns the current updated Vector2
  75274. */
  75275. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75276. /**
  75277. * Multiplies in place the current Vector2 coordinates by the given ones
  75278. * @param otherVector defines the other vector
  75279. * @returns the current updated Vector2
  75280. */
  75281. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75282. /**
  75283. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  75284. * @param otherVector defines the other vector
  75285. * @returns a new Vector2
  75286. */
  75287. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  75288. /**
  75289. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  75290. * @param otherVector defines the other vector
  75291. * @param result defines the target vector
  75292. * @returns the unmodified current Vector2
  75293. */
  75294. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75295. /**
  75296. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  75297. * @param x defines the first coordinate
  75298. * @param y defines the second coordinate
  75299. * @returns a new Vector2
  75300. */
  75301. multiplyByFloats(x: number, y: number): Vector2;
  75302. /**
  75303. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  75304. * @param otherVector defines the other vector
  75305. * @returns a new Vector2
  75306. */
  75307. divide(otherVector: Vector2): Vector2;
  75308. /**
  75309. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  75310. * @param otherVector defines the other vector
  75311. * @param result defines the target vector
  75312. * @returns the unmodified current Vector2
  75313. */
  75314. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75315. /**
  75316. * Divides the current Vector2 coordinates by the given ones
  75317. * @param otherVector defines the other vector
  75318. * @returns the current updated Vector2
  75319. */
  75320. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75321. /**
  75322. * Gets a new Vector2 with current Vector2 negated coordinates
  75323. * @returns a new Vector2
  75324. */
  75325. negate(): Vector2;
  75326. /**
  75327. * Negate this vector in place
  75328. * @returns this
  75329. */
  75330. negateInPlace(): Vector2;
  75331. /**
  75332. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  75333. * @param result defines the Vector3 object where to store the result
  75334. * @returns the current Vector2
  75335. */
  75336. negateToRef(result: Vector2): Vector2;
  75337. /**
  75338. * Multiply the Vector2 coordinates by scale
  75339. * @param scale defines the scaling factor
  75340. * @returns the current updated Vector2
  75341. */
  75342. scaleInPlace(scale: number): Vector2;
  75343. /**
  75344. * Returns a new Vector2 scaled by "scale" from the current Vector2
  75345. * @param scale defines the scaling factor
  75346. * @returns a new Vector2
  75347. */
  75348. scale(scale: number): Vector2;
  75349. /**
  75350. * Scale the current Vector2 values by a factor to a given Vector2
  75351. * @param scale defines the scale factor
  75352. * @param result defines the Vector2 object where to store the result
  75353. * @returns the unmodified current Vector2
  75354. */
  75355. scaleToRef(scale: number, result: Vector2): Vector2;
  75356. /**
  75357. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  75358. * @param scale defines the scale factor
  75359. * @param result defines the Vector2 object where to store the result
  75360. * @returns the unmodified current Vector2
  75361. */
  75362. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  75363. /**
  75364. * Gets a boolean if two vectors are equals
  75365. * @param otherVector defines the other vector
  75366. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  75367. */
  75368. equals(otherVector: DeepImmutable<Vector2>): boolean;
  75369. /**
  75370. * Gets a boolean if two vectors are equals (using an epsilon value)
  75371. * @param otherVector defines the other vector
  75372. * @param epsilon defines the minimal distance to consider equality
  75373. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  75374. */
  75375. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  75376. /**
  75377. * Gets a new Vector2 from current Vector2 floored values
  75378. * @returns a new Vector2
  75379. */
  75380. floor(): Vector2;
  75381. /**
  75382. * Gets a new Vector2 from current Vector2 floored values
  75383. * @returns a new Vector2
  75384. */
  75385. fract(): Vector2;
  75386. /**
  75387. * Gets the length of the vector
  75388. * @returns the vector length (float)
  75389. */
  75390. length(): number;
  75391. /**
  75392. * Gets the vector squared length
  75393. * @returns the vector squared length (float)
  75394. */
  75395. lengthSquared(): number;
  75396. /**
  75397. * Normalize the vector
  75398. * @returns the current updated Vector2
  75399. */
  75400. normalize(): Vector2;
  75401. /**
  75402. * Gets a new Vector2 copied from the Vector2
  75403. * @returns a new Vector2
  75404. */
  75405. clone(): Vector2;
  75406. /**
  75407. * Gets a new Vector2(0, 0)
  75408. * @returns a new Vector2
  75409. */
  75410. static Zero(): Vector2;
  75411. /**
  75412. * Gets a new Vector2(1, 1)
  75413. * @returns a new Vector2
  75414. */
  75415. static One(): Vector2;
  75416. /**
  75417. * Gets a new Vector2 set from the given index element of the given array
  75418. * @param array defines the data source
  75419. * @param offset defines the offset in the data source
  75420. * @returns a new Vector2
  75421. */
  75422. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75423. /**
  75424. * Sets "result" from the given index element of the given array
  75425. * @param array defines the data source
  75426. * @param offset defines the offset in the data source
  75427. * @param result defines the target vector
  75428. */
  75429. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75430. /**
  75431. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75432. * @param value1 defines 1st point of control
  75433. * @param value2 defines 2nd point of control
  75434. * @param value3 defines 3rd point of control
  75435. * @param value4 defines 4th point of control
  75436. * @param amount defines the interpolation factor
  75437. * @returns a new Vector2
  75438. */
  75439. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75440. /**
  75441. * 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".
  75442. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75443. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75444. * @param value defines the value to clamp
  75445. * @param min defines the lower limit
  75446. * @param max defines the upper limit
  75447. * @returns a new Vector2
  75448. */
  75449. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75450. /**
  75451. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75452. * @param value1 defines the 1st control point
  75453. * @param tangent1 defines the outgoing tangent
  75454. * @param value2 defines the 2nd control point
  75455. * @param tangent2 defines the incoming tangent
  75456. * @param amount defines the interpolation factor
  75457. * @returns a new Vector2
  75458. */
  75459. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75460. /**
  75461. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75462. * @param start defines the start vector
  75463. * @param end defines the end vector
  75464. * @param amount defines the interpolation factor
  75465. * @returns a new Vector2
  75466. */
  75467. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75468. /**
  75469. * Gets the dot product of the vector "left" and the vector "right"
  75470. * @param left defines first vector
  75471. * @param right defines second vector
  75472. * @returns the dot product (float)
  75473. */
  75474. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75475. /**
  75476. * Returns a new Vector2 equal to the normalized given vector
  75477. * @param vector defines the vector to normalize
  75478. * @returns a new Vector2
  75479. */
  75480. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75481. /**
  75482. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75483. * @param left defines 1st vector
  75484. * @param right defines 2nd vector
  75485. * @returns a new Vector2
  75486. */
  75487. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75488. /**
  75489. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75490. * @param left defines 1st vector
  75491. * @param right defines 2nd vector
  75492. * @returns a new Vector2
  75493. */
  75494. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75495. /**
  75496. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75497. * @param vector defines the vector to transform
  75498. * @param transformation defines the matrix to apply
  75499. * @returns a new Vector2
  75500. */
  75501. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75502. /**
  75503. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75504. * @param vector defines the vector to transform
  75505. * @param transformation defines the matrix to apply
  75506. * @param result defines the target vector
  75507. */
  75508. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75509. /**
  75510. * Determines if a given vector is included in a triangle
  75511. * @param p defines the vector to test
  75512. * @param p0 defines 1st triangle point
  75513. * @param p1 defines 2nd triangle point
  75514. * @param p2 defines 3rd triangle point
  75515. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75516. */
  75517. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75518. /**
  75519. * Gets the distance between the vectors "value1" and "value2"
  75520. * @param value1 defines first vector
  75521. * @param value2 defines second vector
  75522. * @returns the distance between vectors
  75523. */
  75524. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75525. /**
  75526. * Returns the squared distance between the vectors "value1" and "value2"
  75527. * @param value1 defines first vector
  75528. * @param value2 defines second vector
  75529. * @returns the squared distance between vectors
  75530. */
  75531. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75532. /**
  75533. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75534. * @param value1 defines first vector
  75535. * @param value2 defines second vector
  75536. * @returns a new Vector2
  75537. */
  75538. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75539. /**
  75540. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75541. * @param p defines the middle point
  75542. * @param segA defines one point of the segment
  75543. * @param segB defines the other point of the segment
  75544. * @returns the shortest distance
  75545. */
  75546. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75547. }
  75548. /**
  75549. * Class used to store (x,y,z) vector representation
  75550. * A Vector3 is the main object used in 3D geometry
  75551. * It can represent etiher the coordinates of a point the space, either a direction
  75552. * Reminder: js uses a left handed forward facing system
  75553. */
  75554. export class Vector3 {
  75555. /**
  75556. * Defines the first coordinates (on X axis)
  75557. */
  75558. x: number;
  75559. /**
  75560. * Defines the second coordinates (on Y axis)
  75561. */
  75562. y: number;
  75563. /**
  75564. * Defines the third coordinates (on Z axis)
  75565. */
  75566. z: number;
  75567. private static _UpReadOnly;
  75568. private static _ZeroReadOnly;
  75569. /**
  75570. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75571. * @param x defines the first coordinates (on X axis)
  75572. * @param y defines the second coordinates (on Y axis)
  75573. * @param z defines the third coordinates (on Z axis)
  75574. */
  75575. constructor(
  75576. /**
  75577. * Defines the first coordinates (on X axis)
  75578. */
  75579. x?: number,
  75580. /**
  75581. * Defines the second coordinates (on Y axis)
  75582. */
  75583. y?: number,
  75584. /**
  75585. * Defines the third coordinates (on Z axis)
  75586. */
  75587. z?: number);
  75588. /**
  75589. * Creates a string representation of the Vector3
  75590. * @returns a string with the Vector3 coordinates.
  75591. */
  75592. toString(): string;
  75593. /**
  75594. * Gets the class name
  75595. * @returns the string "Vector3"
  75596. */
  75597. getClassName(): string;
  75598. /**
  75599. * Creates the Vector3 hash code
  75600. * @returns a number which tends to be unique between Vector3 instances
  75601. */
  75602. getHashCode(): number;
  75603. /**
  75604. * Creates an array containing three elements : the coordinates of the Vector3
  75605. * @returns a new array of numbers
  75606. */
  75607. asArray(): number[];
  75608. /**
  75609. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75610. * @param array defines the destination array
  75611. * @param index defines the offset in the destination array
  75612. * @returns the current Vector3
  75613. */
  75614. toArray(array: FloatArray, index?: number): Vector3;
  75615. /**
  75616. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75617. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75618. */
  75619. toQuaternion(): Quaternion;
  75620. /**
  75621. * Adds the given vector to the current Vector3
  75622. * @param otherVector defines the second operand
  75623. * @returns the current updated Vector3
  75624. */
  75625. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75626. /**
  75627. * Adds the given coordinates to the current Vector3
  75628. * @param x defines the x coordinate of the operand
  75629. * @param y defines the y coordinate of the operand
  75630. * @param z defines the z coordinate of the operand
  75631. * @returns the current updated Vector3
  75632. */
  75633. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75634. /**
  75635. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75636. * @param otherVector defines the second operand
  75637. * @returns the resulting Vector3
  75638. */
  75639. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75640. /**
  75641. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75642. * @param otherVector defines the second operand
  75643. * @param result defines the Vector3 object where to store the result
  75644. * @returns the current Vector3
  75645. */
  75646. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75647. /**
  75648. * Subtract the given vector from the current Vector3
  75649. * @param otherVector defines the second operand
  75650. * @returns the current updated Vector3
  75651. */
  75652. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75653. /**
  75654. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75655. * @param otherVector defines the second operand
  75656. * @returns the resulting Vector3
  75657. */
  75658. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75659. /**
  75660. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75661. * @param otherVector defines the second operand
  75662. * @param result defines the Vector3 object where to store the result
  75663. * @returns the current Vector3
  75664. */
  75665. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75666. /**
  75667. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75668. * @param x defines the x coordinate of the operand
  75669. * @param y defines the y coordinate of the operand
  75670. * @param z defines the z coordinate of the operand
  75671. * @returns the resulting Vector3
  75672. */
  75673. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75674. /**
  75675. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75676. * @param x defines the x coordinate of the operand
  75677. * @param y defines the y coordinate of the operand
  75678. * @param z defines the z coordinate of the operand
  75679. * @param result defines the Vector3 object where to store the result
  75680. * @returns the current Vector3
  75681. */
  75682. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  75683. /**
  75684. * Gets a new Vector3 set with the current Vector3 negated coordinates
  75685. * @returns a new Vector3
  75686. */
  75687. negate(): Vector3;
  75688. /**
  75689. * Negate this vector in place
  75690. * @returns this
  75691. */
  75692. negateInPlace(): Vector3;
  75693. /**
  75694. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  75695. * @param result defines the Vector3 object where to store the result
  75696. * @returns the current Vector3
  75697. */
  75698. negateToRef(result: Vector3): Vector3;
  75699. /**
  75700. * Multiplies the Vector3 coordinates by the float "scale"
  75701. * @param scale defines the multiplier factor
  75702. * @returns the current updated Vector3
  75703. */
  75704. scaleInPlace(scale: number): Vector3;
  75705. /**
  75706. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  75707. * @param scale defines the multiplier factor
  75708. * @returns a new Vector3
  75709. */
  75710. scale(scale: number): Vector3;
  75711. /**
  75712. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  75713. * @param scale defines the multiplier factor
  75714. * @param result defines the Vector3 object where to store the result
  75715. * @returns the current Vector3
  75716. */
  75717. scaleToRef(scale: number, result: Vector3): Vector3;
  75718. /**
  75719. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  75720. * @param scale defines the scale factor
  75721. * @param result defines the Vector3 object where to store the result
  75722. * @returns the unmodified current Vector3
  75723. */
  75724. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  75725. /**
  75726. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  75727. * @param otherVector defines the second operand
  75728. * @returns true if both vectors are equals
  75729. */
  75730. equals(otherVector: DeepImmutable<Vector3>): boolean;
  75731. /**
  75732. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  75733. * @param otherVector defines the second operand
  75734. * @param epsilon defines the minimal distance to define values as equals
  75735. * @returns true if both vectors are distant less than epsilon
  75736. */
  75737. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  75738. /**
  75739. * Returns true if the current Vector3 coordinates equals the given floats
  75740. * @param x defines the x coordinate of the operand
  75741. * @param y defines the y coordinate of the operand
  75742. * @param z defines the z coordinate of the operand
  75743. * @returns true if both vectors are equals
  75744. */
  75745. equalsToFloats(x: number, y: number, z: number): boolean;
  75746. /**
  75747. * Multiplies the current Vector3 coordinates by the given ones
  75748. * @param otherVector defines the second operand
  75749. * @returns the current updated Vector3
  75750. */
  75751. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75752. /**
  75753. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  75754. * @param otherVector defines the second operand
  75755. * @returns the new Vector3
  75756. */
  75757. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  75758. /**
  75759. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  75760. * @param otherVector defines the second operand
  75761. * @param result defines the Vector3 object where to store the result
  75762. * @returns the current Vector3
  75763. */
  75764. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75765. /**
  75766. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  75767. * @param x defines the x coordinate of the operand
  75768. * @param y defines the y coordinate of the operand
  75769. * @param z defines the z coordinate of the operand
  75770. * @returns the new Vector3
  75771. */
  75772. multiplyByFloats(x: number, y: number, z: number): Vector3;
  75773. /**
  75774. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  75775. * @param otherVector defines the second operand
  75776. * @returns the new Vector3
  75777. */
  75778. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  75779. /**
  75780. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  75781. * @param otherVector defines the second operand
  75782. * @param result defines the Vector3 object where to store the result
  75783. * @returns the current Vector3
  75784. */
  75785. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75786. /**
  75787. * Divides the current Vector3 coordinates by the given ones.
  75788. * @param otherVector defines the second operand
  75789. * @returns the current updated Vector3
  75790. */
  75791. divideInPlace(otherVector: Vector3): Vector3;
  75792. /**
  75793. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  75794. * @param other defines the second operand
  75795. * @returns the current updated Vector3
  75796. */
  75797. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75798. /**
  75799. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  75800. * @param other defines the second operand
  75801. * @returns the current updated Vector3
  75802. */
  75803. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75804. /**
  75805. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  75806. * @param x defines the x coordinate of the operand
  75807. * @param y defines the y coordinate of the operand
  75808. * @param z defines the z coordinate of the operand
  75809. * @returns the current updated Vector3
  75810. */
  75811. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75812. /**
  75813. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75814. * @param x defines the x coordinate of the operand
  75815. * @param y defines the y coordinate of the operand
  75816. * @param z defines the z coordinate of the operand
  75817. * @returns the current updated Vector3
  75818. */
  75819. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75820. /**
  75821. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  75822. * Check if is non uniform within a certain amount of decimal places to account for this
  75823. * @param epsilon the amount the values can differ
  75824. * @returns if the the vector is non uniform to a certain number of decimal places
  75825. */
  75826. isNonUniformWithinEpsilon(epsilon: number): boolean;
  75827. /**
  75828. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  75829. */
  75830. get isNonUniform(): boolean;
  75831. /**
  75832. * Gets a new Vector3 from current Vector3 floored values
  75833. * @returns a new Vector3
  75834. */
  75835. floor(): Vector3;
  75836. /**
  75837. * Gets a new Vector3 from current Vector3 floored values
  75838. * @returns a new Vector3
  75839. */
  75840. fract(): Vector3;
  75841. /**
  75842. * Gets the length of the Vector3
  75843. * @returns the length of the Vector3
  75844. */
  75845. length(): number;
  75846. /**
  75847. * Gets the squared length of the Vector3
  75848. * @returns squared length of the Vector3
  75849. */
  75850. lengthSquared(): number;
  75851. /**
  75852. * Normalize the current Vector3.
  75853. * Please note that this is an in place operation.
  75854. * @returns the current updated Vector3
  75855. */
  75856. normalize(): Vector3;
  75857. /**
  75858. * Reorders the x y z properties of the vector in place
  75859. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  75860. * @returns the current updated vector
  75861. */
  75862. reorderInPlace(order: string): this;
  75863. /**
  75864. * Rotates the vector around 0,0,0 by a quaternion
  75865. * @param quaternion the rotation quaternion
  75866. * @param result vector to store the result
  75867. * @returns the resulting vector
  75868. */
  75869. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  75870. /**
  75871. * Rotates a vector around a given point
  75872. * @param quaternion the rotation quaternion
  75873. * @param point the point to rotate around
  75874. * @param result vector to store the result
  75875. * @returns the resulting vector
  75876. */
  75877. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  75878. /**
  75879. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  75880. * The cross product is then orthogonal to both current and "other"
  75881. * @param other defines the right operand
  75882. * @returns the cross product
  75883. */
  75884. cross(other: Vector3): Vector3;
  75885. /**
  75886. * Normalize the current Vector3 with the given input length.
  75887. * Please note that this is an in place operation.
  75888. * @param len the length of the vector
  75889. * @returns the current updated Vector3
  75890. */
  75891. normalizeFromLength(len: number): Vector3;
  75892. /**
  75893. * Normalize the current Vector3 to a new vector
  75894. * @returns the new Vector3
  75895. */
  75896. normalizeToNew(): Vector3;
  75897. /**
  75898. * Normalize the current Vector3 to the reference
  75899. * @param reference define the Vector3 to update
  75900. * @returns the updated Vector3
  75901. */
  75902. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  75903. /**
  75904. * Creates a new Vector3 copied from the current Vector3
  75905. * @returns the new Vector3
  75906. */
  75907. clone(): Vector3;
  75908. /**
  75909. * Copies the given vector coordinates to the current Vector3 ones
  75910. * @param source defines the source Vector3
  75911. * @returns the current updated Vector3
  75912. */
  75913. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  75914. /**
  75915. * Copies the given floats to the current Vector3 coordinates
  75916. * @param x defines the x coordinate of the operand
  75917. * @param y defines the y coordinate of the operand
  75918. * @param z defines the z coordinate of the operand
  75919. * @returns the current updated Vector3
  75920. */
  75921. copyFromFloats(x: number, y: number, z: number): Vector3;
  75922. /**
  75923. * Copies the given floats to the current Vector3 coordinates
  75924. * @param x defines the x coordinate of the operand
  75925. * @param y defines the y coordinate of the operand
  75926. * @param z defines the z coordinate of the operand
  75927. * @returns the current updated Vector3
  75928. */
  75929. set(x: number, y: number, z: number): Vector3;
  75930. /**
  75931. * Copies the given float to the current Vector3 coordinates
  75932. * @param v defines the x, y and z coordinates of the operand
  75933. * @returns the current updated Vector3
  75934. */
  75935. setAll(v: number): Vector3;
  75936. /**
  75937. * Get the clip factor between two vectors
  75938. * @param vector0 defines the first operand
  75939. * @param vector1 defines the second operand
  75940. * @param axis defines the axis to use
  75941. * @param size defines the size along the axis
  75942. * @returns the clip factor
  75943. */
  75944. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  75945. /**
  75946. * Get angle between two vectors
  75947. * @param vector0 angle between vector0 and vector1
  75948. * @param vector1 angle between vector0 and vector1
  75949. * @param normal direction of the normal
  75950. * @return the angle between vector0 and vector1
  75951. */
  75952. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  75953. /**
  75954. * Returns a new Vector3 set from the index "offset" of the given array
  75955. * @param array defines the source array
  75956. * @param offset defines the offset in the source array
  75957. * @returns the new Vector3
  75958. */
  75959. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  75960. /**
  75961. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  75962. * @param array defines the source array
  75963. * @param offset defines the offset in the source array
  75964. * @returns the new Vector3
  75965. * @deprecated Please use FromArray instead.
  75966. */
  75967. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  75968. /**
  75969. * Sets the given vector "result" with the element values from the index "offset" of the given array
  75970. * @param array defines the source array
  75971. * @param offset defines the offset in the source array
  75972. * @param result defines the Vector3 where to store the result
  75973. */
  75974. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  75975. /**
  75976. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  75977. * @param array defines the source array
  75978. * @param offset defines the offset in the source array
  75979. * @param result defines the Vector3 where to store the result
  75980. * @deprecated Please use FromArrayToRef instead.
  75981. */
  75982. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  75983. /**
  75984. * Sets the given vector "result" with the given floats.
  75985. * @param x defines the x coordinate of the source
  75986. * @param y defines the y coordinate of the source
  75987. * @param z defines the z coordinate of the source
  75988. * @param result defines the Vector3 where to store the result
  75989. */
  75990. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  75991. /**
  75992. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  75993. * @returns a new empty Vector3
  75994. */
  75995. static Zero(): Vector3;
  75996. /**
  75997. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  75998. * @returns a new unit Vector3
  75999. */
  76000. static One(): Vector3;
  76001. /**
  76002. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  76003. * @returns a new up Vector3
  76004. */
  76005. static Up(): Vector3;
  76006. /**
  76007. * Gets a up Vector3 that must not be updated
  76008. */
  76009. static get UpReadOnly(): DeepImmutable<Vector3>;
  76010. /**
  76011. * Gets a zero Vector3 that must not be updated
  76012. */
  76013. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  76014. /**
  76015. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  76016. * @returns a new down Vector3
  76017. */
  76018. static Down(): Vector3;
  76019. /**
  76020. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  76021. * @returns a new forward Vector3
  76022. */
  76023. static Forward(): Vector3;
  76024. /**
  76025. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  76026. * @returns a new forward Vector3
  76027. */
  76028. static Backward(): Vector3;
  76029. /**
  76030. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  76031. * @returns a new right Vector3
  76032. */
  76033. static Right(): Vector3;
  76034. /**
  76035. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  76036. * @returns a new left Vector3
  76037. */
  76038. static Left(): Vector3;
  76039. /**
  76040. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  76041. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76042. * @param vector defines the Vector3 to transform
  76043. * @param transformation defines the transformation matrix
  76044. * @returns the transformed Vector3
  76045. */
  76046. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76047. /**
  76048. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  76049. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76050. * @param vector defines the Vector3 to transform
  76051. * @param transformation defines the transformation matrix
  76052. * @param result defines the Vector3 where to store the result
  76053. */
  76054. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76055. /**
  76056. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  76057. * This method computes tranformed coordinates only, not transformed direction vectors
  76058. * @param x define the x coordinate of the source vector
  76059. * @param y define the y coordinate of the source vector
  76060. * @param z define the z coordinate of the source vector
  76061. * @param transformation defines the transformation matrix
  76062. * @param result defines the Vector3 where to store the result
  76063. */
  76064. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76065. /**
  76066. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  76067. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76068. * @param vector defines the Vector3 to transform
  76069. * @param transformation defines the transformation matrix
  76070. * @returns the new Vector3
  76071. */
  76072. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76073. /**
  76074. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  76075. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76076. * @param vector defines the Vector3 to transform
  76077. * @param transformation defines the transformation matrix
  76078. * @param result defines the Vector3 where to store the result
  76079. */
  76080. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76081. /**
  76082. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  76083. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76084. * @param x define the x coordinate of the source vector
  76085. * @param y define the y coordinate of the source vector
  76086. * @param z define the z coordinate of the source vector
  76087. * @param transformation defines the transformation matrix
  76088. * @param result defines the Vector3 where to store the result
  76089. */
  76090. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76091. /**
  76092. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  76093. * @param value1 defines the first control point
  76094. * @param value2 defines the second control point
  76095. * @param value3 defines the third control point
  76096. * @param value4 defines the fourth control point
  76097. * @param amount defines the amount on the spline to use
  76098. * @returns the new Vector3
  76099. */
  76100. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  76101. /**
  76102. * 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"
  76103. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76104. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76105. * @param value defines the current value
  76106. * @param min defines the lower range value
  76107. * @param max defines the upper range value
  76108. * @returns the new Vector3
  76109. */
  76110. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  76111. /**
  76112. * 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"
  76113. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76114. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76115. * @param value defines the current value
  76116. * @param min defines the lower range value
  76117. * @param max defines the upper range value
  76118. * @param result defines the Vector3 where to store the result
  76119. */
  76120. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  76121. /**
  76122. * Checks if a given vector is inside a specific range
  76123. * @param v defines the vector to test
  76124. * @param min defines the minimum range
  76125. * @param max defines the maximum range
  76126. */
  76127. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  76128. /**
  76129. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  76130. * @param value1 defines the first control point
  76131. * @param tangent1 defines the first tangent vector
  76132. * @param value2 defines the second control point
  76133. * @param tangent2 defines the second tangent vector
  76134. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  76135. * @returns the new Vector3
  76136. */
  76137. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  76138. /**
  76139. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  76140. * @param start defines the start value
  76141. * @param end defines the end value
  76142. * @param amount max defines amount between both (between 0 and 1)
  76143. * @returns the new Vector3
  76144. */
  76145. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  76146. /**
  76147. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  76148. * @param start defines the start value
  76149. * @param end defines the end value
  76150. * @param amount max defines amount between both (between 0 and 1)
  76151. * @param result defines the Vector3 where to store the result
  76152. */
  76153. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  76154. /**
  76155. * Returns the dot product (float) between the vectors "left" and "right"
  76156. * @param left defines the left operand
  76157. * @param right defines the right operand
  76158. * @returns the dot product
  76159. */
  76160. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  76161. /**
  76162. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  76163. * The cross product is then orthogonal to both "left" and "right"
  76164. * @param left defines the left operand
  76165. * @param right defines the right operand
  76166. * @returns the cross product
  76167. */
  76168. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76169. /**
  76170. * Sets the given vector "result" with the cross product of "left" and "right"
  76171. * The cross product is then orthogonal to both "left" and "right"
  76172. * @param left defines the left operand
  76173. * @param right defines the right operand
  76174. * @param result defines the Vector3 where to store the result
  76175. */
  76176. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  76177. /**
  76178. * Returns a new Vector3 as the normalization of the given vector
  76179. * @param vector defines the Vector3 to normalize
  76180. * @returns the new Vector3
  76181. */
  76182. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  76183. /**
  76184. * Sets the given vector "result" with the normalization of the given first vector
  76185. * @param vector defines the Vector3 to normalize
  76186. * @param result defines the Vector3 where to store the result
  76187. */
  76188. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  76189. /**
  76190. * Project a Vector3 onto screen space
  76191. * @param vector defines the Vector3 to project
  76192. * @param world defines the world matrix to use
  76193. * @param transform defines the transform (view x projection) matrix to use
  76194. * @param viewport defines the screen viewport to use
  76195. * @returns the new Vector3
  76196. */
  76197. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  76198. /** @hidden */
  76199. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  76200. /**
  76201. * Unproject from screen space to object space
  76202. * @param source defines the screen space Vector3 to use
  76203. * @param viewportWidth defines the current width of the viewport
  76204. * @param viewportHeight defines the current height of the viewport
  76205. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76206. * @param transform defines the transform (view x projection) matrix to use
  76207. * @returns the new Vector3
  76208. */
  76209. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  76210. /**
  76211. * Unproject from screen space to object space
  76212. * @param source defines the screen space Vector3 to use
  76213. * @param viewportWidth defines the current width of the viewport
  76214. * @param viewportHeight defines the current height of the viewport
  76215. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76216. * @param view defines the view matrix to use
  76217. * @param projection defines the projection matrix to use
  76218. * @returns the new Vector3
  76219. */
  76220. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  76221. /**
  76222. * Unproject from screen space to object space
  76223. * @param source defines the screen space Vector3 to use
  76224. * @param viewportWidth defines the current width of the viewport
  76225. * @param viewportHeight defines the current height of the viewport
  76226. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76227. * @param view defines the view matrix to use
  76228. * @param projection defines the projection matrix to use
  76229. * @param result defines the Vector3 where to store the result
  76230. */
  76231. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76232. /**
  76233. * Unproject from screen space to object space
  76234. * @param sourceX defines the screen space x coordinate to use
  76235. * @param sourceY defines the screen space y coordinate to use
  76236. * @param sourceZ defines the screen space z coordinate to use
  76237. * @param viewportWidth defines the current width of the viewport
  76238. * @param viewportHeight defines the current height of the viewport
  76239. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76240. * @param view defines the view matrix to use
  76241. * @param projection defines the projection matrix to use
  76242. * @param result defines the Vector3 where to store the result
  76243. */
  76244. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76245. /**
  76246. * Gets the minimal coordinate values between two Vector3
  76247. * @param left defines the first operand
  76248. * @param right defines the second operand
  76249. * @returns the new Vector3
  76250. */
  76251. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76252. /**
  76253. * Gets the maximal coordinate values between two Vector3
  76254. * @param left defines the first operand
  76255. * @param right defines the second operand
  76256. * @returns the new Vector3
  76257. */
  76258. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76259. /**
  76260. * Returns the distance between the vectors "value1" and "value2"
  76261. * @param value1 defines the first operand
  76262. * @param value2 defines the second operand
  76263. * @returns the distance
  76264. */
  76265. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76266. /**
  76267. * Returns the squared distance between the vectors "value1" and "value2"
  76268. * @param value1 defines the first operand
  76269. * @param value2 defines the second operand
  76270. * @returns the squared distance
  76271. */
  76272. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76273. /**
  76274. * Returns a new Vector3 located at the center between "value1" and "value2"
  76275. * @param value1 defines the first operand
  76276. * @param value2 defines the second operand
  76277. * @returns the new Vector3
  76278. */
  76279. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  76280. /**
  76281. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  76282. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  76283. * to something in order to rotate it from its local system to the given target system
  76284. * Note: axis1, axis2 and axis3 are normalized during this operation
  76285. * @param axis1 defines the first axis
  76286. * @param axis2 defines the second axis
  76287. * @param axis3 defines the third axis
  76288. * @returns a new Vector3
  76289. */
  76290. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  76291. /**
  76292. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  76293. * @param axis1 defines the first axis
  76294. * @param axis2 defines the second axis
  76295. * @param axis3 defines the third axis
  76296. * @param ref defines the Vector3 where to store the result
  76297. */
  76298. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  76299. }
  76300. /**
  76301. * Vector4 class created for EulerAngle class conversion to Quaternion
  76302. */
  76303. export class Vector4 {
  76304. /** x value of the vector */
  76305. x: number;
  76306. /** y value of the vector */
  76307. y: number;
  76308. /** z value of the vector */
  76309. z: number;
  76310. /** w value of the vector */
  76311. w: number;
  76312. /**
  76313. * Creates a Vector4 object from the given floats.
  76314. * @param x x value of the vector
  76315. * @param y y value of the vector
  76316. * @param z z value of the vector
  76317. * @param w w value of the vector
  76318. */
  76319. constructor(
  76320. /** x value of the vector */
  76321. x: number,
  76322. /** y value of the vector */
  76323. y: number,
  76324. /** z value of the vector */
  76325. z: number,
  76326. /** w value of the vector */
  76327. w: number);
  76328. /**
  76329. * Returns the string with the Vector4 coordinates.
  76330. * @returns a string containing all the vector values
  76331. */
  76332. toString(): string;
  76333. /**
  76334. * Returns the string "Vector4".
  76335. * @returns "Vector4"
  76336. */
  76337. getClassName(): string;
  76338. /**
  76339. * Returns the Vector4 hash code.
  76340. * @returns a unique hash code
  76341. */
  76342. getHashCode(): number;
  76343. /**
  76344. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  76345. * @returns the resulting array
  76346. */
  76347. asArray(): number[];
  76348. /**
  76349. * Populates the given array from the given index with the Vector4 coordinates.
  76350. * @param array array to populate
  76351. * @param index index of the array to start at (default: 0)
  76352. * @returns the Vector4.
  76353. */
  76354. toArray(array: FloatArray, index?: number): Vector4;
  76355. /**
  76356. * Adds the given vector to the current Vector4.
  76357. * @param otherVector the vector to add
  76358. * @returns the updated Vector4.
  76359. */
  76360. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76361. /**
  76362. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  76363. * @param otherVector the vector to add
  76364. * @returns the resulting vector
  76365. */
  76366. add(otherVector: DeepImmutable<Vector4>): Vector4;
  76367. /**
  76368. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  76369. * @param otherVector the vector to add
  76370. * @param result the vector to store the result
  76371. * @returns the current Vector4.
  76372. */
  76373. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76374. /**
  76375. * Subtract in place the given vector from the current Vector4.
  76376. * @param otherVector the vector to subtract
  76377. * @returns the updated Vector4.
  76378. */
  76379. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76380. /**
  76381. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  76382. * @param otherVector the vector to add
  76383. * @returns the new vector with the result
  76384. */
  76385. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  76386. /**
  76387. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  76388. * @param otherVector the vector to subtract
  76389. * @param result the vector to store the result
  76390. * @returns the current Vector4.
  76391. */
  76392. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76393. /**
  76394. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76395. */
  76396. /**
  76397. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76398. * @param x value to subtract
  76399. * @param y value to subtract
  76400. * @param z value to subtract
  76401. * @param w value to subtract
  76402. * @returns new vector containing the result
  76403. */
  76404. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76405. /**
  76406. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76407. * @param x value to subtract
  76408. * @param y value to subtract
  76409. * @param z value to subtract
  76410. * @param w value to subtract
  76411. * @param result the vector to store the result in
  76412. * @returns the current Vector4.
  76413. */
  76414. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76415. /**
  76416. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76417. * @returns a new vector with the negated values
  76418. */
  76419. negate(): Vector4;
  76420. /**
  76421. * Negate this vector in place
  76422. * @returns this
  76423. */
  76424. negateInPlace(): Vector4;
  76425. /**
  76426. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76427. * @param result defines the Vector3 object where to store the result
  76428. * @returns the current Vector4
  76429. */
  76430. negateToRef(result: Vector4): Vector4;
  76431. /**
  76432. * Multiplies the current Vector4 coordinates by scale (float).
  76433. * @param scale the number to scale with
  76434. * @returns the updated Vector4.
  76435. */
  76436. scaleInPlace(scale: number): Vector4;
  76437. /**
  76438. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76439. * @param scale the number to scale with
  76440. * @returns a new vector with the result
  76441. */
  76442. scale(scale: number): Vector4;
  76443. /**
  76444. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76445. * @param scale the number to scale with
  76446. * @param result a vector to store the result in
  76447. * @returns the current Vector4.
  76448. */
  76449. scaleToRef(scale: number, result: Vector4): Vector4;
  76450. /**
  76451. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76452. * @param scale defines the scale factor
  76453. * @param result defines the Vector4 object where to store the result
  76454. * @returns the unmodified current Vector4
  76455. */
  76456. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76457. /**
  76458. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76459. * @param otherVector the vector to compare against
  76460. * @returns true if they are equal
  76461. */
  76462. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76463. /**
  76464. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76465. * @param otherVector vector to compare against
  76466. * @param epsilon (Default: very small number)
  76467. * @returns true if they are equal
  76468. */
  76469. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76470. /**
  76471. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76472. * @param x x value to compare against
  76473. * @param y y value to compare against
  76474. * @param z z value to compare against
  76475. * @param w w value to compare against
  76476. * @returns true if equal
  76477. */
  76478. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76479. /**
  76480. * Multiplies in place the current Vector4 by the given one.
  76481. * @param otherVector vector to multiple with
  76482. * @returns the updated Vector4.
  76483. */
  76484. multiplyInPlace(otherVector: Vector4): Vector4;
  76485. /**
  76486. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76487. * @param otherVector vector to multiple with
  76488. * @returns resulting new vector
  76489. */
  76490. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76491. /**
  76492. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76493. * @param otherVector vector to multiple with
  76494. * @param result vector to store the result
  76495. * @returns the current Vector4.
  76496. */
  76497. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76498. /**
  76499. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76500. * @param x x value multiply with
  76501. * @param y y value multiply with
  76502. * @param z z value multiply with
  76503. * @param w w value multiply with
  76504. * @returns resulting new vector
  76505. */
  76506. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76507. /**
  76508. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76509. * @param otherVector vector to devide with
  76510. * @returns resulting new vector
  76511. */
  76512. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76513. /**
  76514. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76515. * @param otherVector vector to devide with
  76516. * @param result vector to store the result
  76517. * @returns the current Vector4.
  76518. */
  76519. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76520. /**
  76521. * Divides the current Vector3 coordinates by the given ones.
  76522. * @param otherVector vector to devide with
  76523. * @returns the updated Vector3.
  76524. */
  76525. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76526. /**
  76527. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76528. * @param other defines the second operand
  76529. * @returns the current updated Vector4
  76530. */
  76531. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76532. /**
  76533. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76534. * @param other defines the second operand
  76535. * @returns the current updated Vector4
  76536. */
  76537. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76538. /**
  76539. * Gets a new Vector4 from current Vector4 floored values
  76540. * @returns a new Vector4
  76541. */
  76542. floor(): Vector4;
  76543. /**
  76544. * Gets a new Vector4 from current Vector3 floored values
  76545. * @returns a new Vector4
  76546. */
  76547. fract(): Vector4;
  76548. /**
  76549. * Returns the Vector4 length (float).
  76550. * @returns the length
  76551. */
  76552. length(): number;
  76553. /**
  76554. * Returns the Vector4 squared length (float).
  76555. * @returns the length squared
  76556. */
  76557. lengthSquared(): number;
  76558. /**
  76559. * Normalizes in place the Vector4.
  76560. * @returns the updated Vector4.
  76561. */
  76562. normalize(): Vector4;
  76563. /**
  76564. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76565. * @returns this converted to a new vector3
  76566. */
  76567. toVector3(): Vector3;
  76568. /**
  76569. * Returns a new Vector4 copied from the current one.
  76570. * @returns the new cloned vector
  76571. */
  76572. clone(): Vector4;
  76573. /**
  76574. * Updates the current Vector4 with the given one coordinates.
  76575. * @param source the source vector to copy from
  76576. * @returns the updated Vector4.
  76577. */
  76578. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  76579. /**
  76580. * Updates the current Vector4 coordinates with the given floats.
  76581. * @param x float to copy from
  76582. * @param y float to copy from
  76583. * @param z float to copy from
  76584. * @param w float to copy from
  76585. * @returns the updated Vector4.
  76586. */
  76587. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76588. /**
  76589. * Updates the current Vector4 coordinates with the given floats.
  76590. * @param x float to set from
  76591. * @param y float to set from
  76592. * @param z float to set from
  76593. * @param w float to set from
  76594. * @returns the updated Vector4.
  76595. */
  76596. set(x: number, y: number, z: number, w: number): Vector4;
  76597. /**
  76598. * Copies the given float to the current Vector3 coordinates
  76599. * @param v defines the x, y, z and w coordinates of the operand
  76600. * @returns the current updated Vector3
  76601. */
  76602. setAll(v: number): Vector4;
  76603. /**
  76604. * Returns a new Vector4 set from the starting index of the given array.
  76605. * @param array the array to pull values from
  76606. * @param offset the offset into the array to start at
  76607. * @returns the new vector
  76608. */
  76609. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76610. /**
  76611. * Updates the given vector "result" from the starting index of the given array.
  76612. * @param array the array to pull values from
  76613. * @param offset the offset into the array to start at
  76614. * @param result the vector to store the result in
  76615. */
  76616. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76617. /**
  76618. * Updates the given vector "result" from the starting index of the given Float32Array.
  76619. * @param array the array to pull values from
  76620. * @param offset the offset into the array to start at
  76621. * @param result the vector to store the result in
  76622. */
  76623. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76624. /**
  76625. * Updates the given vector "result" coordinates from the given floats.
  76626. * @param x float to set from
  76627. * @param y float to set from
  76628. * @param z float to set from
  76629. * @param w float to set from
  76630. * @param result the vector to the floats in
  76631. */
  76632. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76633. /**
  76634. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76635. * @returns the new vector
  76636. */
  76637. static Zero(): Vector4;
  76638. /**
  76639. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76640. * @returns the new vector
  76641. */
  76642. static One(): Vector4;
  76643. /**
  76644. * Returns a new normalized Vector4 from the given one.
  76645. * @param vector the vector to normalize
  76646. * @returns the vector
  76647. */
  76648. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76649. /**
  76650. * Updates the given vector "result" from the normalization of the given one.
  76651. * @param vector the vector to normalize
  76652. * @param result the vector to store the result in
  76653. */
  76654. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76655. /**
  76656. * Returns a vector with the minimum values from the left and right vectors
  76657. * @param left left vector to minimize
  76658. * @param right right vector to minimize
  76659. * @returns a new vector with the minimum of the left and right vector values
  76660. */
  76661. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76662. /**
  76663. * Returns a vector with the maximum values from the left and right vectors
  76664. * @param left left vector to maximize
  76665. * @param right right vector to maximize
  76666. * @returns a new vector with the maximum of the left and right vector values
  76667. */
  76668. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76669. /**
  76670. * Returns the distance (float) between the vectors "value1" and "value2".
  76671. * @param value1 value to calulate the distance between
  76672. * @param value2 value to calulate the distance between
  76673. * @return the distance between the two vectors
  76674. */
  76675. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76676. /**
  76677. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76678. * @param value1 value to calulate the distance between
  76679. * @param value2 value to calulate the distance between
  76680. * @return the distance between the two vectors squared
  76681. */
  76682. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76683. /**
  76684. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  76685. * @param value1 value to calulate the center between
  76686. * @param value2 value to calulate the center between
  76687. * @return the center between the two vectors
  76688. */
  76689. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  76690. /**
  76691. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  76692. * This methods computes transformed normalized direction vectors only.
  76693. * @param vector the vector to transform
  76694. * @param transformation the transformation matrix to apply
  76695. * @returns the new vector
  76696. */
  76697. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  76698. /**
  76699. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  76700. * This methods computes transformed normalized direction vectors only.
  76701. * @param vector the vector to transform
  76702. * @param transformation the transformation matrix to apply
  76703. * @param result the vector to store the result in
  76704. */
  76705. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76706. /**
  76707. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  76708. * This methods computes transformed normalized direction vectors only.
  76709. * @param x value to transform
  76710. * @param y value to transform
  76711. * @param z value to transform
  76712. * @param w value to transform
  76713. * @param transformation the transformation matrix to apply
  76714. * @param result the vector to store the results in
  76715. */
  76716. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76717. /**
  76718. * Creates a new Vector4 from a Vector3
  76719. * @param source defines the source data
  76720. * @param w defines the 4th component (default is 0)
  76721. * @returns a new Vector4
  76722. */
  76723. static FromVector3(source: Vector3, w?: number): Vector4;
  76724. }
  76725. /**
  76726. * Class used to store quaternion data
  76727. * @see https://en.wikipedia.org/wiki/Quaternion
  76728. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76729. */
  76730. export class Quaternion {
  76731. /** defines the first component (0 by default) */
  76732. x: number;
  76733. /** defines the second component (0 by default) */
  76734. y: number;
  76735. /** defines the third component (0 by default) */
  76736. z: number;
  76737. /** defines the fourth component (1.0 by default) */
  76738. w: number;
  76739. /**
  76740. * Creates a new Quaternion from the given floats
  76741. * @param x defines the first component (0 by default)
  76742. * @param y defines the second component (0 by default)
  76743. * @param z defines the third component (0 by default)
  76744. * @param w defines the fourth component (1.0 by default)
  76745. */
  76746. constructor(
  76747. /** defines the first component (0 by default) */
  76748. x?: number,
  76749. /** defines the second component (0 by default) */
  76750. y?: number,
  76751. /** defines the third component (0 by default) */
  76752. z?: number,
  76753. /** defines the fourth component (1.0 by default) */
  76754. w?: number);
  76755. /**
  76756. * Gets a string representation for the current quaternion
  76757. * @returns a string with the Quaternion coordinates
  76758. */
  76759. toString(): string;
  76760. /**
  76761. * Gets the class name of the quaternion
  76762. * @returns the string "Quaternion"
  76763. */
  76764. getClassName(): string;
  76765. /**
  76766. * Gets a hash code for this quaternion
  76767. * @returns the quaternion hash code
  76768. */
  76769. getHashCode(): number;
  76770. /**
  76771. * Copy the quaternion to an array
  76772. * @returns a new array populated with 4 elements from the quaternion coordinates
  76773. */
  76774. asArray(): number[];
  76775. /**
  76776. * Check if two quaternions are equals
  76777. * @param otherQuaternion defines the second operand
  76778. * @return true if the current quaternion and the given one coordinates are strictly equals
  76779. */
  76780. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  76781. /**
  76782. * Gets a boolean if two quaternions are equals (using an epsilon value)
  76783. * @param otherQuaternion defines the other quaternion
  76784. * @param epsilon defines the minimal distance to consider equality
  76785. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  76786. */
  76787. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  76788. /**
  76789. * Clone the current quaternion
  76790. * @returns a new quaternion copied from the current one
  76791. */
  76792. clone(): Quaternion;
  76793. /**
  76794. * Copy a quaternion to the current one
  76795. * @param other defines the other quaternion
  76796. * @returns the updated current quaternion
  76797. */
  76798. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  76799. /**
  76800. * Updates the current quaternion with the given float coordinates
  76801. * @param x defines the x coordinate
  76802. * @param y defines the y coordinate
  76803. * @param z defines the z coordinate
  76804. * @param w defines the w coordinate
  76805. * @returns the updated current quaternion
  76806. */
  76807. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  76808. /**
  76809. * Updates the current quaternion from the given float coordinates
  76810. * @param x defines the x coordinate
  76811. * @param y defines the y coordinate
  76812. * @param z defines the z coordinate
  76813. * @param w defines the w coordinate
  76814. * @returns the updated current quaternion
  76815. */
  76816. set(x: number, y: number, z: number, w: number): Quaternion;
  76817. /**
  76818. * Adds two quaternions
  76819. * @param other defines the second operand
  76820. * @returns a new quaternion as the addition result of the given one and the current quaternion
  76821. */
  76822. add(other: DeepImmutable<Quaternion>): Quaternion;
  76823. /**
  76824. * Add a quaternion to the current one
  76825. * @param other defines the quaternion to add
  76826. * @returns the current quaternion
  76827. */
  76828. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  76829. /**
  76830. * Subtract two quaternions
  76831. * @param other defines the second operand
  76832. * @returns a new quaternion as the subtraction result of the given one from the current one
  76833. */
  76834. subtract(other: Quaternion): Quaternion;
  76835. /**
  76836. * Multiplies the current quaternion by a scale factor
  76837. * @param value defines the scale factor
  76838. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76839. */
  76840. scale(value: number): Quaternion;
  76841. /**
  76842. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76843. * @param scale defines the scale factor
  76844. * @param result defines the Quaternion object where to store the result
  76845. * @returns the unmodified current quaternion
  76846. */
  76847. scaleToRef(scale: number, result: Quaternion): Quaternion;
  76848. /**
  76849. * Multiplies in place the current quaternion by a scale factor
  76850. * @param value defines the scale factor
  76851. * @returns the current modified quaternion
  76852. */
  76853. scaleInPlace(value: number): Quaternion;
  76854. /**
  76855. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76856. * @param scale defines the scale factor
  76857. * @param result defines the Quaternion object where to store the result
  76858. * @returns the unmodified current quaternion
  76859. */
  76860. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  76861. /**
  76862. * Multiplies two quaternions
  76863. * @param q1 defines the second operand
  76864. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76865. */
  76866. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  76867. /**
  76868. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  76869. * @param q1 defines the second operand
  76870. * @param result defines the target quaternion
  76871. * @returns the current quaternion
  76872. */
  76873. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  76874. /**
  76875. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  76876. * @param q1 defines the second operand
  76877. * @returns the currentupdated quaternion
  76878. */
  76879. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  76880. /**
  76881. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  76882. * @param ref defines the target quaternion
  76883. * @returns the current quaternion
  76884. */
  76885. conjugateToRef(ref: Quaternion): Quaternion;
  76886. /**
  76887. * Conjugates in place (1-q) the current quaternion
  76888. * @returns the current updated quaternion
  76889. */
  76890. conjugateInPlace(): Quaternion;
  76891. /**
  76892. * Conjugates in place (1-q) the current quaternion
  76893. * @returns a new quaternion
  76894. */
  76895. conjugate(): Quaternion;
  76896. /**
  76897. * Gets length of current quaternion
  76898. * @returns the quaternion length (float)
  76899. */
  76900. length(): number;
  76901. /**
  76902. * Normalize in place the current quaternion
  76903. * @returns the current updated quaternion
  76904. */
  76905. normalize(): Quaternion;
  76906. /**
  76907. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  76908. * @param order is a reserved parameter and is ignore for now
  76909. * @returns a new Vector3 containing the Euler angles
  76910. */
  76911. toEulerAngles(order?: string): Vector3;
  76912. /**
  76913. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  76914. * @param result defines the vector which will be filled with the Euler angles
  76915. * @param order is a reserved parameter and is ignore for now
  76916. * @returns the current unchanged quaternion
  76917. */
  76918. toEulerAnglesToRef(result: Vector3): Quaternion;
  76919. /**
  76920. * Updates the given rotation matrix with the current quaternion values
  76921. * @param result defines the target matrix
  76922. * @returns the current unchanged quaternion
  76923. */
  76924. toRotationMatrix(result: Matrix): Quaternion;
  76925. /**
  76926. * Updates the current quaternion from the given rotation matrix values
  76927. * @param matrix defines the source matrix
  76928. * @returns the current updated quaternion
  76929. */
  76930. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76931. /**
  76932. * Creates a new quaternion from a rotation matrix
  76933. * @param matrix defines the source matrix
  76934. * @returns a new quaternion created from the given rotation matrix values
  76935. */
  76936. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76937. /**
  76938. * Updates the given quaternion with the given rotation matrix values
  76939. * @param matrix defines the source matrix
  76940. * @param result defines the target quaternion
  76941. */
  76942. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  76943. /**
  76944. * Returns the dot product (float) between the quaternions "left" and "right"
  76945. * @param left defines the left operand
  76946. * @param right defines the right operand
  76947. * @returns the dot product
  76948. */
  76949. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  76950. /**
  76951. * Checks if the two quaternions are close to each other
  76952. * @param quat0 defines the first quaternion to check
  76953. * @param quat1 defines the second quaternion to check
  76954. * @returns true if the two quaternions are close to each other
  76955. */
  76956. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  76957. /**
  76958. * Creates an empty quaternion
  76959. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  76960. */
  76961. static Zero(): Quaternion;
  76962. /**
  76963. * Inverse a given quaternion
  76964. * @param q defines the source quaternion
  76965. * @returns a new quaternion as the inverted current quaternion
  76966. */
  76967. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  76968. /**
  76969. * Inverse a given quaternion
  76970. * @param q defines the source quaternion
  76971. * @param result the quaternion the result will be stored in
  76972. * @returns the result quaternion
  76973. */
  76974. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  76975. /**
  76976. * Creates an identity quaternion
  76977. * @returns the identity quaternion
  76978. */
  76979. static Identity(): Quaternion;
  76980. /**
  76981. * Gets a boolean indicating if the given quaternion is identity
  76982. * @param quaternion defines the quaternion to check
  76983. * @returns true if the quaternion is identity
  76984. */
  76985. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  76986. /**
  76987. * Creates a quaternion from a rotation around an axis
  76988. * @param axis defines the axis to use
  76989. * @param angle defines the angle to use
  76990. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  76991. */
  76992. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  76993. /**
  76994. * Creates a rotation around an axis and stores it into the given quaternion
  76995. * @param axis defines the axis to use
  76996. * @param angle defines the angle to use
  76997. * @param result defines the target quaternion
  76998. * @returns the target quaternion
  76999. */
  77000. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  77001. /**
  77002. * Creates a new quaternion from data stored into an array
  77003. * @param array defines the data source
  77004. * @param offset defines the offset in the source array where the data starts
  77005. * @returns a new quaternion
  77006. */
  77007. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  77008. /**
  77009. * Create a quaternion from Euler rotation angles
  77010. * @param x Pitch
  77011. * @param y Yaw
  77012. * @param z Roll
  77013. * @returns the new Quaternion
  77014. */
  77015. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  77016. /**
  77017. * Updates a quaternion from Euler rotation angles
  77018. * @param x Pitch
  77019. * @param y Yaw
  77020. * @param z Roll
  77021. * @param result the quaternion to store the result
  77022. * @returns the updated quaternion
  77023. */
  77024. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  77025. /**
  77026. * Create a quaternion from Euler rotation vector
  77027. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77028. * @returns the new Quaternion
  77029. */
  77030. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  77031. /**
  77032. * Updates a quaternion from Euler rotation vector
  77033. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77034. * @param result the quaternion to store the result
  77035. * @returns the updated quaternion
  77036. */
  77037. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  77038. /**
  77039. * Creates a new quaternion from the given Euler float angles (y, x, z)
  77040. * @param yaw defines the rotation around Y axis
  77041. * @param pitch defines the rotation around X axis
  77042. * @param roll defines the rotation around Z axis
  77043. * @returns the new quaternion
  77044. */
  77045. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  77046. /**
  77047. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  77048. * @param yaw defines the rotation around Y axis
  77049. * @param pitch defines the rotation around X axis
  77050. * @param roll defines the rotation around Z axis
  77051. * @param result defines the target quaternion
  77052. */
  77053. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  77054. /**
  77055. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  77056. * @param alpha defines the rotation around first axis
  77057. * @param beta defines the rotation around second axis
  77058. * @param gamma defines the rotation around third axis
  77059. * @returns the new quaternion
  77060. */
  77061. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  77062. /**
  77063. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  77064. * @param alpha defines the rotation around first axis
  77065. * @param beta defines the rotation around second axis
  77066. * @param gamma defines the rotation around third axis
  77067. * @param result defines the target quaternion
  77068. */
  77069. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  77070. /**
  77071. * 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)
  77072. * @param axis1 defines the first axis
  77073. * @param axis2 defines the second axis
  77074. * @param axis3 defines the third axis
  77075. * @returns the new quaternion
  77076. */
  77077. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  77078. /**
  77079. * 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
  77080. * @param axis1 defines the first axis
  77081. * @param axis2 defines the second axis
  77082. * @param axis3 defines the third axis
  77083. * @param ref defines the target quaternion
  77084. */
  77085. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  77086. /**
  77087. * Interpolates between two quaternions
  77088. * @param left defines first quaternion
  77089. * @param right defines second quaternion
  77090. * @param amount defines the gradient to use
  77091. * @returns the new interpolated quaternion
  77092. */
  77093. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77094. /**
  77095. * Interpolates between two quaternions and stores it into a target quaternion
  77096. * @param left defines first quaternion
  77097. * @param right defines second quaternion
  77098. * @param amount defines the gradient to use
  77099. * @param result defines the target quaternion
  77100. */
  77101. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  77102. /**
  77103. * Interpolate between two quaternions using Hermite interpolation
  77104. * @param value1 defines first quaternion
  77105. * @param tangent1 defines the incoming tangent
  77106. * @param value2 defines second quaternion
  77107. * @param tangent2 defines the outgoing tangent
  77108. * @param amount defines the target quaternion
  77109. * @returns the new interpolated quaternion
  77110. */
  77111. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77112. }
  77113. /**
  77114. * Class used to store matrix data (4x4)
  77115. */
  77116. export class Matrix {
  77117. private static _updateFlagSeed;
  77118. private static _identityReadOnly;
  77119. private _isIdentity;
  77120. private _isIdentityDirty;
  77121. private _isIdentity3x2;
  77122. private _isIdentity3x2Dirty;
  77123. /**
  77124. * Gets the update flag of the matrix which is an unique number for the matrix.
  77125. * It will be incremented every time the matrix data change.
  77126. * You can use it to speed the comparison between two versions of the same matrix.
  77127. */
  77128. updateFlag: number;
  77129. private readonly _m;
  77130. /**
  77131. * Gets the internal data of the matrix
  77132. */
  77133. get m(): DeepImmutable<Float32Array>;
  77134. /** @hidden */
  77135. _markAsUpdated(): void;
  77136. /** @hidden */
  77137. private _updateIdentityStatus;
  77138. /**
  77139. * Creates an empty matrix (filled with zeros)
  77140. */
  77141. constructor();
  77142. /**
  77143. * Check if the current matrix is identity
  77144. * @returns true is the matrix is the identity matrix
  77145. */
  77146. isIdentity(): boolean;
  77147. /**
  77148. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  77149. * @returns true is the matrix is the identity matrix
  77150. */
  77151. isIdentityAs3x2(): boolean;
  77152. /**
  77153. * Gets the determinant of the matrix
  77154. * @returns the matrix determinant
  77155. */
  77156. determinant(): number;
  77157. /**
  77158. * Returns the matrix as a Float32Array
  77159. * @returns the matrix underlying array
  77160. */
  77161. toArray(): DeepImmutable<Float32Array>;
  77162. /**
  77163. * Returns the matrix as a Float32Array
  77164. * @returns the matrix underlying array.
  77165. */
  77166. asArray(): DeepImmutable<Float32Array>;
  77167. /**
  77168. * Inverts the current matrix in place
  77169. * @returns the current inverted matrix
  77170. */
  77171. invert(): Matrix;
  77172. /**
  77173. * Sets all the matrix elements to zero
  77174. * @returns the current matrix
  77175. */
  77176. reset(): Matrix;
  77177. /**
  77178. * Adds the current matrix with a second one
  77179. * @param other defines the matrix to add
  77180. * @returns a new matrix as the addition of the current matrix and the given one
  77181. */
  77182. add(other: DeepImmutable<Matrix>): Matrix;
  77183. /**
  77184. * Sets the given matrix "result" to the addition of the current matrix and the given one
  77185. * @param other defines the matrix to add
  77186. * @param result defines the target matrix
  77187. * @returns the current matrix
  77188. */
  77189. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77190. /**
  77191. * Adds in place the given matrix to the current matrix
  77192. * @param other defines the second operand
  77193. * @returns the current updated matrix
  77194. */
  77195. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  77196. /**
  77197. * Sets the given matrix to the current inverted Matrix
  77198. * @param other defines the target matrix
  77199. * @returns the unmodified current matrix
  77200. */
  77201. invertToRef(other: Matrix): Matrix;
  77202. /**
  77203. * add a value at the specified position in the current Matrix
  77204. * @param index the index of the value within the matrix. between 0 and 15.
  77205. * @param value the value to be added
  77206. * @returns the current updated matrix
  77207. */
  77208. addAtIndex(index: number, value: number): Matrix;
  77209. /**
  77210. * mutiply the specified position in the current Matrix by a value
  77211. * @param index the index of the value within the matrix. between 0 and 15.
  77212. * @param value the value to be added
  77213. * @returns the current updated matrix
  77214. */
  77215. multiplyAtIndex(index: number, value: number): Matrix;
  77216. /**
  77217. * Inserts the translation vector (using 3 floats) in the current matrix
  77218. * @param x defines the 1st component of the translation
  77219. * @param y defines the 2nd component of the translation
  77220. * @param z defines the 3rd component of the translation
  77221. * @returns the current updated matrix
  77222. */
  77223. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77224. /**
  77225. * Adds the translation vector (using 3 floats) in the current matrix
  77226. * @param x defines the 1st component of the translation
  77227. * @param y defines the 2nd component of the translation
  77228. * @param z defines the 3rd component of the translation
  77229. * @returns the current updated matrix
  77230. */
  77231. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77232. /**
  77233. * Inserts the translation vector in the current matrix
  77234. * @param vector3 defines the translation to insert
  77235. * @returns the current updated matrix
  77236. */
  77237. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  77238. /**
  77239. * Gets the translation value of the current matrix
  77240. * @returns a new Vector3 as the extracted translation from the matrix
  77241. */
  77242. getTranslation(): Vector3;
  77243. /**
  77244. * Fill a Vector3 with the extracted translation from the matrix
  77245. * @param result defines the Vector3 where to store the translation
  77246. * @returns the current matrix
  77247. */
  77248. getTranslationToRef(result: Vector3): Matrix;
  77249. /**
  77250. * Remove rotation and scaling part from the matrix
  77251. * @returns the updated matrix
  77252. */
  77253. removeRotationAndScaling(): Matrix;
  77254. /**
  77255. * Multiply two matrices
  77256. * @param other defines the second operand
  77257. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  77258. */
  77259. multiply(other: DeepImmutable<Matrix>): Matrix;
  77260. /**
  77261. * Copy the current matrix from the given one
  77262. * @param other defines the source matrix
  77263. * @returns the current updated matrix
  77264. */
  77265. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  77266. /**
  77267. * Populates the given array from the starting index with the current matrix values
  77268. * @param array defines the target array
  77269. * @param offset defines the offset in the target array where to start storing values
  77270. * @returns the current matrix
  77271. */
  77272. copyToArray(array: Float32Array, offset?: number): Matrix;
  77273. /**
  77274. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  77275. * @param other defines the second operand
  77276. * @param result defines the matrix where to store the multiplication
  77277. * @returns the current matrix
  77278. */
  77279. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77280. /**
  77281. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  77282. * @param other defines the second operand
  77283. * @param result defines the array where to store the multiplication
  77284. * @param offset defines the offset in the target array where to start storing values
  77285. * @returns the current matrix
  77286. */
  77287. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  77288. /**
  77289. * Check equality between this matrix and a second one
  77290. * @param value defines the second matrix to compare
  77291. * @returns true is the current matrix and the given one values are strictly equal
  77292. */
  77293. equals(value: DeepImmutable<Matrix>): boolean;
  77294. /**
  77295. * Clone the current matrix
  77296. * @returns a new matrix from the current matrix
  77297. */
  77298. clone(): Matrix;
  77299. /**
  77300. * Returns the name of the current matrix class
  77301. * @returns the string "Matrix"
  77302. */
  77303. getClassName(): string;
  77304. /**
  77305. * Gets the hash code of the current matrix
  77306. * @returns the hash code
  77307. */
  77308. getHashCode(): number;
  77309. /**
  77310. * Decomposes the current Matrix into a translation, rotation and scaling components
  77311. * @param scale defines the scale vector3 given as a reference to update
  77312. * @param rotation defines the rotation quaternion given as a reference to update
  77313. * @param translation defines the translation vector3 given as a reference to update
  77314. * @returns true if operation was successful
  77315. */
  77316. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  77317. /**
  77318. * Gets specific row of the matrix
  77319. * @param index defines the number of the row to get
  77320. * @returns the index-th row of the current matrix as a new Vector4
  77321. */
  77322. getRow(index: number): Nullable<Vector4>;
  77323. /**
  77324. * Sets the index-th row of the current matrix to the vector4 values
  77325. * @param index defines the number of the row to set
  77326. * @param row defines the target vector4
  77327. * @returns the updated current matrix
  77328. */
  77329. setRow(index: number, row: Vector4): Matrix;
  77330. /**
  77331. * Compute the transpose of the matrix
  77332. * @returns the new transposed matrix
  77333. */
  77334. transpose(): Matrix;
  77335. /**
  77336. * Compute the transpose of the matrix and store it in a given matrix
  77337. * @param result defines the target matrix
  77338. * @returns the current matrix
  77339. */
  77340. transposeToRef(result: Matrix): Matrix;
  77341. /**
  77342. * Sets the index-th row of the current matrix with the given 4 x float values
  77343. * @param index defines the row index
  77344. * @param x defines the x component to set
  77345. * @param y defines the y component to set
  77346. * @param z defines the z component to set
  77347. * @param w defines the w component to set
  77348. * @returns the updated current matrix
  77349. */
  77350. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  77351. /**
  77352. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  77353. * @param scale defines the scale factor
  77354. * @returns a new matrix
  77355. */
  77356. scale(scale: number): Matrix;
  77357. /**
  77358. * Scale the current matrix values by a factor to a given result matrix
  77359. * @param scale defines the scale factor
  77360. * @param result defines the matrix to store the result
  77361. * @returns the current matrix
  77362. */
  77363. scaleToRef(scale: number, result: Matrix): Matrix;
  77364. /**
  77365. * Scale the current matrix values by a factor and add the result to a given matrix
  77366. * @param scale defines the scale factor
  77367. * @param result defines the Matrix to store the result
  77368. * @returns the current matrix
  77369. */
  77370. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  77371. /**
  77372. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  77373. * @param ref matrix to store the result
  77374. */
  77375. toNormalMatrix(ref: Matrix): void;
  77376. /**
  77377. * Gets only rotation part of the current matrix
  77378. * @returns a new matrix sets to the extracted rotation matrix from the current one
  77379. */
  77380. getRotationMatrix(): Matrix;
  77381. /**
  77382. * Extracts the rotation matrix from the current one and sets it as the given "result"
  77383. * @param result defines the target matrix to store data to
  77384. * @returns the current matrix
  77385. */
  77386. getRotationMatrixToRef(result: Matrix): Matrix;
  77387. /**
  77388. * Toggles model matrix from being right handed to left handed in place and vice versa
  77389. */
  77390. toggleModelMatrixHandInPlace(): void;
  77391. /**
  77392. * Toggles projection matrix from being right handed to left handed in place and vice versa
  77393. */
  77394. toggleProjectionMatrixHandInPlace(): void;
  77395. /**
  77396. * Creates a matrix from an array
  77397. * @param array defines the source array
  77398. * @param offset defines an offset in the source array
  77399. * @returns a new Matrix set from the starting index of the given array
  77400. */
  77401. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77402. /**
  77403. * Copy the content of an array into a given matrix
  77404. * @param array defines the source array
  77405. * @param offset defines an offset in the source array
  77406. * @param result defines the target matrix
  77407. */
  77408. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77409. /**
  77410. * Stores an array into a matrix after having multiplied each component by a given factor
  77411. * @param array defines the source array
  77412. * @param offset defines the offset in the source array
  77413. * @param scale defines the scaling factor
  77414. * @param result defines the target matrix
  77415. */
  77416. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77417. /**
  77418. * Gets an identity matrix that must not be updated
  77419. */
  77420. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77421. /**
  77422. * Stores a list of values (16) inside a given matrix
  77423. * @param initialM11 defines 1st value of 1st row
  77424. * @param initialM12 defines 2nd value of 1st row
  77425. * @param initialM13 defines 3rd value of 1st row
  77426. * @param initialM14 defines 4th value of 1st row
  77427. * @param initialM21 defines 1st value of 2nd row
  77428. * @param initialM22 defines 2nd value of 2nd row
  77429. * @param initialM23 defines 3rd value of 2nd row
  77430. * @param initialM24 defines 4th value of 2nd row
  77431. * @param initialM31 defines 1st value of 3rd row
  77432. * @param initialM32 defines 2nd value of 3rd row
  77433. * @param initialM33 defines 3rd value of 3rd row
  77434. * @param initialM34 defines 4th value of 3rd row
  77435. * @param initialM41 defines 1st value of 4th row
  77436. * @param initialM42 defines 2nd value of 4th row
  77437. * @param initialM43 defines 3rd value of 4th row
  77438. * @param initialM44 defines 4th value of 4th row
  77439. * @param result defines the target matrix
  77440. */
  77441. 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;
  77442. /**
  77443. * Creates new matrix from a list of values (16)
  77444. * @param initialM11 defines 1st value of 1st row
  77445. * @param initialM12 defines 2nd value of 1st row
  77446. * @param initialM13 defines 3rd value of 1st row
  77447. * @param initialM14 defines 4th value of 1st row
  77448. * @param initialM21 defines 1st value of 2nd row
  77449. * @param initialM22 defines 2nd value of 2nd row
  77450. * @param initialM23 defines 3rd value of 2nd row
  77451. * @param initialM24 defines 4th value of 2nd row
  77452. * @param initialM31 defines 1st value of 3rd row
  77453. * @param initialM32 defines 2nd value of 3rd row
  77454. * @param initialM33 defines 3rd value of 3rd row
  77455. * @param initialM34 defines 4th value of 3rd row
  77456. * @param initialM41 defines 1st value of 4th row
  77457. * @param initialM42 defines 2nd value of 4th row
  77458. * @param initialM43 defines 3rd value of 4th row
  77459. * @param initialM44 defines 4th value of 4th row
  77460. * @returns the new matrix
  77461. */
  77462. 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;
  77463. /**
  77464. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77465. * @param scale defines the scale vector3
  77466. * @param rotation defines the rotation quaternion
  77467. * @param translation defines the translation vector3
  77468. * @returns a new matrix
  77469. */
  77470. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77471. /**
  77472. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77473. * @param scale defines the scale vector3
  77474. * @param rotation defines the rotation quaternion
  77475. * @param translation defines the translation vector3
  77476. * @param result defines the target matrix
  77477. */
  77478. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77479. /**
  77480. * Creates a new identity matrix
  77481. * @returns a new identity matrix
  77482. */
  77483. static Identity(): Matrix;
  77484. /**
  77485. * Creates a new identity matrix and stores the result in a given matrix
  77486. * @param result defines the target matrix
  77487. */
  77488. static IdentityToRef(result: Matrix): void;
  77489. /**
  77490. * Creates a new zero matrix
  77491. * @returns a new zero matrix
  77492. */
  77493. static Zero(): Matrix;
  77494. /**
  77495. * Creates a new rotation matrix for "angle" radians around the X axis
  77496. * @param angle defines the angle (in radians) to use
  77497. * @return the new matrix
  77498. */
  77499. static RotationX(angle: number): Matrix;
  77500. /**
  77501. * Creates a new matrix as the invert of a given matrix
  77502. * @param source defines the source matrix
  77503. * @returns the new matrix
  77504. */
  77505. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77506. /**
  77507. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77508. * @param angle defines the angle (in radians) to use
  77509. * @param result defines the target matrix
  77510. */
  77511. static RotationXToRef(angle: number, result: Matrix): void;
  77512. /**
  77513. * Creates a new rotation matrix for "angle" radians around the Y axis
  77514. * @param angle defines the angle (in radians) to use
  77515. * @return the new matrix
  77516. */
  77517. static RotationY(angle: number): Matrix;
  77518. /**
  77519. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77520. * @param angle defines the angle (in radians) to use
  77521. * @param result defines the target matrix
  77522. */
  77523. static RotationYToRef(angle: number, result: Matrix): void;
  77524. /**
  77525. * Creates a new rotation matrix for "angle" radians around the Z axis
  77526. * @param angle defines the angle (in radians) to use
  77527. * @return the new matrix
  77528. */
  77529. static RotationZ(angle: number): Matrix;
  77530. /**
  77531. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77532. * @param angle defines the angle (in radians) to use
  77533. * @param result defines the target matrix
  77534. */
  77535. static RotationZToRef(angle: number, result: Matrix): void;
  77536. /**
  77537. * Creates a new rotation matrix for "angle" radians around the given axis
  77538. * @param axis defines the axis to use
  77539. * @param angle defines the angle (in radians) to use
  77540. * @return the new matrix
  77541. */
  77542. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77543. /**
  77544. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77545. * @param axis defines the axis to use
  77546. * @param angle defines the angle (in radians) to use
  77547. * @param result defines the target matrix
  77548. */
  77549. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77550. /**
  77551. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77552. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77553. * @param from defines the vector to align
  77554. * @param to defines the vector to align to
  77555. * @param result defines the target matrix
  77556. */
  77557. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77558. /**
  77559. * Creates a rotation matrix
  77560. * @param yaw defines the yaw angle in radians (Y axis)
  77561. * @param pitch defines the pitch angle in radians (X axis)
  77562. * @param roll defines the roll angle in radians (X axis)
  77563. * @returns the new rotation matrix
  77564. */
  77565. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77566. /**
  77567. * Creates a rotation matrix and stores it in a given matrix
  77568. * @param yaw defines the yaw angle in radians (Y axis)
  77569. * @param pitch defines the pitch angle in radians (X axis)
  77570. * @param roll defines the roll angle in radians (X axis)
  77571. * @param result defines the target matrix
  77572. */
  77573. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  77574. /**
  77575. * Creates a scaling matrix
  77576. * @param x defines the scale factor on X axis
  77577. * @param y defines the scale factor on Y axis
  77578. * @param z defines the scale factor on Z axis
  77579. * @returns the new matrix
  77580. */
  77581. static Scaling(x: number, y: number, z: number): Matrix;
  77582. /**
  77583. * Creates a scaling matrix and stores it in a given matrix
  77584. * @param x defines the scale factor on X axis
  77585. * @param y defines the scale factor on Y axis
  77586. * @param z defines the scale factor on Z axis
  77587. * @param result defines the target matrix
  77588. */
  77589. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  77590. /**
  77591. * Creates a translation matrix
  77592. * @param x defines the translation on X axis
  77593. * @param y defines the translation on Y axis
  77594. * @param z defines the translationon Z axis
  77595. * @returns the new matrix
  77596. */
  77597. static Translation(x: number, y: number, z: number): Matrix;
  77598. /**
  77599. * Creates a translation matrix and stores it in a given matrix
  77600. * @param x defines the translation on X axis
  77601. * @param y defines the translation on Y axis
  77602. * @param z defines the translationon Z axis
  77603. * @param result defines the target matrix
  77604. */
  77605. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  77606. /**
  77607. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77608. * @param startValue defines the start value
  77609. * @param endValue defines the end value
  77610. * @param gradient defines the gradient factor
  77611. * @returns the new matrix
  77612. */
  77613. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77614. /**
  77615. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77616. * @param startValue defines the start value
  77617. * @param endValue defines the end value
  77618. * @param gradient defines the gradient factor
  77619. * @param result defines the Matrix object where to store data
  77620. */
  77621. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77622. /**
  77623. * Builds a new matrix whose values are computed by:
  77624. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77625. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77626. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77627. * @param startValue defines the first matrix
  77628. * @param endValue defines the second matrix
  77629. * @param gradient defines the gradient between the two matrices
  77630. * @returns the new matrix
  77631. */
  77632. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77633. /**
  77634. * Update a matrix to values which are computed by:
  77635. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77636. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77637. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77638. * @param startValue defines the first matrix
  77639. * @param endValue defines the second matrix
  77640. * @param gradient defines the gradient between the two matrices
  77641. * @param result defines the target matrix
  77642. */
  77643. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77644. /**
  77645. * 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"
  77646. * This function works in left handed mode
  77647. * @param eye defines the final position of the entity
  77648. * @param target defines where the entity should look at
  77649. * @param up defines the up vector for the entity
  77650. * @returns the new matrix
  77651. */
  77652. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77653. /**
  77654. * 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".
  77655. * This function works in left handed mode
  77656. * @param eye defines the final position of the entity
  77657. * @param target defines where the entity should look at
  77658. * @param up defines the up vector for the entity
  77659. * @param result defines the target matrix
  77660. */
  77661. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77662. /**
  77663. * 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"
  77664. * This function works in right handed mode
  77665. * @param eye defines the final position of the entity
  77666. * @param target defines where the entity should look at
  77667. * @param up defines the up vector for the entity
  77668. * @returns the new matrix
  77669. */
  77670. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77671. /**
  77672. * 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".
  77673. * This function works in right handed mode
  77674. * @param eye defines the final position of the entity
  77675. * @param target defines where the entity should look at
  77676. * @param up defines the up vector for the entity
  77677. * @param result defines the target matrix
  77678. */
  77679. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77680. /**
  77681. * Create a left-handed orthographic projection matrix
  77682. * @param width defines the viewport width
  77683. * @param height defines the viewport height
  77684. * @param znear defines the near clip plane
  77685. * @param zfar defines the far clip plane
  77686. * @returns a new matrix as a left-handed orthographic projection matrix
  77687. */
  77688. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77689. /**
  77690. * Store a left-handed orthographic projection to a given matrix
  77691. * @param width defines the viewport width
  77692. * @param height defines the viewport height
  77693. * @param znear defines the near clip plane
  77694. * @param zfar defines the far clip plane
  77695. * @param result defines the target matrix
  77696. */
  77697. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  77698. /**
  77699. * Create a left-handed orthographic projection matrix
  77700. * @param left defines the viewport left coordinate
  77701. * @param right defines the viewport right coordinate
  77702. * @param bottom defines the viewport bottom coordinate
  77703. * @param top defines the viewport top coordinate
  77704. * @param znear defines the near clip plane
  77705. * @param zfar defines the far clip plane
  77706. * @returns a new matrix as a left-handed orthographic projection matrix
  77707. */
  77708. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77709. /**
  77710. * Stores a left-handed orthographic projection into a given matrix
  77711. * @param left defines the viewport left coordinate
  77712. * @param right defines the viewport right coordinate
  77713. * @param bottom defines the viewport bottom coordinate
  77714. * @param top defines the viewport top coordinate
  77715. * @param znear defines the near clip plane
  77716. * @param zfar defines the far clip plane
  77717. * @param result defines the target matrix
  77718. */
  77719. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77720. /**
  77721. * Creates a right-handed orthographic projection matrix
  77722. * @param left defines the viewport left coordinate
  77723. * @param right defines the viewport right coordinate
  77724. * @param bottom defines the viewport bottom coordinate
  77725. * @param top defines the viewport top coordinate
  77726. * @param znear defines the near clip plane
  77727. * @param zfar defines the far clip plane
  77728. * @returns a new matrix as a right-handed orthographic projection matrix
  77729. */
  77730. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77731. /**
  77732. * Stores a right-handed orthographic projection into a given matrix
  77733. * @param left defines the viewport left coordinate
  77734. * @param right defines the viewport right coordinate
  77735. * @param bottom defines the viewport bottom coordinate
  77736. * @param top defines the viewport top coordinate
  77737. * @param znear defines the near clip plane
  77738. * @param zfar defines the far clip plane
  77739. * @param result defines the target matrix
  77740. */
  77741. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77742. /**
  77743. * Creates a left-handed perspective projection matrix
  77744. * @param width defines the viewport width
  77745. * @param height defines the viewport height
  77746. * @param znear defines the near clip plane
  77747. * @param zfar defines the far clip plane
  77748. * @returns a new matrix as a left-handed perspective projection matrix
  77749. */
  77750. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77751. /**
  77752. * Creates a left-handed perspective projection matrix
  77753. * @param fov defines the horizontal field of view
  77754. * @param aspect defines the aspect ratio
  77755. * @param znear defines the near clip plane
  77756. * @param zfar defines the far clip plane
  77757. * @returns a new matrix as a left-handed perspective projection matrix
  77758. */
  77759. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77760. /**
  77761. * Stores a left-handed perspective projection into a given matrix
  77762. * @param fov defines the horizontal field of view
  77763. * @param aspect defines the aspect ratio
  77764. * @param znear defines the near clip plane
  77765. * @param zfar defines the far clip plane
  77766. * @param result defines the target matrix
  77767. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77768. */
  77769. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77770. /**
  77771. * Stores a left-handed perspective projection into a given matrix with depth reversed
  77772. * @param fov defines the horizontal field of view
  77773. * @param aspect defines the aspect ratio
  77774. * @param znear defines the near clip plane
  77775. * @param zfar not used as infinity is used as far clip
  77776. * @param result defines the target matrix
  77777. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77778. */
  77779. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77780. /**
  77781. * Creates a right-handed perspective projection matrix
  77782. * @param fov defines the horizontal field of view
  77783. * @param aspect defines the aspect ratio
  77784. * @param znear defines the near clip plane
  77785. * @param zfar defines the far clip plane
  77786. * @returns a new matrix as a right-handed perspective projection matrix
  77787. */
  77788. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77789. /**
  77790. * Stores a right-handed perspective projection into a given matrix
  77791. * @param fov defines the horizontal field of view
  77792. * @param aspect defines the aspect ratio
  77793. * @param znear defines the near clip plane
  77794. * @param zfar defines the far clip plane
  77795. * @param result defines the target matrix
  77796. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77797. */
  77798. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77799. /**
  77800. * Stores a right-handed perspective projection into a given matrix
  77801. * @param fov defines the horizontal field of view
  77802. * @param aspect defines the aspect ratio
  77803. * @param znear defines the near clip plane
  77804. * @param zfar not used as infinity is used as far clip
  77805. * @param result defines the target matrix
  77806. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77807. */
  77808. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77809. /**
  77810. * Stores a perspective projection for WebVR info a given matrix
  77811. * @param fov defines the field of view
  77812. * @param znear defines the near clip plane
  77813. * @param zfar defines the far clip plane
  77814. * @param result defines the target matrix
  77815. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  77816. */
  77817. static PerspectiveFovWebVRToRef(fov: {
  77818. upDegrees: number;
  77819. downDegrees: number;
  77820. leftDegrees: number;
  77821. rightDegrees: number;
  77822. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  77823. /**
  77824. * Computes a complete transformation matrix
  77825. * @param viewport defines the viewport to use
  77826. * @param world defines the world matrix
  77827. * @param view defines the view matrix
  77828. * @param projection defines the projection matrix
  77829. * @param zmin defines the near clip plane
  77830. * @param zmax defines the far clip plane
  77831. * @returns the transformation matrix
  77832. */
  77833. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  77834. /**
  77835. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  77836. * @param matrix defines the matrix to use
  77837. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  77838. */
  77839. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  77840. /**
  77841. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  77842. * @param matrix defines the matrix to use
  77843. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  77844. */
  77845. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  77846. /**
  77847. * Compute the transpose of a given matrix
  77848. * @param matrix defines the matrix to transpose
  77849. * @returns the new matrix
  77850. */
  77851. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  77852. /**
  77853. * Compute the transpose of a matrix and store it in a target matrix
  77854. * @param matrix defines the matrix to transpose
  77855. * @param result defines the target matrix
  77856. */
  77857. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  77858. /**
  77859. * Computes a reflection matrix from a plane
  77860. * @param plane defines the reflection plane
  77861. * @returns a new matrix
  77862. */
  77863. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  77864. /**
  77865. * Computes a reflection matrix from a plane
  77866. * @param plane defines the reflection plane
  77867. * @param result defines the target matrix
  77868. */
  77869. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  77870. /**
  77871. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  77872. * @param xaxis defines the value of the 1st axis
  77873. * @param yaxis defines the value of the 2nd axis
  77874. * @param zaxis defines the value of the 3rd axis
  77875. * @param result defines the target matrix
  77876. */
  77877. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  77878. /**
  77879. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  77880. * @param quat defines the quaternion to use
  77881. * @param result defines the target matrix
  77882. */
  77883. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  77884. }
  77885. /**
  77886. * @hidden
  77887. */
  77888. export class TmpVectors {
  77889. static Vector2: Vector2[];
  77890. static Vector3: Vector3[];
  77891. static Vector4: Vector4[];
  77892. static Quaternion: Quaternion[];
  77893. static Matrix: Matrix[];
  77894. }
  77895. }
  77896. declare module BABYLON {
  77897. /**
  77898. * Defines potential orientation for back face culling
  77899. */
  77900. export enum Orientation {
  77901. /**
  77902. * Clockwise
  77903. */
  77904. CW = 0,
  77905. /** Counter clockwise */
  77906. CCW = 1
  77907. }
  77908. /** Class used to represent a Bezier curve */
  77909. export class BezierCurve {
  77910. /**
  77911. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77912. * @param t defines the time
  77913. * @param x1 defines the left coordinate on X axis
  77914. * @param y1 defines the left coordinate on Y axis
  77915. * @param x2 defines the right coordinate on X axis
  77916. * @param y2 defines the right coordinate on Y axis
  77917. * @returns the interpolated value
  77918. */
  77919. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  77920. }
  77921. /**
  77922. * Defines angle representation
  77923. */
  77924. export class Angle {
  77925. private _radians;
  77926. /**
  77927. * Creates an Angle object of "radians" radians (float).
  77928. * @param radians the angle in radians
  77929. */
  77930. constructor(radians: number);
  77931. /**
  77932. * Get value in degrees
  77933. * @returns the Angle value in degrees (float)
  77934. */
  77935. degrees(): number;
  77936. /**
  77937. * Get value in radians
  77938. * @returns the Angle value in radians (float)
  77939. */
  77940. radians(): number;
  77941. /**
  77942. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  77943. * @param a defines first vector
  77944. * @param b defines second vector
  77945. * @returns a new Angle
  77946. */
  77947. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  77948. /**
  77949. * Gets a new Angle object from the given float in radians
  77950. * @param radians defines the angle value in radians
  77951. * @returns a new Angle
  77952. */
  77953. static FromRadians(radians: number): Angle;
  77954. /**
  77955. * Gets a new Angle object from the given float in degrees
  77956. * @param degrees defines the angle value in degrees
  77957. * @returns a new Angle
  77958. */
  77959. static FromDegrees(degrees: number): Angle;
  77960. }
  77961. /**
  77962. * This represents an arc in a 2d space.
  77963. */
  77964. export class Arc2 {
  77965. /** Defines the start point of the arc */
  77966. startPoint: Vector2;
  77967. /** Defines the mid point of the arc */
  77968. midPoint: Vector2;
  77969. /** Defines the end point of the arc */
  77970. endPoint: Vector2;
  77971. /**
  77972. * Defines the center point of the arc.
  77973. */
  77974. centerPoint: Vector2;
  77975. /**
  77976. * Defines the radius of the arc.
  77977. */
  77978. radius: number;
  77979. /**
  77980. * Defines the angle of the arc (from mid point to end point).
  77981. */
  77982. angle: Angle;
  77983. /**
  77984. * Defines the start angle of the arc (from start point to middle point).
  77985. */
  77986. startAngle: Angle;
  77987. /**
  77988. * Defines the orientation of the arc (clock wise/counter clock wise).
  77989. */
  77990. orientation: Orientation;
  77991. /**
  77992. * Creates an Arc object from the three given points : start, middle and end.
  77993. * @param startPoint Defines the start point of the arc
  77994. * @param midPoint Defines the midlle point of the arc
  77995. * @param endPoint Defines the end point of the arc
  77996. */
  77997. constructor(
  77998. /** Defines the start point of the arc */
  77999. startPoint: Vector2,
  78000. /** Defines the mid point of the arc */
  78001. midPoint: Vector2,
  78002. /** Defines the end point of the arc */
  78003. endPoint: Vector2);
  78004. }
  78005. /**
  78006. * Represents a 2D path made up of multiple 2D points
  78007. */
  78008. export class Path2 {
  78009. private _points;
  78010. private _length;
  78011. /**
  78012. * If the path start and end point are the same
  78013. */
  78014. closed: boolean;
  78015. /**
  78016. * Creates a Path2 object from the starting 2D coordinates x and y.
  78017. * @param x the starting points x value
  78018. * @param y the starting points y value
  78019. */
  78020. constructor(x: number, y: number);
  78021. /**
  78022. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  78023. * @param x the added points x value
  78024. * @param y the added points y value
  78025. * @returns the updated Path2.
  78026. */
  78027. addLineTo(x: number, y: number): Path2;
  78028. /**
  78029. * 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.
  78030. * @param midX middle point x value
  78031. * @param midY middle point y value
  78032. * @param endX end point x value
  78033. * @param endY end point y value
  78034. * @param numberOfSegments (default: 36)
  78035. * @returns the updated Path2.
  78036. */
  78037. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  78038. /**
  78039. * Closes the Path2.
  78040. * @returns the Path2.
  78041. */
  78042. close(): Path2;
  78043. /**
  78044. * Gets the sum of the distance between each sequential point in the path
  78045. * @returns the Path2 total length (float).
  78046. */
  78047. length(): number;
  78048. /**
  78049. * Gets the points which construct the path
  78050. * @returns the Path2 internal array of points.
  78051. */
  78052. getPoints(): Vector2[];
  78053. /**
  78054. * Retreives the point at the distance aways from the starting point
  78055. * @param normalizedLengthPosition the length along the path to retreive the point from
  78056. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  78057. */
  78058. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  78059. /**
  78060. * Creates a new path starting from an x and y position
  78061. * @param x starting x value
  78062. * @param y starting y value
  78063. * @returns a new Path2 starting at the coordinates (x, y).
  78064. */
  78065. static StartingAt(x: number, y: number): Path2;
  78066. }
  78067. /**
  78068. * Represents a 3D path made up of multiple 3D points
  78069. */
  78070. export class Path3D {
  78071. /**
  78072. * an array of Vector3, the curve axis of the Path3D
  78073. */
  78074. path: Vector3[];
  78075. private _curve;
  78076. private _distances;
  78077. private _tangents;
  78078. private _normals;
  78079. private _binormals;
  78080. private _raw;
  78081. private _alignTangentsWithPath;
  78082. private readonly _pointAtData;
  78083. /**
  78084. * new Path3D(path, normal, raw)
  78085. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  78086. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  78087. * @param path an array of Vector3, the curve axis of the Path3D
  78088. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  78089. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  78090. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  78091. */
  78092. constructor(
  78093. /**
  78094. * an array of Vector3, the curve axis of the Path3D
  78095. */
  78096. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  78097. /**
  78098. * Returns the Path3D array of successive Vector3 designing its curve.
  78099. * @returns the Path3D array of successive Vector3 designing its curve.
  78100. */
  78101. getCurve(): Vector3[];
  78102. /**
  78103. * Returns the Path3D array of successive Vector3 designing its curve.
  78104. * @returns the Path3D array of successive Vector3 designing its curve.
  78105. */
  78106. getPoints(): Vector3[];
  78107. /**
  78108. * @returns the computed length (float) of the path.
  78109. */
  78110. length(): number;
  78111. /**
  78112. * Returns an array populated with tangent vectors on each Path3D curve point.
  78113. * @returns an array populated with tangent vectors on each Path3D curve point.
  78114. */
  78115. getTangents(): Vector3[];
  78116. /**
  78117. * Returns an array populated with normal vectors on each Path3D curve point.
  78118. * @returns an array populated with normal vectors on each Path3D curve point.
  78119. */
  78120. getNormals(): Vector3[];
  78121. /**
  78122. * Returns an array populated with binormal vectors on each Path3D curve point.
  78123. * @returns an array populated with binormal vectors on each Path3D curve point.
  78124. */
  78125. getBinormals(): Vector3[];
  78126. /**
  78127. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  78128. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  78129. */
  78130. getDistances(): number[];
  78131. /**
  78132. * Returns an interpolated point along this path
  78133. * @param position the position of the point along this path, from 0.0 to 1.0
  78134. * @returns a new Vector3 as the point
  78135. */
  78136. getPointAt(position: number): Vector3;
  78137. /**
  78138. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78139. * @param position the position of the point along this path, from 0.0 to 1.0
  78140. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  78141. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  78142. */
  78143. getTangentAt(position: number, interpolated?: boolean): Vector3;
  78144. /**
  78145. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78146. * @param position the position of the point along this path, from 0.0 to 1.0
  78147. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  78148. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  78149. */
  78150. getNormalAt(position: number, interpolated?: boolean): Vector3;
  78151. /**
  78152. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  78153. * @param position the position of the point along this path, from 0.0 to 1.0
  78154. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  78155. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  78156. */
  78157. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  78158. /**
  78159. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  78160. * @param position the position of the point along this path, from 0.0 to 1.0
  78161. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  78162. */
  78163. getDistanceAt(position: number): number;
  78164. /**
  78165. * Returns the array index of the previous point of an interpolated point along this path
  78166. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78167. * @returns the array index
  78168. */
  78169. getPreviousPointIndexAt(position: number): number;
  78170. /**
  78171. * 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)
  78172. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78173. * @returns the sub position
  78174. */
  78175. getSubPositionAt(position: number): number;
  78176. /**
  78177. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  78178. * @param target the vector of which to get the closest position to
  78179. * @returns the position of the closest virtual point on this path to the target vector
  78180. */
  78181. getClosestPositionTo(target: Vector3): number;
  78182. /**
  78183. * Returns a sub path (slice) of this path
  78184. * @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
  78185. * @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
  78186. * @returns a sub path (slice) of this path
  78187. */
  78188. slice(start?: number, end?: number): Path3D;
  78189. /**
  78190. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  78191. * @param path path which all values are copied into the curves points
  78192. * @param firstNormal which should be projected onto the curve
  78193. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  78194. * @returns the same object updated.
  78195. */
  78196. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  78197. private _compute;
  78198. private _getFirstNonNullVector;
  78199. private _getLastNonNullVector;
  78200. private _normalVector;
  78201. /**
  78202. * Updates the point at data for an interpolated point along this curve
  78203. * @param position the position of the point along this curve, from 0.0 to 1.0
  78204. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  78205. * @returns the (updated) point at data
  78206. */
  78207. private _updatePointAtData;
  78208. /**
  78209. * Updates the point at data from the specified parameters
  78210. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  78211. * @param point the interpolated point
  78212. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  78213. */
  78214. private _setPointAtData;
  78215. /**
  78216. * Updates the point at interpolation matrix for the tangents, normals and binormals
  78217. */
  78218. private _updateInterpolationMatrix;
  78219. }
  78220. /**
  78221. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78222. * A Curve3 is designed from a series of successive Vector3.
  78223. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  78224. */
  78225. export class Curve3 {
  78226. private _points;
  78227. private _length;
  78228. /**
  78229. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  78230. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  78231. * @param v1 (Vector3) the control point
  78232. * @param v2 (Vector3) the end point of the Quadratic Bezier
  78233. * @param nbPoints (integer) the wanted number of points in the curve
  78234. * @returns the created Curve3
  78235. */
  78236. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78237. /**
  78238. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  78239. * @param v0 (Vector3) the origin point of the Cubic Bezier
  78240. * @param v1 (Vector3) the first control point
  78241. * @param v2 (Vector3) the second control point
  78242. * @param v3 (Vector3) the end point of the Cubic Bezier
  78243. * @param nbPoints (integer) the wanted number of points in the curve
  78244. * @returns the created Curve3
  78245. */
  78246. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78247. /**
  78248. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  78249. * @param p1 (Vector3) the origin point of the Hermite Spline
  78250. * @param t1 (Vector3) the tangent vector at the origin point
  78251. * @param p2 (Vector3) the end point of the Hermite Spline
  78252. * @param t2 (Vector3) the tangent vector at the end point
  78253. * @param nbPoints (integer) the wanted number of points in the curve
  78254. * @returns the created Curve3
  78255. */
  78256. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78257. /**
  78258. * Returns a Curve3 object along a CatmullRom Spline curve :
  78259. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  78260. * @param nbPoints (integer) the wanted number of points between each curve control points
  78261. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  78262. * @returns the created Curve3
  78263. */
  78264. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  78265. /**
  78266. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78267. * A Curve3 is designed from a series of successive Vector3.
  78268. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  78269. * @param points points which make up the curve
  78270. */
  78271. constructor(points: Vector3[]);
  78272. /**
  78273. * @returns the Curve3 stored array of successive Vector3
  78274. */
  78275. getPoints(): Vector3[];
  78276. /**
  78277. * @returns the computed length (float) of the curve.
  78278. */
  78279. length(): number;
  78280. /**
  78281. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  78282. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  78283. * curveA and curveB keep unchanged.
  78284. * @param curve the curve to continue from this curve
  78285. * @returns the newly constructed curve
  78286. */
  78287. continue(curve: DeepImmutable<Curve3>): Curve3;
  78288. private _computeLength;
  78289. }
  78290. }
  78291. declare module BABYLON {
  78292. /**
  78293. * This represents the main contract an easing function should follow.
  78294. * Easing functions are used throughout the animation system.
  78295. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78296. */
  78297. export interface IEasingFunction {
  78298. /**
  78299. * Given an input gradient between 0 and 1, this returns the corrseponding value
  78300. * of the easing function.
  78301. * The link below provides some of the most common examples of easing functions.
  78302. * @see https://easings.net/
  78303. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78304. * @returns the corresponding value on the curve defined by the easing function
  78305. */
  78306. ease(gradient: number): number;
  78307. }
  78308. /**
  78309. * Base class used for every default easing function.
  78310. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78311. */
  78312. export class EasingFunction implements IEasingFunction {
  78313. /**
  78314. * Interpolation follows the mathematical formula associated with the easing function.
  78315. */
  78316. static readonly EASINGMODE_EASEIN: number;
  78317. /**
  78318. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  78319. */
  78320. static readonly EASINGMODE_EASEOUT: number;
  78321. /**
  78322. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  78323. */
  78324. static readonly EASINGMODE_EASEINOUT: number;
  78325. private _easingMode;
  78326. /**
  78327. * Sets the easing mode of the current function.
  78328. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  78329. */
  78330. setEasingMode(easingMode: number): void;
  78331. /**
  78332. * Gets the current easing mode.
  78333. * @returns the easing mode
  78334. */
  78335. getEasingMode(): number;
  78336. /**
  78337. * @hidden
  78338. */
  78339. easeInCore(gradient: number): number;
  78340. /**
  78341. * Given an input gradient between 0 and 1, this returns the corresponding value
  78342. * of the easing function.
  78343. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78344. * @returns the corresponding value on the curve defined by the easing function
  78345. */
  78346. ease(gradient: number): number;
  78347. }
  78348. /**
  78349. * Easing function with a circle shape (see link below).
  78350. * @see https://easings.net/#easeInCirc
  78351. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78352. */
  78353. export class CircleEase extends EasingFunction implements IEasingFunction {
  78354. /** @hidden */
  78355. easeInCore(gradient: number): number;
  78356. }
  78357. /**
  78358. * Easing function with a ease back shape (see link below).
  78359. * @see https://easings.net/#easeInBack
  78360. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78361. */
  78362. export class BackEase extends EasingFunction implements IEasingFunction {
  78363. /** Defines the amplitude of the function */
  78364. amplitude: number;
  78365. /**
  78366. * Instantiates a back ease easing
  78367. * @see https://easings.net/#easeInBack
  78368. * @param amplitude Defines the amplitude of the function
  78369. */
  78370. constructor(
  78371. /** Defines the amplitude of the function */
  78372. amplitude?: number);
  78373. /** @hidden */
  78374. easeInCore(gradient: number): number;
  78375. }
  78376. /**
  78377. * Easing function with a bouncing shape (see link below).
  78378. * @see https://easings.net/#easeInBounce
  78379. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78380. */
  78381. export class BounceEase extends EasingFunction implements IEasingFunction {
  78382. /** Defines the number of bounces */
  78383. bounces: number;
  78384. /** Defines the amplitude of the bounce */
  78385. bounciness: number;
  78386. /**
  78387. * Instantiates a bounce easing
  78388. * @see https://easings.net/#easeInBounce
  78389. * @param bounces Defines the number of bounces
  78390. * @param bounciness Defines the amplitude of the bounce
  78391. */
  78392. constructor(
  78393. /** Defines the number of bounces */
  78394. bounces?: number,
  78395. /** Defines the amplitude of the bounce */
  78396. bounciness?: number);
  78397. /** @hidden */
  78398. easeInCore(gradient: number): number;
  78399. }
  78400. /**
  78401. * Easing function with a power of 3 shape (see link below).
  78402. * @see https://easings.net/#easeInCubic
  78403. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78404. */
  78405. export class CubicEase extends EasingFunction implements IEasingFunction {
  78406. /** @hidden */
  78407. easeInCore(gradient: number): number;
  78408. }
  78409. /**
  78410. * Easing function with an elastic shape (see link below).
  78411. * @see https://easings.net/#easeInElastic
  78412. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78413. */
  78414. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78415. /** Defines the number of oscillations*/
  78416. oscillations: number;
  78417. /** Defines the amplitude of the oscillations*/
  78418. springiness: number;
  78419. /**
  78420. * Instantiates an elastic easing function
  78421. * @see https://easings.net/#easeInElastic
  78422. * @param oscillations Defines the number of oscillations
  78423. * @param springiness Defines the amplitude of the oscillations
  78424. */
  78425. constructor(
  78426. /** Defines the number of oscillations*/
  78427. oscillations?: number,
  78428. /** Defines the amplitude of the oscillations*/
  78429. springiness?: number);
  78430. /** @hidden */
  78431. easeInCore(gradient: number): number;
  78432. }
  78433. /**
  78434. * Easing function with an exponential shape (see link below).
  78435. * @see https://easings.net/#easeInExpo
  78436. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78437. */
  78438. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78439. /** Defines the exponent of the function */
  78440. exponent: number;
  78441. /**
  78442. * Instantiates an exponential easing function
  78443. * @see https://easings.net/#easeInExpo
  78444. * @param exponent Defines the exponent of the function
  78445. */
  78446. constructor(
  78447. /** Defines the exponent of the function */
  78448. exponent?: number);
  78449. /** @hidden */
  78450. easeInCore(gradient: number): number;
  78451. }
  78452. /**
  78453. * Easing function with a power shape (see link below).
  78454. * @see https://easings.net/#easeInQuad
  78455. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78456. */
  78457. export class PowerEase extends EasingFunction implements IEasingFunction {
  78458. /** Defines the power of the function */
  78459. power: number;
  78460. /**
  78461. * Instantiates an power base easing function
  78462. * @see https://easings.net/#easeInQuad
  78463. * @param power Defines the power of the function
  78464. */
  78465. constructor(
  78466. /** Defines the power of the function */
  78467. power?: number);
  78468. /** @hidden */
  78469. easeInCore(gradient: number): number;
  78470. }
  78471. /**
  78472. * Easing function with a power of 2 shape (see link below).
  78473. * @see https://easings.net/#easeInQuad
  78474. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78475. */
  78476. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78477. /** @hidden */
  78478. easeInCore(gradient: number): number;
  78479. }
  78480. /**
  78481. * Easing function with a power of 4 shape (see link below).
  78482. * @see https://easings.net/#easeInQuart
  78483. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78484. */
  78485. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78486. /** @hidden */
  78487. easeInCore(gradient: number): number;
  78488. }
  78489. /**
  78490. * Easing function with a power of 5 shape (see link below).
  78491. * @see https://easings.net/#easeInQuint
  78492. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78493. */
  78494. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78495. /** @hidden */
  78496. easeInCore(gradient: number): number;
  78497. }
  78498. /**
  78499. * Easing function with a sin shape (see link below).
  78500. * @see https://easings.net/#easeInSine
  78501. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78502. */
  78503. export class SineEase extends EasingFunction implements IEasingFunction {
  78504. /** @hidden */
  78505. easeInCore(gradient: number): number;
  78506. }
  78507. /**
  78508. * Easing function with a bezier shape (see link below).
  78509. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78510. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78511. */
  78512. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78513. /** Defines the x component of the start tangent in the bezier curve */
  78514. x1: number;
  78515. /** Defines the y component of the start tangent in the bezier curve */
  78516. y1: number;
  78517. /** Defines the x component of the end tangent in the bezier curve */
  78518. x2: number;
  78519. /** Defines the y component of the end tangent in the bezier curve */
  78520. y2: number;
  78521. /**
  78522. * Instantiates a bezier function
  78523. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78524. * @param x1 Defines the x component of the start tangent in the bezier curve
  78525. * @param y1 Defines the y component of the start tangent in the bezier curve
  78526. * @param x2 Defines the x component of the end tangent in the bezier curve
  78527. * @param y2 Defines the y component of the end tangent in the bezier curve
  78528. */
  78529. constructor(
  78530. /** Defines the x component of the start tangent in the bezier curve */
  78531. x1?: number,
  78532. /** Defines the y component of the start tangent in the bezier curve */
  78533. y1?: number,
  78534. /** Defines the x component of the end tangent in the bezier curve */
  78535. x2?: number,
  78536. /** Defines the y component of the end tangent in the bezier curve */
  78537. y2?: number);
  78538. /** @hidden */
  78539. easeInCore(gradient: number): number;
  78540. }
  78541. }
  78542. declare module BABYLON {
  78543. /**
  78544. * Class used to hold a RBG color
  78545. */
  78546. export class Color3 {
  78547. /**
  78548. * Defines the red component (between 0 and 1, default is 0)
  78549. */
  78550. r: number;
  78551. /**
  78552. * Defines the green component (between 0 and 1, default is 0)
  78553. */
  78554. g: number;
  78555. /**
  78556. * Defines the blue component (between 0 and 1, default is 0)
  78557. */
  78558. b: number;
  78559. /**
  78560. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78561. * @param r defines the red component (between 0 and 1, default is 0)
  78562. * @param g defines the green component (between 0 and 1, default is 0)
  78563. * @param b defines the blue component (between 0 and 1, default is 0)
  78564. */
  78565. constructor(
  78566. /**
  78567. * Defines the red component (between 0 and 1, default is 0)
  78568. */
  78569. r?: number,
  78570. /**
  78571. * Defines the green component (between 0 and 1, default is 0)
  78572. */
  78573. g?: number,
  78574. /**
  78575. * Defines the blue component (between 0 and 1, default is 0)
  78576. */
  78577. b?: number);
  78578. /**
  78579. * Creates a string with the Color3 current values
  78580. * @returns the string representation of the Color3 object
  78581. */
  78582. toString(): string;
  78583. /**
  78584. * Returns the string "Color3"
  78585. * @returns "Color3"
  78586. */
  78587. getClassName(): string;
  78588. /**
  78589. * Compute the Color3 hash code
  78590. * @returns an unique number that can be used to hash Color3 objects
  78591. */
  78592. getHashCode(): number;
  78593. /**
  78594. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  78595. * @param array defines the array where to store the r,g,b components
  78596. * @param index defines an optional index in the target array to define where to start storing values
  78597. * @returns the current Color3 object
  78598. */
  78599. toArray(array: FloatArray, index?: number): Color3;
  78600. /**
  78601. * Returns a new Color4 object from the current Color3 and the given alpha
  78602. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  78603. * @returns a new Color4 object
  78604. */
  78605. toColor4(alpha?: number): Color4;
  78606. /**
  78607. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78608. * @returns the new array
  78609. */
  78610. asArray(): number[];
  78611. /**
  78612. * Returns the luminance value
  78613. * @returns a float value
  78614. */
  78615. toLuminance(): number;
  78616. /**
  78617. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78618. * @param otherColor defines the second operand
  78619. * @returns the new Color3 object
  78620. */
  78621. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78622. /**
  78623. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78624. * @param otherColor defines the second operand
  78625. * @param result defines the Color3 object where to store the result
  78626. * @returns the current Color3
  78627. */
  78628. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78629. /**
  78630. * Determines equality between Color3 objects
  78631. * @param otherColor defines the second operand
  78632. * @returns true if the rgb values are equal to the given ones
  78633. */
  78634. equals(otherColor: DeepImmutable<Color3>): boolean;
  78635. /**
  78636. * Determines equality between the current Color3 object and a set of r,b,g values
  78637. * @param r defines the red component to check
  78638. * @param g defines the green component to check
  78639. * @param b defines the blue component to check
  78640. * @returns true if the rgb values are equal to the given ones
  78641. */
  78642. equalsFloats(r: number, g: number, b: number): boolean;
  78643. /**
  78644. * Multiplies in place each rgb value by scale
  78645. * @param scale defines the scaling factor
  78646. * @returns the updated Color3
  78647. */
  78648. scale(scale: number): Color3;
  78649. /**
  78650. * Multiplies the rgb values by scale and stores the result into "result"
  78651. * @param scale defines the scaling factor
  78652. * @param result defines the Color3 object where to store the result
  78653. * @returns the unmodified current Color3
  78654. */
  78655. scaleToRef(scale: number, result: Color3): Color3;
  78656. /**
  78657. * Scale the current Color3 values by a factor and add the result to a given Color3
  78658. * @param scale defines the scale factor
  78659. * @param result defines color to store the result into
  78660. * @returns the unmodified current Color3
  78661. */
  78662. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78663. /**
  78664. * Clamps the rgb values by the min and max values and stores the result into "result"
  78665. * @param min defines minimum clamping value (default is 0)
  78666. * @param max defines maximum clamping value (default is 1)
  78667. * @param result defines color to store the result into
  78668. * @returns the original Color3
  78669. */
  78670. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78671. /**
  78672. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78673. * @param otherColor defines the second operand
  78674. * @returns the new Color3
  78675. */
  78676. add(otherColor: DeepImmutable<Color3>): Color3;
  78677. /**
  78678. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  78679. * @param otherColor defines the second operand
  78680. * @param result defines Color3 object to store the result into
  78681. * @returns the unmodified current Color3
  78682. */
  78683. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78684. /**
  78685. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  78686. * @param otherColor defines the second operand
  78687. * @returns the new Color3
  78688. */
  78689. subtract(otherColor: DeepImmutable<Color3>): Color3;
  78690. /**
  78691. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  78692. * @param otherColor defines the second operand
  78693. * @param result defines Color3 object to store the result into
  78694. * @returns the unmodified current Color3
  78695. */
  78696. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78697. /**
  78698. * Copy the current object
  78699. * @returns a new Color3 copied the current one
  78700. */
  78701. clone(): Color3;
  78702. /**
  78703. * Copies the rgb values from the source in the current Color3
  78704. * @param source defines the source Color3 object
  78705. * @returns the updated Color3 object
  78706. */
  78707. copyFrom(source: DeepImmutable<Color3>): Color3;
  78708. /**
  78709. * Updates the Color3 rgb values from the given floats
  78710. * @param r defines the red component to read from
  78711. * @param g defines the green component to read from
  78712. * @param b defines the blue component to read from
  78713. * @returns the current Color3 object
  78714. */
  78715. copyFromFloats(r: number, g: number, b: number): Color3;
  78716. /**
  78717. * Updates the Color3 rgb values from the given floats
  78718. * @param r defines the red component to read from
  78719. * @param g defines the green component to read from
  78720. * @param b defines the blue component to read from
  78721. * @returns the current Color3 object
  78722. */
  78723. set(r: number, g: number, b: number): Color3;
  78724. /**
  78725. * Compute the Color3 hexadecimal code as a string
  78726. * @returns a string containing the hexadecimal representation of the Color3 object
  78727. */
  78728. toHexString(): string;
  78729. /**
  78730. * Computes a new Color3 converted from the current one to linear space
  78731. * @returns a new Color3 object
  78732. */
  78733. toLinearSpace(): Color3;
  78734. /**
  78735. * Converts current color in rgb space to HSV values
  78736. * @returns a new color3 representing the HSV values
  78737. */
  78738. toHSV(): Color3;
  78739. /**
  78740. * Converts current color in rgb space to HSV values
  78741. * @param result defines the Color3 where to store the HSV values
  78742. */
  78743. toHSVToRef(result: Color3): void;
  78744. /**
  78745. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  78746. * @param convertedColor defines the Color3 object where to store the linear space version
  78747. * @returns the unmodified Color3
  78748. */
  78749. toLinearSpaceToRef(convertedColor: Color3): Color3;
  78750. /**
  78751. * Computes a new Color3 converted from the current one to gamma space
  78752. * @returns a new Color3 object
  78753. */
  78754. toGammaSpace(): Color3;
  78755. /**
  78756. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  78757. * @param convertedColor defines the Color3 object where to store the gamma space version
  78758. * @returns the unmodified Color3
  78759. */
  78760. toGammaSpaceToRef(convertedColor: Color3): Color3;
  78761. private static _BlackReadOnly;
  78762. /**
  78763. * Convert Hue, saturation and value to a Color3 (RGB)
  78764. * @param hue defines the hue
  78765. * @param saturation defines the saturation
  78766. * @param value defines the value
  78767. * @param result defines the Color3 where to store the RGB values
  78768. */
  78769. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  78770. /**
  78771. * Creates a new Color3 from the string containing valid hexadecimal values
  78772. * @param hex defines a string containing valid hexadecimal values
  78773. * @returns a new Color3 object
  78774. */
  78775. static FromHexString(hex: string): Color3;
  78776. /**
  78777. * Creates a new Color3 from the starting index of the given array
  78778. * @param array defines the source array
  78779. * @param offset defines an offset in the source array
  78780. * @returns a new Color3 object
  78781. */
  78782. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  78783. /**
  78784. * Creates a new Color3 from integer values (< 256)
  78785. * @param r defines the red component to read from (value between 0 and 255)
  78786. * @param g defines the green component to read from (value between 0 and 255)
  78787. * @param b defines the blue component to read from (value between 0 and 255)
  78788. * @returns a new Color3 object
  78789. */
  78790. static FromInts(r: number, g: number, b: number): Color3;
  78791. /**
  78792. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78793. * @param start defines the start Color3 value
  78794. * @param end defines the end Color3 value
  78795. * @param amount defines the gradient value between start and end
  78796. * @returns a new Color3 object
  78797. */
  78798. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  78799. /**
  78800. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78801. * @param left defines the start value
  78802. * @param right defines the end value
  78803. * @param amount defines the gradient factor
  78804. * @param result defines the Color3 object where to store the result
  78805. */
  78806. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  78807. /**
  78808. * Returns a Color3 value containing a red color
  78809. * @returns a new Color3 object
  78810. */
  78811. static Red(): Color3;
  78812. /**
  78813. * Returns a Color3 value containing a green color
  78814. * @returns a new Color3 object
  78815. */
  78816. static Green(): Color3;
  78817. /**
  78818. * Returns a Color3 value containing a blue color
  78819. * @returns a new Color3 object
  78820. */
  78821. static Blue(): Color3;
  78822. /**
  78823. * Returns a Color3 value containing a black color
  78824. * @returns a new Color3 object
  78825. */
  78826. static Black(): Color3;
  78827. /**
  78828. * Gets a Color3 value containing a black color that must not be updated
  78829. */
  78830. static get BlackReadOnly(): DeepImmutable<Color3>;
  78831. /**
  78832. * Returns a Color3 value containing a white color
  78833. * @returns a new Color3 object
  78834. */
  78835. static White(): Color3;
  78836. /**
  78837. * Returns a Color3 value containing a purple color
  78838. * @returns a new Color3 object
  78839. */
  78840. static Purple(): Color3;
  78841. /**
  78842. * Returns a Color3 value containing a magenta color
  78843. * @returns a new Color3 object
  78844. */
  78845. static Magenta(): Color3;
  78846. /**
  78847. * Returns a Color3 value containing a yellow color
  78848. * @returns a new Color3 object
  78849. */
  78850. static Yellow(): Color3;
  78851. /**
  78852. * Returns a Color3 value containing a gray color
  78853. * @returns a new Color3 object
  78854. */
  78855. static Gray(): Color3;
  78856. /**
  78857. * Returns a Color3 value containing a teal color
  78858. * @returns a new Color3 object
  78859. */
  78860. static Teal(): Color3;
  78861. /**
  78862. * Returns a Color3 value containing a random color
  78863. * @returns a new Color3 object
  78864. */
  78865. static Random(): Color3;
  78866. }
  78867. /**
  78868. * Class used to hold a RBGA color
  78869. */
  78870. export class Color4 {
  78871. /**
  78872. * Defines the red component (between 0 and 1, default is 0)
  78873. */
  78874. r: number;
  78875. /**
  78876. * Defines the green component (between 0 and 1, default is 0)
  78877. */
  78878. g: number;
  78879. /**
  78880. * Defines the blue component (between 0 and 1, default is 0)
  78881. */
  78882. b: number;
  78883. /**
  78884. * Defines the alpha component (between 0 and 1, default is 1)
  78885. */
  78886. a: number;
  78887. /**
  78888. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  78889. * @param r defines the red component (between 0 and 1, default is 0)
  78890. * @param g defines the green component (between 0 and 1, default is 0)
  78891. * @param b defines the blue component (between 0 and 1, default is 0)
  78892. * @param a defines the alpha component (between 0 and 1, default is 1)
  78893. */
  78894. constructor(
  78895. /**
  78896. * Defines the red component (between 0 and 1, default is 0)
  78897. */
  78898. r?: number,
  78899. /**
  78900. * Defines the green component (between 0 and 1, default is 0)
  78901. */
  78902. g?: number,
  78903. /**
  78904. * Defines the blue component (between 0 and 1, default is 0)
  78905. */
  78906. b?: number,
  78907. /**
  78908. * Defines the alpha component (between 0 and 1, default is 1)
  78909. */
  78910. a?: number);
  78911. /**
  78912. * Adds in place the given Color4 values to the current Color4 object
  78913. * @param right defines the second operand
  78914. * @returns the current updated Color4 object
  78915. */
  78916. addInPlace(right: DeepImmutable<Color4>): Color4;
  78917. /**
  78918. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  78919. * @returns the new array
  78920. */
  78921. asArray(): number[];
  78922. /**
  78923. * Stores from the starting index in the given array the Color4 successive values
  78924. * @param array defines the array where to store the r,g,b components
  78925. * @param index defines an optional index in the target array to define where to start storing values
  78926. * @returns the current Color4 object
  78927. */
  78928. toArray(array: number[], index?: number): Color4;
  78929. /**
  78930. * Determines equality between Color4 objects
  78931. * @param otherColor defines the second operand
  78932. * @returns true if the rgba values are equal to the given ones
  78933. */
  78934. equals(otherColor: DeepImmutable<Color4>): boolean;
  78935. /**
  78936. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  78937. * @param right defines the second operand
  78938. * @returns a new Color4 object
  78939. */
  78940. add(right: DeepImmutable<Color4>): Color4;
  78941. /**
  78942. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  78943. * @param right defines the second operand
  78944. * @returns a new Color4 object
  78945. */
  78946. subtract(right: DeepImmutable<Color4>): Color4;
  78947. /**
  78948. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  78949. * @param right defines the second operand
  78950. * @param result defines the Color4 object where to store the result
  78951. * @returns the current Color4 object
  78952. */
  78953. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  78954. /**
  78955. * Creates a new Color4 with the current Color4 values multiplied by scale
  78956. * @param scale defines the scaling factor to apply
  78957. * @returns a new Color4 object
  78958. */
  78959. scale(scale: number): Color4;
  78960. /**
  78961. * Multiplies the current Color4 values by scale and stores the result in "result"
  78962. * @param scale defines the scaling factor to apply
  78963. * @param result defines the Color4 object where to store the result
  78964. * @returns the current unmodified Color4
  78965. */
  78966. scaleToRef(scale: number, result: Color4): Color4;
  78967. /**
  78968. * Scale the current Color4 values by a factor and add the result to a given Color4
  78969. * @param scale defines the scale factor
  78970. * @param result defines the Color4 object where to store the result
  78971. * @returns the unmodified current Color4
  78972. */
  78973. scaleAndAddToRef(scale: number, result: Color4): Color4;
  78974. /**
  78975. * Clamps the rgb values by the min and max values and stores the result into "result"
  78976. * @param min defines minimum clamping value (default is 0)
  78977. * @param max defines maximum clamping value (default is 1)
  78978. * @param result defines color to store the result into.
  78979. * @returns the cuurent Color4
  78980. */
  78981. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  78982. /**
  78983. * Multipy an Color4 value by another and return a new Color4 object
  78984. * @param color defines the Color4 value to multiply by
  78985. * @returns a new Color4 object
  78986. */
  78987. multiply(color: Color4): Color4;
  78988. /**
  78989. * Multipy a Color4 value by another and push the result in a reference value
  78990. * @param color defines the Color4 value to multiply by
  78991. * @param result defines the Color4 to fill the result in
  78992. * @returns the result Color4
  78993. */
  78994. multiplyToRef(color: Color4, result: Color4): Color4;
  78995. /**
  78996. * Creates a string with the Color4 current values
  78997. * @returns the string representation of the Color4 object
  78998. */
  78999. toString(): string;
  79000. /**
  79001. * Returns the string "Color4"
  79002. * @returns "Color4"
  79003. */
  79004. getClassName(): string;
  79005. /**
  79006. * Compute the Color4 hash code
  79007. * @returns an unique number that can be used to hash Color4 objects
  79008. */
  79009. getHashCode(): number;
  79010. /**
  79011. * Creates a new Color4 copied from the current one
  79012. * @returns a new Color4 object
  79013. */
  79014. clone(): Color4;
  79015. /**
  79016. * Copies the given Color4 values into the current one
  79017. * @param source defines the source Color4 object
  79018. * @returns the current updated Color4 object
  79019. */
  79020. copyFrom(source: Color4): Color4;
  79021. /**
  79022. * Copies the given float values into the current one
  79023. * @param r defines the red component to read from
  79024. * @param g defines the green component to read from
  79025. * @param b defines the blue component to read from
  79026. * @param a defines the alpha component to read from
  79027. * @returns the current updated Color4 object
  79028. */
  79029. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  79030. /**
  79031. * Copies the given float values into the current one
  79032. * @param r defines the red component to read from
  79033. * @param g defines the green component to read from
  79034. * @param b defines the blue component to read from
  79035. * @param a defines the alpha component to read from
  79036. * @returns the current updated Color4 object
  79037. */
  79038. set(r: number, g: number, b: number, a: number): Color4;
  79039. /**
  79040. * Compute the Color4 hexadecimal code as a string
  79041. * @returns a string containing the hexadecimal representation of the Color4 object
  79042. */
  79043. toHexString(): string;
  79044. /**
  79045. * Computes a new Color4 converted from the current one to linear space
  79046. * @returns a new Color4 object
  79047. */
  79048. toLinearSpace(): Color4;
  79049. /**
  79050. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  79051. * @param convertedColor defines the Color4 object where to store the linear space version
  79052. * @returns the unmodified Color4
  79053. */
  79054. toLinearSpaceToRef(convertedColor: Color4): Color4;
  79055. /**
  79056. * Computes a new Color4 converted from the current one to gamma space
  79057. * @returns a new Color4 object
  79058. */
  79059. toGammaSpace(): Color4;
  79060. /**
  79061. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  79062. * @param convertedColor defines the Color4 object where to store the gamma space version
  79063. * @returns the unmodified Color4
  79064. */
  79065. toGammaSpaceToRef(convertedColor: Color4): Color4;
  79066. /**
  79067. * Creates a new Color4 from the string containing valid hexadecimal values
  79068. * @param hex defines a string containing valid hexadecimal values
  79069. * @returns a new Color4 object
  79070. */
  79071. static FromHexString(hex: string): Color4;
  79072. /**
  79073. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79074. * @param left defines the start value
  79075. * @param right defines the end value
  79076. * @param amount defines the gradient factor
  79077. * @returns a new Color4 object
  79078. */
  79079. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  79080. /**
  79081. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79082. * @param left defines the start value
  79083. * @param right defines the end value
  79084. * @param amount defines the gradient factor
  79085. * @param result defines the Color4 object where to store data
  79086. */
  79087. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  79088. /**
  79089. * Creates a new Color4 from a Color3 and an alpha value
  79090. * @param color3 defines the source Color3 to read from
  79091. * @param alpha defines the alpha component (1.0 by default)
  79092. * @returns a new Color4 object
  79093. */
  79094. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  79095. /**
  79096. * Creates a new Color4 from the starting index element of the given array
  79097. * @param array defines the source array to read from
  79098. * @param offset defines the offset in the source array
  79099. * @returns a new Color4 object
  79100. */
  79101. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  79102. /**
  79103. * Creates a new Color3 from integer values (< 256)
  79104. * @param r defines the red component to read from (value between 0 and 255)
  79105. * @param g defines the green component to read from (value between 0 and 255)
  79106. * @param b defines the blue component to read from (value between 0 and 255)
  79107. * @param a defines the alpha component to read from (value between 0 and 255)
  79108. * @returns a new Color3 object
  79109. */
  79110. static FromInts(r: number, g: number, b: number, a: number): Color4;
  79111. /**
  79112. * Check the content of a given array and convert it to an array containing RGBA data
  79113. * If the original array was already containing count * 4 values then it is returned directly
  79114. * @param colors defines the array to check
  79115. * @param count defines the number of RGBA data to expect
  79116. * @returns an array containing count * 4 values (RGBA)
  79117. */
  79118. static CheckColors4(colors: number[], count: number): number[];
  79119. }
  79120. /**
  79121. * @hidden
  79122. */
  79123. export class TmpColors {
  79124. static Color3: Color3[];
  79125. static Color4: Color4[];
  79126. }
  79127. }
  79128. declare module BABYLON {
  79129. /**
  79130. * Defines an interface which represents an animation key frame
  79131. */
  79132. export interface IAnimationKey {
  79133. /**
  79134. * Frame of the key frame
  79135. */
  79136. frame: number;
  79137. /**
  79138. * Value at the specifies key frame
  79139. */
  79140. value: any;
  79141. /**
  79142. * The input tangent for the cubic hermite spline
  79143. */
  79144. inTangent?: any;
  79145. /**
  79146. * The output tangent for the cubic hermite spline
  79147. */
  79148. outTangent?: any;
  79149. /**
  79150. * The animation interpolation type
  79151. */
  79152. interpolation?: AnimationKeyInterpolation;
  79153. }
  79154. /**
  79155. * Enum for the animation key frame interpolation type
  79156. */
  79157. export enum AnimationKeyInterpolation {
  79158. /**
  79159. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  79160. */
  79161. STEP = 1
  79162. }
  79163. }
  79164. declare module BABYLON {
  79165. /**
  79166. * Represents the range of an animation
  79167. */
  79168. export class AnimationRange {
  79169. /**The name of the animation range**/
  79170. name: string;
  79171. /**The starting frame of the animation */
  79172. from: number;
  79173. /**The ending frame of the animation*/
  79174. to: number;
  79175. /**
  79176. * Initializes the range of an animation
  79177. * @param name The name of the animation range
  79178. * @param from The starting frame of the animation
  79179. * @param to The ending frame of the animation
  79180. */
  79181. constructor(
  79182. /**The name of the animation range**/
  79183. name: string,
  79184. /**The starting frame of the animation */
  79185. from: number,
  79186. /**The ending frame of the animation*/
  79187. to: number);
  79188. /**
  79189. * Makes a copy of the animation range
  79190. * @returns A copy of the animation range
  79191. */
  79192. clone(): AnimationRange;
  79193. }
  79194. }
  79195. declare module BABYLON {
  79196. /**
  79197. * Composed of a frame, and an action function
  79198. */
  79199. export class AnimationEvent {
  79200. /** The frame for which the event is triggered **/
  79201. frame: number;
  79202. /** The event to perform when triggered **/
  79203. action: (currentFrame: number) => void;
  79204. /** Specifies if the event should be triggered only once**/
  79205. onlyOnce?: boolean | undefined;
  79206. /**
  79207. * Specifies if the animation event is done
  79208. */
  79209. isDone: boolean;
  79210. /**
  79211. * Initializes the animation event
  79212. * @param frame The frame for which the event is triggered
  79213. * @param action The event to perform when triggered
  79214. * @param onlyOnce Specifies if the event should be triggered only once
  79215. */
  79216. constructor(
  79217. /** The frame for which the event is triggered **/
  79218. frame: number,
  79219. /** The event to perform when triggered **/
  79220. action: (currentFrame: number) => void,
  79221. /** Specifies if the event should be triggered only once**/
  79222. onlyOnce?: boolean | undefined);
  79223. /** @hidden */
  79224. _clone(): AnimationEvent;
  79225. }
  79226. }
  79227. declare module BABYLON {
  79228. /**
  79229. * Interface used to define a behavior
  79230. */
  79231. export interface Behavior<T> {
  79232. /** gets or sets behavior's name */
  79233. name: string;
  79234. /**
  79235. * Function called when the behavior needs to be initialized (after attaching it to a target)
  79236. */
  79237. init(): void;
  79238. /**
  79239. * Called when the behavior is attached to a target
  79240. * @param target defines the target where the behavior is attached to
  79241. */
  79242. attach(target: T): void;
  79243. /**
  79244. * Called when the behavior is detached from its target
  79245. */
  79246. detach(): void;
  79247. }
  79248. /**
  79249. * Interface implemented by classes supporting behaviors
  79250. */
  79251. export interface IBehaviorAware<T> {
  79252. /**
  79253. * Attach a behavior
  79254. * @param behavior defines the behavior to attach
  79255. * @returns the current host
  79256. */
  79257. addBehavior(behavior: Behavior<T>): T;
  79258. /**
  79259. * Remove a behavior from the current object
  79260. * @param behavior defines the behavior to detach
  79261. * @returns the current host
  79262. */
  79263. removeBehavior(behavior: Behavior<T>): T;
  79264. /**
  79265. * Gets a behavior using its name to search
  79266. * @param name defines the name to search
  79267. * @returns the behavior or null if not found
  79268. */
  79269. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  79270. }
  79271. }
  79272. declare module BABYLON {
  79273. /**
  79274. * Defines an array and its length.
  79275. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  79276. */
  79277. export interface ISmartArrayLike<T> {
  79278. /**
  79279. * The data of the array.
  79280. */
  79281. data: Array<T>;
  79282. /**
  79283. * The active length of the array.
  79284. */
  79285. length: number;
  79286. }
  79287. /**
  79288. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79289. */
  79290. export class SmartArray<T> implements ISmartArrayLike<T> {
  79291. /**
  79292. * The full set of data from the array.
  79293. */
  79294. data: Array<T>;
  79295. /**
  79296. * The active length of the array.
  79297. */
  79298. length: number;
  79299. protected _id: number;
  79300. /**
  79301. * Instantiates a Smart Array.
  79302. * @param capacity defines the default capacity of the array.
  79303. */
  79304. constructor(capacity: number);
  79305. /**
  79306. * Pushes a value at the end of the active data.
  79307. * @param value defines the object to push in the array.
  79308. */
  79309. push(value: T): void;
  79310. /**
  79311. * Iterates over the active data and apply the lambda to them.
  79312. * @param func defines the action to apply on each value.
  79313. */
  79314. forEach(func: (content: T) => void): void;
  79315. /**
  79316. * Sorts the full sets of data.
  79317. * @param compareFn defines the comparison function to apply.
  79318. */
  79319. sort(compareFn: (a: T, b: T) => number): void;
  79320. /**
  79321. * Resets the active data to an empty array.
  79322. */
  79323. reset(): void;
  79324. /**
  79325. * Releases all the data from the array as well as the array.
  79326. */
  79327. dispose(): void;
  79328. /**
  79329. * Concats the active data with a given array.
  79330. * @param array defines the data to concatenate with.
  79331. */
  79332. concat(array: any): void;
  79333. /**
  79334. * Returns the position of a value in the active data.
  79335. * @param value defines the value to find the index for
  79336. * @returns the index if found in the active data otherwise -1
  79337. */
  79338. indexOf(value: T): number;
  79339. /**
  79340. * Returns whether an element is part of the active data.
  79341. * @param value defines the value to look for
  79342. * @returns true if found in the active data otherwise false
  79343. */
  79344. contains(value: T): boolean;
  79345. private static _GlobalId;
  79346. }
  79347. /**
  79348. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79349. * The data in this array can only be present once
  79350. */
  79351. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  79352. private _duplicateId;
  79353. /**
  79354. * Pushes a value at the end of the active data.
  79355. * THIS DOES NOT PREVENT DUPPLICATE DATA
  79356. * @param value defines the object to push in the array.
  79357. */
  79358. push(value: T): void;
  79359. /**
  79360. * Pushes a value at the end of the active data.
  79361. * If the data is already present, it won t be added again
  79362. * @param value defines the object to push in the array.
  79363. * @returns true if added false if it was already present
  79364. */
  79365. pushNoDuplicate(value: T): boolean;
  79366. /**
  79367. * Resets the active data to an empty array.
  79368. */
  79369. reset(): void;
  79370. /**
  79371. * Concats the active data with a given array.
  79372. * This ensures no dupplicate will be present in the result.
  79373. * @param array defines the data to concatenate with.
  79374. */
  79375. concatWithNoDuplicate(array: any): void;
  79376. }
  79377. }
  79378. declare module BABYLON {
  79379. /**
  79380. * @ignore
  79381. * This is a list of all the different input types that are available in the application.
  79382. * Fo instance: ArcRotateCameraGamepadInput...
  79383. */
  79384. export var CameraInputTypes: {};
  79385. /**
  79386. * This is the contract to implement in order to create a new input class.
  79387. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  79388. */
  79389. export interface ICameraInput<TCamera extends Camera> {
  79390. /**
  79391. * Defines the camera the input is attached to.
  79392. */
  79393. camera: Nullable<TCamera>;
  79394. /**
  79395. * Gets the class name of the current intput.
  79396. * @returns the class name
  79397. */
  79398. getClassName(): string;
  79399. /**
  79400. * Get the friendly name associated with the input class.
  79401. * @returns the input friendly name
  79402. */
  79403. getSimpleName(): string;
  79404. /**
  79405. * Attach the input controls to a specific dom element to get the input from.
  79406. * @param element Defines the element the controls should be listened from
  79407. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79408. */
  79409. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79410. /**
  79411. * Detach the current controls from the specified dom element.
  79412. * @param element Defines the element to stop listening the inputs from
  79413. */
  79414. detachControl(element: Nullable<HTMLElement>): void;
  79415. /**
  79416. * Update the current camera state depending on the inputs that have been used this frame.
  79417. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79418. */
  79419. checkInputs?: () => void;
  79420. }
  79421. /**
  79422. * Represents a map of input types to input instance or input index to input instance.
  79423. */
  79424. export interface CameraInputsMap<TCamera extends Camera> {
  79425. /**
  79426. * Accessor to the input by input type.
  79427. */
  79428. [name: string]: ICameraInput<TCamera>;
  79429. /**
  79430. * Accessor to the input by input index.
  79431. */
  79432. [idx: number]: ICameraInput<TCamera>;
  79433. }
  79434. /**
  79435. * This represents the input manager used within a camera.
  79436. * It helps dealing with all the different kind of input attached to a camera.
  79437. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79438. */
  79439. export class CameraInputsManager<TCamera extends Camera> {
  79440. /**
  79441. * Defines the list of inputs attahed to the camera.
  79442. */
  79443. attached: CameraInputsMap<TCamera>;
  79444. /**
  79445. * Defines the dom element the camera is collecting inputs from.
  79446. * This is null if the controls have not been attached.
  79447. */
  79448. attachedElement: Nullable<HTMLElement>;
  79449. /**
  79450. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79451. */
  79452. noPreventDefault: boolean;
  79453. /**
  79454. * Defined the camera the input manager belongs to.
  79455. */
  79456. camera: TCamera;
  79457. /**
  79458. * Update the current camera state depending on the inputs that have been used this frame.
  79459. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79460. */
  79461. checkInputs: () => void;
  79462. /**
  79463. * Instantiate a new Camera Input Manager.
  79464. * @param camera Defines the camera the input manager blongs to
  79465. */
  79466. constructor(camera: TCamera);
  79467. /**
  79468. * Add an input method to a camera
  79469. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79470. * @param input camera input method
  79471. */
  79472. add(input: ICameraInput<TCamera>): void;
  79473. /**
  79474. * Remove a specific input method from a camera
  79475. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79476. * @param inputToRemove camera input method
  79477. */
  79478. remove(inputToRemove: ICameraInput<TCamera>): void;
  79479. /**
  79480. * Remove a specific input type from a camera
  79481. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79482. * @param inputType the type of the input to remove
  79483. */
  79484. removeByType(inputType: string): void;
  79485. private _addCheckInputs;
  79486. /**
  79487. * Attach the input controls to the currently attached dom element to listen the events from.
  79488. * @param input Defines the input to attach
  79489. */
  79490. attachInput(input: ICameraInput<TCamera>): void;
  79491. /**
  79492. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79493. * @param element Defines the dom element to collect the events from
  79494. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79495. */
  79496. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79497. /**
  79498. * Detach the current manager inputs controls from a specific dom element.
  79499. * @param element Defines the dom element to collect the events from
  79500. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79501. */
  79502. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79503. /**
  79504. * Rebuild the dynamic inputCheck function from the current list of
  79505. * defined inputs in the manager.
  79506. */
  79507. rebuildInputCheck(): void;
  79508. /**
  79509. * Remove all attached input methods from a camera
  79510. */
  79511. clear(): void;
  79512. /**
  79513. * Serialize the current input manager attached to a camera.
  79514. * This ensures than once parsed,
  79515. * the input associated to the camera will be identical to the current ones
  79516. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79517. */
  79518. serialize(serializedCamera: any): void;
  79519. /**
  79520. * Parses an input manager serialized JSON to restore the previous list of inputs
  79521. * and states associated to a camera.
  79522. * @param parsedCamera Defines the JSON to parse
  79523. */
  79524. parse(parsedCamera: any): void;
  79525. }
  79526. }
  79527. declare module BABYLON {
  79528. /**
  79529. * Class used to store data that will be store in GPU memory
  79530. */
  79531. export class Buffer {
  79532. private _engine;
  79533. private _buffer;
  79534. /** @hidden */
  79535. _data: Nullable<DataArray>;
  79536. private _updatable;
  79537. private _instanced;
  79538. private _divisor;
  79539. /**
  79540. * Gets the byte stride.
  79541. */
  79542. readonly byteStride: number;
  79543. /**
  79544. * Constructor
  79545. * @param engine the engine
  79546. * @param data the data to use for this buffer
  79547. * @param updatable whether the data is updatable
  79548. * @param stride the stride (optional)
  79549. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79550. * @param instanced whether the buffer is instanced (optional)
  79551. * @param useBytes set to true if the stride in in bytes (optional)
  79552. * @param divisor sets an optional divisor for instances (1 by default)
  79553. */
  79554. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79555. /**
  79556. * Create a new VertexBuffer based on the current buffer
  79557. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79558. * @param offset defines offset in the buffer (0 by default)
  79559. * @param size defines the size in floats of attributes (position is 3 for instance)
  79560. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79561. * @param instanced defines if the vertex buffer contains indexed data
  79562. * @param useBytes defines if the offset and stride are in bytes *
  79563. * @param divisor sets an optional divisor for instances (1 by default)
  79564. * @returns the new vertex buffer
  79565. */
  79566. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  79567. /**
  79568. * Gets a boolean indicating if the Buffer is updatable?
  79569. * @returns true if the buffer is updatable
  79570. */
  79571. isUpdatable(): boolean;
  79572. /**
  79573. * Gets current buffer's data
  79574. * @returns a DataArray or null
  79575. */
  79576. getData(): Nullable<DataArray>;
  79577. /**
  79578. * Gets underlying native buffer
  79579. * @returns underlying native buffer
  79580. */
  79581. getBuffer(): Nullable<DataBuffer>;
  79582. /**
  79583. * Gets the stride in float32 units (i.e. byte stride / 4).
  79584. * May not be an integer if the byte stride is not divisible by 4.
  79585. * @returns the stride in float32 units
  79586. * @deprecated Please use byteStride instead.
  79587. */
  79588. getStrideSize(): number;
  79589. /**
  79590. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79591. * @param data defines the data to store
  79592. */
  79593. create(data?: Nullable<DataArray>): void;
  79594. /** @hidden */
  79595. _rebuild(): void;
  79596. /**
  79597. * Update current buffer data
  79598. * @param data defines the data to store
  79599. */
  79600. update(data: DataArray): void;
  79601. /**
  79602. * Updates the data directly.
  79603. * @param data the new data
  79604. * @param offset the new offset
  79605. * @param vertexCount the vertex count (optional)
  79606. * @param useBytes set to true if the offset is in bytes
  79607. */
  79608. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79609. /**
  79610. * Release all resources
  79611. */
  79612. dispose(): void;
  79613. }
  79614. /**
  79615. * Specialized buffer used to store vertex data
  79616. */
  79617. export class VertexBuffer {
  79618. /** @hidden */
  79619. _buffer: Buffer;
  79620. private _kind;
  79621. private _size;
  79622. private _ownsBuffer;
  79623. private _instanced;
  79624. private _instanceDivisor;
  79625. /**
  79626. * The byte type.
  79627. */
  79628. static readonly BYTE: number;
  79629. /**
  79630. * The unsigned byte type.
  79631. */
  79632. static readonly UNSIGNED_BYTE: number;
  79633. /**
  79634. * The short type.
  79635. */
  79636. static readonly SHORT: number;
  79637. /**
  79638. * The unsigned short type.
  79639. */
  79640. static readonly UNSIGNED_SHORT: number;
  79641. /**
  79642. * The integer type.
  79643. */
  79644. static readonly INT: number;
  79645. /**
  79646. * The unsigned integer type.
  79647. */
  79648. static readonly UNSIGNED_INT: number;
  79649. /**
  79650. * The float type.
  79651. */
  79652. static readonly FLOAT: number;
  79653. /**
  79654. * Gets or sets the instance divisor when in instanced mode
  79655. */
  79656. get instanceDivisor(): number;
  79657. set instanceDivisor(value: number);
  79658. /**
  79659. * Gets the byte stride.
  79660. */
  79661. readonly byteStride: number;
  79662. /**
  79663. * Gets the byte offset.
  79664. */
  79665. readonly byteOffset: number;
  79666. /**
  79667. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79668. */
  79669. readonly normalized: boolean;
  79670. /**
  79671. * Gets the data type of each component in the array.
  79672. */
  79673. readonly type: number;
  79674. /**
  79675. * Constructor
  79676. * @param engine the engine
  79677. * @param data the data to use for this vertex buffer
  79678. * @param kind the vertex buffer kind
  79679. * @param updatable whether the data is updatable
  79680. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79681. * @param stride the stride (optional)
  79682. * @param instanced whether the buffer is instanced (optional)
  79683. * @param offset the offset of the data (optional)
  79684. * @param size the number of components (optional)
  79685. * @param type the type of the component (optional)
  79686. * @param normalized whether the data contains normalized data (optional)
  79687. * @param useBytes set to true if stride and offset are in bytes (optional)
  79688. * @param divisor defines the instance divisor to use (1 by default)
  79689. */
  79690. 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);
  79691. /** @hidden */
  79692. _rebuild(): void;
  79693. /**
  79694. * Returns the kind of the VertexBuffer (string)
  79695. * @returns a string
  79696. */
  79697. getKind(): string;
  79698. /**
  79699. * Gets a boolean indicating if the VertexBuffer is updatable?
  79700. * @returns true if the buffer is updatable
  79701. */
  79702. isUpdatable(): boolean;
  79703. /**
  79704. * Gets current buffer's data
  79705. * @returns a DataArray or null
  79706. */
  79707. getData(): Nullable<DataArray>;
  79708. /**
  79709. * Gets underlying native buffer
  79710. * @returns underlying native buffer
  79711. */
  79712. getBuffer(): Nullable<DataBuffer>;
  79713. /**
  79714. * Gets the stride in float32 units (i.e. byte stride / 4).
  79715. * May not be an integer if the byte stride is not divisible by 4.
  79716. * @returns the stride in float32 units
  79717. * @deprecated Please use byteStride instead.
  79718. */
  79719. getStrideSize(): number;
  79720. /**
  79721. * Returns the offset as a multiple of the type byte length.
  79722. * @returns the offset in bytes
  79723. * @deprecated Please use byteOffset instead.
  79724. */
  79725. getOffset(): number;
  79726. /**
  79727. * Returns the number of components per vertex attribute (integer)
  79728. * @returns the size in float
  79729. */
  79730. getSize(): number;
  79731. /**
  79732. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  79733. * @returns true if this buffer is instanced
  79734. */
  79735. getIsInstanced(): boolean;
  79736. /**
  79737. * Returns the instancing divisor, zero for non-instanced (integer).
  79738. * @returns a number
  79739. */
  79740. getInstanceDivisor(): number;
  79741. /**
  79742. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79743. * @param data defines the data to store
  79744. */
  79745. create(data?: DataArray): void;
  79746. /**
  79747. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  79748. * This function will create a new buffer if the current one is not updatable
  79749. * @param data defines the data to store
  79750. */
  79751. update(data: DataArray): void;
  79752. /**
  79753. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  79754. * Returns the directly updated WebGLBuffer.
  79755. * @param data the new data
  79756. * @param offset the new offset
  79757. * @param useBytes set to true if the offset is in bytes
  79758. */
  79759. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  79760. /**
  79761. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  79762. */
  79763. dispose(): void;
  79764. /**
  79765. * Enumerates each value of this vertex buffer as numbers.
  79766. * @param count the number of values to enumerate
  79767. * @param callback the callback function called for each value
  79768. */
  79769. forEach(count: number, callback: (value: number, index: number) => void): void;
  79770. /**
  79771. * Positions
  79772. */
  79773. static readonly PositionKind: string;
  79774. /**
  79775. * Normals
  79776. */
  79777. static readonly NormalKind: string;
  79778. /**
  79779. * Tangents
  79780. */
  79781. static readonly TangentKind: string;
  79782. /**
  79783. * Texture coordinates
  79784. */
  79785. static readonly UVKind: string;
  79786. /**
  79787. * Texture coordinates 2
  79788. */
  79789. static readonly UV2Kind: string;
  79790. /**
  79791. * Texture coordinates 3
  79792. */
  79793. static readonly UV3Kind: string;
  79794. /**
  79795. * Texture coordinates 4
  79796. */
  79797. static readonly UV4Kind: string;
  79798. /**
  79799. * Texture coordinates 5
  79800. */
  79801. static readonly UV5Kind: string;
  79802. /**
  79803. * Texture coordinates 6
  79804. */
  79805. static readonly UV6Kind: string;
  79806. /**
  79807. * Colors
  79808. */
  79809. static readonly ColorKind: string;
  79810. /**
  79811. * Matrix indices (for bones)
  79812. */
  79813. static readonly MatricesIndicesKind: string;
  79814. /**
  79815. * Matrix weights (for bones)
  79816. */
  79817. static readonly MatricesWeightsKind: string;
  79818. /**
  79819. * Additional matrix indices (for bones)
  79820. */
  79821. static readonly MatricesIndicesExtraKind: string;
  79822. /**
  79823. * Additional matrix weights (for bones)
  79824. */
  79825. static readonly MatricesWeightsExtraKind: string;
  79826. /**
  79827. * Deduces the stride given a kind.
  79828. * @param kind The kind string to deduce
  79829. * @returns The deduced stride
  79830. */
  79831. static DeduceStride(kind: string): number;
  79832. /**
  79833. * Gets the byte length of the given type.
  79834. * @param type the type
  79835. * @returns the number of bytes
  79836. */
  79837. static GetTypeByteLength(type: number): number;
  79838. /**
  79839. * Enumerates each value of the given parameters as numbers.
  79840. * @param data the data to enumerate
  79841. * @param byteOffset the byte offset of the data
  79842. * @param byteStride the byte stride of the data
  79843. * @param componentCount the number of components per element
  79844. * @param componentType the type of the component
  79845. * @param count the number of values to enumerate
  79846. * @param normalized whether the data is normalized
  79847. * @param callback the callback function called for each value
  79848. */
  79849. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  79850. private static _GetFloatValue;
  79851. }
  79852. }
  79853. declare module BABYLON {
  79854. /**
  79855. * @hidden
  79856. */
  79857. export class IntersectionInfo {
  79858. bu: Nullable<number>;
  79859. bv: Nullable<number>;
  79860. distance: number;
  79861. faceId: number;
  79862. subMeshId: number;
  79863. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  79864. }
  79865. }
  79866. declare module BABYLON {
  79867. /**
  79868. * Represens a plane by the equation ax + by + cz + d = 0
  79869. */
  79870. export class Plane {
  79871. private static _TmpMatrix;
  79872. /**
  79873. * Normal of the plane (a,b,c)
  79874. */
  79875. normal: Vector3;
  79876. /**
  79877. * d component of the plane
  79878. */
  79879. d: number;
  79880. /**
  79881. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79882. * @param a a component of the plane
  79883. * @param b b component of the plane
  79884. * @param c c component of the plane
  79885. * @param d d component of the plane
  79886. */
  79887. constructor(a: number, b: number, c: number, d: number);
  79888. /**
  79889. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79890. */
  79891. asArray(): number[];
  79892. /**
  79893. * @returns a new plane copied from the current Plane.
  79894. */
  79895. clone(): Plane;
  79896. /**
  79897. * @returns the string "Plane".
  79898. */
  79899. getClassName(): string;
  79900. /**
  79901. * @returns the Plane hash code.
  79902. */
  79903. getHashCode(): number;
  79904. /**
  79905. * Normalize the current Plane in place.
  79906. * @returns the updated Plane.
  79907. */
  79908. normalize(): Plane;
  79909. /**
  79910. * Applies a transformation the plane and returns the result
  79911. * @param transformation the transformation matrix to be applied to the plane
  79912. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79913. */
  79914. transform(transformation: DeepImmutable<Matrix>): Plane;
  79915. /**
  79916. * Calcualtte the dot product between the point and the plane normal
  79917. * @param point point to calculate the dot product with
  79918. * @returns the dot product (float) of the point coordinates and the plane normal.
  79919. */
  79920. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79921. /**
  79922. * Updates the current Plane from the plane defined by the three given points.
  79923. * @param point1 one of the points used to contruct the plane
  79924. * @param point2 one of the points used to contruct the plane
  79925. * @param point3 one of the points used to contruct the plane
  79926. * @returns the updated Plane.
  79927. */
  79928. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79929. /**
  79930. * Checks if the plane is facing a given direction
  79931. * @param direction the direction to check if the plane is facing
  79932. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79933. * @returns True is the vector "direction" is the same side than the plane normal.
  79934. */
  79935. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79936. /**
  79937. * Calculates the distance to a point
  79938. * @param point point to calculate distance to
  79939. * @returns the signed distance (float) from the given point to the Plane.
  79940. */
  79941. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79942. /**
  79943. * Creates a plane from an array
  79944. * @param array the array to create a plane from
  79945. * @returns a new Plane from the given array.
  79946. */
  79947. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79948. /**
  79949. * Creates a plane from three points
  79950. * @param point1 point used to create the plane
  79951. * @param point2 point used to create the plane
  79952. * @param point3 point used to create the plane
  79953. * @returns a new Plane defined by the three given points.
  79954. */
  79955. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79956. /**
  79957. * Creates a plane from an origin point and a normal
  79958. * @param origin origin of the plane to be constructed
  79959. * @param normal normal of the plane to be constructed
  79960. * @returns a new Plane the normal vector to this plane at the given origin point.
  79961. * Note : the vector "normal" is updated because normalized.
  79962. */
  79963. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79964. /**
  79965. * Calculates the distance from a plane and a point
  79966. * @param origin origin of the plane to be constructed
  79967. * @param normal normal of the plane to be constructed
  79968. * @param point point to calculate distance to
  79969. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79970. */
  79971. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79972. }
  79973. }
  79974. declare module BABYLON {
  79975. /**
  79976. * Class used to store bounding sphere information
  79977. */
  79978. export class BoundingSphere {
  79979. /**
  79980. * Gets the center of the bounding sphere in local space
  79981. */
  79982. readonly center: Vector3;
  79983. /**
  79984. * Radius of the bounding sphere in local space
  79985. */
  79986. radius: number;
  79987. /**
  79988. * Gets the center of the bounding sphere in world space
  79989. */
  79990. readonly centerWorld: Vector3;
  79991. /**
  79992. * Radius of the bounding sphere in world space
  79993. */
  79994. radiusWorld: number;
  79995. /**
  79996. * Gets the minimum vector in local space
  79997. */
  79998. readonly minimum: Vector3;
  79999. /**
  80000. * Gets the maximum vector in local space
  80001. */
  80002. readonly maximum: Vector3;
  80003. private _worldMatrix;
  80004. private static readonly TmpVector3;
  80005. /**
  80006. * Creates a new bounding sphere
  80007. * @param min defines the minimum vector (in local space)
  80008. * @param max defines the maximum vector (in local space)
  80009. * @param worldMatrix defines the new world matrix
  80010. */
  80011. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80012. /**
  80013. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  80014. * @param min defines the new minimum vector (in local space)
  80015. * @param max defines the new maximum vector (in local space)
  80016. * @param worldMatrix defines the new world matrix
  80017. */
  80018. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80019. /**
  80020. * Scale the current bounding sphere by applying a scale factor
  80021. * @param factor defines the scale factor to apply
  80022. * @returns the current bounding box
  80023. */
  80024. scale(factor: number): BoundingSphere;
  80025. /**
  80026. * Gets the world matrix of the bounding box
  80027. * @returns a matrix
  80028. */
  80029. getWorldMatrix(): DeepImmutable<Matrix>;
  80030. /** @hidden */
  80031. _update(worldMatrix: DeepImmutable<Matrix>): void;
  80032. /**
  80033. * Tests if the bounding sphere is intersecting the frustum planes
  80034. * @param frustumPlanes defines the frustum planes to test
  80035. * @returns true if there is an intersection
  80036. */
  80037. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80038. /**
  80039. * Tests if the bounding sphere center is in between the frustum planes.
  80040. * Used for optimistic fast inclusion.
  80041. * @param frustumPlanes defines the frustum planes to test
  80042. * @returns true if the sphere center is in between the frustum planes
  80043. */
  80044. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80045. /**
  80046. * Tests if a point is inside the bounding sphere
  80047. * @param point defines the point to test
  80048. * @returns true if the point is inside the bounding sphere
  80049. */
  80050. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80051. /**
  80052. * Checks if two sphere intersct
  80053. * @param sphere0 sphere 0
  80054. * @param sphere1 sphere 1
  80055. * @returns true if the speres intersect
  80056. */
  80057. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  80058. }
  80059. }
  80060. declare module BABYLON {
  80061. /**
  80062. * Class used to store bounding box information
  80063. */
  80064. export class BoundingBox implements ICullable {
  80065. /**
  80066. * Gets the 8 vectors representing the bounding box in local space
  80067. */
  80068. readonly vectors: Vector3[];
  80069. /**
  80070. * Gets the center of the bounding box in local space
  80071. */
  80072. readonly center: Vector3;
  80073. /**
  80074. * Gets the center of the bounding box in world space
  80075. */
  80076. readonly centerWorld: Vector3;
  80077. /**
  80078. * Gets the extend size in local space
  80079. */
  80080. readonly extendSize: Vector3;
  80081. /**
  80082. * Gets the extend size in world space
  80083. */
  80084. readonly extendSizeWorld: Vector3;
  80085. /**
  80086. * Gets the OBB (object bounding box) directions
  80087. */
  80088. readonly directions: Vector3[];
  80089. /**
  80090. * Gets the 8 vectors representing the bounding box in world space
  80091. */
  80092. readonly vectorsWorld: Vector3[];
  80093. /**
  80094. * Gets the minimum vector in world space
  80095. */
  80096. readonly minimumWorld: Vector3;
  80097. /**
  80098. * Gets the maximum vector in world space
  80099. */
  80100. readonly maximumWorld: Vector3;
  80101. /**
  80102. * Gets the minimum vector in local space
  80103. */
  80104. readonly minimum: Vector3;
  80105. /**
  80106. * Gets the maximum vector in local space
  80107. */
  80108. readonly maximum: Vector3;
  80109. private _worldMatrix;
  80110. private static readonly TmpVector3;
  80111. /**
  80112. * @hidden
  80113. */
  80114. _tag: number;
  80115. /**
  80116. * Creates a new bounding box
  80117. * @param min defines the minimum vector (in local space)
  80118. * @param max defines the maximum vector (in local space)
  80119. * @param worldMatrix defines the new world matrix
  80120. */
  80121. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80122. /**
  80123. * Recreates the entire bounding box from scratch as if we call the constructor in place
  80124. * @param min defines the new minimum vector (in local space)
  80125. * @param max defines the new maximum vector (in local space)
  80126. * @param worldMatrix defines the new world matrix
  80127. */
  80128. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80129. /**
  80130. * Scale the current bounding box by applying a scale factor
  80131. * @param factor defines the scale factor to apply
  80132. * @returns the current bounding box
  80133. */
  80134. scale(factor: number): BoundingBox;
  80135. /**
  80136. * Gets the world matrix of the bounding box
  80137. * @returns a matrix
  80138. */
  80139. getWorldMatrix(): DeepImmutable<Matrix>;
  80140. /** @hidden */
  80141. _update(world: DeepImmutable<Matrix>): void;
  80142. /**
  80143. * Tests if the bounding box is intersecting the frustum planes
  80144. * @param frustumPlanes defines the frustum planes to test
  80145. * @returns true if there is an intersection
  80146. */
  80147. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80148. /**
  80149. * Tests if the bounding box is entirely inside the frustum planes
  80150. * @param frustumPlanes defines the frustum planes to test
  80151. * @returns true if there is an inclusion
  80152. */
  80153. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80154. /**
  80155. * Tests if a point is inside the bounding box
  80156. * @param point defines the point to test
  80157. * @returns true if the point is inside the bounding box
  80158. */
  80159. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80160. /**
  80161. * Tests if the bounding box intersects with a bounding sphere
  80162. * @param sphere defines the sphere to test
  80163. * @returns true if there is an intersection
  80164. */
  80165. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  80166. /**
  80167. * Tests if the bounding box intersects with a box defined by a min and max vectors
  80168. * @param min defines the min vector to use
  80169. * @param max defines the max vector to use
  80170. * @returns true if there is an intersection
  80171. */
  80172. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  80173. /**
  80174. * Tests if two bounding boxes are intersections
  80175. * @param box0 defines the first box to test
  80176. * @param box1 defines the second box to test
  80177. * @returns true if there is an intersection
  80178. */
  80179. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  80180. /**
  80181. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  80182. * @param minPoint defines the minimum vector of the bounding box
  80183. * @param maxPoint defines the maximum vector of the bounding box
  80184. * @param sphereCenter defines the sphere center
  80185. * @param sphereRadius defines the sphere radius
  80186. * @returns true if there is an intersection
  80187. */
  80188. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  80189. /**
  80190. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  80191. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80192. * @param frustumPlanes defines the frustum planes to test
  80193. * @return true if there is an inclusion
  80194. */
  80195. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80196. /**
  80197. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  80198. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80199. * @param frustumPlanes defines the frustum planes to test
  80200. * @return true if there is an intersection
  80201. */
  80202. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80203. }
  80204. }
  80205. declare module BABYLON {
  80206. /** @hidden */
  80207. export class Collider {
  80208. /** Define if a collision was found */
  80209. collisionFound: boolean;
  80210. /**
  80211. * Define last intersection point in local space
  80212. */
  80213. intersectionPoint: Vector3;
  80214. /**
  80215. * Define last collided mesh
  80216. */
  80217. collidedMesh: Nullable<AbstractMesh>;
  80218. private _collisionPoint;
  80219. private _planeIntersectionPoint;
  80220. private _tempVector;
  80221. private _tempVector2;
  80222. private _tempVector3;
  80223. private _tempVector4;
  80224. private _edge;
  80225. private _baseToVertex;
  80226. private _destinationPoint;
  80227. private _slidePlaneNormal;
  80228. private _displacementVector;
  80229. /** @hidden */
  80230. _radius: Vector3;
  80231. /** @hidden */
  80232. _retry: number;
  80233. private _velocity;
  80234. private _basePoint;
  80235. private _epsilon;
  80236. /** @hidden */
  80237. _velocityWorldLength: number;
  80238. /** @hidden */
  80239. _basePointWorld: Vector3;
  80240. private _velocityWorld;
  80241. private _normalizedVelocity;
  80242. /** @hidden */
  80243. _initialVelocity: Vector3;
  80244. /** @hidden */
  80245. _initialPosition: Vector3;
  80246. private _nearestDistance;
  80247. private _collisionMask;
  80248. get collisionMask(): number;
  80249. set collisionMask(mask: number);
  80250. /**
  80251. * Gets the plane normal used to compute the sliding response (in local space)
  80252. */
  80253. get slidePlaneNormal(): Vector3;
  80254. /** @hidden */
  80255. _initialize(source: Vector3, dir: Vector3, e: number): void;
  80256. /** @hidden */
  80257. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  80258. /** @hidden */
  80259. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  80260. /** @hidden */
  80261. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80262. /** @hidden */
  80263. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80264. /** @hidden */
  80265. _getResponse(pos: Vector3, vel: Vector3): void;
  80266. }
  80267. }
  80268. declare module BABYLON {
  80269. /**
  80270. * Interface for cullable objects
  80271. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  80272. */
  80273. export interface ICullable {
  80274. /**
  80275. * Checks if the object or part of the object is in the frustum
  80276. * @param frustumPlanes Camera near/planes
  80277. * @returns true if the object is in frustum otherwise false
  80278. */
  80279. isInFrustum(frustumPlanes: Plane[]): boolean;
  80280. /**
  80281. * Checks if a cullable object (mesh...) is in the camera frustum
  80282. * Unlike isInFrustum this cheks the full bounding box
  80283. * @param frustumPlanes Camera near/planes
  80284. * @returns true if the object is in frustum otherwise false
  80285. */
  80286. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80287. }
  80288. /**
  80289. * Info for a bounding data of a mesh
  80290. */
  80291. export class BoundingInfo implements ICullable {
  80292. /**
  80293. * Bounding box for the mesh
  80294. */
  80295. readonly boundingBox: BoundingBox;
  80296. /**
  80297. * Bounding sphere for the mesh
  80298. */
  80299. readonly boundingSphere: BoundingSphere;
  80300. private _isLocked;
  80301. private static readonly TmpVector3;
  80302. /**
  80303. * Constructs bounding info
  80304. * @param minimum min vector of the bounding box/sphere
  80305. * @param maximum max vector of the bounding box/sphere
  80306. * @param worldMatrix defines the new world matrix
  80307. */
  80308. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80309. /**
  80310. * Recreates the entire bounding info from scratch as if we call the constructor in place
  80311. * @param min defines the new minimum vector (in local space)
  80312. * @param max defines the new maximum vector (in local space)
  80313. * @param worldMatrix defines the new world matrix
  80314. */
  80315. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80316. /**
  80317. * min vector of the bounding box/sphere
  80318. */
  80319. get minimum(): Vector3;
  80320. /**
  80321. * max vector of the bounding box/sphere
  80322. */
  80323. get maximum(): Vector3;
  80324. /**
  80325. * If the info is locked and won't be updated to avoid perf overhead
  80326. */
  80327. get isLocked(): boolean;
  80328. set isLocked(value: boolean);
  80329. /**
  80330. * Updates the bounding sphere and box
  80331. * @param world world matrix to be used to update
  80332. */
  80333. update(world: DeepImmutable<Matrix>): void;
  80334. /**
  80335. * Recreate the bounding info to be centered around a specific point given a specific extend.
  80336. * @param center New center of the bounding info
  80337. * @param extend New extend of the bounding info
  80338. * @returns the current bounding info
  80339. */
  80340. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  80341. /**
  80342. * Scale the current bounding info by applying a scale factor
  80343. * @param factor defines the scale factor to apply
  80344. * @returns the current bounding info
  80345. */
  80346. scale(factor: number): BoundingInfo;
  80347. /**
  80348. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  80349. * @param frustumPlanes defines the frustum to test
  80350. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  80351. * @returns true if the bounding info is in the frustum planes
  80352. */
  80353. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  80354. /**
  80355. * Gets the world distance between the min and max points of the bounding box
  80356. */
  80357. get diagonalLength(): number;
  80358. /**
  80359. * Checks if a cullable object (mesh...) is in the camera frustum
  80360. * Unlike isInFrustum this cheks the full bounding box
  80361. * @param frustumPlanes Camera near/planes
  80362. * @returns true if the object is in frustum otherwise false
  80363. */
  80364. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80365. /** @hidden */
  80366. _checkCollision(collider: Collider): boolean;
  80367. /**
  80368. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  80369. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80370. * @param point the point to check intersection with
  80371. * @returns if the point intersects
  80372. */
  80373. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80374. /**
  80375. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  80376. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80377. * @param boundingInfo the bounding info to check intersection with
  80378. * @param precise if the intersection should be done using OBB
  80379. * @returns if the bounding info intersects
  80380. */
  80381. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  80382. }
  80383. }
  80384. declare module BABYLON {
  80385. /**
  80386. * Extracts minimum and maximum values from a list of indexed positions
  80387. * @param positions defines the positions to use
  80388. * @param indices defines the indices to the positions
  80389. * @param indexStart defines the start index
  80390. * @param indexCount defines the end index
  80391. * @param bias defines bias value to add to the result
  80392. * @return minimum and maximum values
  80393. */
  80394. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  80395. minimum: Vector3;
  80396. maximum: Vector3;
  80397. };
  80398. /**
  80399. * Extracts minimum and maximum values from a list of positions
  80400. * @param positions defines the positions to use
  80401. * @param start defines the start index in the positions array
  80402. * @param count defines the number of positions to handle
  80403. * @param bias defines bias value to add to the result
  80404. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80405. * @return minimum and maximum values
  80406. */
  80407. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80408. minimum: Vector3;
  80409. maximum: Vector3;
  80410. };
  80411. }
  80412. declare module BABYLON {
  80413. /** @hidden */
  80414. export class WebGLDataBuffer extends DataBuffer {
  80415. private _buffer;
  80416. constructor(resource: WebGLBuffer);
  80417. get underlyingResource(): any;
  80418. }
  80419. }
  80420. declare module BABYLON {
  80421. /** @hidden */
  80422. export class WebGLPipelineContext implements IPipelineContext {
  80423. engine: ThinEngine;
  80424. program: Nullable<WebGLProgram>;
  80425. context?: WebGLRenderingContext;
  80426. vertexShader?: WebGLShader;
  80427. fragmentShader?: WebGLShader;
  80428. isParallelCompiled: boolean;
  80429. onCompiled?: () => void;
  80430. transformFeedback?: WebGLTransformFeedback | null;
  80431. vertexCompilationError: Nullable<string>;
  80432. fragmentCompilationError: Nullable<string>;
  80433. programLinkError: Nullable<string>;
  80434. programValidationError: Nullable<string>;
  80435. get isAsync(): boolean;
  80436. get isReady(): boolean;
  80437. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80438. }
  80439. }
  80440. declare module BABYLON {
  80441. interface ThinEngine {
  80442. /**
  80443. * Create an uniform buffer
  80444. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80445. * @param elements defines the content of the uniform buffer
  80446. * @returns the webGL uniform buffer
  80447. */
  80448. createUniformBuffer(elements: FloatArray): DataBuffer;
  80449. /**
  80450. * Create a dynamic uniform buffer
  80451. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80452. * @param elements defines the content of the uniform buffer
  80453. * @returns the webGL uniform buffer
  80454. */
  80455. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80456. /**
  80457. * Update an existing uniform buffer
  80458. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80459. * @param uniformBuffer defines the target uniform buffer
  80460. * @param elements defines the content to update
  80461. * @param offset defines the offset in the uniform buffer where update should start
  80462. * @param count defines the size of the data to update
  80463. */
  80464. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80465. /**
  80466. * Bind an uniform buffer to the current webGL context
  80467. * @param buffer defines the buffer to bind
  80468. */
  80469. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80470. /**
  80471. * Bind a buffer to the current webGL context at a given location
  80472. * @param buffer defines the buffer to bind
  80473. * @param location defines the index where to bind the buffer
  80474. */
  80475. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80476. /**
  80477. * Bind a specific block at a given index in a specific shader program
  80478. * @param pipelineContext defines the pipeline context to use
  80479. * @param blockName defines the block name
  80480. * @param index defines the index where to bind the block
  80481. */
  80482. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80483. }
  80484. }
  80485. declare module BABYLON {
  80486. /**
  80487. * Uniform buffer objects.
  80488. *
  80489. * Handles blocks of uniform on the GPU.
  80490. *
  80491. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80492. *
  80493. * For more information, please refer to :
  80494. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80495. */
  80496. export class UniformBuffer {
  80497. private _engine;
  80498. private _buffer;
  80499. private _data;
  80500. private _bufferData;
  80501. private _dynamic?;
  80502. private _uniformLocations;
  80503. private _uniformSizes;
  80504. private _uniformLocationPointer;
  80505. private _needSync;
  80506. private _noUBO;
  80507. private _currentEffect;
  80508. /** @hidden */
  80509. _alreadyBound: boolean;
  80510. private static _MAX_UNIFORM_SIZE;
  80511. private static _tempBuffer;
  80512. /**
  80513. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80514. * This is dynamic to allow compat with webgl 1 and 2.
  80515. * You will need to pass the name of the uniform as well as the value.
  80516. */
  80517. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80518. /**
  80519. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80520. * This is dynamic to allow compat with webgl 1 and 2.
  80521. * You will need to pass the name of the uniform as well as the value.
  80522. */
  80523. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80524. /**
  80525. * Lambda to Update a single float in a uniform buffer.
  80526. * This is dynamic to allow compat with webgl 1 and 2.
  80527. * You will need to pass the name of the uniform as well as the value.
  80528. */
  80529. updateFloat: (name: string, x: number) => void;
  80530. /**
  80531. * Lambda to Update a vec2 of float in a uniform buffer.
  80532. * This is dynamic to allow compat with webgl 1 and 2.
  80533. * You will need to pass the name of the uniform as well as the value.
  80534. */
  80535. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80536. /**
  80537. * Lambda to Update a vec3 of float in a uniform buffer.
  80538. * This is dynamic to allow compat with webgl 1 and 2.
  80539. * You will need to pass the name of the uniform as well as the value.
  80540. */
  80541. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80542. /**
  80543. * Lambda to Update a vec4 of float in a uniform buffer.
  80544. * This is dynamic to allow compat with webgl 1 and 2.
  80545. * You will need to pass the name of the uniform as well as the value.
  80546. */
  80547. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80548. /**
  80549. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80550. * This is dynamic to allow compat with webgl 1 and 2.
  80551. * You will need to pass the name of the uniform as well as the value.
  80552. */
  80553. updateMatrix: (name: string, mat: Matrix) => void;
  80554. /**
  80555. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80556. * This is dynamic to allow compat with webgl 1 and 2.
  80557. * You will need to pass the name of the uniform as well as the value.
  80558. */
  80559. updateVector3: (name: string, vector: Vector3) => void;
  80560. /**
  80561. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80562. * This is dynamic to allow compat with webgl 1 and 2.
  80563. * You will need to pass the name of the uniform as well as the value.
  80564. */
  80565. updateVector4: (name: string, vector: Vector4) => void;
  80566. /**
  80567. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  80568. * This is dynamic to allow compat with webgl 1 and 2.
  80569. * You will need to pass the name of the uniform as well as the value.
  80570. */
  80571. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  80572. /**
  80573. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  80574. * This is dynamic to allow compat with webgl 1 and 2.
  80575. * You will need to pass the name of the uniform as well as the value.
  80576. */
  80577. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  80578. /**
  80579. * Instantiates a new Uniform buffer objects.
  80580. *
  80581. * Handles blocks of uniform on the GPU.
  80582. *
  80583. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80584. *
  80585. * For more information, please refer to :
  80586. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80587. * @param engine Define the engine the buffer is associated with
  80588. * @param data Define the data contained in the buffer
  80589. * @param dynamic Define if the buffer is updatable
  80590. */
  80591. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  80592. /**
  80593. * Indicates if the buffer is using the WebGL2 UBO implementation,
  80594. * or just falling back on setUniformXXX calls.
  80595. */
  80596. get useUbo(): boolean;
  80597. /**
  80598. * Indicates if the WebGL underlying uniform buffer is in sync
  80599. * with the javascript cache data.
  80600. */
  80601. get isSync(): boolean;
  80602. /**
  80603. * Indicates if the WebGL underlying uniform buffer is dynamic.
  80604. * Also, a dynamic UniformBuffer will disable cache verification and always
  80605. * update the underlying WebGL uniform buffer to the GPU.
  80606. * @returns if Dynamic, otherwise false
  80607. */
  80608. isDynamic(): boolean;
  80609. /**
  80610. * The data cache on JS side.
  80611. * @returns the underlying data as a float array
  80612. */
  80613. getData(): Float32Array;
  80614. /**
  80615. * The underlying WebGL Uniform buffer.
  80616. * @returns the webgl buffer
  80617. */
  80618. getBuffer(): Nullable<DataBuffer>;
  80619. /**
  80620. * std140 layout specifies how to align data within an UBO structure.
  80621. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80622. * for specs.
  80623. */
  80624. private _fillAlignment;
  80625. /**
  80626. * Adds an uniform in the buffer.
  80627. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80628. * for the layout to be correct !
  80629. * @param name Name of the uniform, as used in the uniform block in the shader.
  80630. * @param size Data size, or data directly.
  80631. */
  80632. addUniform(name: string, size: number | number[]): void;
  80633. /**
  80634. * Adds a Matrix 4x4 to the uniform buffer.
  80635. * @param name Name of the uniform, as used in the uniform block in the shader.
  80636. * @param mat A 4x4 matrix.
  80637. */
  80638. addMatrix(name: string, mat: Matrix): void;
  80639. /**
  80640. * Adds a vec2 to the uniform buffer.
  80641. * @param name Name of the uniform, as used in the uniform block in the shader.
  80642. * @param x Define the x component value of the vec2
  80643. * @param y Define the y component value of the vec2
  80644. */
  80645. addFloat2(name: string, x: number, y: number): void;
  80646. /**
  80647. * Adds a vec3 to the uniform buffer.
  80648. * @param name Name of the uniform, as used in the uniform block in the shader.
  80649. * @param x Define the x component value of the vec3
  80650. * @param y Define the y component value of the vec3
  80651. * @param z Define the z component value of the vec3
  80652. */
  80653. addFloat3(name: string, x: number, y: number, z: number): void;
  80654. /**
  80655. * Adds a vec3 to the uniform buffer.
  80656. * @param name Name of the uniform, as used in the uniform block in the shader.
  80657. * @param color Define the vec3 from a Color
  80658. */
  80659. addColor3(name: string, color: Color3): void;
  80660. /**
  80661. * Adds a vec4 to the uniform buffer.
  80662. * @param name Name of the uniform, as used in the uniform block in the shader.
  80663. * @param color Define the rgb components from a Color
  80664. * @param alpha Define the a component of the vec4
  80665. */
  80666. addColor4(name: string, color: Color3, alpha: number): void;
  80667. /**
  80668. * Adds a vec3 to the uniform buffer.
  80669. * @param name Name of the uniform, as used in the uniform block in the shader.
  80670. * @param vector Define the vec3 components from a Vector
  80671. */
  80672. addVector3(name: string, vector: Vector3): void;
  80673. /**
  80674. * Adds a Matrix 3x3 to the uniform buffer.
  80675. * @param name Name of the uniform, as used in the uniform block in the shader.
  80676. */
  80677. addMatrix3x3(name: string): void;
  80678. /**
  80679. * Adds a Matrix 2x2 to the uniform buffer.
  80680. * @param name Name of the uniform, as used in the uniform block in the shader.
  80681. */
  80682. addMatrix2x2(name: string): void;
  80683. /**
  80684. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  80685. */
  80686. create(): void;
  80687. /** @hidden */
  80688. _rebuild(): void;
  80689. /**
  80690. * Updates the WebGL Uniform Buffer on the GPU.
  80691. * If the `dynamic` flag is set to true, no cache comparison is done.
  80692. * Otherwise, the buffer will be updated only if the cache differs.
  80693. */
  80694. update(): void;
  80695. /**
  80696. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80697. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80698. * @param data Define the flattened data
  80699. * @param size Define the size of the data.
  80700. */
  80701. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  80702. private _valueCache;
  80703. private _cacheMatrix;
  80704. private _updateMatrix3x3ForUniform;
  80705. private _updateMatrix3x3ForEffect;
  80706. private _updateMatrix2x2ForEffect;
  80707. private _updateMatrix2x2ForUniform;
  80708. private _updateFloatForEffect;
  80709. private _updateFloatForUniform;
  80710. private _updateFloat2ForEffect;
  80711. private _updateFloat2ForUniform;
  80712. private _updateFloat3ForEffect;
  80713. private _updateFloat3ForUniform;
  80714. private _updateFloat4ForEffect;
  80715. private _updateFloat4ForUniform;
  80716. private _updateMatrixForEffect;
  80717. private _updateMatrixForUniform;
  80718. private _updateVector3ForEffect;
  80719. private _updateVector3ForUniform;
  80720. private _updateVector4ForEffect;
  80721. private _updateVector4ForUniform;
  80722. private _updateColor3ForEffect;
  80723. private _updateColor3ForUniform;
  80724. private _updateColor4ForEffect;
  80725. private _updateColor4ForUniform;
  80726. /**
  80727. * Sets a sampler uniform on the effect.
  80728. * @param name Define the name of the sampler.
  80729. * @param texture Define the texture to set in the sampler
  80730. */
  80731. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  80732. /**
  80733. * Directly updates the value of the uniform in the cache AND on the GPU.
  80734. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80735. * @param data Define the flattened data
  80736. */
  80737. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  80738. /**
  80739. * Binds this uniform buffer to an effect.
  80740. * @param effect Define the effect to bind the buffer to
  80741. * @param name Name of the uniform block in the shader.
  80742. */
  80743. bindToEffect(effect: Effect, name: string): void;
  80744. /**
  80745. * Disposes the uniform buffer.
  80746. */
  80747. dispose(): void;
  80748. }
  80749. }
  80750. declare module BABYLON {
  80751. /**
  80752. * Enum that determines the text-wrapping mode to use.
  80753. */
  80754. export enum InspectableType {
  80755. /**
  80756. * Checkbox for booleans
  80757. */
  80758. Checkbox = 0,
  80759. /**
  80760. * Sliders for numbers
  80761. */
  80762. Slider = 1,
  80763. /**
  80764. * Vector3
  80765. */
  80766. Vector3 = 2,
  80767. /**
  80768. * Quaternions
  80769. */
  80770. Quaternion = 3,
  80771. /**
  80772. * Color3
  80773. */
  80774. Color3 = 4,
  80775. /**
  80776. * String
  80777. */
  80778. String = 5
  80779. }
  80780. /**
  80781. * Interface used to define custom inspectable properties.
  80782. * This interface is used by the inspector to display custom property grids
  80783. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80784. */
  80785. export interface IInspectable {
  80786. /**
  80787. * Gets the label to display
  80788. */
  80789. label: string;
  80790. /**
  80791. * Gets the name of the property to edit
  80792. */
  80793. propertyName: string;
  80794. /**
  80795. * Gets the type of the editor to use
  80796. */
  80797. type: InspectableType;
  80798. /**
  80799. * Gets the minimum value of the property when using in "slider" mode
  80800. */
  80801. min?: number;
  80802. /**
  80803. * Gets the maximum value of the property when using in "slider" mode
  80804. */
  80805. max?: number;
  80806. /**
  80807. * Gets the setp to use when using in "slider" mode
  80808. */
  80809. step?: number;
  80810. }
  80811. }
  80812. declare module BABYLON {
  80813. /**
  80814. * Class used to provide helper for timing
  80815. */
  80816. export class TimingTools {
  80817. /**
  80818. * Polyfill for setImmediate
  80819. * @param action defines the action to execute after the current execution block
  80820. */
  80821. static SetImmediate(action: () => void): void;
  80822. }
  80823. }
  80824. declare module BABYLON {
  80825. /**
  80826. * Class used to enable instatition of objects by class name
  80827. */
  80828. export class InstantiationTools {
  80829. /**
  80830. * Use this object to register external classes like custom textures or material
  80831. * to allow the laoders to instantiate them
  80832. */
  80833. static RegisteredExternalClasses: {
  80834. [key: string]: Object;
  80835. };
  80836. /**
  80837. * Tries to instantiate a new object from a given class name
  80838. * @param className defines the class name to instantiate
  80839. * @returns the new object or null if the system was not able to do the instantiation
  80840. */
  80841. static Instantiate(className: string): any;
  80842. }
  80843. }
  80844. declare module BABYLON {
  80845. /**
  80846. * Define options used to create a depth texture
  80847. */
  80848. export class DepthTextureCreationOptions {
  80849. /** Specifies whether or not a stencil should be allocated in the texture */
  80850. generateStencil?: boolean;
  80851. /** Specifies whether or not bilinear filtering is enable on the texture */
  80852. bilinearFiltering?: boolean;
  80853. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  80854. comparisonFunction?: number;
  80855. /** Specifies if the created texture is a cube texture */
  80856. isCube?: boolean;
  80857. }
  80858. }
  80859. declare module BABYLON {
  80860. interface ThinEngine {
  80861. /**
  80862. * Creates a depth stencil cube texture.
  80863. * This is only available in WebGL 2.
  80864. * @param size The size of face edge in the cube texture.
  80865. * @param options The options defining the cube texture.
  80866. * @returns The cube texture
  80867. */
  80868. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  80869. /**
  80870. * Creates a cube texture
  80871. * @param rootUrl defines the url where the files to load is located
  80872. * @param scene defines the current scene
  80873. * @param files defines the list of files to load (1 per face)
  80874. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80875. * @param onLoad defines an optional callback raised when the texture is loaded
  80876. * @param onError defines an optional callback raised if there is an issue to load the texture
  80877. * @param format defines the format of the data
  80878. * @param forcedExtension defines the extension to use to pick the right loader
  80879. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80880. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80881. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80882. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  80883. * @returns the cube texture as an InternalTexture
  80884. */
  80885. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  80886. /**
  80887. * Creates a cube texture
  80888. * @param rootUrl defines the url where the files to load is located
  80889. * @param scene defines the current scene
  80890. * @param files defines the list of files to load (1 per face)
  80891. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80892. * @param onLoad defines an optional callback raised when the texture is loaded
  80893. * @param onError defines an optional callback raised if there is an issue to load the texture
  80894. * @param format defines the format of the data
  80895. * @param forcedExtension defines the extension to use to pick the right loader
  80896. * @returns the cube texture as an InternalTexture
  80897. */
  80898. 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;
  80899. /**
  80900. * Creates a cube texture
  80901. * @param rootUrl defines the url where the files to load is located
  80902. * @param scene defines the current scene
  80903. * @param files defines the list of files to load (1 per face)
  80904. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80905. * @param onLoad defines an optional callback raised when the texture is loaded
  80906. * @param onError defines an optional callback raised if there is an issue to load the texture
  80907. * @param format defines the format of the data
  80908. * @param forcedExtension defines the extension to use to pick the right loader
  80909. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80910. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80911. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80912. * @returns the cube texture as an InternalTexture
  80913. */
  80914. 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;
  80915. /** @hidden */
  80916. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  80917. /** @hidden */
  80918. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  80919. /** @hidden */
  80920. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80921. /** @hidden */
  80922. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80923. /**
  80924. * @hidden
  80925. */
  80926. _setCubeMapTextureParams(loadMipmap: boolean): void;
  80927. }
  80928. }
  80929. declare module BABYLON {
  80930. /**
  80931. * Class for creating a cube texture
  80932. */
  80933. export class CubeTexture extends BaseTexture {
  80934. private _delayedOnLoad;
  80935. /**
  80936. * Observable triggered once the texture has been loaded.
  80937. */
  80938. onLoadObservable: Observable<CubeTexture>;
  80939. /**
  80940. * The url of the texture
  80941. */
  80942. url: string;
  80943. /**
  80944. * Gets or sets the center of the bounding box associated with the cube texture.
  80945. * It must define where the camera used to render the texture was set
  80946. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80947. */
  80948. boundingBoxPosition: Vector3;
  80949. private _boundingBoxSize;
  80950. /**
  80951. * Gets or sets the size of the bounding box associated with the cube texture
  80952. * When defined, the cubemap will switch to local mode
  80953. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  80954. * @example https://www.babylonjs-playground.com/#RNASML
  80955. */
  80956. set boundingBoxSize(value: Vector3);
  80957. /**
  80958. * Returns the bounding box size
  80959. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80960. */
  80961. get boundingBoxSize(): Vector3;
  80962. protected _rotationY: number;
  80963. /**
  80964. * Sets texture matrix rotation angle around Y axis in radians.
  80965. */
  80966. set rotationY(value: number);
  80967. /**
  80968. * Gets texture matrix rotation angle around Y axis radians.
  80969. */
  80970. get rotationY(): number;
  80971. /**
  80972. * Are mip maps generated for this texture or not.
  80973. */
  80974. get noMipmap(): boolean;
  80975. private _noMipmap;
  80976. private _files;
  80977. protected _forcedExtension: Nullable<string>;
  80978. private _extensions;
  80979. private _textureMatrix;
  80980. private _format;
  80981. private _createPolynomials;
  80982. /** @hidden */
  80983. _prefiltered: boolean;
  80984. /**
  80985. * Creates a cube texture from an array of image urls
  80986. * @param files defines an array of image urls
  80987. * @param scene defines the hosting scene
  80988. * @param noMipmap specifies if mip maps are not used
  80989. * @returns a cube texture
  80990. */
  80991. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  80992. /**
  80993. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  80994. * @param url defines the url of the prefiltered texture
  80995. * @param scene defines the scene the texture is attached to
  80996. * @param forcedExtension defines the extension of the file if different from the url
  80997. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80998. * @return the prefiltered texture
  80999. */
  81000. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  81001. /**
  81002. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  81003. * as prefiltered data.
  81004. * @param rootUrl defines the url of the texture or the root name of the six images
  81005. * @param scene defines the scene the texture is attached to
  81006. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  81007. * @param noMipmap defines if mipmaps should be created or not
  81008. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  81009. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  81010. * @param onError defines a callback triggered in case of error during load
  81011. * @param format defines the internal format to use for the texture once loaded
  81012. * @param prefiltered defines whether or not the texture is created from prefiltered data
  81013. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  81014. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81015. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81016. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81017. * @return the cube texture
  81018. */
  81019. 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);
  81020. /**
  81021. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  81022. */
  81023. get isPrefiltered(): boolean;
  81024. /**
  81025. * Get the current class name of the texture useful for serialization or dynamic coding.
  81026. * @returns "CubeTexture"
  81027. */
  81028. getClassName(): string;
  81029. /**
  81030. * Update the url (and optional buffer) of this texture if url was null during construction.
  81031. * @param url the url of the texture
  81032. * @param forcedExtension defines the extension to use
  81033. * @param onLoad callback called when the texture is loaded (defaults to null)
  81034. * @param prefiltered Defines whether the updated texture is prefiltered or not
  81035. */
  81036. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  81037. /**
  81038. * Delays loading of the cube texture
  81039. * @param forcedExtension defines the extension to use
  81040. */
  81041. delayLoad(forcedExtension?: string): void;
  81042. /**
  81043. * Returns the reflection texture matrix
  81044. * @returns the reflection texture matrix
  81045. */
  81046. getReflectionTextureMatrix(): Matrix;
  81047. /**
  81048. * Sets the reflection texture matrix
  81049. * @param value Reflection texture matrix
  81050. */
  81051. setReflectionTextureMatrix(value: Matrix): void;
  81052. /**
  81053. * Parses text to create a cube texture
  81054. * @param parsedTexture define the serialized text to read from
  81055. * @param scene defines the hosting scene
  81056. * @param rootUrl defines the root url of the cube texture
  81057. * @returns a cube texture
  81058. */
  81059. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  81060. /**
  81061. * Makes a clone, or deep copy, of the cube texture
  81062. * @returns a new cube texture
  81063. */
  81064. clone(): CubeTexture;
  81065. }
  81066. }
  81067. declare module BABYLON {
  81068. /**
  81069. * Manages the defines for the Material
  81070. */
  81071. export class MaterialDefines {
  81072. /** @hidden */
  81073. protected _keys: string[];
  81074. private _isDirty;
  81075. /** @hidden */
  81076. _renderId: number;
  81077. /** @hidden */
  81078. _areLightsDirty: boolean;
  81079. /** @hidden */
  81080. _areLightsDisposed: boolean;
  81081. /** @hidden */
  81082. _areAttributesDirty: boolean;
  81083. /** @hidden */
  81084. _areTexturesDirty: boolean;
  81085. /** @hidden */
  81086. _areFresnelDirty: boolean;
  81087. /** @hidden */
  81088. _areMiscDirty: boolean;
  81089. /** @hidden */
  81090. _areImageProcessingDirty: boolean;
  81091. /** @hidden */
  81092. _normals: boolean;
  81093. /** @hidden */
  81094. _uvs: boolean;
  81095. /** @hidden */
  81096. _needNormals: boolean;
  81097. /** @hidden */
  81098. _needUVs: boolean;
  81099. [id: string]: any;
  81100. /**
  81101. * Specifies if the material needs to be re-calculated
  81102. */
  81103. get isDirty(): boolean;
  81104. /**
  81105. * Marks the material to indicate that it has been re-calculated
  81106. */
  81107. markAsProcessed(): void;
  81108. /**
  81109. * Marks the material to indicate that it needs to be re-calculated
  81110. */
  81111. markAsUnprocessed(): void;
  81112. /**
  81113. * Marks the material to indicate all of its defines need to be re-calculated
  81114. */
  81115. markAllAsDirty(): void;
  81116. /**
  81117. * Marks the material to indicate that image processing needs to be re-calculated
  81118. */
  81119. markAsImageProcessingDirty(): void;
  81120. /**
  81121. * Marks the material to indicate the lights need to be re-calculated
  81122. * @param disposed Defines whether the light is dirty due to dispose or not
  81123. */
  81124. markAsLightDirty(disposed?: boolean): void;
  81125. /**
  81126. * Marks the attribute state as changed
  81127. */
  81128. markAsAttributesDirty(): void;
  81129. /**
  81130. * Marks the texture state as changed
  81131. */
  81132. markAsTexturesDirty(): void;
  81133. /**
  81134. * Marks the fresnel state as changed
  81135. */
  81136. markAsFresnelDirty(): void;
  81137. /**
  81138. * Marks the misc state as changed
  81139. */
  81140. markAsMiscDirty(): void;
  81141. /**
  81142. * Rebuilds the material defines
  81143. */
  81144. rebuild(): void;
  81145. /**
  81146. * Specifies if two material defines are equal
  81147. * @param other - A material define instance to compare to
  81148. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  81149. */
  81150. isEqual(other: MaterialDefines): boolean;
  81151. /**
  81152. * Clones this instance's defines to another instance
  81153. * @param other - material defines to clone values to
  81154. */
  81155. cloneTo(other: MaterialDefines): void;
  81156. /**
  81157. * Resets the material define values
  81158. */
  81159. reset(): void;
  81160. /**
  81161. * Converts the material define values to a string
  81162. * @returns - String of material define information
  81163. */
  81164. toString(): string;
  81165. }
  81166. }
  81167. declare module BABYLON {
  81168. /**
  81169. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  81170. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  81171. * 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;
  81172. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  81173. */
  81174. export class ColorCurves {
  81175. private _dirty;
  81176. private _tempColor;
  81177. private _globalCurve;
  81178. private _highlightsCurve;
  81179. private _midtonesCurve;
  81180. private _shadowsCurve;
  81181. private _positiveCurve;
  81182. private _negativeCurve;
  81183. private _globalHue;
  81184. private _globalDensity;
  81185. private _globalSaturation;
  81186. private _globalExposure;
  81187. /**
  81188. * Gets the global Hue value.
  81189. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  81190. */
  81191. get globalHue(): number;
  81192. /**
  81193. * Sets the global Hue value.
  81194. * 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).
  81195. */
  81196. set globalHue(value: number);
  81197. /**
  81198. * Gets the global Density value.
  81199. * 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.
  81200. * Values less than zero provide a filter of opposite hue.
  81201. */
  81202. get globalDensity(): number;
  81203. /**
  81204. * Sets the global Density value.
  81205. * 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.
  81206. * Values less than zero provide a filter of opposite hue.
  81207. */
  81208. set globalDensity(value: number);
  81209. /**
  81210. * Gets the global Saturation value.
  81211. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  81212. */
  81213. get globalSaturation(): number;
  81214. /**
  81215. * Sets the global Saturation value.
  81216. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  81217. */
  81218. set globalSaturation(value: number);
  81219. /**
  81220. * Gets the global Exposure value.
  81221. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  81222. */
  81223. get globalExposure(): number;
  81224. /**
  81225. * Sets the global Exposure value.
  81226. * 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.
  81227. */
  81228. set globalExposure(value: number);
  81229. private _highlightsHue;
  81230. private _highlightsDensity;
  81231. private _highlightsSaturation;
  81232. private _highlightsExposure;
  81233. /**
  81234. * Gets the highlights Hue value.
  81235. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  81236. */
  81237. get highlightsHue(): number;
  81238. /**
  81239. * Sets the highlights Hue value.
  81240. * 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).
  81241. */
  81242. set highlightsHue(value: number);
  81243. /**
  81244. * Gets the highlights Density value.
  81245. * 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.
  81246. * Values less than zero provide a filter of opposite hue.
  81247. */
  81248. get highlightsDensity(): number;
  81249. /**
  81250. * Sets the highlights Density value.
  81251. * 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.
  81252. * Values less than zero provide a filter of opposite hue.
  81253. */
  81254. set highlightsDensity(value: number);
  81255. /**
  81256. * Gets the highlights Saturation value.
  81257. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  81258. */
  81259. get highlightsSaturation(): number;
  81260. /**
  81261. * Sets the highlights Saturation value.
  81262. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  81263. */
  81264. set highlightsSaturation(value: number);
  81265. /**
  81266. * Gets the highlights Exposure value.
  81267. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  81268. */
  81269. get highlightsExposure(): number;
  81270. /**
  81271. * Sets the highlights Exposure value.
  81272. * 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.
  81273. */
  81274. set highlightsExposure(value: number);
  81275. private _midtonesHue;
  81276. private _midtonesDensity;
  81277. private _midtonesSaturation;
  81278. private _midtonesExposure;
  81279. /**
  81280. * Gets the midtones Hue value.
  81281. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  81282. */
  81283. get midtonesHue(): number;
  81284. /**
  81285. * Sets the midtones Hue value.
  81286. * 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).
  81287. */
  81288. set midtonesHue(value: number);
  81289. /**
  81290. * Gets the midtones Density value.
  81291. * 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.
  81292. * Values less than zero provide a filter of opposite hue.
  81293. */
  81294. get midtonesDensity(): number;
  81295. /**
  81296. * Sets the midtones Density value.
  81297. * 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.
  81298. * Values less than zero provide a filter of opposite hue.
  81299. */
  81300. set midtonesDensity(value: number);
  81301. /**
  81302. * Gets the midtones Saturation value.
  81303. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  81304. */
  81305. get midtonesSaturation(): number;
  81306. /**
  81307. * Sets the midtones Saturation value.
  81308. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  81309. */
  81310. set midtonesSaturation(value: number);
  81311. /**
  81312. * Gets the midtones Exposure value.
  81313. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  81314. */
  81315. get midtonesExposure(): number;
  81316. /**
  81317. * Sets the midtones Exposure value.
  81318. * 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.
  81319. */
  81320. set midtonesExposure(value: number);
  81321. private _shadowsHue;
  81322. private _shadowsDensity;
  81323. private _shadowsSaturation;
  81324. private _shadowsExposure;
  81325. /**
  81326. * Gets the shadows Hue value.
  81327. * 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).
  81328. */
  81329. get shadowsHue(): number;
  81330. /**
  81331. * Sets the shadows Hue value.
  81332. * 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).
  81333. */
  81334. set shadowsHue(value: number);
  81335. /**
  81336. * Gets the shadows Density value.
  81337. * 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.
  81338. * Values less than zero provide a filter of opposite hue.
  81339. */
  81340. get shadowsDensity(): number;
  81341. /**
  81342. * Sets the shadows Density value.
  81343. * 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.
  81344. * Values less than zero provide a filter of opposite hue.
  81345. */
  81346. set shadowsDensity(value: number);
  81347. /**
  81348. * Gets the shadows Saturation value.
  81349. * 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.
  81350. */
  81351. get shadowsSaturation(): number;
  81352. /**
  81353. * Sets the shadows Saturation value.
  81354. * 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.
  81355. */
  81356. set shadowsSaturation(value: number);
  81357. /**
  81358. * Gets the shadows Exposure value.
  81359. * 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.
  81360. */
  81361. get shadowsExposure(): number;
  81362. /**
  81363. * Sets the shadows Exposure value.
  81364. * 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.
  81365. */
  81366. set shadowsExposure(value: number);
  81367. /**
  81368. * Returns the class name
  81369. * @returns The class name
  81370. */
  81371. getClassName(): string;
  81372. /**
  81373. * Binds the color curves to the shader.
  81374. * @param colorCurves The color curve to bind
  81375. * @param effect The effect to bind to
  81376. * @param positiveUniform The positive uniform shader parameter
  81377. * @param neutralUniform The neutral uniform shader parameter
  81378. * @param negativeUniform The negative uniform shader parameter
  81379. */
  81380. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  81381. /**
  81382. * Prepare the list of uniforms associated with the ColorCurves effects.
  81383. * @param uniformsList The list of uniforms used in the effect
  81384. */
  81385. static PrepareUniforms(uniformsList: string[]): void;
  81386. /**
  81387. * Returns color grading data based on a hue, density, saturation and exposure value.
  81388. * @param filterHue The hue of the color filter.
  81389. * @param filterDensity The density of the color filter.
  81390. * @param saturation The saturation.
  81391. * @param exposure The exposure.
  81392. * @param result The result data container.
  81393. */
  81394. private getColorGradingDataToRef;
  81395. /**
  81396. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  81397. * @param value The input slider value in range [-100,100].
  81398. * @returns Adjusted value.
  81399. */
  81400. private static applyColorGradingSliderNonlinear;
  81401. /**
  81402. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  81403. * @param hue The hue (H) input.
  81404. * @param saturation The saturation (S) input.
  81405. * @param brightness The brightness (B) input.
  81406. * @result An RGBA color represented as Vector4.
  81407. */
  81408. private static fromHSBToRef;
  81409. /**
  81410. * Returns a value clamped between min and max
  81411. * @param value The value to clamp
  81412. * @param min The minimum of value
  81413. * @param max The maximum of value
  81414. * @returns The clamped value.
  81415. */
  81416. private static clamp;
  81417. /**
  81418. * Clones the current color curve instance.
  81419. * @return The cloned curves
  81420. */
  81421. clone(): ColorCurves;
  81422. /**
  81423. * Serializes the current color curve instance to a json representation.
  81424. * @return a JSON representation
  81425. */
  81426. serialize(): any;
  81427. /**
  81428. * Parses the color curve from a json representation.
  81429. * @param source the JSON source to parse
  81430. * @return The parsed curves
  81431. */
  81432. static Parse(source: any): ColorCurves;
  81433. }
  81434. }
  81435. declare module BABYLON {
  81436. /**
  81437. * Interface to follow in your material defines to integrate easily the
  81438. * Image proccessing functions.
  81439. * @hidden
  81440. */
  81441. export interface IImageProcessingConfigurationDefines {
  81442. IMAGEPROCESSING: boolean;
  81443. VIGNETTE: boolean;
  81444. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81445. VIGNETTEBLENDMODEOPAQUE: boolean;
  81446. TONEMAPPING: boolean;
  81447. TONEMAPPING_ACES: boolean;
  81448. CONTRAST: boolean;
  81449. EXPOSURE: boolean;
  81450. COLORCURVES: boolean;
  81451. COLORGRADING: boolean;
  81452. COLORGRADING3D: boolean;
  81453. SAMPLER3DGREENDEPTH: boolean;
  81454. SAMPLER3DBGRMAP: boolean;
  81455. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81456. }
  81457. /**
  81458. * @hidden
  81459. */
  81460. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81461. IMAGEPROCESSING: boolean;
  81462. VIGNETTE: boolean;
  81463. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81464. VIGNETTEBLENDMODEOPAQUE: boolean;
  81465. TONEMAPPING: boolean;
  81466. TONEMAPPING_ACES: boolean;
  81467. CONTRAST: boolean;
  81468. COLORCURVES: boolean;
  81469. COLORGRADING: boolean;
  81470. COLORGRADING3D: boolean;
  81471. SAMPLER3DGREENDEPTH: boolean;
  81472. SAMPLER3DBGRMAP: boolean;
  81473. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81474. EXPOSURE: boolean;
  81475. constructor();
  81476. }
  81477. /**
  81478. * This groups together the common properties used for image processing either in direct forward pass
  81479. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81480. * or not.
  81481. */
  81482. export class ImageProcessingConfiguration {
  81483. /**
  81484. * Default tone mapping applied in BabylonJS.
  81485. */
  81486. static readonly TONEMAPPING_STANDARD: number;
  81487. /**
  81488. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81489. * to other engines rendering to increase portability.
  81490. */
  81491. static readonly TONEMAPPING_ACES: number;
  81492. /**
  81493. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81494. */
  81495. colorCurves: Nullable<ColorCurves>;
  81496. private _colorCurvesEnabled;
  81497. /**
  81498. * Gets wether the color curves effect is enabled.
  81499. */
  81500. get colorCurvesEnabled(): boolean;
  81501. /**
  81502. * Sets wether the color curves effect is enabled.
  81503. */
  81504. set colorCurvesEnabled(value: boolean);
  81505. private _colorGradingTexture;
  81506. /**
  81507. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81508. */
  81509. get colorGradingTexture(): Nullable<BaseTexture>;
  81510. /**
  81511. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81512. */
  81513. set colorGradingTexture(value: Nullable<BaseTexture>);
  81514. private _colorGradingEnabled;
  81515. /**
  81516. * Gets wether the color grading effect is enabled.
  81517. */
  81518. get colorGradingEnabled(): boolean;
  81519. /**
  81520. * Sets wether the color grading effect is enabled.
  81521. */
  81522. set colorGradingEnabled(value: boolean);
  81523. private _colorGradingWithGreenDepth;
  81524. /**
  81525. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81526. */
  81527. get colorGradingWithGreenDepth(): boolean;
  81528. /**
  81529. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81530. */
  81531. set colorGradingWithGreenDepth(value: boolean);
  81532. private _colorGradingBGR;
  81533. /**
  81534. * Gets wether the color grading texture contains BGR values.
  81535. */
  81536. get colorGradingBGR(): boolean;
  81537. /**
  81538. * Sets wether the color grading texture contains BGR values.
  81539. */
  81540. set colorGradingBGR(value: boolean);
  81541. /** @hidden */
  81542. _exposure: number;
  81543. /**
  81544. * Gets the Exposure used in the effect.
  81545. */
  81546. get exposure(): number;
  81547. /**
  81548. * Sets the Exposure used in the effect.
  81549. */
  81550. set exposure(value: number);
  81551. private _toneMappingEnabled;
  81552. /**
  81553. * Gets wether the tone mapping effect is enabled.
  81554. */
  81555. get toneMappingEnabled(): boolean;
  81556. /**
  81557. * Sets wether the tone mapping effect is enabled.
  81558. */
  81559. set toneMappingEnabled(value: boolean);
  81560. private _toneMappingType;
  81561. /**
  81562. * Gets the type of tone mapping effect.
  81563. */
  81564. get toneMappingType(): number;
  81565. /**
  81566. * Sets the type of tone mapping effect used in BabylonJS.
  81567. */
  81568. set toneMappingType(value: number);
  81569. protected _contrast: number;
  81570. /**
  81571. * Gets the contrast used in the effect.
  81572. */
  81573. get contrast(): number;
  81574. /**
  81575. * Sets the contrast used in the effect.
  81576. */
  81577. set contrast(value: number);
  81578. /**
  81579. * Vignette stretch size.
  81580. */
  81581. vignetteStretch: number;
  81582. /**
  81583. * Vignette centre X Offset.
  81584. */
  81585. vignetteCentreX: number;
  81586. /**
  81587. * Vignette centre Y Offset.
  81588. */
  81589. vignetteCentreY: number;
  81590. /**
  81591. * Vignette weight or intensity of the vignette effect.
  81592. */
  81593. vignetteWeight: number;
  81594. /**
  81595. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  81596. * if vignetteEnabled is set to true.
  81597. */
  81598. vignetteColor: Color4;
  81599. /**
  81600. * Camera field of view used by the Vignette effect.
  81601. */
  81602. vignetteCameraFov: number;
  81603. private _vignetteBlendMode;
  81604. /**
  81605. * Gets the vignette blend mode allowing different kind of effect.
  81606. */
  81607. get vignetteBlendMode(): number;
  81608. /**
  81609. * Sets the vignette blend mode allowing different kind of effect.
  81610. */
  81611. set vignetteBlendMode(value: number);
  81612. private _vignetteEnabled;
  81613. /**
  81614. * Gets wether the vignette effect is enabled.
  81615. */
  81616. get vignetteEnabled(): boolean;
  81617. /**
  81618. * Sets wether the vignette effect is enabled.
  81619. */
  81620. set vignetteEnabled(value: boolean);
  81621. private _applyByPostProcess;
  81622. /**
  81623. * Gets wether the image processing is applied through a post process or not.
  81624. */
  81625. get applyByPostProcess(): boolean;
  81626. /**
  81627. * Sets wether the image processing is applied through a post process or not.
  81628. */
  81629. set applyByPostProcess(value: boolean);
  81630. private _isEnabled;
  81631. /**
  81632. * Gets wether the image processing is enabled or not.
  81633. */
  81634. get isEnabled(): boolean;
  81635. /**
  81636. * Sets wether the image processing is enabled or not.
  81637. */
  81638. set isEnabled(value: boolean);
  81639. /**
  81640. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81641. */
  81642. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81643. /**
  81644. * Method called each time the image processing information changes requires to recompile the effect.
  81645. */
  81646. protected _updateParameters(): void;
  81647. /**
  81648. * Gets the current class name.
  81649. * @return "ImageProcessingConfiguration"
  81650. */
  81651. getClassName(): string;
  81652. /**
  81653. * Prepare the list of uniforms associated with the Image Processing effects.
  81654. * @param uniforms The list of uniforms used in the effect
  81655. * @param defines the list of defines currently in use
  81656. */
  81657. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81658. /**
  81659. * Prepare the list of samplers associated with the Image Processing effects.
  81660. * @param samplersList The list of uniforms used in the effect
  81661. * @param defines the list of defines currently in use
  81662. */
  81663. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81664. /**
  81665. * Prepare the list of defines associated to the shader.
  81666. * @param defines the list of defines to complete
  81667. * @param forPostProcess Define if we are currently in post process mode or not
  81668. */
  81669. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81670. /**
  81671. * Returns true if all the image processing information are ready.
  81672. * @returns True if ready, otherwise, false
  81673. */
  81674. isReady(): boolean;
  81675. /**
  81676. * Binds the image processing to the shader.
  81677. * @param effect The effect to bind to
  81678. * @param overrideAspectRatio Override the aspect ratio of the effect
  81679. */
  81680. bind(effect: Effect, overrideAspectRatio?: number): void;
  81681. /**
  81682. * Clones the current image processing instance.
  81683. * @return The cloned image processing
  81684. */
  81685. clone(): ImageProcessingConfiguration;
  81686. /**
  81687. * Serializes the current image processing instance to a json representation.
  81688. * @return a JSON representation
  81689. */
  81690. serialize(): any;
  81691. /**
  81692. * Parses the image processing from a json representation.
  81693. * @param source the JSON source to parse
  81694. * @return The parsed image processing
  81695. */
  81696. static Parse(source: any): ImageProcessingConfiguration;
  81697. private static _VIGNETTEMODE_MULTIPLY;
  81698. private static _VIGNETTEMODE_OPAQUE;
  81699. /**
  81700. * Used to apply the vignette as a mix with the pixel color.
  81701. */
  81702. static get VIGNETTEMODE_MULTIPLY(): number;
  81703. /**
  81704. * Used to apply the vignette as a replacement of the pixel color.
  81705. */
  81706. static get VIGNETTEMODE_OPAQUE(): number;
  81707. }
  81708. }
  81709. declare module BABYLON {
  81710. /** @hidden */
  81711. export var postprocessVertexShader: {
  81712. name: string;
  81713. shader: string;
  81714. };
  81715. }
  81716. declare module BABYLON {
  81717. interface ThinEngine {
  81718. /**
  81719. * Creates a new render target texture
  81720. * @param size defines the size of the texture
  81721. * @param options defines the options used to create the texture
  81722. * @returns a new render target texture stored in an InternalTexture
  81723. */
  81724. createRenderTargetTexture(size: number | {
  81725. width: number;
  81726. height: number;
  81727. layers?: number;
  81728. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  81729. /**
  81730. * Creates a depth stencil texture.
  81731. * This is only available in WebGL 2 or with the depth texture extension available.
  81732. * @param size The size of face edge in the texture.
  81733. * @param options The options defining the texture.
  81734. * @returns The texture
  81735. */
  81736. createDepthStencilTexture(size: number | {
  81737. width: number;
  81738. height: number;
  81739. layers?: number;
  81740. }, options: DepthTextureCreationOptions): InternalTexture;
  81741. /** @hidden */
  81742. _createDepthStencilTexture(size: number | {
  81743. width: number;
  81744. height: number;
  81745. layers?: number;
  81746. }, options: DepthTextureCreationOptions): InternalTexture;
  81747. }
  81748. }
  81749. declare module BABYLON {
  81750. /** Defines supported spaces */
  81751. export enum Space {
  81752. /** Local (object) space */
  81753. LOCAL = 0,
  81754. /** World space */
  81755. WORLD = 1,
  81756. /** Bone space */
  81757. BONE = 2
  81758. }
  81759. /** Defines the 3 main axes */
  81760. export class Axis {
  81761. /** X axis */
  81762. static X: Vector3;
  81763. /** Y axis */
  81764. static Y: Vector3;
  81765. /** Z axis */
  81766. static Z: Vector3;
  81767. }
  81768. }
  81769. declare module BABYLON {
  81770. /**
  81771. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  81772. * This is the base of the follow, arc rotate cameras and Free camera
  81773. * @see http://doc.babylonjs.com/features/cameras
  81774. */
  81775. export class TargetCamera extends Camera {
  81776. private static _RigCamTransformMatrix;
  81777. private static _TargetTransformMatrix;
  81778. private static _TargetFocalPoint;
  81779. /**
  81780. * Define the current direction the camera is moving to
  81781. */
  81782. cameraDirection: Vector3;
  81783. /**
  81784. * Define the current rotation the camera is rotating to
  81785. */
  81786. cameraRotation: Vector2;
  81787. /**
  81788. * When set, the up vector of the camera will be updated by the rotation of the camera
  81789. */
  81790. updateUpVectorFromRotation: boolean;
  81791. private _tmpQuaternion;
  81792. /**
  81793. * Define the current rotation of the camera
  81794. */
  81795. rotation: Vector3;
  81796. /**
  81797. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  81798. */
  81799. rotationQuaternion: Quaternion;
  81800. /**
  81801. * Define the current speed of the camera
  81802. */
  81803. speed: number;
  81804. /**
  81805. * Add constraint to the camera to prevent it to move freely in all directions and
  81806. * around all axis.
  81807. */
  81808. noRotationConstraint: boolean;
  81809. /**
  81810. * Define the current target of the camera as an object or a position.
  81811. */
  81812. lockedTarget: any;
  81813. /** @hidden */
  81814. _currentTarget: Vector3;
  81815. /** @hidden */
  81816. _initialFocalDistance: number;
  81817. /** @hidden */
  81818. _viewMatrix: Matrix;
  81819. /** @hidden */
  81820. _camMatrix: Matrix;
  81821. /** @hidden */
  81822. _cameraTransformMatrix: Matrix;
  81823. /** @hidden */
  81824. _cameraRotationMatrix: Matrix;
  81825. /** @hidden */
  81826. _referencePoint: Vector3;
  81827. /** @hidden */
  81828. _transformedReferencePoint: Vector3;
  81829. protected _globalCurrentTarget: Vector3;
  81830. protected _globalCurrentUpVector: Vector3;
  81831. /** @hidden */
  81832. _reset: () => void;
  81833. private _defaultUp;
  81834. /**
  81835. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  81836. * This is the base of the follow, arc rotate cameras and Free camera
  81837. * @see http://doc.babylonjs.com/features/cameras
  81838. * @param name Defines the name of the camera in the scene
  81839. * @param position Defines the start position of the camera in the scene
  81840. * @param scene Defines the scene the camera belongs to
  81841. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81842. */
  81843. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81844. /**
  81845. * Gets the position in front of the camera at a given distance.
  81846. * @param distance The distance from the camera we want the position to be
  81847. * @returns the position
  81848. */
  81849. getFrontPosition(distance: number): Vector3;
  81850. /** @hidden */
  81851. _getLockedTargetPosition(): Nullable<Vector3>;
  81852. private _storedPosition;
  81853. private _storedRotation;
  81854. private _storedRotationQuaternion;
  81855. /**
  81856. * Store current camera state of the camera (fov, position, rotation, etc..)
  81857. * @returns the camera
  81858. */
  81859. storeState(): Camera;
  81860. /**
  81861. * Restored camera state. You must call storeState() first
  81862. * @returns whether it was successful or not
  81863. * @hidden
  81864. */
  81865. _restoreStateValues(): boolean;
  81866. /** @hidden */
  81867. _initCache(): void;
  81868. /** @hidden */
  81869. _updateCache(ignoreParentClass?: boolean): void;
  81870. /** @hidden */
  81871. _isSynchronizedViewMatrix(): boolean;
  81872. /** @hidden */
  81873. _computeLocalCameraSpeed(): number;
  81874. /**
  81875. * Defines the target the camera should look at.
  81876. * @param target Defines the new target as a Vector or a mesh
  81877. */
  81878. setTarget(target: Vector3): void;
  81879. /**
  81880. * Return the current target position of the camera. This value is expressed in local space.
  81881. * @returns the target position
  81882. */
  81883. getTarget(): Vector3;
  81884. /** @hidden */
  81885. _decideIfNeedsToMove(): boolean;
  81886. /** @hidden */
  81887. _updatePosition(): void;
  81888. /** @hidden */
  81889. _checkInputs(): void;
  81890. protected _updateCameraRotationMatrix(): void;
  81891. /**
  81892. * 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)
  81893. * @returns the current camera
  81894. */
  81895. private _rotateUpVectorWithCameraRotationMatrix;
  81896. private _cachedRotationZ;
  81897. private _cachedQuaternionRotationZ;
  81898. /** @hidden */
  81899. _getViewMatrix(): Matrix;
  81900. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  81901. /**
  81902. * @hidden
  81903. */
  81904. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  81905. /**
  81906. * @hidden
  81907. */
  81908. _updateRigCameras(): void;
  81909. private _getRigCamPositionAndTarget;
  81910. /**
  81911. * Gets the current object class name.
  81912. * @return the class name
  81913. */
  81914. getClassName(): string;
  81915. }
  81916. }
  81917. declare module BABYLON {
  81918. /**
  81919. * Gather the list of keyboard event types as constants.
  81920. */
  81921. export class KeyboardEventTypes {
  81922. /**
  81923. * The keydown event is fired when a key becomes active (pressed).
  81924. */
  81925. static readonly KEYDOWN: number;
  81926. /**
  81927. * The keyup event is fired when a key has been released.
  81928. */
  81929. static readonly KEYUP: number;
  81930. }
  81931. /**
  81932. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81933. */
  81934. export class KeyboardInfo {
  81935. /**
  81936. * Defines the type of event (KeyboardEventTypes)
  81937. */
  81938. type: number;
  81939. /**
  81940. * Defines the related dom event
  81941. */
  81942. event: KeyboardEvent;
  81943. /**
  81944. * Instantiates a new keyboard info.
  81945. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81946. * @param type Defines the type of event (KeyboardEventTypes)
  81947. * @param event Defines the related dom event
  81948. */
  81949. constructor(
  81950. /**
  81951. * Defines the type of event (KeyboardEventTypes)
  81952. */
  81953. type: number,
  81954. /**
  81955. * Defines the related dom event
  81956. */
  81957. event: KeyboardEvent);
  81958. }
  81959. /**
  81960. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81961. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  81962. */
  81963. export class KeyboardInfoPre extends KeyboardInfo {
  81964. /**
  81965. * Defines the type of event (KeyboardEventTypes)
  81966. */
  81967. type: number;
  81968. /**
  81969. * Defines the related dom event
  81970. */
  81971. event: KeyboardEvent;
  81972. /**
  81973. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  81974. */
  81975. skipOnPointerObservable: boolean;
  81976. /**
  81977. * Instantiates a new keyboard pre info.
  81978. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81979. * @param type Defines the type of event (KeyboardEventTypes)
  81980. * @param event Defines the related dom event
  81981. */
  81982. constructor(
  81983. /**
  81984. * Defines the type of event (KeyboardEventTypes)
  81985. */
  81986. type: number,
  81987. /**
  81988. * Defines the related dom event
  81989. */
  81990. event: KeyboardEvent);
  81991. }
  81992. }
  81993. declare module BABYLON {
  81994. /**
  81995. * Manage the keyboard inputs to control the movement of a free camera.
  81996. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81997. */
  81998. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  81999. /**
  82000. * Defines the camera the input is attached to.
  82001. */
  82002. camera: FreeCamera;
  82003. /**
  82004. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82005. */
  82006. keysUp: number[];
  82007. /**
  82008. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82009. */
  82010. keysDown: number[];
  82011. /**
  82012. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82013. */
  82014. keysLeft: number[];
  82015. /**
  82016. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82017. */
  82018. keysRight: number[];
  82019. private _keys;
  82020. private _onCanvasBlurObserver;
  82021. private _onKeyboardObserver;
  82022. private _engine;
  82023. private _scene;
  82024. /**
  82025. * Attach the input controls to a specific dom element to get the input from.
  82026. * @param element Defines the element the controls should be listened from
  82027. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82028. */
  82029. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82030. /**
  82031. * Detach the current controls from the specified dom element.
  82032. * @param element Defines the element to stop listening the inputs from
  82033. */
  82034. detachControl(element: Nullable<HTMLElement>): void;
  82035. /**
  82036. * Update the current camera state depending on the inputs that have been used this frame.
  82037. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82038. */
  82039. checkInputs(): void;
  82040. /**
  82041. * Gets the class name of the current intput.
  82042. * @returns the class name
  82043. */
  82044. getClassName(): string;
  82045. /** @hidden */
  82046. _onLostFocus(): void;
  82047. /**
  82048. * Get the friendly name associated with the input class.
  82049. * @returns the input friendly name
  82050. */
  82051. getSimpleName(): string;
  82052. }
  82053. }
  82054. declare module BABYLON {
  82055. /**
  82056. * Interface describing all the common properties and methods a shadow light needs to implement.
  82057. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  82058. * as well as binding the different shadow properties to the effects.
  82059. */
  82060. export interface IShadowLight extends Light {
  82061. /**
  82062. * The light id in the scene (used in scene.findLighById for instance)
  82063. */
  82064. id: string;
  82065. /**
  82066. * The position the shdow will be casted from.
  82067. */
  82068. position: Vector3;
  82069. /**
  82070. * In 2d mode (needCube being false), the direction used to cast the shadow.
  82071. */
  82072. direction: Vector3;
  82073. /**
  82074. * The transformed position. Position of the light in world space taking parenting in account.
  82075. */
  82076. transformedPosition: Vector3;
  82077. /**
  82078. * The transformed direction. Direction of the light in world space taking parenting in account.
  82079. */
  82080. transformedDirection: Vector3;
  82081. /**
  82082. * The friendly name of the light in the scene.
  82083. */
  82084. name: string;
  82085. /**
  82086. * Defines the shadow projection clipping minimum z value.
  82087. */
  82088. shadowMinZ: number;
  82089. /**
  82090. * Defines the shadow projection clipping maximum z value.
  82091. */
  82092. shadowMaxZ: number;
  82093. /**
  82094. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82095. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82096. */
  82097. computeTransformedInformation(): boolean;
  82098. /**
  82099. * Gets the scene the light belongs to.
  82100. * @returns The scene
  82101. */
  82102. getScene(): Scene;
  82103. /**
  82104. * Callback defining a custom Projection Matrix Builder.
  82105. * This can be used to override the default projection matrix computation.
  82106. */
  82107. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82108. /**
  82109. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82110. * @param matrix The materix to updated with the projection information
  82111. * @param viewMatrix The transform matrix of the light
  82112. * @param renderList The list of mesh to render in the map
  82113. * @returns The current light
  82114. */
  82115. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82116. /**
  82117. * Gets the current depth scale used in ESM.
  82118. * @returns The scale
  82119. */
  82120. getDepthScale(): number;
  82121. /**
  82122. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82123. * @returns true if a cube texture needs to be use
  82124. */
  82125. needCube(): boolean;
  82126. /**
  82127. * Detects if the projection matrix requires to be recomputed this frame.
  82128. * @returns true if it requires to be recomputed otherwise, false.
  82129. */
  82130. needProjectionMatrixCompute(): boolean;
  82131. /**
  82132. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82133. */
  82134. forceProjectionMatrixCompute(): void;
  82135. /**
  82136. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82137. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82138. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82139. */
  82140. getShadowDirection(faceIndex?: number): Vector3;
  82141. /**
  82142. * Gets the minZ used for shadow according to both the scene and the light.
  82143. * @param activeCamera The camera we are returning the min for
  82144. * @returns the depth min z
  82145. */
  82146. getDepthMinZ(activeCamera: Camera): number;
  82147. /**
  82148. * Gets the maxZ used for shadow according to both the scene and the light.
  82149. * @param activeCamera The camera we are returning the max for
  82150. * @returns the depth max z
  82151. */
  82152. getDepthMaxZ(activeCamera: Camera): number;
  82153. }
  82154. /**
  82155. * Base implementation IShadowLight
  82156. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  82157. */
  82158. export abstract class ShadowLight extends Light implements IShadowLight {
  82159. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  82160. protected _position: Vector3;
  82161. protected _setPosition(value: Vector3): void;
  82162. /**
  82163. * Sets the position the shadow will be casted from. Also use as the light position for both
  82164. * point and spot lights.
  82165. */
  82166. get position(): Vector3;
  82167. /**
  82168. * Sets the position the shadow will be casted from. Also use as the light position for both
  82169. * point and spot lights.
  82170. */
  82171. set position(value: Vector3);
  82172. protected _direction: Vector3;
  82173. protected _setDirection(value: Vector3): void;
  82174. /**
  82175. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  82176. * Also use as the light direction on spot and directional lights.
  82177. */
  82178. get direction(): Vector3;
  82179. /**
  82180. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  82181. * Also use as the light direction on spot and directional lights.
  82182. */
  82183. set direction(value: Vector3);
  82184. protected _shadowMinZ: number;
  82185. /**
  82186. * Gets the shadow projection clipping minimum z value.
  82187. */
  82188. get shadowMinZ(): number;
  82189. /**
  82190. * Sets the shadow projection clipping minimum z value.
  82191. */
  82192. set shadowMinZ(value: number);
  82193. protected _shadowMaxZ: number;
  82194. /**
  82195. * Sets the shadow projection clipping maximum z value.
  82196. */
  82197. get shadowMaxZ(): number;
  82198. /**
  82199. * Gets the shadow projection clipping maximum z value.
  82200. */
  82201. set shadowMaxZ(value: number);
  82202. /**
  82203. * Callback defining a custom Projection Matrix Builder.
  82204. * This can be used to override the default projection matrix computation.
  82205. */
  82206. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82207. /**
  82208. * The transformed position. Position of the light in world space taking parenting in account.
  82209. */
  82210. transformedPosition: Vector3;
  82211. /**
  82212. * The transformed direction. Direction of the light in world space taking parenting in account.
  82213. */
  82214. transformedDirection: Vector3;
  82215. private _needProjectionMatrixCompute;
  82216. /**
  82217. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82218. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82219. */
  82220. computeTransformedInformation(): boolean;
  82221. /**
  82222. * Return the depth scale used for the shadow map.
  82223. * @returns the depth scale.
  82224. */
  82225. getDepthScale(): number;
  82226. /**
  82227. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82228. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82229. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82230. */
  82231. getShadowDirection(faceIndex?: number): Vector3;
  82232. /**
  82233. * Returns the ShadowLight absolute position in the World.
  82234. * @returns the position vector in world space
  82235. */
  82236. getAbsolutePosition(): Vector3;
  82237. /**
  82238. * Sets the ShadowLight direction toward the passed target.
  82239. * @param target The point to target in local space
  82240. * @returns the updated ShadowLight direction
  82241. */
  82242. setDirectionToTarget(target: Vector3): Vector3;
  82243. /**
  82244. * Returns the light rotation in euler definition.
  82245. * @returns the x y z rotation in local space.
  82246. */
  82247. getRotation(): Vector3;
  82248. /**
  82249. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82250. * @returns true if a cube texture needs to be use
  82251. */
  82252. needCube(): boolean;
  82253. /**
  82254. * Detects if the projection matrix requires to be recomputed this frame.
  82255. * @returns true if it requires to be recomputed otherwise, false.
  82256. */
  82257. needProjectionMatrixCompute(): boolean;
  82258. /**
  82259. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82260. */
  82261. forceProjectionMatrixCompute(): void;
  82262. /** @hidden */
  82263. _initCache(): void;
  82264. /** @hidden */
  82265. _isSynchronized(): boolean;
  82266. /**
  82267. * Computes the world matrix of the node
  82268. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82269. * @returns the world matrix
  82270. */
  82271. computeWorldMatrix(force?: boolean): Matrix;
  82272. /**
  82273. * Gets the minZ used for shadow according to both the scene and the light.
  82274. * @param activeCamera The camera we are returning the min for
  82275. * @returns the depth min z
  82276. */
  82277. getDepthMinZ(activeCamera: Camera): number;
  82278. /**
  82279. * Gets the maxZ used for shadow according to both the scene and the light.
  82280. * @param activeCamera The camera we are returning the max for
  82281. * @returns the depth max z
  82282. */
  82283. getDepthMaxZ(activeCamera: Camera): number;
  82284. /**
  82285. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82286. * @param matrix The materix to updated with the projection information
  82287. * @param viewMatrix The transform matrix of the light
  82288. * @param renderList The list of mesh to render in the map
  82289. * @returns The current light
  82290. */
  82291. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82292. }
  82293. }
  82294. declare module BABYLON {
  82295. /**
  82296. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  82297. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  82298. */
  82299. export class EffectFallbacks implements IEffectFallbacks {
  82300. private _defines;
  82301. private _currentRank;
  82302. private _maxRank;
  82303. private _mesh;
  82304. /**
  82305. * Removes the fallback from the bound mesh.
  82306. */
  82307. unBindMesh(): void;
  82308. /**
  82309. * Adds a fallback on the specified property.
  82310. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82311. * @param define The name of the define in the shader
  82312. */
  82313. addFallback(rank: number, define: string): void;
  82314. /**
  82315. * Sets the mesh to use CPU skinning when needing to fallback.
  82316. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82317. * @param mesh The mesh to use the fallbacks.
  82318. */
  82319. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  82320. /**
  82321. * Checks to see if more fallbacks are still availible.
  82322. */
  82323. get hasMoreFallbacks(): boolean;
  82324. /**
  82325. * Removes the defines that should be removed when falling back.
  82326. * @param currentDefines defines the current define statements for the shader.
  82327. * @param effect defines the current effect we try to compile
  82328. * @returns The resulting defines with defines of the current rank removed.
  82329. */
  82330. reduce(currentDefines: string, effect: Effect): string;
  82331. }
  82332. }
  82333. declare module BABYLON {
  82334. /**
  82335. * "Static Class" containing the most commonly used helper while dealing with material for
  82336. * rendering purpose.
  82337. *
  82338. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  82339. *
  82340. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  82341. */
  82342. export class MaterialHelper {
  82343. /**
  82344. * Bind the current view position to an effect.
  82345. * @param effect The effect to be bound
  82346. * @param scene The scene the eyes position is used from
  82347. */
  82348. static BindEyePosition(effect: Effect, scene: Scene): void;
  82349. /**
  82350. * Helps preparing the defines values about the UVs in used in the effect.
  82351. * UVs are shared as much as we can accross channels in the shaders.
  82352. * @param texture The texture we are preparing the UVs for
  82353. * @param defines The defines to update
  82354. * @param key The channel key "diffuse", "specular"... used in the shader
  82355. */
  82356. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  82357. /**
  82358. * Binds a texture matrix value to its corrsponding uniform
  82359. * @param texture The texture to bind the matrix for
  82360. * @param uniformBuffer The uniform buffer receivin the data
  82361. * @param key The channel key "diffuse", "specular"... used in the shader
  82362. */
  82363. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  82364. /**
  82365. * Gets the current status of the fog (should it be enabled?)
  82366. * @param mesh defines the mesh to evaluate for fog support
  82367. * @param scene defines the hosting scene
  82368. * @returns true if fog must be enabled
  82369. */
  82370. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  82371. /**
  82372. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  82373. * @param mesh defines the current mesh
  82374. * @param scene defines the current scene
  82375. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  82376. * @param pointsCloud defines if point cloud rendering has to be turned on
  82377. * @param fogEnabled defines if fog has to be turned on
  82378. * @param alphaTest defines if alpha testing has to be turned on
  82379. * @param defines defines the current list of defines
  82380. */
  82381. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  82382. /**
  82383. * Helper used to prepare the list of defines associated with frame values for shader compilation
  82384. * @param scene defines the current scene
  82385. * @param engine defines the current engine
  82386. * @param defines specifies the list of active defines
  82387. * @param useInstances defines if instances have to be turned on
  82388. * @param useClipPlane defines if clip plane have to be turned on
  82389. */
  82390. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  82391. /**
  82392. * Prepares the defines for bones
  82393. * @param mesh The mesh containing the geometry data we will draw
  82394. * @param defines The defines to update
  82395. */
  82396. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  82397. /**
  82398. * Prepares the defines for morph targets
  82399. * @param mesh The mesh containing the geometry data we will draw
  82400. * @param defines The defines to update
  82401. */
  82402. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  82403. /**
  82404. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82405. * @param mesh The mesh containing the geometry data we will draw
  82406. * @param defines The defines to update
  82407. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82408. * @param useBones Precise whether bones should be used or not (override mesh info)
  82409. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82410. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82411. * @returns false if defines are considered not dirty and have not been checked
  82412. */
  82413. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82414. /**
  82415. * Prepares the defines related to multiview
  82416. * @param scene The scene we are intending to draw
  82417. * @param defines The defines to update
  82418. */
  82419. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82420. /**
  82421. * Prepares the defines related to the light information passed in parameter
  82422. * @param scene The scene we are intending to draw
  82423. * @param mesh The mesh the effect is compiling for
  82424. * @param light The light the effect is compiling for
  82425. * @param lightIndex The index of the light
  82426. * @param defines The defines to update
  82427. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82428. * @param state Defines the current state regarding what is needed (normals, etc...)
  82429. */
  82430. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82431. needNormals: boolean;
  82432. needRebuild: boolean;
  82433. shadowEnabled: boolean;
  82434. specularEnabled: boolean;
  82435. lightmapMode: boolean;
  82436. }): void;
  82437. /**
  82438. * Prepares the defines related to the light information passed in parameter
  82439. * @param scene The scene we are intending to draw
  82440. * @param mesh The mesh the effect is compiling for
  82441. * @param defines The defines to update
  82442. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82443. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82444. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82445. * @returns true if normals will be required for the rest of the effect
  82446. */
  82447. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82448. /**
  82449. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82450. * @param lightIndex defines the light index
  82451. * @param uniformsList The uniform list
  82452. * @param samplersList The sampler list
  82453. * @param projectedLightTexture defines if projected texture must be used
  82454. * @param uniformBuffersList defines an optional list of uniform buffers
  82455. */
  82456. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82457. /**
  82458. * Prepares the uniforms and samplers list to be used in the effect
  82459. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82460. * @param samplersList The sampler list
  82461. * @param defines The defines helping in the list generation
  82462. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82463. */
  82464. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82465. /**
  82466. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82467. * @param defines The defines to update while falling back
  82468. * @param fallbacks The authorized effect fallbacks
  82469. * @param maxSimultaneousLights The maximum number of lights allowed
  82470. * @param rank the current rank of the Effect
  82471. * @returns The newly affected rank
  82472. */
  82473. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82474. private static _TmpMorphInfluencers;
  82475. /**
  82476. * Prepares the list of attributes required for morph targets according to the effect defines.
  82477. * @param attribs The current list of supported attribs
  82478. * @param mesh The mesh to prepare the morph targets attributes for
  82479. * @param influencers The number of influencers
  82480. */
  82481. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82482. /**
  82483. * Prepares the list of attributes required for morph targets according to the effect defines.
  82484. * @param attribs The current list of supported attribs
  82485. * @param mesh The mesh to prepare the morph targets attributes for
  82486. * @param defines The current Defines of the effect
  82487. */
  82488. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82489. /**
  82490. * Prepares the list of attributes required for bones according to the effect defines.
  82491. * @param attribs The current list of supported attribs
  82492. * @param mesh The mesh to prepare the bones attributes for
  82493. * @param defines The current Defines of the effect
  82494. * @param fallbacks The current efffect fallback strategy
  82495. */
  82496. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82497. /**
  82498. * Check and prepare the list of attributes required for instances according to the effect defines.
  82499. * @param attribs The current list of supported attribs
  82500. * @param defines The current MaterialDefines of the effect
  82501. */
  82502. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82503. /**
  82504. * Add the list of attributes required for instances to the attribs array.
  82505. * @param attribs The current list of supported attribs
  82506. */
  82507. static PushAttributesForInstances(attribs: string[]): void;
  82508. /**
  82509. * Binds the light information to the effect.
  82510. * @param light The light containing the generator
  82511. * @param effect The effect we are binding the data to
  82512. * @param lightIndex The light index in the effect used to render
  82513. */
  82514. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82515. /**
  82516. * Binds the lights information from the scene to the effect for the given mesh.
  82517. * @param light Light to bind
  82518. * @param lightIndex Light index
  82519. * @param scene The scene where the light belongs to
  82520. * @param effect The effect we are binding the data to
  82521. * @param useSpecular Defines if specular is supported
  82522. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82523. */
  82524. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82525. /**
  82526. * Binds the lights information from the scene to the effect for the given mesh.
  82527. * @param scene The scene the lights belongs to
  82528. * @param mesh The mesh we are binding the information to render
  82529. * @param effect The effect we are binding the data to
  82530. * @param defines The generated defines for the effect
  82531. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82532. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82533. */
  82534. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82535. private static _tempFogColor;
  82536. /**
  82537. * Binds the fog information from the scene to the effect for the given mesh.
  82538. * @param scene The scene the lights belongs to
  82539. * @param mesh The mesh we are binding the information to render
  82540. * @param effect The effect we are binding the data to
  82541. * @param linearSpace Defines if the fog effect is applied in linear space
  82542. */
  82543. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82544. /**
  82545. * Binds the bones information from the mesh to the effect.
  82546. * @param mesh The mesh we are binding the information to render
  82547. * @param effect The effect we are binding the data to
  82548. */
  82549. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  82550. /**
  82551. * Binds the morph targets information from the mesh to the effect.
  82552. * @param abstractMesh The mesh we are binding the information to render
  82553. * @param effect The effect we are binding the data to
  82554. */
  82555. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  82556. /**
  82557. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  82558. * @param defines The generated defines used in the effect
  82559. * @param effect The effect we are binding the data to
  82560. * @param scene The scene we are willing to render with logarithmic scale for
  82561. */
  82562. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  82563. /**
  82564. * Binds the clip plane information from the scene to the effect.
  82565. * @param scene The scene the clip plane information are extracted from
  82566. * @param effect The effect we are binding the data to
  82567. */
  82568. static BindClipPlane(effect: Effect, scene: Scene): void;
  82569. }
  82570. }
  82571. declare module BABYLON {
  82572. /** @hidden */
  82573. export var packingFunctions: {
  82574. name: string;
  82575. shader: string;
  82576. };
  82577. }
  82578. declare module BABYLON {
  82579. /** @hidden */
  82580. export var clipPlaneFragmentDeclaration: {
  82581. name: string;
  82582. shader: string;
  82583. };
  82584. }
  82585. declare module BABYLON {
  82586. /** @hidden */
  82587. export var clipPlaneFragment: {
  82588. name: string;
  82589. shader: string;
  82590. };
  82591. }
  82592. declare module BABYLON {
  82593. /** @hidden */
  82594. export var shadowMapPixelShader: {
  82595. name: string;
  82596. shader: string;
  82597. };
  82598. }
  82599. declare module BABYLON {
  82600. /** @hidden */
  82601. export var bonesDeclaration: {
  82602. name: string;
  82603. shader: string;
  82604. };
  82605. }
  82606. declare module BABYLON {
  82607. /** @hidden */
  82608. export var morphTargetsVertexGlobalDeclaration: {
  82609. name: string;
  82610. shader: string;
  82611. };
  82612. }
  82613. declare module BABYLON {
  82614. /** @hidden */
  82615. export var morphTargetsVertexDeclaration: {
  82616. name: string;
  82617. shader: string;
  82618. };
  82619. }
  82620. declare module BABYLON {
  82621. /** @hidden */
  82622. export var instancesDeclaration: {
  82623. name: string;
  82624. shader: string;
  82625. };
  82626. }
  82627. declare module BABYLON {
  82628. /** @hidden */
  82629. export var helperFunctions: {
  82630. name: string;
  82631. shader: string;
  82632. };
  82633. }
  82634. declare module BABYLON {
  82635. /** @hidden */
  82636. export var clipPlaneVertexDeclaration: {
  82637. name: string;
  82638. shader: string;
  82639. };
  82640. }
  82641. declare module BABYLON {
  82642. /** @hidden */
  82643. export var morphTargetsVertex: {
  82644. name: string;
  82645. shader: string;
  82646. };
  82647. }
  82648. declare module BABYLON {
  82649. /** @hidden */
  82650. export var instancesVertex: {
  82651. name: string;
  82652. shader: string;
  82653. };
  82654. }
  82655. declare module BABYLON {
  82656. /** @hidden */
  82657. export var bonesVertex: {
  82658. name: string;
  82659. shader: string;
  82660. };
  82661. }
  82662. declare module BABYLON {
  82663. /** @hidden */
  82664. export var clipPlaneVertex: {
  82665. name: string;
  82666. shader: string;
  82667. };
  82668. }
  82669. declare module BABYLON {
  82670. /** @hidden */
  82671. export var shadowMapVertexShader: {
  82672. name: string;
  82673. shader: string;
  82674. };
  82675. }
  82676. declare module BABYLON {
  82677. /** @hidden */
  82678. export var depthBoxBlurPixelShader: {
  82679. name: string;
  82680. shader: string;
  82681. };
  82682. }
  82683. declare module BABYLON {
  82684. /**
  82685. * Class representing a ray with position and direction
  82686. */
  82687. export class Ray {
  82688. /** origin point */
  82689. origin: Vector3;
  82690. /** direction */
  82691. direction: Vector3;
  82692. /** length of the ray */
  82693. length: number;
  82694. private static readonly TmpVector3;
  82695. private _tmpRay;
  82696. /**
  82697. * Creates a new ray
  82698. * @param origin origin point
  82699. * @param direction direction
  82700. * @param length length of the ray
  82701. */
  82702. constructor(
  82703. /** origin point */
  82704. origin: Vector3,
  82705. /** direction */
  82706. direction: Vector3,
  82707. /** length of the ray */
  82708. length?: number);
  82709. /**
  82710. * Checks if the ray intersects a box
  82711. * @param minimum bound of the box
  82712. * @param maximum bound of the box
  82713. * @param intersectionTreshold extra extend to be added to the box in all direction
  82714. * @returns if the box was hit
  82715. */
  82716. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  82717. /**
  82718. * Checks if the ray intersects a box
  82719. * @param box the bounding box to check
  82720. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  82721. * @returns if the box was hit
  82722. */
  82723. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  82724. /**
  82725. * If the ray hits a sphere
  82726. * @param sphere the bounding sphere to check
  82727. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  82728. * @returns true if it hits the sphere
  82729. */
  82730. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  82731. /**
  82732. * If the ray hits a triange
  82733. * @param vertex0 triangle vertex
  82734. * @param vertex1 triangle vertex
  82735. * @param vertex2 triangle vertex
  82736. * @returns intersection information if hit
  82737. */
  82738. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  82739. /**
  82740. * Checks if ray intersects a plane
  82741. * @param plane the plane to check
  82742. * @returns the distance away it was hit
  82743. */
  82744. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  82745. /**
  82746. * Calculate the intercept of a ray on a given axis
  82747. * @param axis to check 'x' | 'y' | 'z'
  82748. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  82749. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  82750. */
  82751. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  82752. /**
  82753. * Checks if ray intersects a mesh
  82754. * @param mesh the mesh to check
  82755. * @param fastCheck if only the bounding box should checked
  82756. * @returns picking info of the intersecton
  82757. */
  82758. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  82759. /**
  82760. * Checks if ray intersects a mesh
  82761. * @param meshes the meshes to check
  82762. * @param fastCheck if only the bounding box should checked
  82763. * @param results array to store result in
  82764. * @returns Array of picking infos
  82765. */
  82766. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  82767. private _comparePickingInfo;
  82768. private static smallnum;
  82769. private static rayl;
  82770. /**
  82771. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  82772. * @param sega the first point of the segment to test the intersection against
  82773. * @param segb the second point of the segment to test the intersection against
  82774. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  82775. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  82776. */
  82777. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  82778. /**
  82779. * Update the ray from viewport position
  82780. * @param x position
  82781. * @param y y position
  82782. * @param viewportWidth viewport width
  82783. * @param viewportHeight viewport height
  82784. * @param world world matrix
  82785. * @param view view matrix
  82786. * @param projection projection matrix
  82787. * @returns this ray updated
  82788. */
  82789. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82790. /**
  82791. * Creates a ray with origin and direction of 0,0,0
  82792. * @returns the new ray
  82793. */
  82794. static Zero(): Ray;
  82795. /**
  82796. * Creates a new ray from screen space and viewport
  82797. * @param x position
  82798. * @param y y position
  82799. * @param viewportWidth viewport width
  82800. * @param viewportHeight viewport height
  82801. * @param world world matrix
  82802. * @param view view matrix
  82803. * @param projection projection matrix
  82804. * @returns new ray
  82805. */
  82806. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82807. /**
  82808. * 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
  82809. * transformed to the given world matrix.
  82810. * @param origin The origin point
  82811. * @param end The end point
  82812. * @param world a matrix to transform the ray to. Default is the identity matrix.
  82813. * @returns the new ray
  82814. */
  82815. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  82816. /**
  82817. * Transforms a ray by a matrix
  82818. * @param ray ray to transform
  82819. * @param matrix matrix to apply
  82820. * @returns the resulting new ray
  82821. */
  82822. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  82823. /**
  82824. * Transforms a ray by a matrix
  82825. * @param ray ray to transform
  82826. * @param matrix matrix to apply
  82827. * @param result ray to store result in
  82828. */
  82829. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  82830. /**
  82831. * Unproject a ray from screen space to object space
  82832. * @param sourceX defines the screen space x coordinate to use
  82833. * @param sourceY defines the screen space y coordinate to use
  82834. * @param viewportWidth defines the current width of the viewport
  82835. * @param viewportHeight defines the current height of the viewport
  82836. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82837. * @param view defines the view matrix to use
  82838. * @param projection defines the projection matrix to use
  82839. */
  82840. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  82841. }
  82842. /**
  82843. * Type used to define predicate used to select faces when a mesh intersection is detected
  82844. */
  82845. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  82846. interface Scene {
  82847. /** @hidden */
  82848. _tempPickingRay: Nullable<Ray>;
  82849. /** @hidden */
  82850. _cachedRayForTransform: Ray;
  82851. /** @hidden */
  82852. _pickWithRayInverseMatrix: Matrix;
  82853. /** @hidden */
  82854. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  82855. /** @hidden */
  82856. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  82857. }
  82858. }
  82859. declare module BABYLON {
  82860. /**
  82861. * Groups all the scene component constants in one place to ease maintenance.
  82862. * @hidden
  82863. */
  82864. export class SceneComponentConstants {
  82865. static readonly NAME_EFFECTLAYER: string;
  82866. static readonly NAME_LAYER: string;
  82867. static readonly NAME_LENSFLARESYSTEM: string;
  82868. static readonly NAME_BOUNDINGBOXRENDERER: string;
  82869. static readonly NAME_PARTICLESYSTEM: string;
  82870. static readonly NAME_GAMEPAD: string;
  82871. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  82872. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  82873. static readonly NAME_DEPTHRENDERER: string;
  82874. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  82875. static readonly NAME_SPRITE: string;
  82876. static readonly NAME_OUTLINERENDERER: string;
  82877. static readonly NAME_PROCEDURALTEXTURE: string;
  82878. static readonly NAME_SHADOWGENERATOR: string;
  82879. static readonly NAME_OCTREE: string;
  82880. static readonly NAME_PHYSICSENGINE: string;
  82881. static readonly NAME_AUDIO: string;
  82882. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  82883. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82884. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  82885. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82886. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  82887. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  82888. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  82889. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  82890. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  82891. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  82892. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  82893. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  82894. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  82895. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  82896. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  82897. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  82898. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  82899. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  82900. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  82901. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  82902. static readonly STEP_AFTERRENDER_AUDIO: number;
  82903. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  82904. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  82905. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  82906. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  82907. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  82908. static readonly STEP_POINTERMOVE_SPRITE: number;
  82909. static readonly STEP_POINTERDOWN_SPRITE: number;
  82910. static readonly STEP_POINTERUP_SPRITE: number;
  82911. }
  82912. /**
  82913. * This represents a scene component.
  82914. *
  82915. * This is used to decouple the dependency the scene is having on the different workloads like
  82916. * layers, post processes...
  82917. */
  82918. export interface ISceneComponent {
  82919. /**
  82920. * The name of the component. Each component must have a unique name.
  82921. */
  82922. name: string;
  82923. /**
  82924. * The scene the component belongs to.
  82925. */
  82926. scene: Scene;
  82927. /**
  82928. * Register the component to one instance of a scene.
  82929. */
  82930. register(): void;
  82931. /**
  82932. * Rebuilds the elements related to this component in case of
  82933. * context lost for instance.
  82934. */
  82935. rebuild(): void;
  82936. /**
  82937. * Disposes the component and the associated ressources.
  82938. */
  82939. dispose(): void;
  82940. }
  82941. /**
  82942. * This represents a SERIALIZABLE scene component.
  82943. *
  82944. * This extends Scene Component to add Serialization methods on top.
  82945. */
  82946. export interface ISceneSerializableComponent extends ISceneComponent {
  82947. /**
  82948. * Adds all the elements from the container to the scene
  82949. * @param container the container holding the elements
  82950. */
  82951. addFromContainer(container: AbstractScene): void;
  82952. /**
  82953. * Removes all the elements in the container from the scene
  82954. * @param container contains the elements to remove
  82955. * @param dispose if the removed element should be disposed (default: false)
  82956. */
  82957. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  82958. /**
  82959. * Serializes the component data to the specified json object
  82960. * @param serializationObject The object to serialize to
  82961. */
  82962. serialize(serializationObject: any): void;
  82963. }
  82964. /**
  82965. * Strong typing of a Mesh related stage step action
  82966. */
  82967. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  82968. /**
  82969. * Strong typing of a Evaluate Sub Mesh related stage step action
  82970. */
  82971. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  82972. /**
  82973. * Strong typing of a Active Mesh related stage step action
  82974. */
  82975. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  82976. /**
  82977. * Strong typing of a Camera related stage step action
  82978. */
  82979. export type CameraStageAction = (camera: Camera) => void;
  82980. /**
  82981. * Strong typing of a Camera Frame buffer related stage step action
  82982. */
  82983. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  82984. /**
  82985. * Strong typing of a Render Target related stage step action
  82986. */
  82987. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  82988. /**
  82989. * Strong typing of a RenderingGroup related stage step action
  82990. */
  82991. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  82992. /**
  82993. * Strong typing of a Mesh Render related stage step action
  82994. */
  82995. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  82996. /**
  82997. * Strong typing of a simple stage step action
  82998. */
  82999. export type SimpleStageAction = () => void;
  83000. /**
  83001. * Strong typing of a render target action.
  83002. */
  83003. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  83004. /**
  83005. * Strong typing of a pointer move action.
  83006. */
  83007. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  83008. /**
  83009. * Strong typing of a pointer up/down action.
  83010. */
  83011. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  83012. /**
  83013. * Representation of a stage in the scene (Basically a list of ordered steps)
  83014. * @hidden
  83015. */
  83016. export class Stage<T extends Function> extends Array<{
  83017. index: number;
  83018. component: ISceneComponent;
  83019. action: T;
  83020. }> {
  83021. /**
  83022. * Hide ctor from the rest of the world.
  83023. * @param items The items to add.
  83024. */
  83025. private constructor();
  83026. /**
  83027. * Creates a new Stage.
  83028. * @returns A new instance of a Stage
  83029. */
  83030. static Create<T extends Function>(): Stage<T>;
  83031. /**
  83032. * Registers a step in an ordered way in the targeted stage.
  83033. * @param index Defines the position to register the step in
  83034. * @param component Defines the component attached to the step
  83035. * @param action Defines the action to launch during the step
  83036. */
  83037. registerStep(index: number, component: ISceneComponent, action: T): void;
  83038. /**
  83039. * Clears all the steps from the stage.
  83040. */
  83041. clear(): void;
  83042. }
  83043. }
  83044. declare module BABYLON {
  83045. interface Scene {
  83046. /** @hidden */
  83047. _pointerOverSprite: Nullable<Sprite>;
  83048. /** @hidden */
  83049. _pickedDownSprite: Nullable<Sprite>;
  83050. /** @hidden */
  83051. _tempSpritePickingRay: Nullable<Ray>;
  83052. /**
  83053. * All of the sprite managers added to this scene
  83054. * @see http://doc.babylonjs.com/babylon101/sprites
  83055. */
  83056. spriteManagers: Array<ISpriteManager>;
  83057. /**
  83058. * An event triggered when sprites rendering is about to start
  83059. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83060. */
  83061. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83062. /**
  83063. * An event triggered when sprites rendering is done
  83064. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83065. */
  83066. onAfterSpritesRenderingObservable: Observable<Scene>;
  83067. /** @hidden */
  83068. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83069. /** Launch a ray to try to pick a sprite in the scene
  83070. * @param x position on screen
  83071. * @param y position on screen
  83072. * @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
  83073. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83074. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83075. * @returns a PickingInfo
  83076. */
  83077. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83078. /** Use the given ray to pick a sprite in the scene
  83079. * @param ray The ray (in world space) to use to pick meshes
  83080. * @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
  83081. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83082. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83083. * @returns a PickingInfo
  83084. */
  83085. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83086. /** @hidden */
  83087. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83088. /** Launch a ray to try to pick sprites in the scene
  83089. * @param x position on screen
  83090. * @param y position on screen
  83091. * @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
  83092. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83093. * @returns a PickingInfo array
  83094. */
  83095. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83096. /** Use the given ray to pick sprites in the scene
  83097. * @param ray The ray (in world space) to use to pick meshes
  83098. * @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
  83099. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83100. * @returns a PickingInfo array
  83101. */
  83102. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83103. /**
  83104. * Force the sprite under the pointer
  83105. * @param sprite defines the sprite to use
  83106. */
  83107. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  83108. /**
  83109. * Gets the sprite under the pointer
  83110. * @returns a Sprite or null if no sprite is under the pointer
  83111. */
  83112. getPointerOverSprite(): Nullable<Sprite>;
  83113. }
  83114. /**
  83115. * Defines the sprite scene component responsible to manage sprites
  83116. * in a given scene.
  83117. */
  83118. export class SpriteSceneComponent implements ISceneComponent {
  83119. /**
  83120. * The component name helpfull to identify the component in the list of scene components.
  83121. */
  83122. readonly name: string;
  83123. /**
  83124. * The scene the component belongs to.
  83125. */
  83126. scene: Scene;
  83127. /** @hidden */
  83128. private _spritePredicate;
  83129. /**
  83130. * Creates a new instance of the component for the given scene
  83131. * @param scene Defines the scene to register the component in
  83132. */
  83133. constructor(scene: Scene);
  83134. /**
  83135. * Registers the component in a given scene
  83136. */
  83137. register(): void;
  83138. /**
  83139. * Rebuilds the elements related to this component in case of
  83140. * context lost for instance.
  83141. */
  83142. rebuild(): void;
  83143. /**
  83144. * Disposes the component and the associated ressources.
  83145. */
  83146. dispose(): void;
  83147. private _pickSpriteButKeepRay;
  83148. private _pointerMove;
  83149. private _pointerDown;
  83150. private _pointerUp;
  83151. }
  83152. }
  83153. declare module BABYLON {
  83154. /** @hidden */
  83155. export var fogFragmentDeclaration: {
  83156. name: string;
  83157. shader: string;
  83158. };
  83159. }
  83160. declare module BABYLON {
  83161. /** @hidden */
  83162. export var fogFragment: {
  83163. name: string;
  83164. shader: string;
  83165. };
  83166. }
  83167. declare module BABYLON {
  83168. /** @hidden */
  83169. export var spritesPixelShader: {
  83170. name: string;
  83171. shader: string;
  83172. };
  83173. }
  83174. declare module BABYLON {
  83175. /** @hidden */
  83176. export var fogVertexDeclaration: {
  83177. name: string;
  83178. shader: string;
  83179. };
  83180. }
  83181. declare module BABYLON {
  83182. /** @hidden */
  83183. export var spritesVertexShader: {
  83184. name: string;
  83185. shader: string;
  83186. };
  83187. }
  83188. declare module BABYLON {
  83189. /**
  83190. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83191. */
  83192. export interface ISpriteManager extends IDisposable {
  83193. /**
  83194. * Restricts the camera to viewing objects with the same layerMask.
  83195. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83196. */
  83197. layerMask: number;
  83198. /**
  83199. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83200. */
  83201. isPickable: boolean;
  83202. /**
  83203. * Specifies the rendering group id for this mesh (0 by default)
  83204. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83205. */
  83206. renderingGroupId: number;
  83207. /**
  83208. * Defines the list of sprites managed by the manager.
  83209. */
  83210. sprites: Array<Sprite>;
  83211. /**
  83212. * Tests the intersection of a sprite with a specific ray.
  83213. * @param ray The ray we are sending to test the collision
  83214. * @param camera The camera space we are sending rays in
  83215. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83216. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83217. * @returns picking info or null.
  83218. */
  83219. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83220. /**
  83221. * Intersects the sprites with a ray
  83222. * @param ray defines the ray to intersect with
  83223. * @param camera defines the current active camera
  83224. * @param predicate defines a predicate used to select candidate sprites
  83225. * @returns null if no hit or a PickingInfo array
  83226. */
  83227. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83228. /**
  83229. * Renders the list of sprites on screen.
  83230. */
  83231. render(): void;
  83232. }
  83233. /**
  83234. * Class used to manage multiple sprites on the same spritesheet
  83235. * @see http://doc.babylonjs.com/babylon101/sprites
  83236. */
  83237. export class SpriteManager implements ISpriteManager {
  83238. /** defines the manager's name */
  83239. name: string;
  83240. /** Gets the list of sprites */
  83241. sprites: Sprite[];
  83242. /** Gets or sets the rendering group id (0 by default) */
  83243. renderingGroupId: number;
  83244. /** Gets or sets camera layer mask */
  83245. layerMask: number;
  83246. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83247. fogEnabled: boolean;
  83248. /** Gets or sets a boolean indicating if the sprites are pickable */
  83249. isPickable: boolean;
  83250. /** Defines the default width of a cell in the spritesheet */
  83251. cellWidth: number;
  83252. /** Defines the default height of a cell in the spritesheet */
  83253. cellHeight: number;
  83254. /** Associative array from JSON sprite data file */
  83255. private _cellData;
  83256. /** Array of sprite names from JSON sprite data file */
  83257. private _spriteMap;
  83258. /** True when packed cell data from JSON file is ready*/
  83259. private _packedAndReady;
  83260. /**
  83261. * An event triggered when the manager is disposed.
  83262. */
  83263. onDisposeObservable: Observable<SpriteManager>;
  83264. private _onDisposeObserver;
  83265. /**
  83266. * Callback called when the manager is disposed
  83267. */
  83268. set onDispose(callback: () => void);
  83269. private _capacity;
  83270. private _fromPacked;
  83271. private _spriteTexture;
  83272. private _epsilon;
  83273. private _scene;
  83274. private _vertexData;
  83275. private _buffer;
  83276. private _vertexBuffers;
  83277. private _indexBuffer;
  83278. private _effectBase;
  83279. private _effectFog;
  83280. /**
  83281. * Gets or sets the spritesheet texture
  83282. */
  83283. get texture(): Texture;
  83284. set texture(value: Texture);
  83285. private _blendMode;
  83286. /**
  83287. * Blend mode use to render the particle, it can be any of
  83288. * the static Constants.ALPHA_x properties provided in this class.
  83289. * Default value is Constants.ALPHA_COMBINE
  83290. */
  83291. get blendMode(): number;
  83292. set blendMode(blendMode: number);
  83293. /** Disables writing to the depth buffer when rendering the sprites.
  83294. * It can be handy to disable depth writing when using textures without alpha channel
  83295. * and setting some specific blend modes.
  83296. */
  83297. disableDepthWrite: boolean;
  83298. /**
  83299. * Creates a new sprite manager
  83300. * @param name defines the manager's name
  83301. * @param imgUrl defines the sprite sheet url
  83302. * @param capacity defines the maximum allowed number of sprites
  83303. * @param cellSize defines the size of a sprite cell
  83304. * @param scene defines the hosting scene
  83305. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83306. * @param samplingMode defines the smapling mode to use with spritesheet
  83307. * @param fromPacked set to false; do not alter
  83308. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83309. */
  83310. constructor(
  83311. /** defines the manager's name */
  83312. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83313. private _makePacked;
  83314. private _appendSpriteVertex;
  83315. /**
  83316. * Intersects the sprites with a ray
  83317. * @param ray defines the ray to intersect with
  83318. * @param camera defines the current active camera
  83319. * @param predicate defines a predicate used to select candidate sprites
  83320. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83321. * @returns null if no hit or a PickingInfo
  83322. */
  83323. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83324. /**
  83325. * Intersects the sprites with a ray
  83326. * @param ray defines the ray to intersect with
  83327. * @param camera defines the current active camera
  83328. * @param predicate defines a predicate used to select candidate sprites
  83329. * @returns null if no hit or a PickingInfo array
  83330. */
  83331. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83332. /**
  83333. * Render all child sprites
  83334. */
  83335. render(): void;
  83336. /**
  83337. * Release associated resources
  83338. */
  83339. dispose(): void;
  83340. }
  83341. }
  83342. declare module BABYLON {
  83343. /** Interface used by value gradients (color, factor, ...) */
  83344. export interface IValueGradient {
  83345. /**
  83346. * Gets or sets the gradient value (between 0 and 1)
  83347. */
  83348. gradient: number;
  83349. }
  83350. /** Class used to store color4 gradient */
  83351. export class ColorGradient implements IValueGradient {
  83352. /**
  83353. * Gets or sets the gradient value (between 0 and 1)
  83354. */
  83355. gradient: number;
  83356. /**
  83357. * Gets or sets first associated color
  83358. */
  83359. color1: Color4;
  83360. /**
  83361. * Gets or sets second associated color
  83362. */
  83363. color2?: Color4;
  83364. /**
  83365. * Will get a color picked randomly between color1 and color2.
  83366. * If color2 is undefined then color1 will be used
  83367. * @param result defines the target Color4 to store the result in
  83368. */
  83369. getColorToRef(result: Color4): void;
  83370. }
  83371. /** Class used to store color 3 gradient */
  83372. export class Color3Gradient implements IValueGradient {
  83373. /**
  83374. * Gets or sets the gradient value (between 0 and 1)
  83375. */
  83376. gradient: number;
  83377. /**
  83378. * Gets or sets the associated color
  83379. */
  83380. color: Color3;
  83381. }
  83382. /** Class used to store factor gradient */
  83383. export class FactorGradient implements IValueGradient {
  83384. /**
  83385. * Gets or sets the gradient value (between 0 and 1)
  83386. */
  83387. gradient: number;
  83388. /**
  83389. * Gets or sets first associated factor
  83390. */
  83391. factor1: number;
  83392. /**
  83393. * Gets or sets second associated factor
  83394. */
  83395. factor2?: number;
  83396. /**
  83397. * Will get a number picked randomly between factor1 and factor2.
  83398. * If factor2 is undefined then factor1 will be used
  83399. * @returns the picked number
  83400. */
  83401. getFactor(): number;
  83402. }
  83403. /**
  83404. * Helper used to simplify some generic gradient tasks
  83405. */
  83406. export class GradientHelper {
  83407. /**
  83408. * Gets the current gradient from an array of IValueGradient
  83409. * @param ratio defines the current ratio to get
  83410. * @param gradients defines the array of IValueGradient
  83411. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83412. */
  83413. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83414. }
  83415. }
  83416. declare module BABYLON {
  83417. /**
  83418. * Interface for the size containing width and height
  83419. */
  83420. export interface ISize {
  83421. /**
  83422. * Width
  83423. */
  83424. width: number;
  83425. /**
  83426. * Heighht
  83427. */
  83428. height: number;
  83429. }
  83430. /**
  83431. * Size containing widht and height
  83432. */
  83433. export class Size implements ISize {
  83434. /**
  83435. * Width
  83436. */
  83437. width: number;
  83438. /**
  83439. * Height
  83440. */
  83441. height: number;
  83442. /**
  83443. * Creates a Size object from the given width and height (floats).
  83444. * @param width width of the new size
  83445. * @param height height of the new size
  83446. */
  83447. constructor(width: number, height: number);
  83448. /**
  83449. * Returns a string with the Size width and height
  83450. * @returns a string with the Size width and height
  83451. */
  83452. toString(): string;
  83453. /**
  83454. * "Size"
  83455. * @returns the string "Size"
  83456. */
  83457. getClassName(): string;
  83458. /**
  83459. * Returns the Size hash code.
  83460. * @returns a hash code for a unique width and height
  83461. */
  83462. getHashCode(): number;
  83463. /**
  83464. * Updates the current size from the given one.
  83465. * @param src the given size
  83466. */
  83467. copyFrom(src: Size): void;
  83468. /**
  83469. * Updates in place the current Size from the given floats.
  83470. * @param width width of the new size
  83471. * @param height height of the new size
  83472. * @returns the updated Size.
  83473. */
  83474. copyFromFloats(width: number, height: number): Size;
  83475. /**
  83476. * Updates in place the current Size from the given floats.
  83477. * @param width width to set
  83478. * @param height height to set
  83479. * @returns the updated Size.
  83480. */
  83481. set(width: number, height: number): Size;
  83482. /**
  83483. * Multiplies the width and height by numbers
  83484. * @param w factor to multiple the width by
  83485. * @param h factor to multiple the height by
  83486. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83487. */
  83488. multiplyByFloats(w: number, h: number): Size;
  83489. /**
  83490. * Clones the size
  83491. * @returns a new Size copied from the given one.
  83492. */
  83493. clone(): Size;
  83494. /**
  83495. * True if the current Size and the given one width and height are strictly equal.
  83496. * @param other the other size to compare against
  83497. * @returns True if the current Size and the given one width and height are strictly equal.
  83498. */
  83499. equals(other: Size): boolean;
  83500. /**
  83501. * The surface of the Size : width * height (float).
  83502. */
  83503. get surface(): number;
  83504. /**
  83505. * Create a new size of zero
  83506. * @returns a new Size set to (0.0, 0.0)
  83507. */
  83508. static Zero(): Size;
  83509. /**
  83510. * Sums the width and height of two sizes
  83511. * @param otherSize size to add to this size
  83512. * @returns a new Size set as the addition result of the current Size and the given one.
  83513. */
  83514. add(otherSize: Size): Size;
  83515. /**
  83516. * Subtracts the width and height of two
  83517. * @param otherSize size to subtract to this size
  83518. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83519. */
  83520. subtract(otherSize: Size): Size;
  83521. /**
  83522. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83523. * @param start starting size to lerp between
  83524. * @param end end size to lerp between
  83525. * @param amount amount to lerp between the start and end values
  83526. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83527. */
  83528. static Lerp(start: Size, end: Size, amount: number): Size;
  83529. }
  83530. }
  83531. declare module BABYLON {
  83532. interface ThinEngine {
  83533. /**
  83534. * Creates a dynamic texture
  83535. * @param width defines the width of the texture
  83536. * @param height defines the height of the texture
  83537. * @param generateMipMaps defines if the engine should generate the mip levels
  83538. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83539. * @returns the dynamic texture inside an InternalTexture
  83540. */
  83541. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83542. /**
  83543. * Update the content of a dynamic texture
  83544. * @param texture defines the texture to update
  83545. * @param canvas defines the canvas containing the source
  83546. * @param invertY defines if data must be stored with Y axis inverted
  83547. * @param premulAlpha defines if alpha is stored as premultiplied
  83548. * @param format defines the format of the data
  83549. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83550. */
  83551. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83552. }
  83553. }
  83554. declare module BABYLON {
  83555. /**
  83556. * Helper class used to generate a canvas to manipulate images
  83557. */
  83558. export class CanvasGenerator {
  83559. /**
  83560. * Create a new canvas (or offscreen canvas depending on the context)
  83561. * @param width defines the expected width
  83562. * @param height defines the expected height
  83563. * @return a new canvas or offscreen canvas
  83564. */
  83565. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83566. }
  83567. }
  83568. declare module BABYLON {
  83569. /**
  83570. * A class extending Texture allowing drawing on a texture
  83571. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83572. */
  83573. export class DynamicTexture extends Texture {
  83574. private _generateMipMaps;
  83575. private _canvas;
  83576. private _context;
  83577. private _engine;
  83578. /**
  83579. * Creates a DynamicTexture
  83580. * @param name defines the name of the texture
  83581. * @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
  83582. * @param scene defines the scene where you want the texture
  83583. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83584. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83585. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83586. */
  83587. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83588. /**
  83589. * Get the current class name of the texture useful for serialization or dynamic coding.
  83590. * @returns "DynamicTexture"
  83591. */
  83592. getClassName(): string;
  83593. /**
  83594. * Gets the current state of canRescale
  83595. */
  83596. get canRescale(): boolean;
  83597. private _recreate;
  83598. /**
  83599. * Scales the texture
  83600. * @param ratio the scale factor to apply to both width and height
  83601. */
  83602. scale(ratio: number): void;
  83603. /**
  83604. * Resizes the texture
  83605. * @param width the new width
  83606. * @param height the new height
  83607. */
  83608. scaleTo(width: number, height: number): void;
  83609. /**
  83610. * Gets the context of the canvas used by the texture
  83611. * @returns the canvas context of the dynamic texture
  83612. */
  83613. getContext(): CanvasRenderingContext2D;
  83614. /**
  83615. * Clears the texture
  83616. */
  83617. clear(): void;
  83618. /**
  83619. * Updates the texture
  83620. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83621. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83622. */
  83623. update(invertY?: boolean, premulAlpha?: boolean): void;
  83624. /**
  83625. * Draws text onto the texture
  83626. * @param text defines the text to be drawn
  83627. * @param x defines the placement of the text from the left
  83628. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83629. * @param font defines the font to be used with font-style, font-size, font-name
  83630. * @param color defines the color used for the text
  83631. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83632. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83633. * @param update defines whether texture is immediately update (default is true)
  83634. */
  83635. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83636. /**
  83637. * Clones the texture
  83638. * @returns the clone of the texture.
  83639. */
  83640. clone(): DynamicTexture;
  83641. /**
  83642. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83643. * @returns a serialized dynamic texture object
  83644. */
  83645. serialize(): any;
  83646. /** @hidden */
  83647. _rebuild(): void;
  83648. }
  83649. }
  83650. declare module BABYLON {
  83651. interface Engine {
  83652. /**
  83653. * Creates a raw texture
  83654. * @param data defines the data to store in the texture
  83655. * @param width defines the width of the texture
  83656. * @param height defines the height of the texture
  83657. * @param format defines the format of the data
  83658. * @param generateMipMaps defines if the engine should generate the mip levels
  83659. * @param invertY defines if data must be stored with Y axis inverted
  83660. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83661. * @param compression defines the compression used (null by default)
  83662. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83663. * @returns the raw texture inside an InternalTexture
  83664. */
  83665. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83666. /**
  83667. * Update a raw texture
  83668. * @param texture defines the texture to update
  83669. * @param data defines the data to store in the texture
  83670. * @param format defines the format of the data
  83671. * @param invertY defines if data must be stored with Y axis inverted
  83672. */
  83673. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83674. /**
  83675. * Update a raw texture
  83676. * @param texture defines the texture to update
  83677. * @param data defines the data to store in the texture
  83678. * @param format defines the format of the data
  83679. * @param invertY defines if data must be stored with Y axis inverted
  83680. * @param compression defines the compression used (null by default)
  83681. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83682. */
  83683. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83684. /**
  83685. * Creates a new raw cube texture
  83686. * @param data defines the array of data to use to create each face
  83687. * @param size defines the size of the textures
  83688. * @param format defines the format of the data
  83689. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83690. * @param generateMipMaps defines if the engine should generate the mip levels
  83691. * @param invertY defines if data must be stored with Y axis inverted
  83692. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83693. * @param compression defines the compression used (null by default)
  83694. * @returns the cube texture as an InternalTexture
  83695. */
  83696. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83697. /**
  83698. * Update a raw cube texture
  83699. * @param texture defines the texture to udpdate
  83700. * @param data defines the data to store
  83701. * @param format defines the data format
  83702. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83703. * @param invertY defines if data must be stored with Y axis inverted
  83704. */
  83705. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83706. /**
  83707. * Update a raw cube texture
  83708. * @param texture defines the texture to udpdate
  83709. * @param data defines the data to store
  83710. * @param format defines the data format
  83711. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83712. * @param invertY defines if data must be stored with Y axis inverted
  83713. * @param compression defines the compression used (null by default)
  83714. */
  83715. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83716. /**
  83717. * Update a raw cube texture
  83718. * @param texture defines the texture to udpdate
  83719. * @param data defines the data to store
  83720. * @param format defines the data format
  83721. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83722. * @param invertY defines if data must be stored with Y axis inverted
  83723. * @param compression defines the compression used (null by default)
  83724. * @param level defines which level of the texture to update
  83725. */
  83726. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83727. /**
  83728. * Creates a new raw cube texture from a specified url
  83729. * @param url defines the url where the data is located
  83730. * @param scene defines the current scene
  83731. * @param size defines the size of the textures
  83732. * @param format defines the format of the data
  83733. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83734. * @param noMipmap defines if the engine should avoid generating the mip levels
  83735. * @param callback defines a callback used to extract texture data from loaded data
  83736. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83737. * @param onLoad defines a callback called when texture is loaded
  83738. * @param onError defines a callback called if there is an error
  83739. * @returns the cube texture as an InternalTexture
  83740. */
  83741. 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;
  83742. /**
  83743. * Creates a new raw cube texture from a specified url
  83744. * @param url defines the url where the data is located
  83745. * @param scene defines the current scene
  83746. * @param size defines the size of the textures
  83747. * @param format defines the format of the data
  83748. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83749. * @param noMipmap defines if the engine should avoid generating the mip levels
  83750. * @param callback defines a callback used to extract texture data from loaded data
  83751. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83752. * @param onLoad defines a callback called when texture is loaded
  83753. * @param onError defines a callback called if there is an error
  83754. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83755. * @param invertY defines if data must be stored with Y axis inverted
  83756. * @returns the cube texture as an InternalTexture
  83757. */
  83758. 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;
  83759. /**
  83760. * Creates a new raw 3D texture
  83761. * @param data defines the data used to create the texture
  83762. * @param width defines the width of the texture
  83763. * @param height defines the height of the texture
  83764. * @param depth defines the depth of the texture
  83765. * @param format defines the format of the texture
  83766. * @param generateMipMaps defines if the engine must generate mip levels
  83767. * @param invertY defines if data must be stored with Y axis inverted
  83768. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83769. * @param compression defines the compressed used (can be null)
  83770. * @param textureType defines the compressed used (can be null)
  83771. * @returns a new raw 3D texture (stored in an InternalTexture)
  83772. */
  83773. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83774. /**
  83775. * Update a raw 3D texture
  83776. * @param texture defines the texture to update
  83777. * @param data defines the data to store
  83778. * @param format defines the data format
  83779. * @param invertY defines if data must be stored with Y axis inverted
  83780. */
  83781. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83782. /**
  83783. * Update a raw 3D texture
  83784. * @param texture defines the texture to update
  83785. * @param data defines the data to store
  83786. * @param format defines the data format
  83787. * @param invertY defines if data must be stored with Y axis inverted
  83788. * @param compression defines the used compression (can be null)
  83789. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83790. */
  83791. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83792. /**
  83793. * Creates a new raw 2D array texture
  83794. * @param data defines the data used to create the texture
  83795. * @param width defines the width of the texture
  83796. * @param height defines the height of the texture
  83797. * @param depth defines the number of layers of the texture
  83798. * @param format defines the format of the texture
  83799. * @param generateMipMaps defines if the engine must generate mip levels
  83800. * @param invertY defines if data must be stored with Y axis inverted
  83801. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83802. * @param compression defines the compressed used (can be null)
  83803. * @param textureType defines the compressed used (can be null)
  83804. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83805. */
  83806. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83807. /**
  83808. * Update a raw 2D array texture
  83809. * @param texture defines the texture to update
  83810. * @param data defines the data to store
  83811. * @param format defines the data format
  83812. * @param invertY defines if data must be stored with Y axis inverted
  83813. */
  83814. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83815. /**
  83816. * Update a raw 2D array texture
  83817. * @param texture defines the texture to update
  83818. * @param data defines the data to store
  83819. * @param format defines the data format
  83820. * @param invertY defines if data must be stored with Y axis inverted
  83821. * @param compression defines the used compression (can be null)
  83822. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83823. */
  83824. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83825. }
  83826. }
  83827. declare module BABYLON {
  83828. /**
  83829. * Raw texture can help creating a texture directly from an array of data.
  83830. * This can be super useful if you either get the data from an uncompressed source or
  83831. * if you wish to create your texture pixel by pixel.
  83832. */
  83833. export class RawTexture extends Texture {
  83834. /**
  83835. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83836. */
  83837. format: number;
  83838. private _engine;
  83839. /**
  83840. * Instantiates a new RawTexture.
  83841. * Raw texture can help creating a texture directly from an array of data.
  83842. * This can be super useful if you either get the data from an uncompressed source or
  83843. * if you wish to create your texture pixel by pixel.
  83844. * @param data define the array of data to use to create the texture
  83845. * @param width define the width of the texture
  83846. * @param height define the height of the texture
  83847. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83848. * @param scene define the scene the texture belongs to
  83849. * @param generateMipMaps define whether mip maps should be generated or not
  83850. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83851. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83852. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83853. */
  83854. constructor(data: ArrayBufferView, width: number, height: number,
  83855. /**
  83856. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83857. */
  83858. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83859. /**
  83860. * Updates the texture underlying data.
  83861. * @param data Define the new data of the texture
  83862. */
  83863. update(data: ArrayBufferView): void;
  83864. /**
  83865. * Creates a luminance texture from some data.
  83866. * @param data Define the texture data
  83867. * @param width Define the width of the texture
  83868. * @param height Define the height of the texture
  83869. * @param scene Define the scene the texture belongs to
  83870. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83871. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83872. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83873. * @returns the luminance texture
  83874. */
  83875. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83876. /**
  83877. * Creates a luminance alpha texture from some data.
  83878. * @param data Define the texture data
  83879. * @param width Define the width of the texture
  83880. * @param height Define the height of the texture
  83881. * @param scene Define the scene the texture belongs to
  83882. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83883. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83884. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83885. * @returns the luminance alpha texture
  83886. */
  83887. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83888. /**
  83889. * Creates an alpha texture from some data.
  83890. * @param data Define the texture data
  83891. * @param width Define the width of the texture
  83892. * @param height Define the height of the texture
  83893. * @param scene Define the scene the texture belongs to
  83894. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83895. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83896. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83897. * @returns the alpha texture
  83898. */
  83899. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83900. /**
  83901. * Creates a RGB texture from some data.
  83902. * @param data Define the texture data
  83903. * @param width Define the width of the texture
  83904. * @param height Define the height of the texture
  83905. * @param scene Define the scene the texture belongs to
  83906. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83907. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83908. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83909. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83910. * @returns the RGB alpha texture
  83911. */
  83912. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83913. /**
  83914. * Creates a RGBA texture from some data.
  83915. * @param data Define the texture data
  83916. * @param width Define the width of the texture
  83917. * @param height Define the height of the texture
  83918. * @param scene Define the scene the texture belongs to
  83919. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83920. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83921. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83922. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83923. * @returns the RGBA texture
  83924. */
  83925. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83926. /**
  83927. * Creates a R texture from some data.
  83928. * @param data Define the texture data
  83929. * @param width Define the width of the texture
  83930. * @param height Define the height of the texture
  83931. * @param scene Define the scene the texture belongs to
  83932. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83933. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83934. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83935. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83936. * @returns the R texture
  83937. */
  83938. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83939. }
  83940. }
  83941. declare module BABYLON {
  83942. interface AbstractScene {
  83943. /**
  83944. * The list of procedural textures added to the scene
  83945. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83946. */
  83947. proceduralTextures: Array<ProceduralTexture>;
  83948. }
  83949. /**
  83950. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  83951. * in a given scene.
  83952. */
  83953. export class ProceduralTextureSceneComponent implements ISceneComponent {
  83954. /**
  83955. * The component name helpfull to identify the component in the list of scene components.
  83956. */
  83957. readonly name: string;
  83958. /**
  83959. * The scene the component belongs to.
  83960. */
  83961. scene: Scene;
  83962. /**
  83963. * Creates a new instance of the component for the given scene
  83964. * @param scene Defines the scene to register the component in
  83965. */
  83966. constructor(scene: Scene);
  83967. /**
  83968. * Registers the component in a given scene
  83969. */
  83970. register(): void;
  83971. /**
  83972. * Rebuilds the elements related to this component in case of
  83973. * context lost for instance.
  83974. */
  83975. rebuild(): void;
  83976. /**
  83977. * Disposes the component and the associated ressources.
  83978. */
  83979. dispose(): void;
  83980. private _beforeClear;
  83981. }
  83982. }
  83983. declare module BABYLON {
  83984. interface ThinEngine {
  83985. /**
  83986. * Creates a new render target cube texture
  83987. * @param size defines the size of the texture
  83988. * @param options defines the options used to create the texture
  83989. * @returns a new render target cube texture stored in an InternalTexture
  83990. */
  83991. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  83992. }
  83993. }
  83994. declare module BABYLON {
  83995. /** @hidden */
  83996. export var proceduralVertexShader: {
  83997. name: string;
  83998. shader: string;
  83999. };
  84000. }
  84001. declare module BABYLON {
  84002. /**
  84003. * 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.
  84004. * This is the base class of any Procedural texture and contains most of the shareable code.
  84005. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84006. */
  84007. export class ProceduralTexture extends Texture {
  84008. isCube: boolean;
  84009. /**
  84010. * Define if the texture is enabled or not (disabled texture will not render)
  84011. */
  84012. isEnabled: boolean;
  84013. /**
  84014. * Define if the texture must be cleared before rendering (default is true)
  84015. */
  84016. autoClear: boolean;
  84017. /**
  84018. * Callback called when the texture is generated
  84019. */
  84020. onGenerated: () => void;
  84021. /**
  84022. * Event raised when the texture is generated
  84023. */
  84024. onGeneratedObservable: Observable<ProceduralTexture>;
  84025. /** @hidden */
  84026. _generateMipMaps: boolean;
  84027. /** @hidden **/
  84028. _effect: Effect;
  84029. /** @hidden */
  84030. _textures: {
  84031. [key: string]: Texture;
  84032. };
  84033. private _size;
  84034. private _currentRefreshId;
  84035. private _frameId;
  84036. private _refreshRate;
  84037. private _vertexBuffers;
  84038. private _indexBuffer;
  84039. private _uniforms;
  84040. private _samplers;
  84041. private _fragment;
  84042. private _floats;
  84043. private _ints;
  84044. private _floatsArrays;
  84045. private _colors3;
  84046. private _colors4;
  84047. private _vectors2;
  84048. private _vectors3;
  84049. private _matrices;
  84050. private _fallbackTexture;
  84051. private _fallbackTextureUsed;
  84052. private _engine;
  84053. private _cachedDefines;
  84054. private _contentUpdateId;
  84055. private _contentData;
  84056. /**
  84057. * Instantiates a new procedural texture.
  84058. * 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.
  84059. * This is the base class of any Procedural texture and contains most of the shareable code.
  84060. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84061. * @param name Define the name of the texture
  84062. * @param size Define the size of the texture to create
  84063. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84064. * @param scene Define the scene the texture belongs to
  84065. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84066. * @param generateMipMaps Define if the texture should creates mip maps or not
  84067. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84068. */
  84069. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84070. /**
  84071. * The effect that is created when initializing the post process.
  84072. * @returns The created effect corresponding the the postprocess.
  84073. */
  84074. getEffect(): Effect;
  84075. /**
  84076. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84077. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84078. */
  84079. getContent(): Nullable<ArrayBufferView>;
  84080. private _createIndexBuffer;
  84081. /** @hidden */
  84082. _rebuild(): void;
  84083. /**
  84084. * Resets the texture in order to recreate its associated resources.
  84085. * This can be called in case of context loss
  84086. */
  84087. reset(): void;
  84088. protected _getDefines(): string;
  84089. /**
  84090. * Is the texture ready to be used ? (rendered at least once)
  84091. * @returns true if ready, otherwise, false.
  84092. */
  84093. isReady(): boolean;
  84094. /**
  84095. * Resets the refresh counter of the texture and start bak from scratch.
  84096. * Could be useful to regenerate the texture if it is setup to render only once.
  84097. */
  84098. resetRefreshCounter(): void;
  84099. /**
  84100. * Set the fragment shader to use in order to render the texture.
  84101. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84102. */
  84103. setFragment(fragment: any): void;
  84104. /**
  84105. * Define the refresh rate of the texture or the rendering frequency.
  84106. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84107. */
  84108. get refreshRate(): number;
  84109. set refreshRate(value: number);
  84110. /** @hidden */
  84111. _shouldRender(): boolean;
  84112. /**
  84113. * Get the size the texture is rendering at.
  84114. * @returns the size (texture is always squared)
  84115. */
  84116. getRenderSize(): number;
  84117. /**
  84118. * Resize the texture to new value.
  84119. * @param size Define the new size the texture should have
  84120. * @param generateMipMaps Define whether the new texture should create mip maps
  84121. */
  84122. resize(size: number, generateMipMaps: boolean): void;
  84123. private _checkUniform;
  84124. /**
  84125. * Set a texture in the shader program used to render.
  84126. * @param name Define the name of the uniform samplers as defined in the shader
  84127. * @param texture Define the texture to bind to this sampler
  84128. * @return the texture itself allowing "fluent" like uniform updates
  84129. */
  84130. setTexture(name: string, texture: Texture): ProceduralTexture;
  84131. /**
  84132. * Set a float in the shader.
  84133. * @param name Define the name of the uniform as defined in the shader
  84134. * @param value Define the value to give to the uniform
  84135. * @return the texture itself allowing "fluent" like uniform updates
  84136. */
  84137. setFloat(name: string, value: number): ProceduralTexture;
  84138. /**
  84139. * Set a int in the shader.
  84140. * @param name Define the name of the uniform as defined in the shader
  84141. * @param value Define the value to give to the uniform
  84142. * @return the texture itself allowing "fluent" like uniform updates
  84143. */
  84144. setInt(name: string, value: number): ProceduralTexture;
  84145. /**
  84146. * Set an array of floats in the shader.
  84147. * @param name Define the name of the uniform as defined in the shader
  84148. * @param value Define the value to give to the uniform
  84149. * @return the texture itself allowing "fluent" like uniform updates
  84150. */
  84151. setFloats(name: string, value: number[]): ProceduralTexture;
  84152. /**
  84153. * Set a vec3 in the shader from a Color3.
  84154. * @param name Define the name of the uniform as defined in the shader
  84155. * @param value Define the value to give to the uniform
  84156. * @return the texture itself allowing "fluent" like uniform updates
  84157. */
  84158. setColor3(name: string, value: Color3): ProceduralTexture;
  84159. /**
  84160. * Set a vec4 in the shader from a Color4.
  84161. * @param name Define the name of the uniform as defined in the shader
  84162. * @param value Define the value to give to the uniform
  84163. * @return the texture itself allowing "fluent" like uniform updates
  84164. */
  84165. setColor4(name: string, value: Color4): ProceduralTexture;
  84166. /**
  84167. * Set a vec2 in the shader from a Vector2.
  84168. * @param name Define the name of the uniform as defined in the shader
  84169. * @param value Define the value to give to the uniform
  84170. * @return the texture itself allowing "fluent" like uniform updates
  84171. */
  84172. setVector2(name: string, value: Vector2): ProceduralTexture;
  84173. /**
  84174. * Set a vec3 in the shader from a Vector3.
  84175. * @param name Define the name of the uniform as defined in the shader
  84176. * @param value Define the value to give to the uniform
  84177. * @return the texture itself allowing "fluent" like uniform updates
  84178. */
  84179. setVector3(name: string, value: Vector3): ProceduralTexture;
  84180. /**
  84181. * Set a mat4 in the shader from a MAtrix.
  84182. * @param name Define the name of the uniform as defined in the shader
  84183. * @param value Define the value to give to the uniform
  84184. * @return the texture itself allowing "fluent" like uniform updates
  84185. */
  84186. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84187. /**
  84188. * Render the texture to its associated render target.
  84189. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84190. */
  84191. render(useCameraPostProcess?: boolean): void;
  84192. /**
  84193. * Clone the texture.
  84194. * @returns the cloned texture
  84195. */
  84196. clone(): ProceduralTexture;
  84197. /**
  84198. * Dispose the texture and release its asoociated resources.
  84199. */
  84200. dispose(): void;
  84201. }
  84202. }
  84203. declare module BABYLON {
  84204. /**
  84205. * This represents the base class for particle system in Babylon.
  84206. * 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.
  84207. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84208. * @example https://doc.babylonjs.com/babylon101/particles
  84209. */
  84210. export class BaseParticleSystem {
  84211. /**
  84212. * Source color is added to the destination color without alpha affecting the result
  84213. */
  84214. static BLENDMODE_ONEONE: number;
  84215. /**
  84216. * Blend current color and particle color using particle’s alpha
  84217. */
  84218. static BLENDMODE_STANDARD: number;
  84219. /**
  84220. * Add current color and particle color multiplied by particle’s alpha
  84221. */
  84222. static BLENDMODE_ADD: number;
  84223. /**
  84224. * Multiply current color with particle color
  84225. */
  84226. static BLENDMODE_MULTIPLY: number;
  84227. /**
  84228. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84229. */
  84230. static BLENDMODE_MULTIPLYADD: number;
  84231. /**
  84232. * List of animations used by the particle system.
  84233. */
  84234. animations: Animation[];
  84235. /**
  84236. * The id of the Particle system.
  84237. */
  84238. id: string;
  84239. /**
  84240. * The friendly name of the Particle system.
  84241. */
  84242. name: string;
  84243. /**
  84244. * The rendering group used by the Particle system to chose when to render.
  84245. */
  84246. renderingGroupId: number;
  84247. /**
  84248. * The emitter represents the Mesh or position we are attaching the particle system to.
  84249. */
  84250. emitter: Nullable<AbstractMesh | Vector3>;
  84251. /**
  84252. * The maximum number of particles to emit per frame
  84253. */
  84254. emitRate: number;
  84255. /**
  84256. * If you want to launch only a few particles at once, that can be done, as well.
  84257. */
  84258. manualEmitCount: number;
  84259. /**
  84260. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84261. */
  84262. updateSpeed: number;
  84263. /**
  84264. * The amount of time the particle system is running (depends of the overall update speed).
  84265. */
  84266. targetStopDuration: number;
  84267. /**
  84268. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84269. */
  84270. disposeOnStop: boolean;
  84271. /**
  84272. * Minimum power of emitting particles.
  84273. */
  84274. minEmitPower: number;
  84275. /**
  84276. * Maximum power of emitting particles.
  84277. */
  84278. maxEmitPower: number;
  84279. /**
  84280. * Minimum life time of emitting particles.
  84281. */
  84282. minLifeTime: number;
  84283. /**
  84284. * Maximum life time of emitting particles.
  84285. */
  84286. maxLifeTime: number;
  84287. /**
  84288. * Minimum Size of emitting particles.
  84289. */
  84290. minSize: number;
  84291. /**
  84292. * Maximum Size of emitting particles.
  84293. */
  84294. maxSize: number;
  84295. /**
  84296. * Minimum scale of emitting particles on X axis.
  84297. */
  84298. minScaleX: number;
  84299. /**
  84300. * Maximum scale of emitting particles on X axis.
  84301. */
  84302. maxScaleX: number;
  84303. /**
  84304. * Minimum scale of emitting particles on Y axis.
  84305. */
  84306. minScaleY: number;
  84307. /**
  84308. * Maximum scale of emitting particles on Y axis.
  84309. */
  84310. maxScaleY: number;
  84311. /**
  84312. * Gets or sets the minimal initial rotation in radians.
  84313. */
  84314. minInitialRotation: number;
  84315. /**
  84316. * Gets or sets the maximal initial rotation in radians.
  84317. */
  84318. maxInitialRotation: number;
  84319. /**
  84320. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84321. */
  84322. minAngularSpeed: number;
  84323. /**
  84324. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84325. */
  84326. maxAngularSpeed: number;
  84327. /**
  84328. * The texture used to render each particle. (this can be a spritesheet)
  84329. */
  84330. particleTexture: Nullable<Texture>;
  84331. /**
  84332. * The layer mask we are rendering the particles through.
  84333. */
  84334. layerMask: number;
  84335. /**
  84336. * This can help using your own shader to render the particle system.
  84337. * The according effect will be created
  84338. */
  84339. customShader: any;
  84340. /**
  84341. * By default particle system starts as soon as they are created. This prevents the
  84342. * automatic start to happen and let you decide when to start emitting particles.
  84343. */
  84344. preventAutoStart: boolean;
  84345. private _noiseTexture;
  84346. /**
  84347. * Gets or sets a texture used to add random noise to particle positions
  84348. */
  84349. get noiseTexture(): Nullable<ProceduralTexture>;
  84350. set noiseTexture(value: Nullable<ProceduralTexture>);
  84351. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84352. noiseStrength: Vector3;
  84353. /**
  84354. * Callback triggered when the particle animation is ending.
  84355. */
  84356. onAnimationEnd: Nullable<() => void>;
  84357. /**
  84358. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84359. */
  84360. blendMode: number;
  84361. /**
  84362. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84363. * to override the particles.
  84364. */
  84365. forceDepthWrite: boolean;
  84366. /** 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 */
  84367. preWarmCycles: number;
  84368. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84369. preWarmStepOffset: number;
  84370. /**
  84371. * 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)
  84372. */
  84373. spriteCellChangeSpeed: number;
  84374. /**
  84375. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84376. */
  84377. startSpriteCellID: number;
  84378. /**
  84379. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84380. */
  84381. endSpriteCellID: number;
  84382. /**
  84383. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84384. */
  84385. spriteCellWidth: number;
  84386. /**
  84387. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84388. */
  84389. spriteCellHeight: number;
  84390. /**
  84391. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84392. */
  84393. spriteRandomStartCell: boolean;
  84394. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84395. translationPivot: Vector2;
  84396. /** @hidden */
  84397. protected _isAnimationSheetEnabled: boolean;
  84398. /**
  84399. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84400. */
  84401. beginAnimationOnStart: boolean;
  84402. /**
  84403. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84404. */
  84405. beginAnimationFrom: number;
  84406. /**
  84407. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84408. */
  84409. beginAnimationTo: number;
  84410. /**
  84411. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84412. */
  84413. beginAnimationLoop: boolean;
  84414. /**
  84415. * Gets or sets a world offset applied to all particles
  84416. */
  84417. worldOffset: Vector3;
  84418. /**
  84419. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84420. */
  84421. get isAnimationSheetEnabled(): boolean;
  84422. set isAnimationSheetEnabled(value: boolean);
  84423. /**
  84424. * Get hosting scene
  84425. * @returns the scene
  84426. */
  84427. getScene(): Scene;
  84428. /**
  84429. * You can use gravity if you want to give an orientation to your particles.
  84430. */
  84431. gravity: Vector3;
  84432. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84433. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84434. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84435. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84436. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84437. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84438. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84439. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84440. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84441. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84442. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84443. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84444. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84445. /**
  84446. * Defines the delay in milliseconds before starting the system (0 by default)
  84447. */
  84448. startDelay: number;
  84449. /**
  84450. * Gets the current list of drag gradients.
  84451. * You must use addDragGradient and removeDragGradient to udpate this list
  84452. * @returns the list of drag gradients
  84453. */
  84454. getDragGradients(): Nullable<Array<FactorGradient>>;
  84455. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84456. limitVelocityDamping: number;
  84457. /**
  84458. * Gets the current list of limit velocity gradients.
  84459. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84460. * @returns the list of limit velocity gradients
  84461. */
  84462. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84463. /**
  84464. * Gets the current list of color gradients.
  84465. * You must use addColorGradient and removeColorGradient to udpate this list
  84466. * @returns the list of color gradients
  84467. */
  84468. getColorGradients(): Nullable<Array<ColorGradient>>;
  84469. /**
  84470. * Gets the current list of size gradients.
  84471. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84472. * @returns the list of size gradients
  84473. */
  84474. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84475. /**
  84476. * Gets the current list of color remap gradients.
  84477. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84478. * @returns the list of color remap gradients
  84479. */
  84480. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84481. /**
  84482. * Gets the current list of alpha remap gradients.
  84483. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84484. * @returns the list of alpha remap gradients
  84485. */
  84486. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84487. /**
  84488. * Gets the current list of life time gradients.
  84489. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84490. * @returns the list of life time gradients
  84491. */
  84492. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84493. /**
  84494. * Gets the current list of angular speed gradients.
  84495. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84496. * @returns the list of angular speed gradients
  84497. */
  84498. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84499. /**
  84500. * Gets the current list of velocity gradients.
  84501. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84502. * @returns the list of velocity gradients
  84503. */
  84504. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84505. /**
  84506. * Gets the current list of start size gradients.
  84507. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84508. * @returns the list of start size gradients
  84509. */
  84510. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84511. /**
  84512. * Gets the current list of emit rate gradients.
  84513. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84514. * @returns the list of emit rate gradients
  84515. */
  84516. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84517. /**
  84518. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84519. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84520. */
  84521. get direction1(): Vector3;
  84522. set direction1(value: Vector3);
  84523. /**
  84524. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84525. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84526. */
  84527. get direction2(): Vector3;
  84528. set direction2(value: Vector3);
  84529. /**
  84530. * 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.
  84531. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84532. */
  84533. get minEmitBox(): Vector3;
  84534. set minEmitBox(value: Vector3);
  84535. /**
  84536. * 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.
  84537. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84538. */
  84539. get maxEmitBox(): Vector3;
  84540. set maxEmitBox(value: Vector3);
  84541. /**
  84542. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84543. */
  84544. color1: Color4;
  84545. /**
  84546. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84547. */
  84548. color2: Color4;
  84549. /**
  84550. * Color the particle will have at the end of its lifetime
  84551. */
  84552. colorDead: Color4;
  84553. /**
  84554. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84555. */
  84556. textureMask: Color4;
  84557. /**
  84558. * The particle emitter type defines the emitter used by the particle system.
  84559. * It can be for example box, sphere, or cone...
  84560. */
  84561. particleEmitterType: IParticleEmitterType;
  84562. /** @hidden */
  84563. _isSubEmitter: boolean;
  84564. /**
  84565. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84566. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84567. */
  84568. billboardMode: number;
  84569. protected _isBillboardBased: boolean;
  84570. /**
  84571. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84572. */
  84573. get isBillboardBased(): boolean;
  84574. set isBillboardBased(value: boolean);
  84575. /**
  84576. * The scene the particle system belongs to.
  84577. */
  84578. protected _scene: Scene;
  84579. /**
  84580. * Local cache of defines for image processing.
  84581. */
  84582. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84583. /**
  84584. * Default configuration related to image processing available in the standard Material.
  84585. */
  84586. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84587. /**
  84588. * Gets the image processing configuration used either in this material.
  84589. */
  84590. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  84591. /**
  84592. * Sets the Default image processing configuration used either in the this material.
  84593. *
  84594. * If sets to null, the scene one is in use.
  84595. */
  84596. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  84597. /**
  84598. * Attaches a new image processing configuration to the Standard Material.
  84599. * @param configuration
  84600. */
  84601. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84602. /** @hidden */
  84603. protected _reset(): void;
  84604. /** @hidden */
  84605. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84606. /**
  84607. * Instantiates a particle system.
  84608. * 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.
  84609. * @param name The name of the particle system
  84610. */
  84611. constructor(name: string);
  84612. /**
  84613. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84614. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84615. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84616. * @returns the emitter
  84617. */
  84618. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84619. /**
  84620. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84621. * @param radius The radius of the hemisphere to emit from
  84622. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84623. * @returns the emitter
  84624. */
  84625. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84626. /**
  84627. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84628. * @param radius The radius of the sphere to emit from
  84629. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84630. * @returns the emitter
  84631. */
  84632. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84633. /**
  84634. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84635. * @param radius The radius of the sphere to emit from
  84636. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84637. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84638. * @returns the emitter
  84639. */
  84640. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84641. /**
  84642. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84643. * @param radius The radius of the emission cylinder
  84644. * @param height The height of the emission cylinder
  84645. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84646. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84647. * @returns the emitter
  84648. */
  84649. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84650. /**
  84651. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84652. * @param radius The radius of the cylinder to emit from
  84653. * @param height The height of the emission cylinder
  84654. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84655. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84656. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84657. * @returns the emitter
  84658. */
  84659. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84660. /**
  84661. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84662. * @param radius The radius of the cone to emit from
  84663. * @param angle The base angle of the cone
  84664. * @returns the emitter
  84665. */
  84666. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84667. /**
  84668. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84669. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84670. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84671. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84672. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84673. * @returns the emitter
  84674. */
  84675. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84676. }
  84677. }
  84678. declare module BABYLON {
  84679. /**
  84680. * Type of sub emitter
  84681. */
  84682. export enum SubEmitterType {
  84683. /**
  84684. * Attached to the particle over it's lifetime
  84685. */
  84686. ATTACHED = 0,
  84687. /**
  84688. * Created when the particle dies
  84689. */
  84690. END = 1
  84691. }
  84692. /**
  84693. * Sub emitter class used to emit particles from an existing particle
  84694. */
  84695. export class SubEmitter {
  84696. /**
  84697. * the particle system to be used by the sub emitter
  84698. */
  84699. particleSystem: ParticleSystem;
  84700. /**
  84701. * Type of the submitter (Default: END)
  84702. */
  84703. type: SubEmitterType;
  84704. /**
  84705. * 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)
  84706. * Note: This only is supported when using an emitter of type Mesh
  84707. */
  84708. inheritDirection: boolean;
  84709. /**
  84710. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84711. */
  84712. inheritedVelocityAmount: number;
  84713. /**
  84714. * Creates a sub emitter
  84715. * @param particleSystem the particle system to be used by the sub emitter
  84716. */
  84717. constructor(
  84718. /**
  84719. * the particle system to be used by the sub emitter
  84720. */
  84721. particleSystem: ParticleSystem);
  84722. /**
  84723. * Clones the sub emitter
  84724. * @returns the cloned sub emitter
  84725. */
  84726. clone(): SubEmitter;
  84727. /**
  84728. * Serialize current object to a JSON object
  84729. * @returns the serialized object
  84730. */
  84731. serialize(): any;
  84732. /** @hidden */
  84733. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84734. /**
  84735. * Creates a new SubEmitter from a serialized JSON version
  84736. * @param serializationObject defines the JSON object to read from
  84737. * @param scene defines the hosting scene
  84738. * @param rootUrl defines the rootUrl for data loading
  84739. * @returns a new SubEmitter
  84740. */
  84741. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84742. /** Release associated resources */
  84743. dispose(): void;
  84744. }
  84745. }
  84746. declare module BABYLON {
  84747. /** @hidden */
  84748. export var imageProcessingDeclaration: {
  84749. name: string;
  84750. shader: string;
  84751. };
  84752. }
  84753. declare module BABYLON {
  84754. /** @hidden */
  84755. export var imageProcessingFunctions: {
  84756. name: string;
  84757. shader: string;
  84758. };
  84759. }
  84760. declare module BABYLON {
  84761. /** @hidden */
  84762. export var particlesPixelShader: {
  84763. name: string;
  84764. shader: string;
  84765. };
  84766. }
  84767. declare module BABYLON {
  84768. /** @hidden */
  84769. export var particlesVertexShader: {
  84770. name: string;
  84771. shader: string;
  84772. };
  84773. }
  84774. declare module BABYLON {
  84775. /**
  84776. * This represents a particle system in Babylon.
  84777. * 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.
  84778. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84779. * @example https://doc.babylonjs.com/babylon101/particles
  84780. */
  84781. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84782. /**
  84783. * Billboard mode will only apply to Y axis
  84784. */
  84785. static readonly BILLBOARDMODE_Y: number;
  84786. /**
  84787. * Billboard mode will apply to all axes
  84788. */
  84789. static readonly BILLBOARDMODE_ALL: number;
  84790. /**
  84791. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84792. */
  84793. static readonly BILLBOARDMODE_STRETCHED: number;
  84794. /**
  84795. * This function can be defined to provide custom update for active particles.
  84796. * This function will be called instead of regular update (age, position, color, etc.).
  84797. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84798. */
  84799. updateFunction: (particles: Particle[]) => void;
  84800. private _emitterWorldMatrix;
  84801. /**
  84802. * This function can be defined to specify initial direction for every new particle.
  84803. * It by default use the emitterType defined function
  84804. */
  84805. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  84806. /**
  84807. * This function can be defined to specify initial position for every new particle.
  84808. * It by default use the emitterType defined function
  84809. */
  84810. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  84811. /**
  84812. * @hidden
  84813. */
  84814. _inheritedVelocityOffset: Vector3;
  84815. /**
  84816. * An event triggered when the system is disposed
  84817. */
  84818. onDisposeObservable: Observable<ParticleSystem>;
  84819. private _onDisposeObserver;
  84820. /**
  84821. * Sets a callback that will be triggered when the system is disposed
  84822. */
  84823. set onDispose(callback: () => void);
  84824. private _particles;
  84825. private _epsilon;
  84826. private _capacity;
  84827. private _stockParticles;
  84828. private _newPartsExcess;
  84829. private _vertexData;
  84830. private _vertexBuffer;
  84831. private _vertexBuffers;
  84832. private _spriteBuffer;
  84833. private _indexBuffer;
  84834. private _effect;
  84835. private _customEffect;
  84836. private _cachedDefines;
  84837. private _scaledColorStep;
  84838. private _colorDiff;
  84839. private _scaledDirection;
  84840. private _scaledGravity;
  84841. private _currentRenderId;
  84842. private _alive;
  84843. private _useInstancing;
  84844. private _started;
  84845. private _stopped;
  84846. private _actualFrame;
  84847. private _scaledUpdateSpeed;
  84848. private _vertexBufferSize;
  84849. /** @hidden */
  84850. _currentEmitRateGradient: Nullable<FactorGradient>;
  84851. /** @hidden */
  84852. _currentEmitRate1: number;
  84853. /** @hidden */
  84854. _currentEmitRate2: number;
  84855. /** @hidden */
  84856. _currentStartSizeGradient: Nullable<FactorGradient>;
  84857. /** @hidden */
  84858. _currentStartSize1: number;
  84859. /** @hidden */
  84860. _currentStartSize2: number;
  84861. private readonly _rawTextureWidth;
  84862. private _rampGradientsTexture;
  84863. private _useRampGradients;
  84864. /** Gets or sets a boolean indicating that ramp gradients must be used
  84865. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84866. */
  84867. get useRampGradients(): boolean;
  84868. set useRampGradients(value: boolean);
  84869. /**
  84870. * 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.
  84871. * 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: [])
  84872. */
  84873. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  84874. private _subEmitters;
  84875. /**
  84876. * @hidden
  84877. * If the particle systems emitter should be disposed when the particle system is disposed
  84878. */
  84879. _disposeEmitterOnDispose: boolean;
  84880. /**
  84881. * The current active Sub-systems, this property is used by the root particle system only.
  84882. */
  84883. activeSubSystems: Array<ParticleSystem>;
  84884. /**
  84885. * Specifies if the particles are updated in emitter local space or world space
  84886. */
  84887. isLocal: boolean;
  84888. private _rootParticleSystem;
  84889. /**
  84890. * Gets the current list of active particles
  84891. */
  84892. get particles(): Particle[];
  84893. /**
  84894. * Returns the string "ParticleSystem"
  84895. * @returns a string containing the class name
  84896. */
  84897. getClassName(): string;
  84898. /**
  84899. * Instantiates a particle system.
  84900. * 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.
  84901. * @param name The name of the particle system
  84902. * @param capacity The max number of particles alive at the same time
  84903. * @param scene The scene the particle system belongs to
  84904. * @param customEffect a custom effect used to change the way particles are rendered by default
  84905. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84906. * @param epsilon Offset used to render the particles
  84907. */
  84908. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84909. private _addFactorGradient;
  84910. private _removeFactorGradient;
  84911. /**
  84912. * Adds a new life time gradient
  84913. * @param gradient defines the gradient to use (between 0 and 1)
  84914. * @param factor defines the life time factor to affect to the specified gradient
  84915. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84916. * @returns the current particle system
  84917. */
  84918. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84919. /**
  84920. * Remove a specific life time gradient
  84921. * @param gradient defines the gradient to remove
  84922. * @returns the current particle system
  84923. */
  84924. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84925. /**
  84926. * Adds a new size gradient
  84927. * @param gradient defines the gradient to use (between 0 and 1)
  84928. * @param factor defines the size factor to affect to the specified gradient
  84929. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84930. * @returns the current particle system
  84931. */
  84932. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84933. /**
  84934. * Remove a specific size gradient
  84935. * @param gradient defines the gradient to remove
  84936. * @returns the current particle system
  84937. */
  84938. removeSizeGradient(gradient: number): IParticleSystem;
  84939. /**
  84940. * Adds a new color remap gradient
  84941. * @param gradient defines the gradient to use (between 0 and 1)
  84942. * @param min defines the color remap minimal range
  84943. * @param max defines the color remap maximal range
  84944. * @returns the current particle system
  84945. */
  84946. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84947. /**
  84948. * Remove a specific color remap gradient
  84949. * @param gradient defines the gradient to remove
  84950. * @returns the current particle system
  84951. */
  84952. removeColorRemapGradient(gradient: number): IParticleSystem;
  84953. /**
  84954. * Adds a new alpha remap gradient
  84955. * @param gradient defines the gradient to use (between 0 and 1)
  84956. * @param min defines the alpha remap minimal range
  84957. * @param max defines the alpha remap maximal range
  84958. * @returns the current particle system
  84959. */
  84960. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84961. /**
  84962. * Remove a specific alpha remap gradient
  84963. * @param gradient defines the gradient to remove
  84964. * @returns the current particle system
  84965. */
  84966. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  84967. /**
  84968. * Adds a new angular speed gradient
  84969. * @param gradient defines the gradient to use (between 0 and 1)
  84970. * @param factor defines the angular speed to affect to the specified gradient
  84971. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84972. * @returns the current particle system
  84973. */
  84974. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84975. /**
  84976. * Remove a specific angular speed gradient
  84977. * @param gradient defines the gradient to remove
  84978. * @returns the current particle system
  84979. */
  84980. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84981. /**
  84982. * Adds a new velocity gradient
  84983. * @param gradient defines the gradient to use (between 0 and 1)
  84984. * @param factor defines the velocity to affect to the specified gradient
  84985. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84986. * @returns the current particle system
  84987. */
  84988. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84989. /**
  84990. * Remove a specific velocity gradient
  84991. * @param gradient defines the gradient to remove
  84992. * @returns the current particle system
  84993. */
  84994. removeVelocityGradient(gradient: number): IParticleSystem;
  84995. /**
  84996. * Adds a new limit velocity gradient
  84997. * @param gradient defines the gradient to use (between 0 and 1)
  84998. * @param factor defines the limit velocity value to affect to the specified gradient
  84999. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85000. * @returns the current particle system
  85001. */
  85002. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85003. /**
  85004. * Remove a specific limit velocity gradient
  85005. * @param gradient defines the gradient to remove
  85006. * @returns the current particle system
  85007. */
  85008. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85009. /**
  85010. * Adds a new drag gradient
  85011. * @param gradient defines the gradient to use (between 0 and 1)
  85012. * @param factor defines the drag value to affect to the specified gradient
  85013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85014. * @returns the current particle system
  85015. */
  85016. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85017. /**
  85018. * Remove a specific drag gradient
  85019. * @param gradient defines the gradient to remove
  85020. * @returns the current particle system
  85021. */
  85022. removeDragGradient(gradient: number): IParticleSystem;
  85023. /**
  85024. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85025. * @param gradient defines the gradient to use (between 0 and 1)
  85026. * @param factor defines the emit rate value to affect to the specified gradient
  85027. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85028. * @returns the current particle system
  85029. */
  85030. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85031. /**
  85032. * Remove a specific emit rate gradient
  85033. * @param gradient defines the gradient to remove
  85034. * @returns the current particle system
  85035. */
  85036. removeEmitRateGradient(gradient: number): IParticleSystem;
  85037. /**
  85038. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85039. * @param gradient defines the gradient to use (between 0 and 1)
  85040. * @param factor defines the start size value to affect to the specified gradient
  85041. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85042. * @returns the current particle system
  85043. */
  85044. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85045. /**
  85046. * Remove a specific start size gradient
  85047. * @param gradient defines the gradient to remove
  85048. * @returns the current particle system
  85049. */
  85050. removeStartSizeGradient(gradient: number): IParticleSystem;
  85051. private _createRampGradientTexture;
  85052. /**
  85053. * Gets the current list of ramp gradients.
  85054. * You must use addRampGradient and removeRampGradient to udpate this list
  85055. * @returns the list of ramp gradients
  85056. */
  85057. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85058. /**
  85059. * Adds a new ramp gradient used to remap particle colors
  85060. * @param gradient defines the gradient to use (between 0 and 1)
  85061. * @param color defines the color to affect to the specified gradient
  85062. * @returns the current particle system
  85063. */
  85064. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85065. /**
  85066. * Remove a specific ramp gradient
  85067. * @param gradient defines the gradient to remove
  85068. * @returns the current particle system
  85069. */
  85070. removeRampGradient(gradient: number): ParticleSystem;
  85071. /**
  85072. * Adds a new color gradient
  85073. * @param gradient defines the gradient to use (between 0 and 1)
  85074. * @param color1 defines the color to affect to the specified gradient
  85075. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85076. * @returns this particle system
  85077. */
  85078. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85079. /**
  85080. * Remove a specific color gradient
  85081. * @param gradient defines the gradient to remove
  85082. * @returns this particle system
  85083. */
  85084. removeColorGradient(gradient: number): IParticleSystem;
  85085. private _fetchR;
  85086. protected _reset(): void;
  85087. private _resetEffect;
  85088. private _createVertexBuffers;
  85089. private _createIndexBuffer;
  85090. /**
  85091. * Gets the maximum number of particles active at the same time.
  85092. * @returns The max number of active particles.
  85093. */
  85094. getCapacity(): number;
  85095. /**
  85096. * Gets whether there are still active particles in the system.
  85097. * @returns True if it is alive, otherwise false.
  85098. */
  85099. isAlive(): boolean;
  85100. /**
  85101. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85102. * @returns True if it has been started, otherwise false.
  85103. */
  85104. isStarted(): boolean;
  85105. private _prepareSubEmitterInternalArray;
  85106. /**
  85107. * Starts the particle system and begins to emit
  85108. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85109. */
  85110. start(delay?: number): void;
  85111. /**
  85112. * Stops the particle system.
  85113. * @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.
  85114. */
  85115. stop(stopSubEmitters?: boolean): void;
  85116. /**
  85117. * Remove all active particles
  85118. */
  85119. reset(): void;
  85120. /**
  85121. * @hidden (for internal use only)
  85122. */
  85123. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85124. /**
  85125. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85126. * Its lifetime will start back at 0.
  85127. */
  85128. recycleParticle: (particle: Particle) => void;
  85129. private _stopSubEmitters;
  85130. private _createParticle;
  85131. private _removeFromRoot;
  85132. private _emitFromParticle;
  85133. private _update;
  85134. /** @hidden */
  85135. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85136. /** @hidden */
  85137. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85138. /** @hidden */
  85139. private _getEffect;
  85140. /**
  85141. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85142. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85143. */
  85144. animate(preWarmOnly?: boolean): void;
  85145. private _appendParticleVertices;
  85146. /**
  85147. * Rebuilds the particle system.
  85148. */
  85149. rebuild(): void;
  85150. /**
  85151. * Is this system ready to be used/rendered
  85152. * @return true if the system is ready
  85153. */
  85154. isReady(): boolean;
  85155. private _render;
  85156. /**
  85157. * Renders the particle system in its current state.
  85158. * @returns the current number of particles
  85159. */
  85160. render(): number;
  85161. /**
  85162. * Disposes the particle system and free the associated resources
  85163. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85164. */
  85165. dispose(disposeTexture?: boolean): void;
  85166. /**
  85167. * Clones the particle system.
  85168. * @param name The name of the cloned object
  85169. * @param newEmitter The new emitter to use
  85170. * @returns the cloned particle system
  85171. */
  85172. clone(name: string, newEmitter: any): ParticleSystem;
  85173. /**
  85174. * Serializes the particle system to a JSON object.
  85175. * @returns the JSON object
  85176. */
  85177. serialize(): any;
  85178. /** @hidden */
  85179. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85180. /** @hidden */
  85181. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85182. /**
  85183. * Parses a JSON object to create a particle system.
  85184. * @param parsedParticleSystem The JSON object to parse
  85185. * @param scene The scene to create the particle system in
  85186. * @param rootUrl The root url to use to load external dependencies like texture
  85187. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85188. * @returns the Parsed particle system
  85189. */
  85190. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85191. }
  85192. }
  85193. declare module BABYLON {
  85194. /**
  85195. * A particle represents one of the element emitted by a particle system.
  85196. * This is mainly define by its coordinates, direction, velocity and age.
  85197. */
  85198. export class Particle {
  85199. /**
  85200. * The particle system the particle belongs to.
  85201. */
  85202. particleSystem: ParticleSystem;
  85203. private static _Count;
  85204. /**
  85205. * Unique ID of the particle
  85206. */
  85207. id: number;
  85208. /**
  85209. * The world position of the particle in the scene.
  85210. */
  85211. position: Vector3;
  85212. /**
  85213. * The world direction of the particle in the scene.
  85214. */
  85215. direction: Vector3;
  85216. /**
  85217. * The color of the particle.
  85218. */
  85219. color: Color4;
  85220. /**
  85221. * The color change of the particle per step.
  85222. */
  85223. colorStep: Color4;
  85224. /**
  85225. * Defines how long will the life of the particle be.
  85226. */
  85227. lifeTime: number;
  85228. /**
  85229. * The current age of the particle.
  85230. */
  85231. age: number;
  85232. /**
  85233. * The current size of the particle.
  85234. */
  85235. size: number;
  85236. /**
  85237. * The current scale of the particle.
  85238. */
  85239. scale: Vector2;
  85240. /**
  85241. * The current angle of the particle.
  85242. */
  85243. angle: number;
  85244. /**
  85245. * Defines how fast is the angle changing.
  85246. */
  85247. angularSpeed: number;
  85248. /**
  85249. * Defines the cell index used by the particle to be rendered from a sprite.
  85250. */
  85251. cellIndex: number;
  85252. /**
  85253. * The information required to support color remapping
  85254. */
  85255. remapData: Vector4;
  85256. /** @hidden */
  85257. _randomCellOffset?: number;
  85258. /** @hidden */
  85259. _initialDirection: Nullable<Vector3>;
  85260. /** @hidden */
  85261. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85262. /** @hidden */
  85263. _initialStartSpriteCellID: number;
  85264. /** @hidden */
  85265. _initialEndSpriteCellID: number;
  85266. /** @hidden */
  85267. _currentColorGradient: Nullable<ColorGradient>;
  85268. /** @hidden */
  85269. _currentColor1: Color4;
  85270. /** @hidden */
  85271. _currentColor2: Color4;
  85272. /** @hidden */
  85273. _currentSizeGradient: Nullable<FactorGradient>;
  85274. /** @hidden */
  85275. _currentSize1: number;
  85276. /** @hidden */
  85277. _currentSize2: number;
  85278. /** @hidden */
  85279. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85280. /** @hidden */
  85281. _currentAngularSpeed1: number;
  85282. /** @hidden */
  85283. _currentAngularSpeed2: number;
  85284. /** @hidden */
  85285. _currentVelocityGradient: Nullable<FactorGradient>;
  85286. /** @hidden */
  85287. _currentVelocity1: number;
  85288. /** @hidden */
  85289. _currentVelocity2: number;
  85290. /** @hidden */
  85291. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85292. /** @hidden */
  85293. _currentLimitVelocity1: number;
  85294. /** @hidden */
  85295. _currentLimitVelocity2: number;
  85296. /** @hidden */
  85297. _currentDragGradient: Nullable<FactorGradient>;
  85298. /** @hidden */
  85299. _currentDrag1: number;
  85300. /** @hidden */
  85301. _currentDrag2: number;
  85302. /** @hidden */
  85303. _randomNoiseCoordinates1: Vector3;
  85304. /** @hidden */
  85305. _randomNoiseCoordinates2: Vector3;
  85306. /** @hidden */
  85307. _localPosition?: Vector3;
  85308. /**
  85309. * Creates a new instance Particle
  85310. * @param particleSystem the particle system the particle belongs to
  85311. */
  85312. constructor(
  85313. /**
  85314. * The particle system the particle belongs to.
  85315. */
  85316. particleSystem: ParticleSystem);
  85317. private updateCellInfoFromSystem;
  85318. /**
  85319. * Defines how the sprite cell index is updated for the particle
  85320. */
  85321. updateCellIndex(): void;
  85322. /** @hidden */
  85323. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85324. /** @hidden */
  85325. _inheritParticleInfoToSubEmitters(): void;
  85326. /** @hidden */
  85327. _reset(): void;
  85328. /**
  85329. * Copy the properties of particle to another one.
  85330. * @param other the particle to copy the information to.
  85331. */
  85332. copyTo(other: Particle): void;
  85333. }
  85334. }
  85335. declare module BABYLON {
  85336. /**
  85337. * Particle emitter represents a volume emitting particles.
  85338. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85339. */
  85340. export interface IParticleEmitterType {
  85341. /**
  85342. * Called by the particle System when the direction is computed for the created particle.
  85343. * @param worldMatrix is the world matrix of the particle system
  85344. * @param directionToUpdate is the direction vector to update with the result
  85345. * @param particle is the particle we are computed the direction for
  85346. * @param isLocal defines if the direction should be set in local space
  85347. */
  85348. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85349. /**
  85350. * Called by the particle System when the position is computed for the created particle.
  85351. * @param worldMatrix is the world matrix of the particle system
  85352. * @param positionToUpdate is the position vector to update with the result
  85353. * @param particle is the particle we are computed the position for
  85354. * @param isLocal defines if the position should be set in local space
  85355. */
  85356. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85357. /**
  85358. * Clones the current emitter and returns a copy of it
  85359. * @returns the new emitter
  85360. */
  85361. clone(): IParticleEmitterType;
  85362. /**
  85363. * Called by the GPUParticleSystem to setup the update shader
  85364. * @param effect defines the update shader
  85365. */
  85366. applyToShader(effect: Effect): void;
  85367. /**
  85368. * Returns a string to use to update the GPU particles update shader
  85369. * @returns the effect defines string
  85370. */
  85371. getEffectDefines(): string;
  85372. /**
  85373. * Returns a string representing the class name
  85374. * @returns a string containing the class name
  85375. */
  85376. getClassName(): string;
  85377. /**
  85378. * Serializes the particle system to a JSON object.
  85379. * @returns the JSON object
  85380. */
  85381. serialize(): any;
  85382. /**
  85383. * Parse properties from a JSON object
  85384. * @param serializationObject defines the JSON object
  85385. * @param scene defines the hosting scene
  85386. */
  85387. parse(serializationObject: any, scene: Scene): void;
  85388. }
  85389. }
  85390. declare module BABYLON {
  85391. /**
  85392. * Particle emitter emitting particles from the inside of a box.
  85393. * It emits the particles randomly between 2 given directions.
  85394. */
  85395. export class BoxParticleEmitter implements IParticleEmitterType {
  85396. /**
  85397. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85398. */
  85399. direction1: Vector3;
  85400. /**
  85401. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85402. */
  85403. direction2: Vector3;
  85404. /**
  85405. * 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.
  85406. */
  85407. minEmitBox: Vector3;
  85408. /**
  85409. * 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.
  85410. */
  85411. maxEmitBox: Vector3;
  85412. /**
  85413. * Creates a new instance BoxParticleEmitter
  85414. */
  85415. constructor();
  85416. /**
  85417. * Called by the particle System when the direction is computed for the created particle.
  85418. * @param worldMatrix is the world matrix of the particle system
  85419. * @param directionToUpdate is the direction vector to update with the result
  85420. * @param particle is the particle we are computed the direction for
  85421. * @param isLocal defines if the direction should be set in local space
  85422. */
  85423. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85424. /**
  85425. * Called by the particle System when the position is computed for the created particle.
  85426. * @param worldMatrix is the world matrix of the particle system
  85427. * @param positionToUpdate is the position vector to update with the result
  85428. * @param particle is the particle we are computed the position for
  85429. * @param isLocal defines if the position should be set in local space
  85430. */
  85431. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85432. /**
  85433. * Clones the current emitter and returns a copy of it
  85434. * @returns the new emitter
  85435. */
  85436. clone(): BoxParticleEmitter;
  85437. /**
  85438. * Called by the GPUParticleSystem to setup the update shader
  85439. * @param effect defines the update shader
  85440. */
  85441. applyToShader(effect: Effect): void;
  85442. /**
  85443. * Returns a string to use to update the GPU particles update shader
  85444. * @returns a string containng the defines string
  85445. */
  85446. getEffectDefines(): string;
  85447. /**
  85448. * Returns the string "BoxParticleEmitter"
  85449. * @returns a string containing the class name
  85450. */
  85451. getClassName(): string;
  85452. /**
  85453. * Serializes the particle system to a JSON object.
  85454. * @returns the JSON object
  85455. */
  85456. serialize(): any;
  85457. /**
  85458. * Parse properties from a JSON object
  85459. * @param serializationObject defines the JSON object
  85460. */
  85461. parse(serializationObject: any): void;
  85462. }
  85463. }
  85464. declare module BABYLON {
  85465. /**
  85466. * Particle emitter emitting particles from the inside of a cone.
  85467. * It emits the particles alongside the cone volume from the base to the particle.
  85468. * The emission direction might be randomized.
  85469. */
  85470. export class ConeParticleEmitter implements IParticleEmitterType {
  85471. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85472. directionRandomizer: number;
  85473. private _radius;
  85474. private _angle;
  85475. private _height;
  85476. /**
  85477. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85478. */
  85479. radiusRange: number;
  85480. /**
  85481. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85482. */
  85483. heightRange: number;
  85484. /**
  85485. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85486. */
  85487. emitFromSpawnPointOnly: boolean;
  85488. /**
  85489. * Gets or sets the radius of the emission cone
  85490. */
  85491. get radius(): number;
  85492. set radius(value: number);
  85493. /**
  85494. * Gets or sets the angle of the emission cone
  85495. */
  85496. get angle(): number;
  85497. set angle(value: number);
  85498. private _buildHeight;
  85499. /**
  85500. * Creates a new instance ConeParticleEmitter
  85501. * @param radius the radius of the emission cone (1 by default)
  85502. * @param angle the cone base angle (PI by default)
  85503. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85504. */
  85505. constructor(radius?: number, angle?: number,
  85506. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85507. directionRandomizer?: number);
  85508. /**
  85509. * Called by the particle System when the direction is computed for the created particle.
  85510. * @param worldMatrix is the world matrix of the particle system
  85511. * @param directionToUpdate is the direction vector to update with the result
  85512. * @param particle is the particle we are computed the direction for
  85513. * @param isLocal defines if the direction should be set in local space
  85514. */
  85515. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85516. /**
  85517. * Called by the particle System when the position is computed for the created particle.
  85518. * @param worldMatrix is the world matrix of the particle system
  85519. * @param positionToUpdate is the position vector to update with the result
  85520. * @param particle is the particle we are computed the position for
  85521. * @param isLocal defines if the position should be set in local space
  85522. */
  85523. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85524. /**
  85525. * Clones the current emitter and returns a copy of it
  85526. * @returns the new emitter
  85527. */
  85528. clone(): ConeParticleEmitter;
  85529. /**
  85530. * Called by the GPUParticleSystem to setup the update shader
  85531. * @param effect defines the update shader
  85532. */
  85533. applyToShader(effect: Effect): void;
  85534. /**
  85535. * Returns a string to use to update the GPU particles update shader
  85536. * @returns a string containng the defines string
  85537. */
  85538. getEffectDefines(): string;
  85539. /**
  85540. * Returns the string "ConeParticleEmitter"
  85541. * @returns a string containing the class name
  85542. */
  85543. getClassName(): string;
  85544. /**
  85545. * Serializes the particle system to a JSON object.
  85546. * @returns the JSON object
  85547. */
  85548. serialize(): any;
  85549. /**
  85550. * Parse properties from a JSON object
  85551. * @param serializationObject defines the JSON object
  85552. */
  85553. parse(serializationObject: any): void;
  85554. }
  85555. }
  85556. declare module BABYLON {
  85557. /**
  85558. * Particle emitter emitting particles from the inside of a cylinder.
  85559. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85560. */
  85561. export class CylinderParticleEmitter implements IParticleEmitterType {
  85562. /**
  85563. * The radius of the emission cylinder.
  85564. */
  85565. radius: number;
  85566. /**
  85567. * The height of the emission cylinder.
  85568. */
  85569. height: number;
  85570. /**
  85571. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85572. */
  85573. radiusRange: number;
  85574. /**
  85575. * How much to randomize the particle direction [0-1].
  85576. */
  85577. directionRandomizer: number;
  85578. /**
  85579. * Creates a new instance CylinderParticleEmitter
  85580. * @param radius the radius of the emission cylinder (1 by default)
  85581. * @param height the height of the emission cylinder (1 by default)
  85582. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85583. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85584. */
  85585. constructor(
  85586. /**
  85587. * The radius of the emission cylinder.
  85588. */
  85589. radius?: number,
  85590. /**
  85591. * The height of the emission cylinder.
  85592. */
  85593. height?: number,
  85594. /**
  85595. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85596. */
  85597. radiusRange?: number,
  85598. /**
  85599. * How much to randomize the particle direction [0-1].
  85600. */
  85601. directionRandomizer?: number);
  85602. /**
  85603. * Called by the particle System when the direction is computed for the created particle.
  85604. * @param worldMatrix is the world matrix of the particle system
  85605. * @param directionToUpdate is the direction vector to update with the result
  85606. * @param particle is the particle we are computed the direction for
  85607. * @param isLocal defines if the direction should be set in local space
  85608. */
  85609. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85610. /**
  85611. * Called by the particle System when the position is computed for the created particle.
  85612. * @param worldMatrix is the world matrix of the particle system
  85613. * @param positionToUpdate is the position vector to update with the result
  85614. * @param particle is the particle we are computed the position for
  85615. * @param isLocal defines if the position should be set in local space
  85616. */
  85617. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85618. /**
  85619. * Clones the current emitter and returns a copy of it
  85620. * @returns the new emitter
  85621. */
  85622. clone(): CylinderParticleEmitter;
  85623. /**
  85624. * Called by the GPUParticleSystem to setup the update shader
  85625. * @param effect defines the update shader
  85626. */
  85627. applyToShader(effect: Effect): void;
  85628. /**
  85629. * Returns a string to use to update the GPU particles update shader
  85630. * @returns a string containng the defines string
  85631. */
  85632. getEffectDefines(): string;
  85633. /**
  85634. * Returns the string "CylinderParticleEmitter"
  85635. * @returns a string containing the class name
  85636. */
  85637. getClassName(): string;
  85638. /**
  85639. * Serializes the particle system to a JSON object.
  85640. * @returns the JSON object
  85641. */
  85642. serialize(): any;
  85643. /**
  85644. * Parse properties from a JSON object
  85645. * @param serializationObject defines the JSON object
  85646. */
  85647. parse(serializationObject: any): void;
  85648. }
  85649. /**
  85650. * Particle emitter emitting particles from the inside of a cylinder.
  85651. * It emits the particles randomly between two vectors.
  85652. */
  85653. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85654. /**
  85655. * The min limit of the emission direction.
  85656. */
  85657. direction1: Vector3;
  85658. /**
  85659. * The max limit of the emission direction.
  85660. */
  85661. direction2: Vector3;
  85662. /**
  85663. * Creates a new instance CylinderDirectedParticleEmitter
  85664. * @param radius the radius of the emission cylinder (1 by default)
  85665. * @param height the height of the emission cylinder (1 by default)
  85666. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85667. * @param direction1 the min limit of the emission direction (up vector by default)
  85668. * @param direction2 the max limit of the emission direction (up vector by default)
  85669. */
  85670. constructor(radius?: number, height?: number, radiusRange?: number,
  85671. /**
  85672. * The min limit of the emission direction.
  85673. */
  85674. direction1?: Vector3,
  85675. /**
  85676. * The max limit of the emission direction.
  85677. */
  85678. direction2?: Vector3);
  85679. /**
  85680. * Called by the particle System when the direction is computed for the created particle.
  85681. * @param worldMatrix is the world matrix of the particle system
  85682. * @param directionToUpdate is the direction vector to update with the result
  85683. * @param particle is the particle we are computed the direction for
  85684. */
  85685. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85686. /**
  85687. * Clones the current emitter and returns a copy of it
  85688. * @returns the new emitter
  85689. */
  85690. clone(): CylinderDirectedParticleEmitter;
  85691. /**
  85692. * Called by the GPUParticleSystem to setup the update shader
  85693. * @param effect defines the update shader
  85694. */
  85695. applyToShader(effect: Effect): void;
  85696. /**
  85697. * Returns a string to use to update the GPU particles update shader
  85698. * @returns a string containng the defines string
  85699. */
  85700. getEffectDefines(): string;
  85701. /**
  85702. * Returns the string "CylinderDirectedParticleEmitter"
  85703. * @returns a string containing the class name
  85704. */
  85705. getClassName(): string;
  85706. /**
  85707. * Serializes the particle system to a JSON object.
  85708. * @returns the JSON object
  85709. */
  85710. serialize(): any;
  85711. /**
  85712. * Parse properties from a JSON object
  85713. * @param serializationObject defines the JSON object
  85714. */
  85715. parse(serializationObject: any): void;
  85716. }
  85717. }
  85718. declare module BABYLON {
  85719. /**
  85720. * Particle emitter emitting particles from the inside of a hemisphere.
  85721. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85722. */
  85723. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85724. /**
  85725. * The radius of the emission hemisphere.
  85726. */
  85727. radius: number;
  85728. /**
  85729. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85730. */
  85731. radiusRange: number;
  85732. /**
  85733. * How much to randomize the particle direction [0-1].
  85734. */
  85735. directionRandomizer: number;
  85736. /**
  85737. * Creates a new instance HemisphericParticleEmitter
  85738. * @param radius the radius of the emission hemisphere (1 by default)
  85739. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85740. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85741. */
  85742. constructor(
  85743. /**
  85744. * The radius of the emission hemisphere.
  85745. */
  85746. radius?: number,
  85747. /**
  85748. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85749. */
  85750. radiusRange?: number,
  85751. /**
  85752. * How much to randomize the particle direction [0-1].
  85753. */
  85754. directionRandomizer?: number);
  85755. /**
  85756. * Called by the particle System when the direction is computed for the created particle.
  85757. * @param worldMatrix is the world matrix of the particle system
  85758. * @param directionToUpdate is the direction vector to update with the result
  85759. * @param particle is the particle we are computed the direction for
  85760. * @param isLocal defines if the direction should be set in local space
  85761. */
  85762. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85763. /**
  85764. * Called by the particle System when the position is computed for the created particle.
  85765. * @param worldMatrix is the world matrix of the particle system
  85766. * @param positionToUpdate is the position vector to update with the result
  85767. * @param particle is the particle we are computed the position for
  85768. * @param isLocal defines if the position should be set in local space
  85769. */
  85770. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85771. /**
  85772. * Clones the current emitter and returns a copy of it
  85773. * @returns the new emitter
  85774. */
  85775. clone(): HemisphericParticleEmitter;
  85776. /**
  85777. * Called by the GPUParticleSystem to setup the update shader
  85778. * @param effect defines the update shader
  85779. */
  85780. applyToShader(effect: Effect): void;
  85781. /**
  85782. * Returns a string to use to update the GPU particles update shader
  85783. * @returns a string containng the defines string
  85784. */
  85785. getEffectDefines(): string;
  85786. /**
  85787. * Returns the string "HemisphericParticleEmitter"
  85788. * @returns a string containing the class name
  85789. */
  85790. getClassName(): string;
  85791. /**
  85792. * Serializes the particle system to a JSON object.
  85793. * @returns the JSON object
  85794. */
  85795. serialize(): any;
  85796. /**
  85797. * Parse properties from a JSON object
  85798. * @param serializationObject defines the JSON object
  85799. */
  85800. parse(serializationObject: any): void;
  85801. }
  85802. }
  85803. declare module BABYLON {
  85804. /**
  85805. * Particle emitter emitting particles from a point.
  85806. * It emits the particles randomly between 2 given directions.
  85807. */
  85808. export class PointParticleEmitter implements IParticleEmitterType {
  85809. /**
  85810. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85811. */
  85812. direction1: Vector3;
  85813. /**
  85814. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85815. */
  85816. direction2: Vector3;
  85817. /**
  85818. * Creates a new instance PointParticleEmitter
  85819. */
  85820. constructor();
  85821. /**
  85822. * Called by the particle System when the direction is computed for the created particle.
  85823. * @param worldMatrix is the world matrix of the particle system
  85824. * @param directionToUpdate is the direction vector to update with the result
  85825. * @param particle is the particle we are computed the direction for
  85826. * @param isLocal defines if the direction should be set in local space
  85827. */
  85828. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85829. /**
  85830. * Called by the particle System when the position is computed for the created particle.
  85831. * @param worldMatrix is the world matrix of the particle system
  85832. * @param positionToUpdate is the position vector to update with the result
  85833. * @param particle is the particle we are computed the position for
  85834. * @param isLocal defines if the position should be set in local space
  85835. */
  85836. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85837. /**
  85838. * Clones the current emitter and returns a copy of it
  85839. * @returns the new emitter
  85840. */
  85841. clone(): PointParticleEmitter;
  85842. /**
  85843. * Called by the GPUParticleSystem to setup the update shader
  85844. * @param effect defines the update shader
  85845. */
  85846. applyToShader(effect: Effect): void;
  85847. /**
  85848. * Returns a string to use to update the GPU particles update shader
  85849. * @returns a string containng the defines string
  85850. */
  85851. getEffectDefines(): string;
  85852. /**
  85853. * Returns the string "PointParticleEmitter"
  85854. * @returns a string containing the class name
  85855. */
  85856. getClassName(): string;
  85857. /**
  85858. * Serializes the particle system to a JSON object.
  85859. * @returns the JSON object
  85860. */
  85861. serialize(): any;
  85862. /**
  85863. * Parse properties from a JSON object
  85864. * @param serializationObject defines the JSON object
  85865. */
  85866. parse(serializationObject: any): void;
  85867. }
  85868. }
  85869. declare module BABYLON {
  85870. /**
  85871. * Particle emitter emitting particles from the inside of a sphere.
  85872. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  85873. */
  85874. export class SphereParticleEmitter implements IParticleEmitterType {
  85875. /**
  85876. * The radius of the emission sphere.
  85877. */
  85878. radius: number;
  85879. /**
  85880. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85881. */
  85882. radiusRange: number;
  85883. /**
  85884. * How much to randomize the particle direction [0-1].
  85885. */
  85886. directionRandomizer: number;
  85887. /**
  85888. * Creates a new instance SphereParticleEmitter
  85889. * @param radius the radius of the emission sphere (1 by default)
  85890. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85891. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85892. */
  85893. constructor(
  85894. /**
  85895. * The radius of the emission sphere.
  85896. */
  85897. radius?: number,
  85898. /**
  85899. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85900. */
  85901. radiusRange?: number,
  85902. /**
  85903. * How much to randomize the particle direction [0-1].
  85904. */
  85905. directionRandomizer?: number);
  85906. /**
  85907. * Called by the particle System when the direction is computed for the created particle.
  85908. * @param worldMatrix is the world matrix of the particle system
  85909. * @param directionToUpdate is the direction vector to update with the result
  85910. * @param particle is the particle we are computed the direction for
  85911. * @param isLocal defines if the direction should be set in local space
  85912. */
  85913. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85914. /**
  85915. * Called by the particle System when the position is computed for the created particle.
  85916. * @param worldMatrix is the world matrix of the particle system
  85917. * @param positionToUpdate is the position vector to update with the result
  85918. * @param particle is the particle we are computed the position for
  85919. * @param isLocal defines if the position should be set in local space
  85920. */
  85921. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85922. /**
  85923. * Clones the current emitter and returns a copy of it
  85924. * @returns the new emitter
  85925. */
  85926. clone(): SphereParticleEmitter;
  85927. /**
  85928. * Called by the GPUParticleSystem to setup the update shader
  85929. * @param effect defines the update shader
  85930. */
  85931. applyToShader(effect: Effect): void;
  85932. /**
  85933. * Returns a string to use to update the GPU particles update shader
  85934. * @returns a string containng the defines string
  85935. */
  85936. getEffectDefines(): string;
  85937. /**
  85938. * Returns the string "SphereParticleEmitter"
  85939. * @returns a string containing the class name
  85940. */
  85941. getClassName(): string;
  85942. /**
  85943. * Serializes the particle system to a JSON object.
  85944. * @returns the JSON object
  85945. */
  85946. serialize(): any;
  85947. /**
  85948. * Parse properties from a JSON object
  85949. * @param serializationObject defines the JSON object
  85950. */
  85951. parse(serializationObject: any): void;
  85952. }
  85953. /**
  85954. * Particle emitter emitting particles from the inside of a sphere.
  85955. * It emits the particles randomly between two vectors.
  85956. */
  85957. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  85958. /**
  85959. * The min limit of the emission direction.
  85960. */
  85961. direction1: Vector3;
  85962. /**
  85963. * The max limit of the emission direction.
  85964. */
  85965. direction2: Vector3;
  85966. /**
  85967. * Creates a new instance SphereDirectedParticleEmitter
  85968. * @param radius the radius of the emission sphere (1 by default)
  85969. * @param direction1 the min limit of the emission direction (up vector by default)
  85970. * @param direction2 the max limit of the emission direction (up vector by default)
  85971. */
  85972. constructor(radius?: number,
  85973. /**
  85974. * The min limit of the emission direction.
  85975. */
  85976. direction1?: Vector3,
  85977. /**
  85978. * The max limit of the emission direction.
  85979. */
  85980. direction2?: Vector3);
  85981. /**
  85982. * Called by the particle System when the direction is computed for the created particle.
  85983. * @param worldMatrix is the world matrix of the particle system
  85984. * @param directionToUpdate is the direction vector to update with the result
  85985. * @param particle is the particle we are computed the direction for
  85986. */
  85987. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85988. /**
  85989. * Clones the current emitter and returns a copy of it
  85990. * @returns the new emitter
  85991. */
  85992. clone(): SphereDirectedParticleEmitter;
  85993. /**
  85994. * Called by the GPUParticleSystem to setup the update shader
  85995. * @param effect defines the update shader
  85996. */
  85997. applyToShader(effect: Effect): void;
  85998. /**
  85999. * Returns a string to use to update the GPU particles update shader
  86000. * @returns a string containng the defines string
  86001. */
  86002. getEffectDefines(): string;
  86003. /**
  86004. * Returns the string "SphereDirectedParticleEmitter"
  86005. * @returns a string containing the class name
  86006. */
  86007. getClassName(): string;
  86008. /**
  86009. * Serializes the particle system to a JSON object.
  86010. * @returns the JSON object
  86011. */
  86012. serialize(): any;
  86013. /**
  86014. * Parse properties from a JSON object
  86015. * @param serializationObject defines the JSON object
  86016. */
  86017. parse(serializationObject: any): void;
  86018. }
  86019. }
  86020. declare module BABYLON {
  86021. /**
  86022. * Particle emitter emitting particles from a custom list of positions.
  86023. */
  86024. export class CustomParticleEmitter implements IParticleEmitterType {
  86025. /**
  86026. * Gets or sets the position generator that will create the inital position of each particle.
  86027. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86028. */
  86029. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  86030. /**
  86031. * Gets or sets the destination generator that will create the final destination of each particle.
  86032. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86033. */
  86034. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  86035. /**
  86036. * Creates a new instance CustomParticleEmitter
  86037. */
  86038. constructor();
  86039. /**
  86040. * Called by the particle System when the direction is computed for the created particle.
  86041. * @param worldMatrix is the world matrix of the particle system
  86042. * @param directionToUpdate is the direction vector to update with the result
  86043. * @param particle is the particle we are computed the direction for
  86044. * @param isLocal defines if the direction should be set in local space
  86045. */
  86046. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86047. /**
  86048. * Called by the particle System when the position is computed for the created particle.
  86049. * @param worldMatrix is the world matrix of the particle system
  86050. * @param positionToUpdate is the position vector to update with the result
  86051. * @param particle is the particle we are computed the position for
  86052. * @param isLocal defines if the position should be set in local space
  86053. */
  86054. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86055. /**
  86056. * Clones the current emitter and returns a copy of it
  86057. * @returns the new emitter
  86058. */
  86059. clone(): CustomParticleEmitter;
  86060. /**
  86061. * Called by the GPUParticleSystem to setup the update shader
  86062. * @param effect defines the update shader
  86063. */
  86064. applyToShader(effect: Effect): void;
  86065. /**
  86066. * Returns a string to use to update the GPU particles update shader
  86067. * @returns a string containng the defines string
  86068. */
  86069. getEffectDefines(): string;
  86070. /**
  86071. * Returns the string "PointParticleEmitter"
  86072. * @returns a string containing the class name
  86073. */
  86074. getClassName(): string;
  86075. /**
  86076. * Serializes the particle system to a JSON object.
  86077. * @returns the JSON object
  86078. */
  86079. serialize(): any;
  86080. /**
  86081. * Parse properties from a JSON object
  86082. * @param serializationObject defines the JSON object
  86083. */
  86084. parse(serializationObject: any): void;
  86085. }
  86086. }
  86087. declare module BABYLON {
  86088. /**
  86089. * Particle emitter emitting particles from the inside of a box.
  86090. * It emits the particles randomly between 2 given directions.
  86091. */
  86092. export class MeshParticleEmitter implements IParticleEmitterType {
  86093. /** Defines the mesh to use as source */
  86094. mesh?: AbstractMesh | undefined;
  86095. private _indices;
  86096. private _positions;
  86097. private _normals;
  86098. private _storedNormal;
  86099. /**
  86100. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86101. */
  86102. direction1: Vector3;
  86103. /**
  86104. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86105. */
  86106. direction2: Vector3;
  86107. /**
  86108. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  86109. */
  86110. useMeshNormalsForDirection: boolean;
  86111. /**
  86112. * Creates a new instance MeshParticleEmitter
  86113. * @param mesh defines the mesh to use as source
  86114. */
  86115. constructor(
  86116. /** Defines the mesh to use as source */
  86117. mesh?: AbstractMesh | undefined);
  86118. /**
  86119. * Called by the particle System when the direction is computed for the created particle.
  86120. * @param worldMatrix is the world matrix of the particle system
  86121. * @param directionToUpdate is the direction vector to update with the result
  86122. * @param particle is the particle we are computed the direction for
  86123. * @param isLocal defines if the direction should be set in local space
  86124. */
  86125. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86126. /**
  86127. * Called by the particle System when the position is computed for the created particle.
  86128. * @param worldMatrix is the world matrix of the particle system
  86129. * @param positionToUpdate is the position vector to update with the result
  86130. * @param particle is the particle we are computed the position for
  86131. * @param isLocal defines if the position should be set in local space
  86132. */
  86133. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86134. /**
  86135. * Clones the current emitter and returns a copy of it
  86136. * @returns the new emitter
  86137. */
  86138. clone(): MeshParticleEmitter;
  86139. /**
  86140. * Called by the GPUParticleSystem to setup the update shader
  86141. * @param effect defines the update shader
  86142. */
  86143. applyToShader(effect: Effect): void;
  86144. /**
  86145. * Returns a string to use to update the GPU particles update shader
  86146. * @returns a string containng the defines string
  86147. */
  86148. getEffectDefines(): string;
  86149. /**
  86150. * Returns the string "BoxParticleEmitter"
  86151. * @returns a string containing the class name
  86152. */
  86153. getClassName(): string;
  86154. /**
  86155. * Serializes the particle system to a JSON object.
  86156. * @returns the JSON object
  86157. */
  86158. serialize(): any;
  86159. /**
  86160. * Parse properties from a JSON object
  86161. * @param serializationObject defines the JSON object
  86162. * @param scene defines the hosting scene
  86163. */
  86164. parse(serializationObject: any, scene: Scene): void;
  86165. }
  86166. }
  86167. declare module BABYLON {
  86168. /**
  86169. * Interface representing a particle system in Babylon.js.
  86170. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86171. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86172. */
  86173. export interface IParticleSystem {
  86174. /**
  86175. * List of animations used by the particle system.
  86176. */
  86177. animations: Animation[];
  86178. /**
  86179. * The id of the Particle system.
  86180. */
  86181. id: string;
  86182. /**
  86183. * The name of the Particle system.
  86184. */
  86185. name: string;
  86186. /**
  86187. * The emitter represents the Mesh or position we are attaching the particle system to.
  86188. */
  86189. emitter: Nullable<AbstractMesh | Vector3>;
  86190. /**
  86191. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86192. */
  86193. isBillboardBased: boolean;
  86194. /**
  86195. * The rendering group used by the Particle system to chose when to render.
  86196. */
  86197. renderingGroupId: number;
  86198. /**
  86199. * The layer mask we are rendering the particles through.
  86200. */
  86201. layerMask: number;
  86202. /**
  86203. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86204. */
  86205. updateSpeed: number;
  86206. /**
  86207. * The amount of time the particle system is running (depends of the overall update speed).
  86208. */
  86209. targetStopDuration: number;
  86210. /**
  86211. * The texture used to render each particle. (this can be a spritesheet)
  86212. */
  86213. particleTexture: Nullable<Texture>;
  86214. /**
  86215. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86216. */
  86217. blendMode: number;
  86218. /**
  86219. * Minimum life time of emitting particles.
  86220. */
  86221. minLifeTime: number;
  86222. /**
  86223. * Maximum life time of emitting particles.
  86224. */
  86225. maxLifeTime: number;
  86226. /**
  86227. * Minimum Size of emitting particles.
  86228. */
  86229. minSize: number;
  86230. /**
  86231. * Maximum Size of emitting particles.
  86232. */
  86233. maxSize: number;
  86234. /**
  86235. * Minimum scale of emitting particles on X axis.
  86236. */
  86237. minScaleX: number;
  86238. /**
  86239. * Maximum scale of emitting particles on X axis.
  86240. */
  86241. maxScaleX: number;
  86242. /**
  86243. * Minimum scale of emitting particles on Y axis.
  86244. */
  86245. minScaleY: number;
  86246. /**
  86247. * Maximum scale of emitting particles on Y axis.
  86248. */
  86249. maxScaleY: number;
  86250. /**
  86251. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86252. */
  86253. color1: Color4;
  86254. /**
  86255. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86256. */
  86257. color2: Color4;
  86258. /**
  86259. * Color the particle will have at the end of its lifetime.
  86260. */
  86261. colorDead: Color4;
  86262. /**
  86263. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86264. */
  86265. emitRate: number;
  86266. /**
  86267. * You can use gravity if you want to give an orientation to your particles.
  86268. */
  86269. gravity: Vector3;
  86270. /**
  86271. * Minimum power of emitting particles.
  86272. */
  86273. minEmitPower: number;
  86274. /**
  86275. * Maximum power of emitting particles.
  86276. */
  86277. maxEmitPower: number;
  86278. /**
  86279. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86280. */
  86281. minAngularSpeed: number;
  86282. /**
  86283. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86284. */
  86285. maxAngularSpeed: number;
  86286. /**
  86287. * Gets or sets the minimal initial rotation in radians.
  86288. */
  86289. minInitialRotation: number;
  86290. /**
  86291. * Gets or sets the maximal initial rotation in radians.
  86292. */
  86293. maxInitialRotation: number;
  86294. /**
  86295. * The particle emitter type defines the emitter used by the particle system.
  86296. * It can be for example box, sphere, or cone...
  86297. */
  86298. particleEmitterType: Nullable<IParticleEmitterType>;
  86299. /**
  86300. * Defines the delay in milliseconds before starting the system (0 by default)
  86301. */
  86302. startDelay: number;
  86303. /**
  86304. * 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
  86305. */
  86306. preWarmCycles: number;
  86307. /**
  86308. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86309. */
  86310. preWarmStepOffset: number;
  86311. /**
  86312. * 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)
  86313. */
  86314. spriteCellChangeSpeed: number;
  86315. /**
  86316. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86317. */
  86318. startSpriteCellID: number;
  86319. /**
  86320. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86321. */
  86322. endSpriteCellID: number;
  86323. /**
  86324. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86325. */
  86326. spriteCellWidth: number;
  86327. /**
  86328. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86329. */
  86330. spriteCellHeight: number;
  86331. /**
  86332. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86333. */
  86334. spriteRandomStartCell: boolean;
  86335. /**
  86336. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86337. */
  86338. isAnimationSheetEnabled: boolean;
  86339. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86340. translationPivot: Vector2;
  86341. /**
  86342. * Gets or sets a texture used to add random noise to particle positions
  86343. */
  86344. noiseTexture: Nullable<BaseTexture>;
  86345. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86346. noiseStrength: Vector3;
  86347. /**
  86348. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86349. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86350. */
  86351. billboardMode: number;
  86352. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86353. limitVelocityDamping: number;
  86354. /**
  86355. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86356. */
  86357. beginAnimationOnStart: boolean;
  86358. /**
  86359. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86360. */
  86361. beginAnimationFrom: number;
  86362. /**
  86363. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86364. */
  86365. beginAnimationTo: number;
  86366. /**
  86367. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86368. */
  86369. beginAnimationLoop: boolean;
  86370. /**
  86371. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86372. */
  86373. disposeOnStop: boolean;
  86374. /**
  86375. * Specifies if the particles are updated in emitter local space or world space
  86376. */
  86377. isLocal: boolean;
  86378. /**
  86379. * Gets the maximum number of particles active at the same time.
  86380. * @returns The max number of active particles.
  86381. */
  86382. getCapacity(): number;
  86383. /**
  86384. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86385. * @returns True if it has been started, otherwise false.
  86386. */
  86387. isStarted(): boolean;
  86388. /**
  86389. * Animates the particle system for this frame.
  86390. */
  86391. animate(): void;
  86392. /**
  86393. * Renders the particle system in its current state.
  86394. * @returns the current number of particles
  86395. */
  86396. render(): number;
  86397. /**
  86398. * Dispose the particle system and frees its associated resources.
  86399. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86400. */
  86401. dispose(disposeTexture?: boolean): void;
  86402. /**
  86403. * Clones the particle system.
  86404. * @param name The name of the cloned object
  86405. * @param newEmitter The new emitter to use
  86406. * @returns the cloned particle system
  86407. */
  86408. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86409. /**
  86410. * Serializes the particle system to a JSON object.
  86411. * @returns the JSON object
  86412. */
  86413. serialize(): any;
  86414. /**
  86415. * Rebuild the particle system
  86416. */
  86417. rebuild(): void;
  86418. /**
  86419. * Starts the particle system and begins to emit
  86420. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86421. */
  86422. start(delay?: number): void;
  86423. /**
  86424. * Stops the particle system.
  86425. */
  86426. stop(): void;
  86427. /**
  86428. * Remove all active particles
  86429. */
  86430. reset(): void;
  86431. /**
  86432. * Is this system ready to be used/rendered
  86433. * @return true if the system is ready
  86434. */
  86435. isReady(): boolean;
  86436. /**
  86437. * Adds a new color gradient
  86438. * @param gradient defines the gradient to use (between 0 and 1)
  86439. * @param color1 defines the color to affect to the specified gradient
  86440. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86441. * @returns the current particle system
  86442. */
  86443. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86444. /**
  86445. * Remove a specific color gradient
  86446. * @param gradient defines the gradient to remove
  86447. * @returns the current particle system
  86448. */
  86449. removeColorGradient(gradient: number): IParticleSystem;
  86450. /**
  86451. * Adds a new size gradient
  86452. * @param gradient defines the gradient to use (between 0 and 1)
  86453. * @param factor defines the size factor to affect to the specified gradient
  86454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86455. * @returns the current particle system
  86456. */
  86457. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86458. /**
  86459. * Remove a specific size gradient
  86460. * @param gradient defines the gradient to remove
  86461. * @returns the current particle system
  86462. */
  86463. removeSizeGradient(gradient: number): IParticleSystem;
  86464. /**
  86465. * Gets the current list of color gradients.
  86466. * You must use addColorGradient and removeColorGradient to udpate this list
  86467. * @returns the list of color gradients
  86468. */
  86469. getColorGradients(): Nullable<Array<ColorGradient>>;
  86470. /**
  86471. * Gets the current list of size gradients.
  86472. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86473. * @returns the list of size gradients
  86474. */
  86475. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86476. /**
  86477. * Gets the current list of angular speed gradients.
  86478. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86479. * @returns the list of angular speed gradients
  86480. */
  86481. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86482. /**
  86483. * Adds a new angular speed gradient
  86484. * @param gradient defines the gradient to use (between 0 and 1)
  86485. * @param factor defines the angular speed to affect to the specified gradient
  86486. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86487. * @returns the current particle system
  86488. */
  86489. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86490. /**
  86491. * Remove a specific angular speed gradient
  86492. * @param gradient defines the gradient to remove
  86493. * @returns the current particle system
  86494. */
  86495. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86496. /**
  86497. * Gets the current list of velocity gradients.
  86498. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86499. * @returns the list of velocity gradients
  86500. */
  86501. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86502. /**
  86503. * Adds a new velocity gradient
  86504. * @param gradient defines the gradient to use (between 0 and 1)
  86505. * @param factor defines the velocity to affect to the specified gradient
  86506. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86507. * @returns the current particle system
  86508. */
  86509. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86510. /**
  86511. * Remove a specific velocity gradient
  86512. * @param gradient defines the gradient to remove
  86513. * @returns the current particle system
  86514. */
  86515. removeVelocityGradient(gradient: number): IParticleSystem;
  86516. /**
  86517. * Gets the current list of limit velocity gradients.
  86518. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86519. * @returns the list of limit velocity gradients
  86520. */
  86521. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86522. /**
  86523. * Adds a new limit velocity gradient
  86524. * @param gradient defines the gradient to use (between 0 and 1)
  86525. * @param factor defines the limit velocity to affect to the specified gradient
  86526. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86527. * @returns the current particle system
  86528. */
  86529. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86530. /**
  86531. * Remove a specific limit velocity gradient
  86532. * @param gradient defines the gradient to remove
  86533. * @returns the current particle system
  86534. */
  86535. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86536. /**
  86537. * Adds a new drag gradient
  86538. * @param gradient defines the gradient to use (between 0 and 1)
  86539. * @param factor defines the drag to affect to the specified gradient
  86540. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86541. * @returns the current particle system
  86542. */
  86543. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86544. /**
  86545. * Remove a specific drag gradient
  86546. * @param gradient defines the gradient to remove
  86547. * @returns the current particle system
  86548. */
  86549. removeDragGradient(gradient: number): IParticleSystem;
  86550. /**
  86551. * Gets the current list of drag gradients.
  86552. * You must use addDragGradient and removeDragGradient to udpate this list
  86553. * @returns the list of drag gradients
  86554. */
  86555. getDragGradients(): Nullable<Array<FactorGradient>>;
  86556. /**
  86557. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86558. * @param gradient defines the gradient to use (between 0 and 1)
  86559. * @param factor defines the emit rate to affect to the specified gradient
  86560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86561. * @returns the current particle system
  86562. */
  86563. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86564. /**
  86565. * Remove a specific emit rate gradient
  86566. * @param gradient defines the gradient to remove
  86567. * @returns the current particle system
  86568. */
  86569. removeEmitRateGradient(gradient: number): IParticleSystem;
  86570. /**
  86571. * Gets the current list of emit rate gradients.
  86572. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86573. * @returns the list of emit rate gradients
  86574. */
  86575. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86576. /**
  86577. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86578. * @param gradient defines the gradient to use (between 0 and 1)
  86579. * @param factor defines the start size to affect to the specified gradient
  86580. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86581. * @returns the current particle system
  86582. */
  86583. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86584. /**
  86585. * Remove a specific start size gradient
  86586. * @param gradient defines the gradient to remove
  86587. * @returns the current particle system
  86588. */
  86589. removeStartSizeGradient(gradient: number): IParticleSystem;
  86590. /**
  86591. * Gets the current list of start size gradients.
  86592. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86593. * @returns the list of start size gradients
  86594. */
  86595. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86596. /**
  86597. * Adds a new life time gradient
  86598. * @param gradient defines the gradient to use (between 0 and 1)
  86599. * @param factor defines the life time factor to affect to the specified gradient
  86600. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86601. * @returns the current particle system
  86602. */
  86603. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86604. /**
  86605. * Remove a specific life time gradient
  86606. * @param gradient defines the gradient to remove
  86607. * @returns the current particle system
  86608. */
  86609. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86610. /**
  86611. * Gets the current list of life time gradients.
  86612. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86613. * @returns the list of life time gradients
  86614. */
  86615. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86616. /**
  86617. * Gets the current list of color gradients.
  86618. * You must use addColorGradient and removeColorGradient to udpate this list
  86619. * @returns the list of color gradients
  86620. */
  86621. getColorGradients(): Nullable<Array<ColorGradient>>;
  86622. /**
  86623. * Adds a new ramp gradient used to remap particle colors
  86624. * @param gradient defines the gradient to use (between 0 and 1)
  86625. * @param color defines the color to affect to the specified gradient
  86626. * @returns the current particle system
  86627. */
  86628. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86629. /**
  86630. * Gets the current list of ramp gradients.
  86631. * You must use addRampGradient and removeRampGradient to udpate this list
  86632. * @returns the list of ramp gradients
  86633. */
  86634. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86635. /** Gets or sets a boolean indicating that ramp gradients must be used
  86636. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86637. */
  86638. useRampGradients: boolean;
  86639. /**
  86640. * Adds a new color remap gradient
  86641. * @param gradient defines the gradient to use (between 0 and 1)
  86642. * @param min defines the color remap minimal range
  86643. * @param max defines the color remap maximal range
  86644. * @returns the current particle system
  86645. */
  86646. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86647. /**
  86648. * Gets the current list of color remap gradients.
  86649. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86650. * @returns the list of color remap gradients
  86651. */
  86652. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86653. /**
  86654. * Adds a new alpha remap gradient
  86655. * @param gradient defines the gradient to use (between 0 and 1)
  86656. * @param min defines the alpha remap minimal range
  86657. * @param max defines the alpha remap maximal range
  86658. * @returns the current particle system
  86659. */
  86660. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86661. /**
  86662. * Gets the current list of alpha remap gradients.
  86663. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86664. * @returns the list of alpha remap gradients
  86665. */
  86666. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86667. /**
  86668. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86669. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86670. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86671. * @returns the emitter
  86672. */
  86673. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86674. /**
  86675. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86676. * @param radius The radius of the hemisphere to emit from
  86677. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86678. * @returns the emitter
  86679. */
  86680. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86681. /**
  86682. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86683. * @param radius The radius of the sphere to emit from
  86684. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86685. * @returns the emitter
  86686. */
  86687. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86688. /**
  86689. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86690. * @param radius The radius of the sphere to emit from
  86691. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86692. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86693. * @returns the emitter
  86694. */
  86695. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86696. /**
  86697. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86698. * @param radius The radius of the emission cylinder
  86699. * @param height The height of the emission cylinder
  86700. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86701. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86702. * @returns the emitter
  86703. */
  86704. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86705. /**
  86706. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86707. * @param radius The radius of the cylinder to emit from
  86708. * @param height The height of the emission cylinder
  86709. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86710. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86711. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86712. * @returns the emitter
  86713. */
  86714. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86715. /**
  86716. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86717. * @param radius The radius of the cone to emit from
  86718. * @param angle The base angle of the cone
  86719. * @returns the emitter
  86720. */
  86721. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86722. /**
  86723. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86724. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86725. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86726. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86727. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86728. * @returns the emitter
  86729. */
  86730. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86731. /**
  86732. * Get hosting scene
  86733. * @returns the scene
  86734. */
  86735. getScene(): Scene;
  86736. }
  86737. }
  86738. declare module BABYLON {
  86739. /**
  86740. * 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.
  86741. * @see https://doc.babylonjs.com/how_to/transformnode
  86742. */
  86743. export class TransformNode extends Node {
  86744. /**
  86745. * Object will not rotate to face the camera
  86746. */
  86747. static BILLBOARDMODE_NONE: number;
  86748. /**
  86749. * Object will rotate to face the camera but only on the x axis
  86750. */
  86751. static BILLBOARDMODE_X: number;
  86752. /**
  86753. * Object will rotate to face the camera but only on the y axis
  86754. */
  86755. static BILLBOARDMODE_Y: number;
  86756. /**
  86757. * Object will rotate to face the camera but only on the z axis
  86758. */
  86759. static BILLBOARDMODE_Z: number;
  86760. /**
  86761. * Object will rotate to face the camera
  86762. */
  86763. static BILLBOARDMODE_ALL: number;
  86764. /**
  86765. * Object will rotate to face the camera's position instead of orientation
  86766. */
  86767. static BILLBOARDMODE_USE_POSITION: number;
  86768. private _forward;
  86769. private _forwardInverted;
  86770. private _up;
  86771. private _right;
  86772. private _rightInverted;
  86773. private _position;
  86774. private _rotation;
  86775. private _rotationQuaternion;
  86776. protected _scaling: Vector3;
  86777. protected _isDirty: boolean;
  86778. private _transformToBoneReferal;
  86779. private _isAbsoluteSynced;
  86780. private _billboardMode;
  86781. /**
  86782. * Gets or sets the billboard mode. Default is 0.
  86783. *
  86784. * | Value | Type | Description |
  86785. * | --- | --- | --- |
  86786. * | 0 | BILLBOARDMODE_NONE | |
  86787. * | 1 | BILLBOARDMODE_X | |
  86788. * | 2 | BILLBOARDMODE_Y | |
  86789. * | 4 | BILLBOARDMODE_Z | |
  86790. * | 7 | BILLBOARDMODE_ALL | |
  86791. *
  86792. */
  86793. get billboardMode(): number;
  86794. set billboardMode(value: number);
  86795. private _preserveParentRotationForBillboard;
  86796. /**
  86797. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  86798. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  86799. */
  86800. get preserveParentRotationForBillboard(): boolean;
  86801. set preserveParentRotationForBillboard(value: boolean);
  86802. /**
  86803. * 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
  86804. */
  86805. scalingDeterminant: number;
  86806. private _infiniteDistance;
  86807. /**
  86808. * Gets or sets the distance of the object to max, often used by skybox
  86809. */
  86810. get infiniteDistance(): boolean;
  86811. set infiniteDistance(value: boolean);
  86812. /**
  86813. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  86814. * By default the system will update normals to compensate
  86815. */
  86816. ignoreNonUniformScaling: boolean;
  86817. /**
  86818. * 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
  86819. */
  86820. reIntegrateRotationIntoRotationQuaternion: boolean;
  86821. /** @hidden */
  86822. _poseMatrix: Nullable<Matrix>;
  86823. /** @hidden */
  86824. _localMatrix: Matrix;
  86825. private _usePivotMatrix;
  86826. private _absolutePosition;
  86827. private _absoluteScaling;
  86828. private _absoluteRotationQuaternion;
  86829. private _pivotMatrix;
  86830. private _pivotMatrixInverse;
  86831. protected _postMultiplyPivotMatrix: boolean;
  86832. protected _isWorldMatrixFrozen: boolean;
  86833. /** @hidden */
  86834. _indexInSceneTransformNodesArray: number;
  86835. /**
  86836. * An event triggered after the world matrix is updated
  86837. */
  86838. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  86839. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  86840. /**
  86841. * Gets a string identifying the name of the class
  86842. * @returns "TransformNode" string
  86843. */
  86844. getClassName(): string;
  86845. /**
  86846. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  86847. */
  86848. get position(): Vector3;
  86849. set position(newPosition: Vector3);
  86850. /**
  86851. * 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)).
  86852. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  86853. */
  86854. get rotation(): Vector3;
  86855. set rotation(newRotation: Vector3);
  86856. /**
  86857. * 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)).
  86858. */
  86859. get scaling(): Vector3;
  86860. set scaling(newScaling: Vector3);
  86861. /**
  86862. * 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).
  86863. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  86864. */
  86865. get rotationQuaternion(): Nullable<Quaternion>;
  86866. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  86867. /**
  86868. * The forward direction of that transform in world space.
  86869. */
  86870. get forward(): Vector3;
  86871. /**
  86872. * The up direction of that transform in world space.
  86873. */
  86874. get up(): Vector3;
  86875. /**
  86876. * The right direction of that transform in world space.
  86877. */
  86878. get right(): Vector3;
  86879. /**
  86880. * Copies the parameter passed Matrix into the mesh Pose matrix.
  86881. * @param matrix the matrix to copy the pose from
  86882. * @returns this TransformNode.
  86883. */
  86884. updatePoseMatrix(matrix: Matrix): TransformNode;
  86885. /**
  86886. * Returns the mesh Pose matrix.
  86887. * @returns the pose matrix
  86888. */
  86889. getPoseMatrix(): Matrix;
  86890. /** @hidden */
  86891. _isSynchronized(): boolean;
  86892. /** @hidden */
  86893. _initCache(): void;
  86894. /**
  86895. * Flag the transform node as dirty (Forcing it to update everything)
  86896. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  86897. * @returns this transform node
  86898. */
  86899. markAsDirty(property: string): TransformNode;
  86900. /**
  86901. * Returns the current mesh absolute position.
  86902. * Returns a Vector3.
  86903. */
  86904. get absolutePosition(): Vector3;
  86905. /**
  86906. * Returns the current mesh absolute scaling.
  86907. * Returns a Vector3.
  86908. */
  86909. get absoluteScaling(): Vector3;
  86910. /**
  86911. * Returns the current mesh absolute rotation.
  86912. * Returns a Quaternion.
  86913. */
  86914. get absoluteRotationQuaternion(): Quaternion;
  86915. /**
  86916. * Sets a new matrix to apply before all other transformation
  86917. * @param matrix defines the transform matrix
  86918. * @returns the current TransformNode
  86919. */
  86920. setPreTransformMatrix(matrix: Matrix): TransformNode;
  86921. /**
  86922. * Sets a new pivot matrix to the current node
  86923. * @param matrix defines the new pivot matrix to use
  86924. * @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
  86925. * @returns the current TransformNode
  86926. */
  86927. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  86928. /**
  86929. * Returns the mesh pivot matrix.
  86930. * Default : Identity.
  86931. * @returns the matrix
  86932. */
  86933. getPivotMatrix(): Matrix;
  86934. /**
  86935. * Instantiate (when possible) or clone that node with its hierarchy
  86936. * @param newParent defines the new parent to use for the instance (or clone)
  86937. * @param options defines options to configure how copy is done
  86938. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  86939. * @returns an instance (or a clone) of the current node with its hiearchy
  86940. */
  86941. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  86942. doNotInstantiate: boolean;
  86943. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  86944. /**
  86945. * Prevents the World matrix to be computed any longer
  86946. * @param newWorldMatrix defines an optional matrix to use as world matrix
  86947. * @returns the TransformNode.
  86948. */
  86949. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  86950. /**
  86951. * Allows back the World matrix computation.
  86952. * @returns the TransformNode.
  86953. */
  86954. unfreezeWorldMatrix(): this;
  86955. /**
  86956. * True if the World matrix has been frozen.
  86957. */
  86958. get isWorldMatrixFrozen(): boolean;
  86959. /**
  86960. * Retuns the mesh absolute position in the World.
  86961. * @returns a Vector3.
  86962. */
  86963. getAbsolutePosition(): Vector3;
  86964. /**
  86965. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  86966. * @param absolutePosition the absolute position to set
  86967. * @returns the TransformNode.
  86968. */
  86969. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86970. /**
  86971. * Sets the mesh position in its local space.
  86972. * @param vector3 the position to set in localspace
  86973. * @returns the TransformNode.
  86974. */
  86975. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  86976. /**
  86977. * Returns the mesh position in the local space from the current World matrix values.
  86978. * @returns a new Vector3.
  86979. */
  86980. getPositionExpressedInLocalSpace(): Vector3;
  86981. /**
  86982. * Translates the mesh along the passed Vector3 in its local space.
  86983. * @param vector3 the distance to translate in localspace
  86984. * @returns the TransformNode.
  86985. */
  86986. locallyTranslate(vector3: Vector3): TransformNode;
  86987. private static _lookAtVectorCache;
  86988. /**
  86989. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  86990. * @param targetPoint the position (must be in same space as current mesh) to look at
  86991. * @param yawCor optional yaw (y-axis) correction in radians
  86992. * @param pitchCor optional pitch (x-axis) correction in radians
  86993. * @param rollCor optional roll (z-axis) correction in radians
  86994. * @param space the choosen space of the target
  86995. * @returns the TransformNode.
  86996. */
  86997. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  86998. /**
  86999. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87000. * This Vector3 is expressed in the World space.
  87001. * @param localAxis axis to rotate
  87002. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87003. */
  87004. getDirection(localAxis: Vector3): Vector3;
  87005. /**
  87006. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  87007. * localAxis is expressed in the mesh local space.
  87008. * result is computed in the Wordl space from the mesh World matrix.
  87009. * @param localAxis axis to rotate
  87010. * @param result the resulting transformnode
  87011. * @returns this TransformNode.
  87012. */
  87013. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  87014. /**
  87015. * Sets this transform node rotation to the given local axis.
  87016. * @param localAxis the axis in local space
  87017. * @param yawCor optional yaw (y-axis) correction in radians
  87018. * @param pitchCor optional pitch (x-axis) correction in radians
  87019. * @param rollCor optional roll (z-axis) correction in radians
  87020. * @returns this TransformNode
  87021. */
  87022. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  87023. /**
  87024. * Sets a new pivot point to the current node
  87025. * @param point defines the new pivot point to use
  87026. * @param space defines if the point is in world or local space (local by default)
  87027. * @returns the current TransformNode
  87028. */
  87029. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  87030. /**
  87031. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  87032. * @returns the pivot point
  87033. */
  87034. getPivotPoint(): Vector3;
  87035. /**
  87036. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  87037. * @param result the vector3 to store the result
  87038. * @returns this TransformNode.
  87039. */
  87040. getPivotPointToRef(result: Vector3): TransformNode;
  87041. /**
  87042. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  87043. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  87044. */
  87045. getAbsolutePivotPoint(): Vector3;
  87046. /**
  87047. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  87048. * @param result vector3 to store the result
  87049. * @returns this TransformNode.
  87050. */
  87051. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  87052. /**
  87053. * Defines the passed node as the parent of the current node.
  87054. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  87055. * @see https://doc.babylonjs.com/how_to/parenting
  87056. * @param node the node ot set as the parent
  87057. * @returns this TransformNode.
  87058. */
  87059. setParent(node: Nullable<Node>): TransformNode;
  87060. private _nonUniformScaling;
  87061. /**
  87062. * True if the scaling property of this object is non uniform eg. (1,2,1)
  87063. */
  87064. get nonUniformScaling(): boolean;
  87065. /** @hidden */
  87066. _updateNonUniformScalingState(value: boolean): boolean;
  87067. /**
  87068. * Attach the current TransformNode to another TransformNode associated with a bone
  87069. * @param bone Bone affecting the TransformNode
  87070. * @param affectedTransformNode TransformNode associated with the bone
  87071. * @returns this object
  87072. */
  87073. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  87074. /**
  87075. * Detach the transform node if its associated with a bone
  87076. * @returns this object
  87077. */
  87078. detachFromBone(): TransformNode;
  87079. private static _rotationAxisCache;
  87080. /**
  87081. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87082. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87083. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87084. * The passed axis is also normalized.
  87085. * @param axis the axis to rotate around
  87086. * @param amount the amount to rotate in radians
  87087. * @param space Space to rotate in (Default: local)
  87088. * @returns the TransformNode.
  87089. */
  87090. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87091. /**
  87092. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87093. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87094. * The passed axis is also normalized. .
  87095. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87096. * @param point the point to rotate around
  87097. * @param axis the axis to rotate around
  87098. * @param amount the amount to rotate in radians
  87099. * @returns the TransformNode
  87100. */
  87101. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87102. /**
  87103. * Translates the mesh along the axis vector for the passed distance in the given space.
  87104. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87105. * @param axis the axis to translate in
  87106. * @param distance the distance to translate
  87107. * @param space Space to rotate in (Default: local)
  87108. * @returns the TransformNode.
  87109. */
  87110. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87111. /**
  87112. * Adds a rotation step to the mesh current rotation.
  87113. * x, y, z are Euler angles expressed in radians.
  87114. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87115. * This means this rotation is made in the mesh local space only.
  87116. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87117. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87118. * ```javascript
  87119. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87120. * ```
  87121. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87122. * 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.
  87123. * @param x Rotation to add
  87124. * @param y Rotation to add
  87125. * @param z Rotation to add
  87126. * @returns the TransformNode.
  87127. */
  87128. addRotation(x: number, y: number, z: number): TransformNode;
  87129. /**
  87130. * @hidden
  87131. */
  87132. protected _getEffectiveParent(): Nullable<Node>;
  87133. /**
  87134. * Computes the world matrix of the node
  87135. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87136. * @returns the world matrix
  87137. */
  87138. computeWorldMatrix(force?: boolean): Matrix;
  87139. /**
  87140. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87141. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87142. */
  87143. resetLocalMatrix(independentOfChildren?: boolean): void;
  87144. protected _afterComputeWorldMatrix(): void;
  87145. /**
  87146. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87147. * @param func callback function to add
  87148. *
  87149. * @returns the TransformNode.
  87150. */
  87151. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87152. /**
  87153. * Removes a registered callback function.
  87154. * @param func callback function to remove
  87155. * @returns the TransformNode.
  87156. */
  87157. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87158. /**
  87159. * Gets the position of the current mesh in camera space
  87160. * @param camera defines the camera to use
  87161. * @returns a position
  87162. */
  87163. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87164. /**
  87165. * Returns the distance from the mesh to the active camera
  87166. * @param camera defines the camera to use
  87167. * @returns the distance
  87168. */
  87169. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87170. /**
  87171. * Clone the current transform node
  87172. * @param name Name of the new clone
  87173. * @param newParent New parent for the clone
  87174. * @param doNotCloneChildren Do not clone children hierarchy
  87175. * @returns the new transform node
  87176. */
  87177. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87178. /**
  87179. * Serializes the objects information.
  87180. * @param currentSerializationObject defines the object to serialize in
  87181. * @returns the serialized object
  87182. */
  87183. serialize(currentSerializationObject?: any): any;
  87184. /**
  87185. * Returns a new TransformNode object parsed from the source provided.
  87186. * @param parsedTransformNode is the source.
  87187. * @param scene the scne the object belongs to
  87188. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87189. * @returns a new TransformNode object parsed from the source provided.
  87190. */
  87191. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87192. /**
  87193. * Get all child-transformNodes of this node
  87194. * @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
  87195. * @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
  87196. * @returns an array of TransformNode
  87197. */
  87198. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87199. /**
  87200. * Releases resources associated with this transform node.
  87201. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87202. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87203. */
  87204. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87205. /**
  87206. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87207. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87208. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87209. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87210. * @returns the current mesh
  87211. */
  87212. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87213. private _syncAbsoluteScalingAndRotation;
  87214. }
  87215. }
  87216. declare module BABYLON {
  87217. /**
  87218. * Class used to override all child animations of a given target
  87219. */
  87220. export class AnimationPropertiesOverride {
  87221. /**
  87222. * Gets or sets a value indicating if animation blending must be used
  87223. */
  87224. enableBlending: boolean;
  87225. /**
  87226. * Gets or sets the blending speed to use when enableBlending is true
  87227. */
  87228. blendingSpeed: number;
  87229. /**
  87230. * Gets or sets the default loop mode to use
  87231. */
  87232. loopMode: number;
  87233. }
  87234. }
  87235. declare module BABYLON {
  87236. /**
  87237. * Class used to store bone information
  87238. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87239. */
  87240. export class Bone extends Node {
  87241. /**
  87242. * defines the bone name
  87243. */
  87244. name: string;
  87245. private static _tmpVecs;
  87246. private static _tmpQuat;
  87247. private static _tmpMats;
  87248. /**
  87249. * Gets the list of child bones
  87250. */
  87251. children: Bone[];
  87252. /** Gets the animations associated with this bone */
  87253. animations: Animation[];
  87254. /**
  87255. * Gets or sets bone length
  87256. */
  87257. length: number;
  87258. /**
  87259. * @hidden Internal only
  87260. * Set this value to map this bone to a different index in the transform matrices
  87261. * Set this value to -1 to exclude the bone from the transform matrices
  87262. */
  87263. _index: Nullable<number>;
  87264. private _skeleton;
  87265. private _localMatrix;
  87266. private _restPose;
  87267. private _baseMatrix;
  87268. private _absoluteTransform;
  87269. private _invertedAbsoluteTransform;
  87270. private _parent;
  87271. private _scalingDeterminant;
  87272. private _worldTransform;
  87273. private _localScaling;
  87274. private _localRotation;
  87275. private _localPosition;
  87276. private _needToDecompose;
  87277. private _needToCompose;
  87278. /** @hidden */
  87279. _linkedTransformNode: Nullable<TransformNode>;
  87280. /** @hidden */
  87281. _waitingTransformNodeId: Nullable<string>;
  87282. /** @hidden */
  87283. get _matrix(): Matrix;
  87284. /** @hidden */
  87285. set _matrix(value: Matrix);
  87286. /**
  87287. * Create a new bone
  87288. * @param name defines the bone name
  87289. * @param skeleton defines the parent skeleton
  87290. * @param parentBone defines the parent (can be null if the bone is the root)
  87291. * @param localMatrix defines the local matrix
  87292. * @param restPose defines the rest pose matrix
  87293. * @param baseMatrix defines the base matrix
  87294. * @param index defines index of the bone in the hiearchy
  87295. */
  87296. constructor(
  87297. /**
  87298. * defines the bone name
  87299. */
  87300. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  87301. /**
  87302. * Gets the current object class name.
  87303. * @return the class name
  87304. */
  87305. getClassName(): string;
  87306. /**
  87307. * Gets the parent skeleton
  87308. * @returns a skeleton
  87309. */
  87310. getSkeleton(): Skeleton;
  87311. /**
  87312. * Gets parent bone
  87313. * @returns a bone or null if the bone is the root of the bone hierarchy
  87314. */
  87315. getParent(): Nullable<Bone>;
  87316. /**
  87317. * Returns an array containing the root bones
  87318. * @returns an array containing the root bones
  87319. */
  87320. getChildren(): Array<Bone>;
  87321. /**
  87322. * Gets the node index in matrix array generated for rendering
  87323. * @returns the node index
  87324. */
  87325. getIndex(): number;
  87326. /**
  87327. * Sets the parent bone
  87328. * @param parent defines the parent (can be null if the bone is the root)
  87329. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87330. */
  87331. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  87332. /**
  87333. * Gets the local matrix
  87334. * @returns a matrix
  87335. */
  87336. getLocalMatrix(): Matrix;
  87337. /**
  87338. * Gets the base matrix (initial matrix which remains unchanged)
  87339. * @returns a matrix
  87340. */
  87341. getBaseMatrix(): Matrix;
  87342. /**
  87343. * Gets the rest pose matrix
  87344. * @returns a matrix
  87345. */
  87346. getRestPose(): Matrix;
  87347. /**
  87348. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  87349. */
  87350. getWorldMatrix(): Matrix;
  87351. /**
  87352. * Sets the local matrix to rest pose matrix
  87353. */
  87354. returnToRest(): void;
  87355. /**
  87356. * Gets the inverse of the absolute transform matrix.
  87357. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  87358. * @returns a matrix
  87359. */
  87360. getInvertedAbsoluteTransform(): Matrix;
  87361. /**
  87362. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  87363. * @returns a matrix
  87364. */
  87365. getAbsoluteTransform(): Matrix;
  87366. /**
  87367. * Links with the given transform node.
  87368. * The local matrix of this bone is copied from the transform node every frame.
  87369. * @param transformNode defines the transform node to link to
  87370. */
  87371. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  87372. /**
  87373. * Gets the node used to drive the bone's transformation
  87374. * @returns a transform node or null
  87375. */
  87376. getTransformNode(): Nullable<TransformNode>;
  87377. /** Gets or sets current position (in local space) */
  87378. get position(): Vector3;
  87379. set position(newPosition: Vector3);
  87380. /** Gets or sets current rotation (in local space) */
  87381. get rotation(): Vector3;
  87382. set rotation(newRotation: Vector3);
  87383. /** Gets or sets current rotation quaternion (in local space) */
  87384. get rotationQuaternion(): Quaternion;
  87385. set rotationQuaternion(newRotation: Quaternion);
  87386. /** Gets or sets current scaling (in local space) */
  87387. get scaling(): Vector3;
  87388. set scaling(newScaling: Vector3);
  87389. /**
  87390. * Gets the animation properties override
  87391. */
  87392. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  87393. private _decompose;
  87394. private _compose;
  87395. /**
  87396. * Update the base and local matrices
  87397. * @param matrix defines the new base or local matrix
  87398. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87399. * @param updateLocalMatrix defines if the local matrix should be updated
  87400. */
  87401. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  87402. /** @hidden */
  87403. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  87404. /**
  87405. * Flag the bone as dirty (Forcing it to update everything)
  87406. */
  87407. markAsDirty(): void;
  87408. /** @hidden */
  87409. _markAsDirtyAndCompose(): void;
  87410. private _markAsDirtyAndDecompose;
  87411. /**
  87412. * Translate the bone in local or world space
  87413. * @param vec The amount to translate the bone
  87414. * @param space The space that the translation is in
  87415. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87416. */
  87417. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87418. /**
  87419. * Set the postion of the bone in local or world space
  87420. * @param position The position to set the bone
  87421. * @param space The space that the position is in
  87422. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87423. */
  87424. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87425. /**
  87426. * Set the absolute position of the bone (world space)
  87427. * @param position The position to set the bone
  87428. * @param mesh The mesh that this bone is attached to
  87429. */
  87430. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  87431. /**
  87432. * Scale the bone on the x, y and z axes (in local space)
  87433. * @param x The amount to scale the bone on the x axis
  87434. * @param y The amount to scale the bone on the y axis
  87435. * @param z The amount to scale the bone on the z axis
  87436. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  87437. */
  87438. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  87439. /**
  87440. * Set the bone scaling in local space
  87441. * @param scale defines the scaling vector
  87442. */
  87443. setScale(scale: Vector3): void;
  87444. /**
  87445. * Gets the current scaling in local space
  87446. * @returns the current scaling vector
  87447. */
  87448. getScale(): Vector3;
  87449. /**
  87450. * Gets the current scaling in local space and stores it in a target vector
  87451. * @param result defines the target vector
  87452. */
  87453. getScaleToRef(result: Vector3): void;
  87454. /**
  87455. * Set the yaw, pitch, and roll of the bone in local or world space
  87456. * @param yaw The rotation of the bone on the y axis
  87457. * @param pitch The rotation of the bone on the x axis
  87458. * @param roll The rotation of the bone on the z axis
  87459. * @param space The space that the axes of rotation are in
  87460. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87461. */
  87462. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  87463. /**
  87464. * Add a rotation to the bone on an axis in local or world space
  87465. * @param axis The axis to rotate the bone on
  87466. * @param amount The amount to rotate the bone
  87467. * @param space The space that the axis is in
  87468. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87469. */
  87470. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  87471. /**
  87472. * Set the rotation of the bone to a particular axis angle in local or world space
  87473. * @param axis The axis to rotate the bone on
  87474. * @param angle The angle that the bone should be rotated to
  87475. * @param space The space that the axis is in
  87476. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87477. */
  87478. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  87479. /**
  87480. * Set the euler rotation of the bone in local of world space
  87481. * @param rotation The euler rotation that the bone should be set to
  87482. * @param space The space that the rotation is in
  87483. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87484. */
  87485. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87486. /**
  87487. * Set the quaternion rotation of the bone in local of world space
  87488. * @param quat The quaternion rotation that the bone should be set to
  87489. * @param space The space that the rotation is in
  87490. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87491. */
  87492. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  87493. /**
  87494. * Set the rotation matrix of the bone in local of world space
  87495. * @param rotMat The rotation matrix that the bone should be set to
  87496. * @param space The space that the rotation is in
  87497. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87498. */
  87499. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  87500. private _rotateWithMatrix;
  87501. private _getNegativeRotationToRef;
  87502. /**
  87503. * Get the position of the bone in local or world space
  87504. * @param space The space that the returned position is in
  87505. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87506. * @returns The position of the bone
  87507. */
  87508. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87509. /**
  87510. * Copy the position of the bone to a vector3 in local or world space
  87511. * @param space The space that the returned position is in
  87512. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87513. * @param result The vector3 to copy the position to
  87514. */
  87515. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  87516. /**
  87517. * Get the absolute position of the bone (world space)
  87518. * @param mesh The mesh that this bone is attached to
  87519. * @returns The absolute position of the bone
  87520. */
  87521. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  87522. /**
  87523. * Copy the absolute position of the bone (world space) to the result param
  87524. * @param mesh The mesh that this bone is attached to
  87525. * @param result The vector3 to copy the absolute position to
  87526. */
  87527. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  87528. /**
  87529. * Compute the absolute transforms of this bone and its children
  87530. */
  87531. computeAbsoluteTransforms(): void;
  87532. /**
  87533. * Get the world direction from an axis that is in the local space of the bone
  87534. * @param localAxis The local direction that is used to compute the world direction
  87535. * @param mesh The mesh that this bone is attached to
  87536. * @returns The world direction
  87537. */
  87538. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87539. /**
  87540. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  87541. * @param localAxis The local direction that is used to compute the world direction
  87542. * @param mesh The mesh that this bone is attached to
  87543. * @param result The vector3 that the world direction will be copied to
  87544. */
  87545. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87546. /**
  87547. * Get the euler rotation of the bone in local or world space
  87548. * @param space The space that the rotation should be in
  87549. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87550. * @returns The euler rotation
  87551. */
  87552. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87553. /**
  87554. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  87555. * @param space The space that the rotation should be in
  87556. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87557. * @param result The vector3 that the rotation should be copied to
  87558. */
  87559. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87560. /**
  87561. * Get the quaternion rotation of the bone in either local or world space
  87562. * @param space The space that the rotation should be in
  87563. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87564. * @returns The quaternion rotation
  87565. */
  87566. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  87567. /**
  87568. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  87569. * @param space The space that the rotation should be in
  87570. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87571. * @param result The quaternion that the rotation should be copied to
  87572. */
  87573. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  87574. /**
  87575. * Get the rotation matrix of the bone in local or world space
  87576. * @param space The space that the rotation should be in
  87577. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87578. * @returns The rotation matrix
  87579. */
  87580. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  87581. /**
  87582. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  87583. * @param space The space that the rotation should be in
  87584. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87585. * @param result The quaternion that the rotation should be copied to
  87586. */
  87587. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  87588. /**
  87589. * Get the world position of a point that is in the local space of the bone
  87590. * @param position The local position
  87591. * @param mesh The mesh that this bone is attached to
  87592. * @returns The world position
  87593. */
  87594. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87595. /**
  87596. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  87597. * @param position The local position
  87598. * @param mesh The mesh that this bone is attached to
  87599. * @param result The vector3 that the world position should be copied to
  87600. */
  87601. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87602. /**
  87603. * Get the local position of a point that is in world space
  87604. * @param position The world position
  87605. * @param mesh The mesh that this bone is attached to
  87606. * @returns The local position
  87607. */
  87608. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87609. /**
  87610. * Get the local position of a point that is in world space and copy it to the result param
  87611. * @param position The world position
  87612. * @param mesh The mesh that this bone is attached to
  87613. * @param result The vector3 that the local position should be copied to
  87614. */
  87615. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87616. }
  87617. }
  87618. declare module BABYLON {
  87619. /**
  87620. * Defines a runtime animation
  87621. */
  87622. export class RuntimeAnimation {
  87623. private _events;
  87624. /**
  87625. * The current frame of the runtime animation
  87626. */
  87627. private _currentFrame;
  87628. /**
  87629. * The animation used by the runtime animation
  87630. */
  87631. private _animation;
  87632. /**
  87633. * The target of the runtime animation
  87634. */
  87635. private _target;
  87636. /**
  87637. * The initiating animatable
  87638. */
  87639. private _host;
  87640. /**
  87641. * The original value of the runtime animation
  87642. */
  87643. private _originalValue;
  87644. /**
  87645. * The original blend value of the runtime animation
  87646. */
  87647. private _originalBlendValue;
  87648. /**
  87649. * The offsets cache of the runtime animation
  87650. */
  87651. private _offsetsCache;
  87652. /**
  87653. * The high limits cache of the runtime animation
  87654. */
  87655. private _highLimitsCache;
  87656. /**
  87657. * Specifies if the runtime animation has been stopped
  87658. */
  87659. private _stopped;
  87660. /**
  87661. * The blending factor of the runtime animation
  87662. */
  87663. private _blendingFactor;
  87664. /**
  87665. * The BabylonJS scene
  87666. */
  87667. private _scene;
  87668. /**
  87669. * The current value of the runtime animation
  87670. */
  87671. private _currentValue;
  87672. /** @hidden */
  87673. _animationState: _IAnimationState;
  87674. /**
  87675. * The active target of the runtime animation
  87676. */
  87677. private _activeTargets;
  87678. private _currentActiveTarget;
  87679. private _directTarget;
  87680. /**
  87681. * The target path of the runtime animation
  87682. */
  87683. private _targetPath;
  87684. /**
  87685. * The weight of the runtime animation
  87686. */
  87687. private _weight;
  87688. /**
  87689. * The ratio offset of the runtime animation
  87690. */
  87691. private _ratioOffset;
  87692. /**
  87693. * The previous delay of the runtime animation
  87694. */
  87695. private _previousDelay;
  87696. /**
  87697. * The previous ratio of the runtime animation
  87698. */
  87699. private _previousRatio;
  87700. private _enableBlending;
  87701. private _keys;
  87702. private _minFrame;
  87703. private _maxFrame;
  87704. private _minValue;
  87705. private _maxValue;
  87706. private _targetIsArray;
  87707. /**
  87708. * Gets the current frame of the runtime animation
  87709. */
  87710. get currentFrame(): number;
  87711. /**
  87712. * Gets the weight of the runtime animation
  87713. */
  87714. get weight(): number;
  87715. /**
  87716. * Gets the current value of the runtime animation
  87717. */
  87718. get currentValue(): any;
  87719. /**
  87720. * Gets the target path of the runtime animation
  87721. */
  87722. get targetPath(): string;
  87723. /**
  87724. * Gets the actual target of the runtime animation
  87725. */
  87726. get target(): any;
  87727. /** @hidden */
  87728. _onLoop: () => void;
  87729. /**
  87730. * Create a new RuntimeAnimation object
  87731. * @param target defines the target of the animation
  87732. * @param animation defines the source animation object
  87733. * @param scene defines the hosting scene
  87734. * @param host defines the initiating Animatable
  87735. */
  87736. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  87737. private _preparePath;
  87738. /**
  87739. * Gets the animation from the runtime animation
  87740. */
  87741. get animation(): Animation;
  87742. /**
  87743. * Resets the runtime animation to the beginning
  87744. * @param restoreOriginal defines whether to restore the target property to the original value
  87745. */
  87746. reset(restoreOriginal?: boolean): void;
  87747. /**
  87748. * Specifies if the runtime animation is stopped
  87749. * @returns Boolean specifying if the runtime animation is stopped
  87750. */
  87751. isStopped(): boolean;
  87752. /**
  87753. * Disposes of the runtime animation
  87754. */
  87755. dispose(): void;
  87756. /**
  87757. * Apply the interpolated value to the target
  87758. * @param currentValue defines the value computed by the animation
  87759. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  87760. */
  87761. setValue(currentValue: any, weight: number): void;
  87762. private _getOriginalValues;
  87763. private _setValue;
  87764. /**
  87765. * Gets the loop pmode of the runtime animation
  87766. * @returns Loop Mode
  87767. */
  87768. private _getCorrectLoopMode;
  87769. /**
  87770. * Move the current animation to a given frame
  87771. * @param frame defines the frame to move to
  87772. */
  87773. goToFrame(frame: number): void;
  87774. /**
  87775. * @hidden Internal use only
  87776. */
  87777. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  87778. /**
  87779. * Execute the current animation
  87780. * @param delay defines the delay to add to the current frame
  87781. * @param from defines the lower bound of the animation range
  87782. * @param to defines the upper bound of the animation range
  87783. * @param loop defines if the current animation must loop
  87784. * @param speedRatio defines the current speed ratio
  87785. * @param weight defines the weight of the animation (default is -1 so no weight)
  87786. * @param onLoop optional callback called when animation loops
  87787. * @returns a boolean indicating if the animation is running
  87788. */
  87789. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  87790. }
  87791. }
  87792. declare module BABYLON {
  87793. /**
  87794. * Class used to store an actual running animation
  87795. */
  87796. export class Animatable {
  87797. /** defines the target object */
  87798. target: any;
  87799. /** defines the starting frame number (default is 0) */
  87800. fromFrame: number;
  87801. /** defines the ending frame number (default is 100) */
  87802. toFrame: number;
  87803. /** defines if the animation must loop (default is false) */
  87804. loopAnimation: boolean;
  87805. /** defines a callback to call when animation ends if it is not looping */
  87806. onAnimationEnd?: (() => void) | null | undefined;
  87807. /** defines a callback to call when animation loops */
  87808. onAnimationLoop?: (() => void) | null | undefined;
  87809. private _localDelayOffset;
  87810. private _pausedDelay;
  87811. private _runtimeAnimations;
  87812. private _paused;
  87813. private _scene;
  87814. private _speedRatio;
  87815. private _weight;
  87816. private _syncRoot;
  87817. /**
  87818. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  87819. * This will only apply for non looping animation (default is true)
  87820. */
  87821. disposeOnEnd: boolean;
  87822. /**
  87823. * Gets a boolean indicating if the animation has started
  87824. */
  87825. animationStarted: boolean;
  87826. /**
  87827. * Observer raised when the animation ends
  87828. */
  87829. onAnimationEndObservable: Observable<Animatable>;
  87830. /**
  87831. * Observer raised when the animation loops
  87832. */
  87833. onAnimationLoopObservable: Observable<Animatable>;
  87834. /**
  87835. * Gets the root Animatable used to synchronize and normalize animations
  87836. */
  87837. get syncRoot(): Nullable<Animatable>;
  87838. /**
  87839. * Gets the current frame of the first RuntimeAnimation
  87840. * Used to synchronize Animatables
  87841. */
  87842. get masterFrame(): number;
  87843. /**
  87844. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  87845. */
  87846. get weight(): number;
  87847. set weight(value: number);
  87848. /**
  87849. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  87850. */
  87851. get speedRatio(): number;
  87852. set speedRatio(value: number);
  87853. /**
  87854. * Creates a new Animatable
  87855. * @param scene defines the hosting scene
  87856. * @param target defines the target object
  87857. * @param fromFrame defines the starting frame number (default is 0)
  87858. * @param toFrame defines the ending frame number (default is 100)
  87859. * @param loopAnimation defines if the animation must loop (default is false)
  87860. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  87861. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  87862. * @param animations defines a group of animation to add to the new Animatable
  87863. * @param onAnimationLoop defines a callback to call when animation loops
  87864. */
  87865. constructor(scene: Scene,
  87866. /** defines the target object */
  87867. target: any,
  87868. /** defines the starting frame number (default is 0) */
  87869. fromFrame?: number,
  87870. /** defines the ending frame number (default is 100) */
  87871. toFrame?: number,
  87872. /** defines if the animation must loop (default is false) */
  87873. loopAnimation?: boolean, speedRatio?: number,
  87874. /** defines a callback to call when animation ends if it is not looping */
  87875. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  87876. /** defines a callback to call when animation loops */
  87877. onAnimationLoop?: (() => void) | null | undefined);
  87878. /**
  87879. * Synchronize and normalize current Animatable with a source Animatable
  87880. * This is useful when using animation weights and when animations are not of the same length
  87881. * @param root defines the root Animatable to synchronize with
  87882. * @returns the current Animatable
  87883. */
  87884. syncWith(root: Animatable): Animatable;
  87885. /**
  87886. * Gets the list of runtime animations
  87887. * @returns an array of RuntimeAnimation
  87888. */
  87889. getAnimations(): RuntimeAnimation[];
  87890. /**
  87891. * Adds more animations to the current animatable
  87892. * @param target defines the target of the animations
  87893. * @param animations defines the new animations to add
  87894. */
  87895. appendAnimations(target: any, animations: Animation[]): void;
  87896. /**
  87897. * Gets the source animation for a specific property
  87898. * @param property defines the propertyu to look for
  87899. * @returns null or the source animation for the given property
  87900. */
  87901. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  87902. /**
  87903. * Gets the runtime animation for a specific property
  87904. * @param property defines the propertyu to look for
  87905. * @returns null or the runtime animation for the given property
  87906. */
  87907. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  87908. /**
  87909. * Resets the animatable to its original state
  87910. */
  87911. reset(): void;
  87912. /**
  87913. * Allows the animatable to blend with current running animations
  87914. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87915. * @param blendingSpeed defines the blending speed to use
  87916. */
  87917. enableBlending(blendingSpeed: number): void;
  87918. /**
  87919. * Disable animation blending
  87920. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87921. */
  87922. disableBlending(): void;
  87923. /**
  87924. * Jump directly to a given frame
  87925. * @param frame defines the frame to jump to
  87926. */
  87927. goToFrame(frame: number): void;
  87928. /**
  87929. * Pause the animation
  87930. */
  87931. pause(): void;
  87932. /**
  87933. * Restart the animation
  87934. */
  87935. restart(): void;
  87936. private _raiseOnAnimationEnd;
  87937. /**
  87938. * Stop and delete the current animation
  87939. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  87940. * @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)
  87941. */
  87942. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  87943. /**
  87944. * Wait asynchronously for the animation to end
  87945. * @returns a promise which will be fullfilled when the animation ends
  87946. */
  87947. waitAsync(): Promise<Animatable>;
  87948. /** @hidden */
  87949. _animate(delay: number): boolean;
  87950. }
  87951. interface Scene {
  87952. /** @hidden */
  87953. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  87954. /** @hidden */
  87955. _processLateAnimationBindingsForMatrices(holder: {
  87956. totalWeight: number;
  87957. animations: RuntimeAnimation[];
  87958. originalValue: Matrix;
  87959. }): any;
  87960. /** @hidden */
  87961. _processLateAnimationBindingsForQuaternions(holder: {
  87962. totalWeight: number;
  87963. animations: RuntimeAnimation[];
  87964. originalValue: Quaternion;
  87965. }, refQuaternion: Quaternion): Quaternion;
  87966. /** @hidden */
  87967. _processLateAnimationBindings(): void;
  87968. /**
  87969. * Will start the animation sequence of a given target
  87970. * @param target defines the target
  87971. * @param from defines from which frame should animation start
  87972. * @param to defines until which frame should animation run.
  87973. * @param weight defines the weight to apply to the animation (1.0 by default)
  87974. * @param loop defines if the animation loops
  87975. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87976. * @param onAnimationEnd defines the function to be executed when the animation ends
  87977. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87978. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  87979. * @param onAnimationLoop defines the callback to call when an animation loops
  87980. * @returns the animatable object created for this animation
  87981. */
  87982. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  87983. /**
  87984. * Will start the animation sequence of a given target
  87985. * @param target defines the target
  87986. * @param from defines from which frame should animation start
  87987. * @param to defines until which frame should animation run.
  87988. * @param loop defines if the animation loops
  87989. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87990. * @param onAnimationEnd defines the function to be executed when the animation ends
  87991. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87992. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  87993. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  87994. * @param onAnimationLoop defines the callback to call when an animation loops
  87995. * @returns the animatable object created for this animation
  87996. */
  87997. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  87998. /**
  87999. * Will start the animation sequence of a given target and its hierarchy
  88000. * @param target defines the target
  88001. * @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.
  88002. * @param from defines from which frame should animation start
  88003. * @param to defines until which frame should animation run.
  88004. * @param loop defines if the animation loops
  88005. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88006. * @param onAnimationEnd defines the function to be executed when the animation ends
  88007. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88008. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88009. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88010. * @param onAnimationLoop defines the callback to call when an animation loops
  88011. * @returns the list of created animatables
  88012. */
  88013. 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[];
  88014. /**
  88015. * Begin a new animation on a given node
  88016. * @param target defines the target where the animation will take place
  88017. * @param animations defines the list of animations to start
  88018. * @param from defines the initial value
  88019. * @param to defines the final value
  88020. * @param loop defines if you want animation to loop (off by default)
  88021. * @param speedRatio defines the speed ratio to apply to all animations
  88022. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88023. * @param onAnimationLoop defines the callback to call when an animation loops
  88024. * @returns the list of created animatables
  88025. */
  88026. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  88027. /**
  88028. * Begin a new animation on a given node and its hierarchy
  88029. * @param target defines the root node where the animation will take place
  88030. * @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.
  88031. * @param animations defines the list of animations to start
  88032. * @param from defines the initial value
  88033. * @param to defines the final value
  88034. * @param loop defines if you want animation to loop (off by default)
  88035. * @param speedRatio defines the speed ratio to apply to all animations
  88036. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88037. * @param onAnimationLoop defines the callback to call when an animation loops
  88038. * @returns the list of animatables created for all nodes
  88039. */
  88040. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  88041. /**
  88042. * Gets the animatable associated with a specific target
  88043. * @param target defines the target of the animatable
  88044. * @returns the required animatable if found
  88045. */
  88046. getAnimatableByTarget(target: any): Nullable<Animatable>;
  88047. /**
  88048. * Gets all animatables associated with a given target
  88049. * @param target defines the target to look animatables for
  88050. * @returns an array of Animatables
  88051. */
  88052. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  88053. /**
  88054. * Stops and removes all animations that have been applied to the scene
  88055. */
  88056. stopAllAnimations(): void;
  88057. /**
  88058. * Gets the current delta time used by animation engine
  88059. */
  88060. deltaTime: number;
  88061. }
  88062. interface Bone {
  88063. /**
  88064. * Copy an animation range from another bone
  88065. * @param source defines the source bone
  88066. * @param rangeName defines the range name to copy
  88067. * @param frameOffset defines the frame offset
  88068. * @param rescaleAsRequired defines if rescaling must be applied if required
  88069. * @param skelDimensionsRatio defines the scaling ratio
  88070. * @returns true if operation was successful
  88071. */
  88072. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  88073. }
  88074. }
  88075. declare module BABYLON {
  88076. /**
  88077. * Class used to handle skinning animations
  88078. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88079. */
  88080. export class Skeleton implements IAnimatable {
  88081. /** defines the skeleton name */
  88082. name: string;
  88083. /** defines the skeleton Id */
  88084. id: string;
  88085. /**
  88086. * Defines the list of child bones
  88087. */
  88088. bones: Bone[];
  88089. /**
  88090. * Defines an estimate of the dimension of the skeleton at rest
  88091. */
  88092. dimensionsAtRest: Vector3;
  88093. /**
  88094. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  88095. */
  88096. needInitialSkinMatrix: boolean;
  88097. /**
  88098. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  88099. */
  88100. overrideMesh: Nullable<AbstractMesh>;
  88101. /**
  88102. * Gets the list of animations attached to this skeleton
  88103. */
  88104. animations: Array<Animation>;
  88105. private _scene;
  88106. private _isDirty;
  88107. private _transformMatrices;
  88108. private _transformMatrixTexture;
  88109. private _meshesWithPoseMatrix;
  88110. private _animatables;
  88111. private _identity;
  88112. private _synchronizedWithMesh;
  88113. private _ranges;
  88114. private _lastAbsoluteTransformsUpdateId;
  88115. private _canUseTextureForBones;
  88116. private _uniqueId;
  88117. /** @hidden */
  88118. _numBonesWithLinkedTransformNode: number;
  88119. /** @hidden */
  88120. _hasWaitingData: Nullable<boolean>;
  88121. /**
  88122. * Specifies if the skeleton should be serialized
  88123. */
  88124. doNotSerialize: boolean;
  88125. private _useTextureToStoreBoneMatrices;
  88126. /**
  88127. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  88128. * Please note that this option is not available if the hardware does not support it
  88129. */
  88130. get useTextureToStoreBoneMatrices(): boolean;
  88131. set useTextureToStoreBoneMatrices(value: boolean);
  88132. private _animationPropertiesOverride;
  88133. /**
  88134. * Gets or sets the animation properties override
  88135. */
  88136. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88137. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  88138. /**
  88139. * List of inspectable custom properties (used by the Inspector)
  88140. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88141. */
  88142. inspectableCustomProperties: IInspectable[];
  88143. /**
  88144. * An observable triggered before computing the skeleton's matrices
  88145. */
  88146. onBeforeComputeObservable: Observable<Skeleton>;
  88147. /**
  88148. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  88149. */
  88150. get isUsingTextureForMatrices(): boolean;
  88151. /**
  88152. * Gets the unique ID of this skeleton
  88153. */
  88154. get uniqueId(): number;
  88155. /**
  88156. * Creates a new skeleton
  88157. * @param name defines the skeleton name
  88158. * @param id defines the skeleton Id
  88159. * @param scene defines the hosting scene
  88160. */
  88161. constructor(
  88162. /** defines the skeleton name */
  88163. name: string,
  88164. /** defines the skeleton Id */
  88165. id: string, scene: Scene);
  88166. /**
  88167. * Gets the current object class name.
  88168. * @return the class name
  88169. */
  88170. getClassName(): string;
  88171. /**
  88172. * Returns an array containing the root bones
  88173. * @returns an array containing the root bones
  88174. */
  88175. getChildren(): Array<Bone>;
  88176. /**
  88177. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  88178. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88179. * @returns a Float32Array containing matrices data
  88180. */
  88181. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  88182. /**
  88183. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  88184. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88185. * @returns a raw texture containing the data
  88186. */
  88187. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  88188. /**
  88189. * Gets the current hosting scene
  88190. * @returns a scene object
  88191. */
  88192. getScene(): Scene;
  88193. /**
  88194. * Gets a string representing the current skeleton data
  88195. * @param fullDetails defines a boolean indicating if we want a verbose version
  88196. * @returns a string representing the current skeleton data
  88197. */
  88198. toString(fullDetails?: boolean): string;
  88199. /**
  88200. * Get bone's index searching by name
  88201. * @param name defines bone's name to search for
  88202. * @return the indice of the bone. Returns -1 if not found
  88203. */
  88204. getBoneIndexByName(name: string): number;
  88205. /**
  88206. * Creater a new animation range
  88207. * @param name defines the name of the range
  88208. * @param from defines the start key
  88209. * @param to defines the end key
  88210. */
  88211. createAnimationRange(name: string, from: number, to: number): void;
  88212. /**
  88213. * Delete a specific animation range
  88214. * @param name defines the name of the range
  88215. * @param deleteFrames defines if frames must be removed as well
  88216. */
  88217. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88218. /**
  88219. * Gets a specific animation range
  88220. * @param name defines the name of the range to look for
  88221. * @returns the requested animation range or null if not found
  88222. */
  88223. getAnimationRange(name: string): Nullable<AnimationRange>;
  88224. /**
  88225. * Gets the list of all animation ranges defined on this skeleton
  88226. * @returns an array
  88227. */
  88228. getAnimationRanges(): Nullable<AnimationRange>[];
  88229. /**
  88230. * Copy animation range from a source skeleton.
  88231. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  88232. * @param source defines the source skeleton
  88233. * @param name defines the name of the range to copy
  88234. * @param rescaleAsRequired defines if rescaling must be applied if required
  88235. * @returns true if operation was successful
  88236. */
  88237. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  88238. /**
  88239. * Forces the skeleton to go to rest pose
  88240. */
  88241. returnToRest(): void;
  88242. private _getHighestAnimationFrame;
  88243. /**
  88244. * Begin a specific animation range
  88245. * @param name defines the name of the range to start
  88246. * @param loop defines if looping must be turned on (false by default)
  88247. * @param speedRatio defines the speed ratio to apply (1 by default)
  88248. * @param onAnimationEnd defines a callback which will be called when animation will end
  88249. * @returns a new animatable
  88250. */
  88251. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88252. /** @hidden */
  88253. _markAsDirty(): void;
  88254. /** @hidden */
  88255. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88256. /** @hidden */
  88257. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88258. private _computeTransformMatrices;
  88259. /**
  88260. * Build all resources required to render a skeleton
  88261. */
  88262. prepare(): void;
  88263. /**
  88264. * Gets the list of animatables currently running for this skeleton
  88265. * @returns an array of animatables
  88266. */
  88267. getAnimatables(): IAnimatable[];
  88268. /**
  88269. * Clone the current skeleton
  88270. * @param name defines the name of the new skeleton
  88271. * @param id defines the id of the new skeleton
  88272. * @returns the new skeleton
  88273. */
  88274. clone(name: string, id?: string): Skeleton;
  88275. /**
  88276. * Enable animation blending for this skeleton
  88277. * @param blendingSpeed defines the blending speed to apply
  88278. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88279. */
  88280. enableBlending(blendingSpeed?: number): void;
  88281. /**
  88282. * Releases all resources associated with the current skeleton
  88283. */
  88284. dispose(): void;
  88285. /**
  88286. * Serialize the skeleton in a JSON object
  88287. * @returns a JSON object
  88288. */
  88289. serialize(): any;
  88290. /**
  88291. * Creates a new skeleton from serialized data
  88292. * @param parsedSkeleton defines the serialized data
  88293. * @param scene defines the hosting scene
  88294. * @returns a new skeleton
  88295. */
  88296. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  88297. /**
  88298. * Compute all node absolute transforms
  88299. * @param forceUpdate defines if computation must be done even if cache is up to date
  88300. */
  88301. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  88302. /**
  88303. * Gets the root pose matrix
  88304. * @returns a matrix
  88305. */
  88306. getPoseMatrix(): Nullable<Matrix>;
  88307. /**
  88308. * Sorts bones per internal index
  88309. */
  88310. sortBones(): void;
  88311. private _sortBones;
  88312. }
  88313. }
  88314. declare module BABYLON {
  88315. /**
  88316. * Creates an instance based on a source mesh.
  88317. */
  88318. export class InstancedMesh extends AbstractMesh {
  88319. private _sourceMesh;
  88320. private _currentLOD;
  88321. /** @hidden */
  88322. _indexInSourceMeshInstanceArray: number;
  88323. constructor(name: string, source: Mesh);
  88324. /**
  88325. * Returns the string "InstancedMesh".
  88326. */
  88327. getClassName(): string;
  88328. /** Gets the list of lights affecting that mesh */
  88329. get lightSources(): Light[];
  88330. _resyncLightSources(): void;
  88331. _resyncLightSource(light: Light): void;
  88332. _removeLightSource(light: Light, dispose: boolean): void;
  88333. /**
  88334. * If the source mesh receives shadows
  88335. */
  88336. get receiveShadows(): boolean;
  88337. /**
  88338. * The material of the source mesh
  88339. */
  88340. get material(): Nullable<Material>;
  88341. /**
  88342. * Visibility of the source mesh
  88343. */
  88344. get visibility(): number;
  88345. /**
  88346. * Skeleton of the source mesh
  88347. */
  88348. get skeleton(): Nullable<Skeleton>;
  88349. /**
  88350. * Rendering ground id of the source mesh
  88351. */
  88352. get renderingGroupId(): number;
  88353. set renderingGroupId(value: number);
  88354. /**
  88355. * Returns the total number of vertices (integer).
  88356. */
  88357. getTotalVertices(): number;
  88358. /**
  88359. * Returns a positive integer : the total number of indices in this mesh geometry.
  88360. * @returns the numner of indices or zero if the mesh has no geometry.
  88361. */
  88362. getTotalIndices(): number;
  88363. /**
  88364. * The source mesh of the instance
  88365. */
  88366. get sourceMesh(): Mesh;
  88367. /**
  88368. * Is this node ready to be used/rendered
  88369. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88370. * @return {boolean} is it ready
  88371. */
  88372. isReady(completeCheck?: boolean): boolean;
  88373. /**
  88374. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88375. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88376. * @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.
  88377. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88378. */
  88379. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88380. /**
  88381. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88382. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88383. * The `data` are either a numeric array either a Float32Array.
  88384. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88385. * 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).
  88386. * Note that a new underlying VertexBuffer object is created each call.
  88387. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88388. *
  88389. * Possible `kind` values :
  88390. * - VertexBuffer.PositionKind
  88391. * - VertexBuffer.UVKind
  88392. * - VertexBuffer.UV2Kind
  88393. * - VertexBuffer.UV3Kind
  88394. * - VertexBuffer.UV4Kind
  88395. * - VertexBuffer.UV5Kind
  88396. * - VertexBuffer.UV6Kind
  88397. * - VertexBuffer.ColorKind
  88398. * - VertexBuffer.MatricesIndicesKind
  88399. * - VertexBuffer.MatricesIndicesExtraKind
  88400. * - VertexBuffer.MatricesWeightsKind
  88401. * - VertexBuffer.MatricesWeightsExtraKind
  88402. *
  88403. * Returns the Mesh.
  88404. */
  88405. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88406. /**
  88407. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88408. * If the mesh has no geometry, it is simply returned as it is.
  88409. * The `data` are either a numeric array either a Float32Array.
  88410. * No new underlying VertexBuffer object is created.
  88411. * 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.
  88412. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88413. *
  88414. * Possible `kind` values :
  88415. * - VertexBuffer.PositionKind
  88416. * - VertexBuffer.UVKind
  88417. * - VertexBuffer.UV2Kind
  88418. * - VertexBuffer.UV3Kind
  88419. * - VertexBuffer.UV4Kind
  88420. * - VertexBuffer.UV5Kind
  88421. * - VertexBuffer.UV6Kind
  88422. * - VertexBuffer.ColorKind
  88423. * - VertexBuffer.MatricesIndicesKind
  88424. * - VertexBuffer.MatricesIndicesExtraKind
  88425. * - VertexBuffer.MatricesWeightsKind
  88426. * - VertexBuffer.MatricesWeightsExtraKind
  88427. *
  88428. * Returns the Mesh.
  88429. */
  88430. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88431. /**
  88432. * Sets the mesh indices.
  88433. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88434. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88435. * This method creates a new index buffer each call.
  88436. * Returns the Mesh.
  88437. */
  88438. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88439. /**
  88440. * Boolean : True if the mesh owns the requested kind of data.
  88441. */
  88442. isVerticesDataPresent(kind: string): boolean;
  88443. /**
  88444. * Returns an array of indices (IndicesArray).
  88445. */
  88446. getIndices(): Nullable<IndicesArray>;
  88447. get _positions(): Nullable<Vector3[]>;
  88448. /**
  88449. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88450. * This means the mesh underlying bounding box and sphere are recomputed.
  88451. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88452. * @returns the current mesh
  88453. */
  88454. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88455. /** @hidden */
  88456. _preActivate(): InstancedMesh;
  88457. /** @hidden */
  88458. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88459. /** @hidden */
  88460. _postActivate(): void;
  88461. getWorldMatrix(): Matrix;
  88462. get isAnInstance(): boolean;
  88463. /**
  88464. * Returns the current associated LOD AbstractMesh.
  88465. */
  88466. getLOD(camera: Camera): AbstractMesh;
  88467. /** @hidden */
  88468. _preActivateForIntermediateRendering(renderId: number): Mesh;
  88469. /** @hidden */
  88470. _syncSubMeshes(): InstancedMesh;
  88471. /** @hidden */
  88472. _generatePointsArray(): boolean;
  88473. /**
  88474. * Creates a new InstancedMesh from the current mesh.
  88475. * - name (string) : the cloned mesh name
  88476. * - newParent (optional Node) : the optional Node to parent the clone to.
  88477. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88478. *
  88479. * Returns the clone.
  88480. */
  88481. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  88482. /**
  88483. * Disposes the InstancedMesh.
  88484. * Returns nothing.
  88485. */
  88486. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88487. }
  88488. interface Mesh {
  88489. /**
  88490. * Register a custom buffer that will be instanced
  88491. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88492. * @param kind defines the buffer kind
  88493. * @param stride defines the stride in floats
  88494. */
  88495. registerInstancedBuffer(kind: string, stride: number): void;
  88496. /** @hidden */
  88497. _userInstancedBuffersStorage: {
  88498. data: {
  88499. [key: string]: Float32Array;
  88500. };
  88501. sizes: {
  88502. [key: string]: number;
  88503. };
  88504. vertexBuffers: {
  88505. [key: string]: Nullable<VertexBuffer>;
  88506. };
  88507. strides: {
  88508. [key: string]: number;
  88509. };
  88510. };
  88511. }
  88512. interface AbstractMesh {
  88513. /**
  88514. * Object used to store instanced buffers defined by user
  88515. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88516. */
  88517. instancedBuffers: {
  88518. [key: string]: any;
  88519. };
  88520. }
  88521. }
  88522. declare module BABYLON {
  88523. /**
  88524. * Defines the options associated with the creation of a shader material.
  88525. */
  88526. export interface IShaderMaterialOptions {
  88527. /**
  88528. * Does the material work in alpha blend mode
  88529. */
  88530. needAlphaBlending: boolean;
  88531. /**
  88532. * Does the material work in alpha test mode
  88533. */
  88534. needAlphaTesting: boolean;
  88535. /**
  88536. * The list of attribute names used in the shader
  88537. */
  88538. attributes: string[];
  88539. /**
  88540. * The list of unifrom names used in the shader
  88541. */
  88542. uniforms: string[];
  88543. /**
  88544. * The list of UBO names used in the shader
  88545. */
  88546. uniformBuffers: string[];
  88547. /**
  88548. * The list of sampler names used in the shader
  88549. */
  88550. samplers: string[];
  88551. /**
  88552. * The list of defines used in the shader
  88553. */
  88554. defines: string[];
  88555. }
  88556. /**
  88557. * 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.
  88558. *
  88559. * This returned material effects how the mesh will look based on the code in the shaders.
  88560. *
  88561. * @see http://doc.babylonjs.com/how_to/shader_material
  88562. */
  88563. export class ShaderMaterial extends Material {
  88564. private _shaderPath;
  88565. private _options;
  88566. private _textures;
  88567. private _textureArrays;
  88568. private _floats;
  88569. private _ints;
  88570. private _floatsArrays;
  88571. private _colors3;
  88572. private _colors3Arrays;
  88573. private _colors4;
  88574. private _colors4Arrays;
  88575. private _vectors2;
  88576. private _vectors3;
  88577. private _vectors4;
  88578. private _matrices;
  88579. private _matrixArrays;
  88580. private _matrices3x3;
  88581. private _matrices2x2;
  88582. private _vectors2Arrays;
  88583. private _vectors3Arrays;
  88584. private _vectors4Arrays;
  88585. private _cachedWorldViewMatrix;
  88586. private _cachedWorldViewProjectionMatrix;
  88587. private _renderId;
  88588. private _multiview;
  88589. /**
  88590. * Instantiate a new shader material.
  88591. * 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.
  88592. * This returned material effects how the mesh will look based on the code in the shaders.
  88593. * @see http://doc.babylonjs.com/how_to/shader_material
  88594. * @param name Define the name of the material in the scene
  88595. * @param scene Define the scene the material belongs to
  88596. * @param shaderPath Defines the route to the shader code in one of three ways:
  88597. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88598. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88599. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88600. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88601. * @param options Define the options used to create the shader
  88602. */
  88603. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88604. /**
  88605. * Gets the shader path used to define the shader code
  88606. * It can be modified to trigger a new compilation
  88607. */
  88608. get shaderPath(): any;
  88609. /**
  88610. * Sets the shader path used to define the shader code
  88611. * It can be modified to trigger a new compilation
  88612. */
  88613. set shaderPath(shaderPath: any);
  88614. /**
  88615. * Gets the options used to compile the shader.
  88616. * They can be modified to trigger a new compilation
  88617. */
  88618. get options(): IShaderMaterialOptions;
  88619. /**
  88620. * Gets the current class name of the material e.g. "ShaderMaterial"
  88621. * Mainly use in serialization.
  88622. * @returns the class name
  88623. */
  88624. getClassName(): string;
  88625. /**
  88626. * Specifies if the material will require alpha blending
  88627. * @returns a boolean specifying if alpha blending is needed
  88628. */
  88629. needAlphaBlending(): boolean;
  88630. /**
  88631. * Specifies if this material should be rendered in alpha test mode
  88632. * @returns a boolean specifying if an alpha test is needed.
  88633. */
  88634. needAlphaTesting(): boolean;
  88635. private _checkUniform;
  88636. /**
  88637. * Set a texture in the shader.
  88638. * @param name Define the name of the uniform samplers as defined in the shader
  88639. * @param texture Define the texture to bind to this sampler
  88640. * @return the material itself allowing "fluent" like uniform updates
  88641. */
  88642. setTexture(name: string, texture: Texture): ShaderMaterial;
  88643. /**
  88644. * Set a texture array in the shader.
  88645. * @param name Define the name of the uniform sampler array as defined in the shader
  88646. * @param textures Define the list of textures to bind to this sampler
  88647. * @return the material itself allowing "fluent" like uniform updates
  88648. */
  88649. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88650. /**
  88651. * Set a float in the shader.
  88652. * @param name Define the name of the uniform as defined in the shader
  88653. * @param value Define the value to give to the uniform
  88654. * @return the material itself allowing "fluent" like uniform updates
  88655. */
  88656. setFloat(name: string, value: number): ShaderMaterial;
  88657. /**
  88658. * Set a int in the shader.
  88659. * @param name Define the name of the uniform as defined in the shader
  88660. * @param value Define the value to give to the uniform
  88661. * @return the material itself allowing "fluent" like uniform updates
  88662. */
  88663. setInt(name: string, value: number): ShaderMaterial;
  88664. /**
  88665. * Set an array of floats in the shader.
  88666. * @param name Define the name of the uniform as defined in the shader
  88667. * @param value Define the value to give to the uniform
  88668. * @return the material itself allowing "fluent" like uniform updates
  88669. */
  88670. setFloats(name: string, value: number[]): ShaderMaterial;
  88671. /**
  88672. * Set a vec3 in the shader from a Color3.
  88673. * @param name Define the name of the uniform as defined in the shader
  88674. * @param value Define the value to give to the uniform
  88675. * @return the material itself allowing "fluent" like uniform updates
  88676. */
  88677. setColor3(name: string, value: Color3): ShaderMaterial;
  88678. /**
  88679. * Set a vec3 array in the shader from a Color3 array.
  88680. * @param name Define the name of the uniform as defined in the shader
  88681. * @param value Define the value to give to the uniform
  88682. * @return the material itself allowing "fluent" like uniform updates
  88683. */
  88684. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88685. /**
  88686. * Set a vec4 in the shader from a Color4.
  88687. * @param name Define the name of the uniform as defined in the shader
  88688. * @param value Define the value to give to the uniform
  88689. * @return the material itself allowing "fluent" like uniform updates
  88690. */
  88691. setColor4(name: string, value: Color4): ShaderMaterial;
  88692. /**
  88693. * Set a vec4 array in the shader from a Color4 array.
  88694. * @param name Define the name of the uniform as defined in the shader
  88695. * @param value Define the value to give to the uniform
  88696. * @return the material itself allowing "fluent" like uniform updates
  88697. */
  88698. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88699. /**
  88700. * Set a vec2 in the shader from a Vector2.
  88701. * @param name Define the name of the uniform as defined in the shader
  88702. * @param value Define the value to give to the uniform
  88703. * @return the material itself allowing "fluent" like uniform updates
  88704. */
  88705. setVector2(name: string, value: Vector2): ShaderMaterial;
  88706. /**
  88707. * Set a vec3 in the shader from a Vector3.
  88708. * @param name Define the name of the uniform as defined in the shader
  88709. * @param value Define the value to give to the uniform
  88710. * @return the material itself allowing "fluent" like uniform updates
  88711. */
  88712. setVector3(name: string, value: Vector3): ShaderMaterial;
  88713. /**
  88714. * Set a vec4 in the shader from a Vector4.
  88715. * @param name Define the name of the uniform as defined in the shader
  88716. * @param value Define the value to give to the uniform
  88717. * @return the material itself allowing "fluent" like uniform updates
  88718. */
  88719. setVector4(name: string, value: Vector4): ShaderMaterial;
  88720. /**
  88721. * Set a mat4 in the shader from a Matrix.
  88722. * @param name Define the name of the uniform as defined in the shader
  88723. * @param value Define the value to give to the uniform
  88724. * @return the material itself allowing "fluent" like uniform updates
  88725. */
  88726. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88727. /**
  88728. * Set a float32Array in the shader from a matrix array.
  88729. * @param name Define the name of the uniform as defined in the shader
  88730. * @param value Define the value to give to the uniform
  88731. * @return the material itself allowing "fluent" like uniform updates
  88732. */
  88733. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88734. /**
  88735. * Set a mat3 in the shader from a Float32Array.
  88736. * @param name Define the name of the uniform as defined in the shader
  88737. * @param value Define the value to give to the uniform
  88738. * @return the material itself allowing "fluent" like uniform updates
  88739. */
  88740. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88741. /**
  88742. * Set a mat2 in the shader from a Float32Array.
  88743. * @param name Define the name of the uniform as defined in the shader
  88744. * @param value Define the value to give to the uniform
  88745. * @return the material itself allowing "fluent" like uniform updates
  88746. */
  88747. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88748. /**
  88749. * Set a vec2 array in the shader from a number array.
  88750. * @param name Define the name of the uniform as defined in the shader
  88751. * @param value Define the value to give to the uniform
  88752. * @return the material itself allowing "fluent" like uniform updates
  88753. */
  88754. setArray2(name: string, value: number[]): ShaderMaterial;
  88755. /**
  88756. * Set a vec3 array in the shader from a number array.
  88757. * @param name Define the name of the uniform as defined in the shader
  88758. * @param value Define the value to give to the uniform
  88759. * @return the material itself allowing "fluent" like uniform updates
  88760. */
  88761. setArray3(name: string, value: number[]): ShaderMaterial;
  88762. /**
  88763. * Set a vec4 array in the shader from a number array.
  88764. * @param name Define the name of the uniform as defined in the shader
  88765. * @param value Define the value to give to the uniform
  88766. * @return the material itself allowing "fluent" like uniform updates
  88767. */
  88768. setArray4(name: string, value: number[]): ShaderMaterial;
  88769. private _checkCache;
  88770. /**
  88771. * Specifies that the submesh is ready to be used
  88772. * @param mesh defines the mesh to check
  88773. * @param subMesh defines which submesh to check
  88774. * @param useInstances specifies that instances should be used
  88775. * @returns a boolean indicating that the submesh is ready or not
  88776. */
  88777. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88778. /**
  88779. * Checks if the material is ready to render the requested mesh
  88780. * @param mesh Define the mesh to render
  88781. * @param useInstances Define whether or not the material is used with instances
  88782. * @returns true if ready, otherwise false
  88783. */
  88784. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88785. /**
  88786. * Binds the world matrix to the material
  88787. * @param world defines the world transformation matrix
  88788. */
  88789. bindOnlyWorldMatrix(world: Matrix): void;
  88790. /**
  88791. * Binds the material to the mesh
  88792. * @param world defines the world transformation matrix
  88793. * @param mesh defines the mesh to bind the material to
  88794. */
  88795. bind(world: Matrix, mesh?: Mesh): void;
  88796. /**
  88797. * Gets the active textures from the material
  88798. * @returns an array of textures
  88799. */
  88800. getActiveTextures(): BaseTexture[];
  88801. /**
  88802. * Specifies if the material uses a texture
  88803. * @param texture defines the texture to check against the material
  88804. * @returns a boolean specifying if the material uses the texture
  88805. */
  88806. hasTexture(texture: BaseTexture): boolean;
  88807. /**
  88808. * Makes a duplicate of the material, and gives it a new name
  88809. * @param name defines the new name for the duplicated material
  88810. * @returns the cloned material
  88811. */
  88812. clone(name: string): ShaderMaterial;
  88813. /**
  88814. * Disposes the material
  88815. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88816. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88817. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88818. */
  88819. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88820. /**
  88821. * Serializes this material in a JSON representation
  88822. * @returns the serialized material object
  88823. */
  88824. serialize(): any;
  88825. /**
  88826. * Creates a shader material from parsed shader material data
  88827. * @param source defines the JSON represnetation of the material
  88828. * @param scene defines the hosting scene
  88829. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88830. * @returns a new material
  88831. */
  88832. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88833. }
  88834. }
  88835. declare module BABYLON {
  88836. /** @hidden */
  88837. export var colorPixelShader: {
  88838. name: string;
  88839. shader: string;
  88840. };
  88841. }
  88842. declare module BABYLON {
  88843. /** @hidden */
  88844. export var colorVertexShader: {
  88845. name: string;
  88846. shader: string;
  88847. };
  88848. }
  88849. declare module BABYLON {
  88850. /**
  88851. * Line mesh
  88852. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88853. */
  88854. export class LinesMesh extends Mesh {
  88855. /**
  88856. * If vertex color should be applied to the mesh
  88857. */
  88858. readonly useVertexColor?: boolean | undefined;
  88859. /**
  88860. * If vertex alpha should be applied to the mesh
  88861. */
  88862. readonly useVertexAlpha?: boolean | undefined;
  88863. /**
  88864. * Color of the line (Default: White)
  88865. */
  88866. color: Color3;
  88867. /**
  88868. * Alpha of the line (Default: 1)
  88869. */
  88870. alpha: number;
  88871. /**
  88872. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88873. * This margin is expressed in world space coordinates, so its value may vary.
  88874. * Default value is 0.1
  88875. */
  88876. intersectionThreshold: number;
  88877. private _colorShader;
  88878. private color4;
  88879. /**
  88880. * Creates a new LinesMesh
  88881. * @param name defines the name
  88882. * @param scene defines the hosting scene
  88883. * @param parent defines the parent mesh if any
  88884. * @param source defines the optional source LinesMesh used to clone data from
  88885. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88886. * When false, achieved by calling a clone(), also passing False.
  88887. * This will make creation of children, recursive.
  88888. * @param useVertexColor defines if this LinesMesh supports vertex color
  88889. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88890. */
  88891. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88892. /**
  88893. * If vertex color should be applied to the mesh
  88894. */
  88895. useVertexColor?: boolean | undefined,
  88896. /**
  88897. * If vertex alpha should be applied to the mesh
  88898. */
  88899. useVertexAlpha?: boolean | undefined);
  88900. private _addClipPlaneDefine;
  88901. private _removeClipPlaneDefine;
  88902. isReady(): boolean;
  88903. /**
  88904. * Returns the string "LineMesh"
  88905. */
  88906. getClassName(): string;
  88907. /**
  88908. * @hidden
  88909. */
  88910. get material(): Material;
  88911. /**
  88912. * @hidden
  88913. */
  88914. set material(value: Material);
  88915. /**
  88916. * @hidden
  88917. */
  88918. get checkCollisions(): boolean;
  88919. /** @hidden */
  88920. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88921. /** @hidden */
  88922. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88923. /**
  88924. * Disposes of the line mesh
  88925. * @param doNotRecurse If children should be disposed
  88926. */
  88927. dispose(doNotRecurse?: boolean): void;
  88928. /**
  88929. * Returns a new LineMesh object cloned from the current one.
  88930. */
  88931. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  88932. /**
  88933. * Creates a new InstancedLinesMesh object from the mesh model.
  88934. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88935. * @param name defines the name of the new instance
  88936. * @returns a new InstancedLinesMesh
  88937. */
  88938. createInstance(name: string): InstancedLinesMesh;
  88939. }
  88940. /**
  88941. * Creates an instance based on a source LinesMesh
  88942. */
  88943. export class InstancedLinesMesh extends InstancedMesh {
  88944. /**
  88945. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88946. * This margin is expressed in world space coordinates, so its value may vary.
  88947. * Initilized with the intersectionThreshold value of the source LinesMesh
  88948. */
  88949. intersectionThreshold: number;
  88950. constructor(name: string, source: LinesMesh);
  88951. /**
  88952. * Returns the string "InstancedLinesMesh".
  88953. */
  88954. getClassName(): string;
  88955. }
  88956. }
  88957. declare module BABYLON {
  88958. /** @hidden */
  88959. export var linePixelShader: {
  88960. name: string;
  88961. shader: string;
  88962. };
  88963. }
  88964. declare module BABYLON {
  88965. /** @hidden */
  88966. export var lineVertexShader: {
  88967. name: string;
  88968. shader: string;
  88969. };
  88970. }
  88971. declare module BABYLON {
  88972. interface AbstractMesh {
  88973. /**
  88974. * Gets the edgesRenderer associated with the mesh
  88975. */
  88976. edgesRenderer: Nullable<EdgesRenderer>;
  88977. }
  88978. interface LinesMesh {
  88979. /**
  88980. * Enables the edge rendering mode on the mesh.
  88981. * This mode makes the mesh edges visible
  88982. * @param epsilon defines the maximal distance between two angles to detect a face
  88983. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88984. * @returns the currentAbstractMesh
  88985. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88986. */
  88987. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88988. }
  88989. interface InstancedLinesMesh {
  88990. /**
  88991. * Enables the edge rendering mode on the mesh.
  88992. * This mode makes the mesh edges visible
  88993. * @param epsilon defines the maximal distance between two angles to detect a face
  88994. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88995. * @returns the current InstancedLinesMesh
  88996. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88997. */
  88998. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  88999. }
  89000. /**
  89001. * Defines the minimum contract an Edges renderer should follow.
  89002. */
  89003. export interface IEdgesRenderer extends IDisposable {
  89004. /**
  89005. * Gets or sets a boolean indicating if the edgesRenderer is active
  89006. */
  89007. isEnabled: boolean;
  89008. /**
  89009. * Renders the edges of the attached mesh,
  89010. */
  89011. render(): void;
  89012. /**
  89013. * Checks wether or not the edges renderer is ready to render.
  89014. * @return true if ready, otherwise false.
  89015. */
  89016. isReady(): boolean;
  89017. }
  89018. /**
  89019. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  89020. */
  89021. export class EdgesRenderer implements IEdgesRenderer {
  89022. /**
  89023. * Define the size of the edges with an orthographic camera
  89024. */
  89025. edgesWidthScalerForOrthographic: number;
  89026. /**
  89027. * Define the size of the edges with a perspective camera
  89028. */
  89029. edgesWidthScalerForPerspective: number;
  89030. protected _source: AbstractMesh;
  89031. protected _linesPositions: number[];
  89032. protected _linesNormals: number[];
  89033. protected _linesIndices: number[];
  89034. protected _epsilon: number;
  89035. protected _indicesCount: number;
  89036. protected _lineShader: ShaderMaterial;
  89037. protected _ib: DataBuffer;
  89038. protected _buffers: {
  89039. [key: string]: Nullable<VertexBuffer>;
  89040. };
  89041. protected _checkVerticesInsteadOfIndices: boolean;
  89042. private _meshRebuildObserver;
  89043. private _meshDisposeObserver;
  89044. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  89045. isEnabled: boolean;
  89046. /**
  89047. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  89048. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  89049. * @param source Mesh used to create edges
  89050. * @param epsilon sum of angles in adjacency to check for edge
  89051. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  89052. * @param generateEdgesLines - should generate Lines or only prepare resources.
  89053. */
  89054. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  89055. protected _prepareRessources(): void;
  89056. /** @hidden */
  89057. _rebuild(): void;
  89058. /**
  89059. * Releases the required resources for the edges renderer
  89060. */
  89061. dispose(): void;
  89062. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  89063. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  89064. /**
  89065. * Checks if the pair of p0 and p1 is en edge
  89066. * @param faceIndex
  89067. * @param edge
  89068. * @param faceNormals
  89069. * @param p0
  89070. * @param p1
  89071. * @private
  89072. */
  89073. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  89074. /**
  89075. * push line into the position, normal and index buffer
  89076. * @protected
  89077. */
  89078. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  89079. /**
  89080. * Generates lines edges from adjacencjes
  89081. * @private
  89082. */
  89083. _generateEdgesLines(): void;
  89084. /**
  89085. * Checks wether or not the edges renderer is ready to render.
  89086. * @return true if ready, otherwise false.
  89087. */
  89088. isReady(): boolean;
  89089. /**
  89090. * Renders the edges of the attached mesh,
  89091. */
  89092. render(): void;
  89093. }
  89094. /**
  89095. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89096. */
  89097. export class LineEdgesRenderer extends EdgesRenderer {
  89098. /**
  89099. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89100. * @param source LineMesh used to generate edges
  89101. * @param epsilon not important (specified angle for edge detection)
  89102. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89103. */
  89104. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89105. /**
  89106. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89107. */
  89108. _generateEdgesLines(): void;
  89109. }
  89110. }
  89111. declare module BABYLON {
  89112. /**
  89113. * This represents the object necessary to create a rendering group.
  89114. * This is exclusively used and created by the rendering manager.
  89115. * To modify the behavior, you use the available helpers in your scene or meshes.
  89116. * @hidden
  89117. */
  89118. export class RenderingGroup {
  89119. index: number;
  89120. private static _zeroVector;
  89121. private _scene;
  89122. private _opaqueSubMeshes;
  89123. private _transparentSubMeshes;
  89124. private _alphaTestSubMeshes;
  89125. private _depthOnlySubMeshes;
  89126. private _particleSystems;
  89127. private _spriteManagers;
  89128. private _opaqueSortCompareFn;
  89129. private _alphaTestSortCompareFn;
  89130. private _transparentSortCompareFn;
  89131. private _renderOpaque;
  89132. private _renderAlphaTest;
  89133. private _renderTransparent;
  89134. /** @hidden */
  89135. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89136. onBeforeTransparentRendering: () => void;
  89137. /**
  89138. * Set the opaque sort comparison function.
  89139. * If null the sub meshes will be render in the order they were created
  89140. */
  89141. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89142. /**
  89143. * Set the alpha test sort comparison function.
  89144. * If null the sub meshes will be render in the order they were created
  89145. */
  89146. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89147. /**
  89148. * Set the transparent sort comparison function.
  89149. * If null the sub meshes will be render in the order they were created
  89150. */
  89151. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89152. /**
  89153. * Creates a new rendering group.
  89154. * @param index The rendering group index
  89155. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89156. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89157. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89158. */
  89159. 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>);
  89160. /**
  89161. * Render all the sub meshes contained in the group.
  89162. * @param customRenderFunction Used to override the default render behaviour of the group.
  89163. * @returns true if rendered some submeshes.
  89164. */
  89165. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89166. /**
  89167. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89168. * @param subMeshes The submeshes to render
  89169. */
  89170. private renderOpaqueSorted;
  89171. /**
  89172. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89173. * @param subMeshes The submeshes to render
  89174. */
  89175. private renderAlphaTestSorted;
  89176. /**
  89177. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89178. * @param subMeshes The submeshes to render
  89179. */
  89180. private renderTransparentSorted;
  89181. /**
  89182. * Renders the submeshes in a specified order.
  89183. * @param subMeshes The submeshes to sort before render
  89184. * @param sortCompareFn The comparison function use to sort
  89185. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89186. * @param transparent Specifies to activate blending if true
  89187. */
  89188. private static renderSorted;
  89189. /**
  89190. * Renders the submeshes in the order they were dispatched (no sort applied).
  89191. * @param subMeshes The submeshes to render
  89192. */
  89193. private static renderUnsorted;
  89194. /**
  89195. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89196. * are rendered back to front if in the same alpha index.
  89197. *
  89198. * @param a The first submesh
  89199. * @param b The second submesh
  89200. * @returns The result of the comparison
  89201. */
  89202. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89203. /**
  89204. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89205. * are rendered back to front.
  89206. *
  89207. * @param a The first submesh
  89208. * @param b The second submesh
  89209. * @returns The result of the comparison
  89210. */
  89211. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89212. /**
  89213. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89214. * are rendered front to back (prevent overdraw).
  89215. *
  89216. * @param a The first submesh
  89217. * @param b The second submesh
  89218. * @returns The result of the comparison
  89219. */
  89220. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89221. /**
  89222. * Resets the different lists of submeshes to prepare a new frame.
  89223. */
  89224. prepare(): void;
  89225. dispose(): void;
  89226. /**
  89227. * Inserts the submesh in its correct queue depending on its material.
  89228. * @param subMesh The submesh to dispatch
  89229. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89230. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89231. */
  89232. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89233. dispatchSprites(spriteManager: ISpriteManager): void;
  89234. dispatchParticles(particleSystem: IParticleSystem): void;
  89235. private _renderParticles;
  89236. private _renderSprites;
  89237. }
  89238. }
  89239. declare module BABYLON {
  89240. /**
  89241. * Interface describing the different options available in the rendering manager
  89242. * regarding Auto Clear between groups.
  89243. */
  89244. export interface IRenderingManagerAutoClearSetup {
  89245. /**
  89246. * Defines whether or not autoclear is enable.
  89247. */
  89248. autoClear: boolean;
  89249. /**
  89250. * Defines whether or not to autoclear the depth buffer.
  89251. */
  89252. depth: boolean;
  89253. /**
  89254. * Defines whether or not to autoclear the stencil buffer.
  89255. */
  89256. stencil: boolean;
  89257. }
  89258. /**
  89259. * This class is used by the onRenderingGroupObservable
  89260. */
  89261. export class RenderingGroupInfo {
  89262. /**
  89263. * The Scene that being rendered
  89264. */
  89265. scene: Scene;
  89266. /**
  89267. * The camera currently used for the rendering pass
  89268. */
  89269. camera: Nullable<Camera>;
  89270. /**
  89271. * The ID of the renderingGroup being processed
  89272. */
  89273. renderingGroupId: number;
  89274. }
  89275. /**
  89276. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89277. * It is enable to manage the different groups as well as the different necessary sort functions.
  89278. * This should not be used directly aside of the few static configurations
  89279. */
  89280. export class RenderingManager {
  89281. /**
  89282. * The max id used for rendering groups (not included)
  89283. */
  89284. static MAX_RENDERINGGROUPS: number;
  89285. /**
  89286. * The min id used for rendering groups (included)
  89287. */
  89288. static MIN_RENDERINGGROUPS: number;
  89289. /**
  89290. * Used to globally prevent autoclearing scenes.
  89291. */
  89292. static AUTOCLEAR: boolean;
  89293. /**
  89294. * @hidden
  89295. */
  89296. _useSceneAutoClearSetup: boolean;
  89297. private _scene;
  89298. private _renderingGroups;
  89299. private _depthStencilBufferAlreadyCleaned;
  89300. private _autoClearDepthStencil;
  89301. private _customOpaqueSortCompareFn;
  89302. private _customAlphaTestSortCompareFn;
  89303. private _customTransparentSortCompareFn;
  89304. private _renderingGroupInfo;
  89305. /**
  89306. * Instantiates a new rendering group for a particular scene
  89307. * @param scene Defines the scene the groups belongs to
  89308. */
  89309. constructor(scene: Scene);
  89310. private _clearDepthStencilBuffer;
  89311. /**
  89312. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89313. * @hidden
  89314. */
  89315. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89316. /**
  89317. * Resets the different information of the group to prepare a new frame
  89318. * @hidden
  89319. */
  89320. reset(): void;
  89321. /**
  89322. * Dispose and release the group and its associated resources.
  89323. * @hidden
  89324. */
  89325. dispose(): void;
  89326. /**
  89327. * Clear the info related to rendering groups preventing retention points during dispose.
  89328. */
  89329. freeRenderingGroups(): void;
  89330. private _prepareRenderingGroup;
  89331. /**
  89332. * Add a sprite manager to the rendering manager in order to render it this frame.
  89333. * @param spriteManager Define the sprite manager to render
  89334. */
  89335. dispatchSprites(spriteManager: ISpriteManager): void;
  89336. /**
  89337. * Add a particle system to the rendering manager in order to render it this frame.
  89338. * @param particleSystem Define the particle system to render
  89339. */
  89340. dispatchParticles(particleSystem: IParticleSystem): void;
  89341. /**
  89342. * Add a submesh to the manager in order to render it this frame
  89343. * @param subMesh The submesh to dispatch
  89344. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89345. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89346. */
  89347. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89348. /**
  89349. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89350. * This allowed control for front to back rendering or reversly depending of the special needs.
  89351. *
  89352. * @param renderingGroupId The rendering group id corresponding to its index
  89353. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89354. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89355. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89356. */
  89357. 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;
  89358. /**
  89359. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89360. *
  89361. * @param renderingGroupId The rendering group id corresponding to its index
  89362. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89363. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89364. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89365. */
  89366. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89367. /**
  89368. * Gets the current auto clear configuration for one rendering group of the rendering
  89369. * manager.
  89370. * @param index the rendering group index to get the information for
  89371. * @returns The auto clear setup for the requested rendering group
  89372. */
  89373. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89374. }
  89375. }
  89376. declare module BABYLON {
  89377. /**
  89378. * Defines the options associated with the creation of a custom shader for a shadow generator.
  89379. */
  89380. export interface ICustomShaderOptions {
  89381. /**
  89382. * Gets or sets the custom shader name to use
  89383. */
  89384. shaderName: string;
  89385. /**
  89386. * The list of attribute names used in the shader
  89387. */
  89388. attributes?: string[];
  89389. /**
  89390. * The list of unifrom names used in the shader
  89391. */
  89392. uniforms?: string[];
  89393. /**
  89394. * The list of sampler names used in the shader
  89395. */
  89396. samplers?: string[];
  89397. /**
  89398. * The list of defines used in the shader
  89399. */
  89400. defines?: string[];
  89401. }
  89402. /**
  89403. * Interface to implement to create a shadow generator compatible with BJS.
  89404. */
  89405. export interface IShadowGenerator {
  89406. /**
  89407. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89408. * @returns The render target texture if present otherwise, null
  89409. */
  89410. getShadowMap(): Nullable<RenderTargetTexture>;
  89411. /**
  89412. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89413. * @param subMesh The submesh we want to render in the shadow map
  89414. * @param useInstances Defines wether will draw in the map using instances
  89415. * @returns true if ready otherwise, false
  89416. */
  89417. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89418. /**
  89419. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89420. * @param defines Defines of the material we want to update
  89421. * @param lightIndex Index of the light in the enabled light list of the material
  89422. */
  89423. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  89424. /**
  89425. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89426. * defined in the generator but impacting the effect).
  89427. * It implies the unifroms available on the materials are the standard BJS ones.
  89428. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89429. * @param effect The effect we are binfing the information for
  89430. */
  89431. bindShadowLight(lightIndex: string, effect: Effect): void;
  89432. /**
  89433. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89434. * (eq to shadow prjection matrix * light transform matrix)
  89435. * @returns The transform matrix used to create the shadow map
  89436. */
  89437. getTransformMatrix(): Matrix;
  89438. /**
  89439. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89440. * Cube and 2D textures for instance.
  89441. */
  89442. recreateShadowMap(): void;
  89443. /**
  89444. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89445. * @param onCompiled Callback triggered at the and of the effects compilation
  89446. * @param options Sets of optional options forcing the compilation with different modes
  89447. */
  89448. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89449. useInstances: boolean;
  89450. }>): void;
  89451. /**
  89452. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89453. * @param options Sets of optional options forcing the compilation with different modes
  89454. * @returns A promise that resolves when the compilation completes
  89455. */
  89456. forceCompilationAsync(options?: Partial<{
  89457. useInstances: boolean;
  89458. }>): Promise<void>;
  89459. /**
  89460. * Serializes the shadow generator setup to a json object.
  89461. * @returns The serialized JSON object
  89462. */
  89463. serialize(): any;
  89464. /**
  89465. * Disposes the Shadow map and related Textures and effects.
  89466. */
  89467. dispose(): void;
  89468. }
  89469. /**
  89470. * Default implementation IShadowGenerator.
  89471. * This is the main object responsible of generating shadows in the framework.
  89472. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  89473. */
  89474. export class ShadowGenerator implements IShadowGenerator {
  89475. /**
  89476. * Name of the shadow generator class
  89477. */
  89478. static CLASSNAME: string;
  89479. /**
  89480. * Shadow generator mode None: no filtering applied.
  89481. */
  89482. static readonly FILTER_NONE: number;
  89483. /**
  89484. * Shadow generator mode ESM: Exponential Shadow Mapping.
  89485. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89486. */
  89487. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  89488. /**
  89489. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  89490. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  89491. */
  89492. static readonly FILTER_POISSONSAMPLING: number;
  89493. /**
  89494. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  89495. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89496. */
  89497. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  89498. /**
  89499. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  89500. * edge artifacts on steep falloff.
  89501. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89502. */
  89503. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  89504. /**
  89505. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  89506. * edge artifacts on steep falloff.
  89507. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89508. */
  89509. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  89510. /**
  89511. * Shadow generator mode PCF: Percentage Closer Filtering
  89512. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89513. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  89514. */
  89515. static readonly FILTER_PCF: number;
  89516. /**
  89517. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  89518. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89519. * Contact Hardening
  89520. */
  89521. static readonly FILTER_PCSS: number;
  89522. /**
  89523. * Reserved for PCF and PCSS
  89524. * Highest Quality.
  89525. *
  89526. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  89527. *
  89528. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  89529. */
  89530. static readonly QUALITY_HIGH: number;
  89531. /**
  89532. * Reserved for PCF and PCSS
  89533. * Good tradeoff for quality/perf cross devices
  89534. *
  89535. * Execute PCF on a 3*3 kernel.
  89536. *
  89537. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  89538. */
  89539. static readonly QUALITY_MEDIUM: number;
  89540. /**
  89541. * Reserved for PCF and PCSS
  89542. * The lowest quality but the fastest.
  89543. *
  89544. * Execute PCF on a 1*1 kernel.
  89545. *
  89546. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  89547. */
  89548. static readonly QUALITY_LOW: number;
  89549. /** Gets or sets the custom shader name to use */
  89550. customShaderOptions: ICustomShaderOptions;
  89551. /**
  89552. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  89553. */
  89554. onBeforeShadowMapRenderObservable: Observable<Effect>;
  89555. /**
  89556. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  89557. */
  89558. onAfterShadowMapRenderObservable: Observable<Effect>;
  89559. /**
  89560. * Observable triggered before a mesh is rendered in the shadow map.
  89561. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  89562. */
  89563. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  89564. /**
  89565. * Observable triggered after a mesh is rendered in the shadow map.
  89566. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  89567. */
  89568. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  89569. protected _bias: number;
  89570. /**
  89571. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  89572. */
  89573. get bias(): number;
  89574. /**
  89575. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  89576. */
  89577. set bias(bias: number);
  89578. protected _normalBias: number;
  89579. /**
  89580. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89581. */
  89582. get normalBias(): number;
  89583. /**
  89584. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89585. */
  89586. set normalBias(normalBias: number);
  89587. protected _blurBoxOffset: number;
  89588. /**
  89589. * Gets the blur box offset: offset applied during the blur pass.
  89590. * Only useful if useKernelBlur = false
  89591. */
  89592. get blurBoxOffset(): number;
  89593. /**
  89594. * Sets the blur box offset: offset applied during the blur pass.
  89595. * Only useful if useKernelBlur = false
  89596. */
  89597. set blurBoxOffset(value: number);
  89598. protected _blurScale: number;
  89599. /**
  89600. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  89601. * 2 means half of the size.
  89602. */
  89603. get blurScale(): number;
  89604. /**
  89605. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  89606. * 2 means half of the size.
  89607. */
  89608. set blurScale(value: number);
  89609. protected _blurKernel: number;
  89610. /**
  89611. * Gets the blur kernel: kernel size of the blur pass.
  89612. * Only useful if useKernelBlur = true
  89613. */
  89614. get blurKernel(): number;
  89615. /**
  89616. * Sets the blur kernel: kernel size of the blur pass.
  89617. * Only useful if useKernelBlur = true
  89618. */
  89619. set blurKernel(value: number);
  89620. protected _useKernelBlur: boolean;
  89621. /**
  89622. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  89623. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89624. */
  89625. get useKernelBlur(): boolean;
  89626. /**
  89627. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  89628. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89629. */
  89630. set useKernelBlur(value: boolean);
  89631. protected _depthScale: number;
  89632. /**
  89633. * Gets the depth scale used in ESM mode.
  89634. */
  89635. get depthScale(): number;
  89636. /**
  89637. * Sets the depth scale used in ESM mode.
  89638. * This can override the scale stored on the light.
  89639. */
  89640. set depthScale(value: number);
  89641. protected _validateFilter(filter: number): number;
  89642. protected _filter: number;
  89643. /**
  89644. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  89645. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89646. */
  89647. get filter(): number;
  89648. /**
  89649. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  89650. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89651. */
  89652. set filter(value: number);
  89653. /**
  89654. * Gets if the current filter is set to Poisson Sampling.
  89655. */
  89656. get usePoissonSampling(): boolean;
  89657. /**
  89658. * Sets the current filter to Poisson Sampling.
  89659. */
  89660. set usePoissonSampling(value: boolean);
  89661. /**
  89662. * Gets if the current filter is set to ESM.
  89663. */
  89664. get useExponentialShadowMap(): boolean;
  89665. /**
  89666. * Sets the current filter is to ESM.
  89667. */
  89668. set useExponentialShadowMap(value: boolean);
  89669. /**
  89670. * Gets if the current filter is set to filtered ESM.
  89671. */
  89672. get useBlurExponentialShadowMap(): boolean;
  89673. /**
  89674. * Gets if the current filter is set to filtered ESM.
  89675. */
  89676. set useBlurExponentialShadowMap(value: boolean);
  89677. /**
  89678. * Gets if the current filter is set to "close ESM" (using the inverse of the
  89679. * exponential to prevent steep falloff artifacts).
  89680. */
  89681. get useCloseExponentialShadowMap(): boolean;
  89682. /**
  89683. * Sets the current filter to "close ESM" (using the inverse of the
  89684. * exponential to prevent steep falloff artifacts).
  89685. */
  89686. set useCloseExponentialShadowMap(value: boolean);
  89687. /**
  89688. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  89689. * exponential to prevent steep falloff artifacts).
  89690. */
  89691. get useBlurCloseExponentialShadowMap(): boolean;
  89692. /**
  89693. * Sets the current filter to filtered "close ESM" (using the inverse of the
  89694. * exponential to prevent steep falloff artifacts).
  89695. */
  89696. set useBlurCloseExponentialShadowMap(value: boolean);
  89697. /**
  89698. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  89699. */
  89700. get usePercentageCloserFiltering(): boolean;
  89701. /**
  89702. * Sets the current filter to "PCF" (percentage closer filtering).
  89703. */
  89704. set usePercentageCloserFiltering(value: boolean);
  89705. protected _filteringQuality: number;
  89706. /**
  89707. * Gets the PCF or PCSS Quality.
  89708. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89709. */
  89710. get filteringQuality(): number;
  89711. /**
  89712. * Sets the PCF or PCSS Quality.
  89713. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89714. */
  89715. set filteringQuality(filteringQuality: number);
  89716. /**
  89717. * Gets if the current filter is set to "PCSS" (contact hardening).
  89718. */
  89719. get useContactHardeningShadow(): boolean;
  89720. /**
  89721. * Sets the current filter to "PCSS" (contact hardening).
  89722. */
  89723. set useContactHardeningShadow(value: boolean);
  89724. protected _contactHardeningLightSizeUVRatio: number;
  89725. /**
  89726. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89727. * Using a ratio helps keeping shape stability independently of the map size.
  89728. *
  89729. * It does not account for the light projection as it was having too much
  89730. * instability during the light setup or during light position changes.
  89731. *
  89732. * Only valid if useContactHardeningShadow is true.
  89733. */
  89734. get contactHardeningLightSizeUVRatio(): number;
  89735. /**
  89736. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89737. * Using a ratio helps keeping shape stability independently of the map size.
  89738. *
  89739. * It does not account for the light projection as it was having too much
  89740. * instability during the light setup or during light position changes.
  89741. *
  89742. * Only valid if useContactHardeningShadow is true.
  89743. */
  89744. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  89745. protected _darkness: number;
  89746. /** Gets or sets the actual darkness of a shadow */
  89747. get darkness(): number;
  89748. set darkness(value: number);
  89749. /**
  89750. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  89751. * 0 means strongest and 1 would means no shadow.
  89752. * @returns the darkness.
  89753. */
  89754. getDarkness(): number;
  89755. /**
  89756. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  89757. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  89758. * @returns the shadow generator allowing fluent coding.
  89759. */
  89760. setDarkness(darkness: number): ShadowGenerator;
  89761. protected _transparencyShadow: boolean;
  89762. /** Gets or sets the ability to have transparent shadow */
  89763. get transparencyShadow(): boolean;
  89764. set transparencyShadow(value: boolean);
  89765. /**
  89766. * Sets the ability to have transparent shadow (boolean).
  89767. * @param transparent True if transparent else False
  89768. * @returns the shadow generator allowing fluent coding
  89769. */
  89770. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  89771. protected _shadowMap: Nullable<RenderTargetTexture>;
  89772. protected _shadowMap2: Nullable<RenderTargetTexture>;
  89773. /**
  89774. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89775. * @returns The render target texture if present otherwise, null
  89776. */
  89777. getShadowMap(): Nullable<RenderTargetTexture>;
  89778. /**
  89779. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  89780. * @returns The render target texture if the shadow map is present otherwise, null
  89781. */
  89782. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  89783. /**
  89784. * Gets the class name of that object
  89785. * @returns "ShadowGenerator"
  89786. */
  89787. getClassName(): string;
  89788. /**
  89789. * Helper function to add a mesh and its descendants to the list of shadow casters.
  89790. * @param mesh Mesh to add
  89791. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  89792. * @returns the Shadow Generator itself
  89793. */
  89794. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89795. /**
  89796. * Helper function to remove a mesh and its descendants from the list of shadow casters
  89797. * @param mesh Mesh to remove
  89798. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  89799. * @returns the Shadow Generator itself
  89800. */
  89801. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89802. /**
  89803. * Controls the extent to which the shadows fade out at the edge of the frustum
  89804. */
  89805. frustumEdgeFalloff: number;
  89806. protected _light: IShadowLight;
  89807. /**
  89808. * Returns the associated light object.
  89809. * @returns the light generating the shadow
  89810. */
  89811. getLight(): IShadowLight;
  89812. /**
  89813. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  89814. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  89815. * It might on the other hand introduce peter panning.
  89816. */
  89817. forceBackFacesOnly: boolean;
  89818. protected _scene: Scene;
  89819. protected _lightDirection: Vector3;
  89820. protected _effect: Effect;
  89821. protected _viewMatrix: Matrix;
  89822. protected _projectionMatrix: Matrix;
  89823. protected _transformMatrix: Matrix;
  89824. protected _cachedPosition: Vector3;
  89825. protected _cachedDirection: Vector3;
  89826. protected _cachedDefines: string;
  89827. protected _currentRenderID: number;
  89828. protected _boxBlurPostprocess: Nullable<PostProcess>;
  89829. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  89830. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  89831. protected _blurPostProcesses: PostProcess[];
  89832. protected _mapSize: number;
  89833. protected _currentFaceIndex: number;
  89834. protected _currentFaceIndexCache: number;
  89835. protected _textureType: number;
  89836. protected _defaultTextureMatrix: Matrix;
  89837. protected _storedUniqueId: Nullable<number>;
  89838. /** @hidden */
  89839. static _SceneComponentInitialization: (scene: Scene) => void;
  89840. /**
  89841. * Creates a ShadowGenerator object.
  89842. * A ShadowGenerator is the required tool to use the shadows.
  89843. * Each light casting shadows needs to use its own ShadowGenerator.
  89844. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  89845. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  89846. * @param light The light object generating the shadows.
  89847. * @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.
  89848. */
  89849. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  89850. protected _initializeGenerator(): void;
  89851. protected _createTargetRenderTexture(): void;
  89852. protected _initializeShadowMap(): void;
  89853. protected _initializeBlurRTTAndPostProcesses(): void;
  89854. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  89855. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  89856. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  89857. protected _applyFilterValues(): void;
  89858. /**
  89859. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89860. * @param onCompiled Callback triggered at the and of the effects compilation
  89861. * @param options Sets of optional options forcing the compilation with different modes
  89862. */
  89863. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89864. useInstances: boolean;
  89865. }>): void;
  89866. /**
  89867. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89868. * @param options Sets of optional options forcing the compilation with different modes
  89869. * @returns A promise that resolves when the compilation completes
  89870. */
  89871. forceCompilationAsync(options?: Partial<{
  89872. useInstances: boolean;
  89873. }>): Promise<void>;
  89874. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  89875. /**
  89876. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89877. * @param subMesh The submesh we want to render in the shadow map
  89878. * @param useInstances Defines wether will draw in the map using instances
  89879. * @returns true if ready otherwise, false
  89880. */
  89881. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89882. /**
  89883. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89884. * @param defines Defines of the material we want to update
  89885. * @param lightIndex Index of the light in the enabled light list of the material
  89886. */
  89887. prepareDefines(defines: any, lightIndex: number): void;
  89888. /**
  89889. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89890. * defined in the generator but impacting the effect).
  89891. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89892. * @param effect The effect we are binfing the information for
  89893. */
  89894. bindShadowLight(lightIndex: string, effect: Effect): void;
  89895. /**
  89896. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89897. * (eq to shadow prjection matrix * light transform matrix)
  89898. * @returns The transform matrix used to create the shadow map
  89899. */
  89900. getTransformMatrix(): Matrix;
  89901. /**
  89902. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89903. * Cube and 2D textures for instance.
  89904. */
  89905. recreateShadowMap(): void;
  89906. protected _disposeBlurPostProcesses(): void;
  89907. protected _disposeRTTandPostProcesses(): void;
  89908. /**
  89909. * Disposes the ShadowGenerator.
  89910. * Returns nothing.
  89911. */
  89912. dispose(): void;
  89913. /**
  89914. * Serializes the shadow generator setup to a json object.
  89915. * @returns The serialized JSON object
  89916. */
  89917. serialize(): any;
  89918. /**
  89919. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  89920. * @param parsedShadowGenerator The JSON object to parse
  89921. * @param scene The scene to create the shadow map for
  89922. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  89923. * @returns The parsed shadow generator
  89924. */
  89925. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  89926. }
  89927. }
  89928. declare module BABYLON {
  89929. /**
  89930. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  89931. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  89932. * 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.
  89933. */
  89934. export abstract class Light extends Node {
  89935. /**
  89936. * Falloff Default: light is falling off following the material specification:
  89937. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  89938. */
  89939. static readonly FALLOFF_DEFAULT: number;
  89940. /**
  89941. * Falloff Physical: light is falling off following the inverse squared distance law.
  89942. */
  89943. static readonly FALLOFF_PHYSICAL: number;
  89944. /**
  89945. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  89946. * to enhance interoperability with other engines.
  89947. */
  89948. static readonly FALLOFF_GLTF: number;
  89949. /**
  89950. * Falloff Standard: light is falling off like in the standard material
  89951. * to enhance interoperability with other materials.
  89952. */
  89953. static readonly FALLOFF_STANDARD: number;
  89954. /**
  89955. * If every light affecting the material is in this lightmapMode,
  89956. * material.lightmapTexture adds or multiplies
  89957. * (depends on material.useLightmapAsShadowmap)
  89958. * after every other light calculations.
  89959. */
  89960. static readonly LIGHTMAP_DEFAULT: number;
  89961. /**
  89962. * material.lightmapTexture as only diffuse lighting from this light
  89963. * adds only specular lighting from this light
  89964. * adds dynamic shadows
  89965. */
  89966. static readonly LIGHTMAP_SPECULAR: number;
  89967. /**
  89968. * material.lightmapTexture as only lighting
  89969. * no light calculation from this light
  89970. * only adds dynamic shadows from this light
  89971. */
  89972. static readonly LIGHTMAP_SHADOWSONLY: number;
  89973. /**
  89974. * Each light type uses the default quantity according to its type:
  89975. * point/spot lights use luminous intensity
  89976. * directional lights use illuminance
  89977. */
  89978. static readonly INTENSITYMODE_AUTOMATIC: number;
  89979. /**
  89980. * lumen (lm)
  89981. */
  89982. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  89983. /**
  89984. * candela (lm/sr)
  89985. */
  89986. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  89987. /**
  89988. * lux (lm/m^2)
  89989. */
  89990. static readonly INTENSITYMODE_ILLUMINANCE: number;
  89991. /**
  89992. * nit (cd/m^2)
  89993. */
  89994. static readonly INTENSITYMODE_LUMINANCE: number;
  89995. /**
  89996. * Light type const id of the point light.
  89997. */
  89998. static readonly LIGHTTYPEID_POINTLIGHT: number;
  89999. /**
  90000. * Light type const id of the directional light.
  90001. */
  90002. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  90003. /**
  90004. * Light type const id of the spot light.
  90005. */
  90006. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  90007. /**
  90008. * Light type const id of the hemispheric light.
  90009. */
  90010. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  90011. /**
  90012. * Diffuse gives the basic color to an object.
  90013. */
  90014. diffuse: Color3;
  90015. /**
  90016. * Specular produces a highlight color on an object.
  90017. * Note: This is note affecting PBR materials.
  90018. */
  90019. specular: Color3;
  90020. /**
  90021. * Defines the falloff type for this light. This lets overrriding how punctual light are
  90022. * falling off base on range or angle.
  90023. * This can be set to any values in Light.FALLOFF_x.
  90024. *
  90025. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  90026. * other types of materials.
  90027. */
  90028. falloffType: number;
  90029. /**
  90030. * Strength of the light.
  90031. * Note: By default it is define in the framework own unit.
  90032. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  90033. */
  90034. intensity: number;
  90035. private _range;
  90036. protected _inverseSquaredRange: number;
  90037. /**
  90038. * Defines how far from the source the light is impacting in scene units.
  90039. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90040. */
  90041. get range(): number;
  90042. /**
  90043. * Defines how far from the source the light is impacting in scene units.
  90044. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90045. */
  90046. set range(value: number);
  90047. /**
  90048. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  90049. * of light.
  90050. */
  90051. private _photometricScale;
  90052. private _intensityMode;
  90053. /**
  90054. * Gets the photometric scale used to interpret the intensity.
  90055. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90056. */
  90057. get intensityMode(): number;
  90058. /**
  90059. * Sets the photometric scale used to interpret the intensity.
  90060. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90061. */
  90062. set intensityMode(value: number);
  90063. private _radius;
  90064. /**
  90065. * Gets the light radius used by PBR Materials to simulate soft area lights.
  90066. */
  90067. get radius(): number;
  90068. /**
  90069. * sets the light radius used by PBR Materials to simulate soft area lights.
  90070. */
  90071. set radius(value: number);
  90072. private _renderPriority;
  90073. /**
  90074. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  90075. * exceeding the number allowed of the materials.
  90076. */
  90077. renderPriority: number;
  90078. private _shadowEnabled;
  90079. /**
  90080. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90081. * the current shadow generator.
  90082. */
  90083. get shadowEnabled(): boolean;
  90084. /**
  90085. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90086. * the current shadow generator.
  90087. */
  90088. set shadowEnabled(value: boolean);
  90089. private _includedOnlyMeshes;
  90090. /**
  90091. * Gets the only meshes impacted by this light.
  90092. */
  90093. get includedOnlyMeshes(): AbstractMesh[];
  90094. /**
  90095. * Sets the only meshes impacted by this light.
  90096. */
  90097. set includedOnlyMeshes(value: AbstractMesh[]);
  90098. private _excludedMeshes;
  90099. /**
  90100. * Gets the meshes not impacted by this light.
  90101. */
  90102. get excludedMeshes(): AbstractMesh[];
  90103. /**
  90104. * Sets the meshes not impacted by this light.
  90105. */
  90106. set excludedMeshes(value: AbstractMesh[]);
  90107. private _excludeWithLayerMask;
  90108. /**
  90109. * Gets the layer id use to find what meshes are not impacted by the light.
  90110. * Inactive if 0
  90111. */
  90112. get excludeWithLayerMask(): number;
  90113. /**
  90114. * Sets the layer id use to find what meshes are not impacted by the light.
  90115. * Inactive if 0
  90116. */
  90117. set excludeWithLayerMask(value: number);
  90118. private _includeOnlyWithLayerMask;
  90119. /**
  90120. * Gets the layer id use to find what meshes are impacted by the light.
  90121. * Inactive if 0
  90122. */
  90123. get includeOnlyWithLayerMask(): number;
  90124. /**
  90125. * Sets the layer id use to find what meshes are impacted by the light.
  90126. * Inactive if 0
  90127. */
  90128. set includeOnlyWithLayerMask(value: number);
  90129. private _lightmapMode;
  90130. /**
  90131. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90132. */
  90133. get lightmapMode(): number;
  90134. /**
  90135. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90136. */
  90137. set lightmapMode(value: number);
  90138. /**
  90139. * Shadow generator associted to the light.
  90140. * @hidden Internal use only.
  90141. */
  90142. _shadowGenerator: Nullable<IShadowGenerator>;
  90143. /**
  90144. * @hidden Internal use only.
  90145. */
  90146. _excludedMeshesIds: string[];
  90147. /**
  90148. * @hidden Internal use only.
  90149. */
  90150. _includedOnlyMeshesIds: string[];
  90151. /**
  90152. * The current light unifom buffer.
  90153. * @hidden Internal use only.
  90154. */
  90155. _uniformBuffer: UniformBuffer;
  90156. /** @hidden */
  90157. _renderId: number;
  90158. /**
  90159. * Creates a Light object in the scene.
  90160. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90161. * @param name The firendly name of the light
  90162. * @param scene The scene the light belongs too
  90163. */
  90164. constructor(name: string, scene: Scene);
  90165. protected abstract _buildUniformLayout(): void;
  90166. /**
  90167. * Sets the passed Effect "effect" with the Light information.
  90168. * @param effect The effect to update
  90169. * @param lightIndex The index of the light in the effect to update
  90170. * @returns The light
  90171. */
  90172. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90173. /**
  90174. * Sets the passed Effect "effect" with the Light textures.
  90175. * @param effect The effect to update
  90176. * @param lightIndex The index of the light in the effect to update
  90177. * @returns The light
  90178. */
  90179. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90180. /**
  90181. * Binds the lights information from the scene to the effect for the given mesh.
  90182. * @param lightIndex Light index
  90183. * @param scene The scene where the light belongs to
  90184. * @param effect The effect we are binding the data to
  90185. * @param useSpecular Defines if specular is supported
  90186. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90187. */
  90188. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90189. /**
  90190. * Sets the passed Effect "effect" with the Light information.
  90191. * @param effect The effect to update
  90192. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90193. * @returns The light
  90194. */
  90195. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90196. /**
  90197. * Returns the string "Light".
  90198. * @returns the class name
  90199. */
  90200. getClassName(): string;
  90201. /** @hidden */
  90202. readonly _isLight: boolean;
  90203. /**
  90204. * Converts the light information to a readable string for debug purpose.
  90205. * @param fullDetails Supports for multiple levels of logging within scene loading
  90206. * @returns the human readable light info
  90207. */
  90208. toString(fullDetails?: boolean): string;
  90209. /** @hidden */
  90210. protected _syncParentEnabledState(): void;
  90211. /**
  90212. * Set the enabled state of this node.
  90213. * @param value - the new enabled state
  90214. */
  90215. setEnabled(value: boolean): void;
  90216. /**
  90217. * Returns the Light associated shadow generator if any.
  90218. * @return the associated shadow generator.
  90219. */
  90220. getShadowGenerator(): Nullable<IShadowGenerator>;
  90221. /**
  90222. * Returns a Vector3, the absolute light position in the World.
  90223. * @returns the world space position of the light
  90224. */
  90225. getAbsolutePosition(): Vector3;
  90226. /**
  90227. * Specifies if the light will affect the passed mesh.
  90228. * @param mesh The mesh to test against the light
  90229. * @return true the mesh is affected otherwise, false.
  90230. */
  90231. canAffectMesh(mesh: AbstractMesh): boolean;
  90232. /**
  90233. * Sort function to order lights for rendering.
  90234. * @param a First Light object to compare to second.
  90235. * @param b Second Light object to compare first.
  90236. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90237. */
  90238. static CompareLightsPriority(a: Light, b: Light): number;
  90239. /**
  90240. * Releases resources associated with this node.
  90241. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90242. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90243. */
  90244. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90245. /**
  90246. * Returns the light type ID (integer).
  90247. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90248. */
  90249. getTypeID(): number;
  90250. /**
  90251. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90252. * @returns the scaled intensity in intensity mode unit
  90253. */
  90254. getScaledIntensity(): number;
  90255. /**
  90256. * Returns a new Light object, named "name", from the current one.
  90257. * @param name The name of the cloned light
  90258. * @returns the new created light
  90259. */
  90260. clone(name: string): Nullable<Light>;
  90261. /**
  90262. * Serializes the current light into a Serialization object.
  90263. * @returns the serialized object.
  90264. */
  90265. serialize(): any;
  90266. /**
  90267. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90268. * This new light is named "name" and added to the passed scene.
  90269. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90270. * @param name The friendly name of the light
  90271. * @param scene The scene the new light will belong to
  90272. * @returns the constructor function
  90273. */
  90274. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90275. /**
  90276. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90277. * @param parsedLight The JSON representation of the light
  90278. * @param scene The scene to create the parsed light in
  90279. * @returns the created light after parsing
  90280. */
  90281. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90282. private _hookArrayForExcluded;
  90283. private _hookArrayForIncludedOnly;
  90284. private _resyncMeshes;
  90285. /**
  90286. * Forces the meshes to update their light related information in their rendering used effects
  90287. * @hidden Internal Use Only
  90288. */
  90289. _markMeshesAsLightDirty(): void;
  90290. /**
  90291. * Recomputes the cached photometric scale if needed.
  90292. */
  90293. private _computePhotometricScale;
  90294. /**
  90295. * Returns the Photometric Scale according to the light type and intensity mode.
  90296. */
  90297. private _getPhotometricScale;
  90298. /**
  90299. * Reorder the light in the scene according to their defined priority.
  90300. * @hidden Internal Use Only
  90301. */
  90302. _reorderLightsInScene(): void;
  90303. /**
  90304. * Prepares the list of defines specific to the light type.
  90305. * @param defines the list of defines
  90306. * @param lightIndex defines the index of the light for the effect
  90307. */
  90308. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90309. }
  90310. }
  90311. declare module BABYLON {
  90312. /**
  90313. * Interface used to define Action
  90314. */
  90315. export interface IAction {
  90316. /**
  90317. * Trigger for the action
  90318. */
  90319. trigger: number;
  90320. /** Options of the trigger */
  90321. triggerOptions: any;
  90322. /**
  90323. * Gets the trigger parameters
  90324. * @returns the trigger parameters
  90325. */
  90326. getTriggerParameter(): any;
  90327. /**
  90328. * Internal only - executes current action event
  90329. * @hidden
  90330. */
  90331. _executeCurrent(evt?: ActionEvent): void;
  90332. /**
  90333. * Serialize placeholder for child classes
  90334. * @param parent of child
  90335. * @returns the serialized object
  90336. */
  90337. serialize(parent: any): any;
  90338. /**
  90339. * Internal only
  90340. * @hidden
  90341. */
  90342. _prepare(): void;
  90343. /**
  90344. * Internal only - manager for action
  90345. * @hidden
  90346. */
  90347. _actionManager: AbstractActionManager;
  90348. /**
  90349. * Adds action to chain of actions, may be a DoNothingAction
  90350. * @param action defines the next action to execute
  90351. * @returns The action passed in
  90352. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90353. */
  90354. then(action: IAction): IAction;
  90355. }
  90356. /**
  90357. * The action to be carried out following a trigger
  90358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90359. */
  90360. export class Action implements IAction {
  90361. /** the trigger, with or without parameters, for the action */
  90362. triggerOptions: any;
  90363. /**
  90364. * Trigger for the action
  90365. */
  90366. trigger: number;
  90367. /**
  90368. * Internal only - manager for action
  90369. * @hidden
  90370. */
  90371. _actionManager: ActionManager;
  90372. private _nextActiveAction;
  90373. private _child;
  90374. private _condition?;
  90375. private _triggerParameter;
  90376. /**
  90377. * An event triggered prior to action being executed.
  90378. */
  90379. onBeforeExecuteObservable: Observable<Action>;
  90380. /**
  90381. * Creates a new Action
  90382. * @param triggerOptions the trigger, with or without parameters, for the action
  90383. * @param condition an optional determinant of action
  90384. */
  90385. constructor(
  90386. /** the trigger, with or without parameters, for the action */
  90387. triggerOptions: any, condition?: Condition);
  90388. /**
  90389. * Internal only
  90390. * @hidden
  90391. */
  90392. _prepare(): void;
  90393. /**
  90394. * Gets the trigger parameters
  90395. * @returns the trigger parameters
  90396. */
  90397. getTriggerParameter(): any;
  90398. /**
  90399. * Internal only - executes current action event
  90400. * @hidden
  90401. */
  90402. _executeCurrent(evt?: ActionEvent): void;
  90403. /**
  90404. * Execute placeholder for child classes
  90405. * @param evt optional action event
  90406. */
  90407. execute(evt?: ActionEvent): void;
  90408. /**
  90409. * Skips to next active action
  90410. */
  90411. skipToNextActiveAction(): void;
  90412. /**
  90413. * Adds action to chain of actions, may be a DoNothingAction
  90414. * @param action defines the next action to execute
  90415. * @returns The action passed in
  90416. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90417. */
  90418. then(action: Action): Action;
  90419. /**
  90420. * Internal only
  90421. * @hidden
  90422. */
  90423. _getProperty(propertyPath: string): string;
  90424. /**
  90425. * Internal only
  90426. * @hidden
  90427. */
  90428. _getEffectiveTarget(target: any, propertyPath: string): any;
  90429. /**
  90430. * Serialize placeholder for child classes
  90431. * @param parent of child
  90432. * @returns the serialized object
  90433. */
  90434. serialize(parent: any): any;
  90435. /**
  90436. * Internal only called by serialize
  90437. * @hidden
  90438. */
  90439. protected _serialize(serializedAction: any, parent?: any): any;
  90440. /**
  90441. * Internal only
  90442. * @hidden
  90443. */
  90444. static _SerializeValueAsString: (value: any) => string;
  90445. /**
  90446. * Internal only
  90447. * @hidden
  90448. */
  90449. static _GetTargetProperty: (target: Node | Scene) => {
  90450. name: string;
  90451. targetType: string;
  90452. value: string;
  90453. };
  90454. }
  90455. }
  90456. declare module BABYLON {
  90457. /**
  90458. * A Condition applied to an Action
  90459. */
  90460. export class Condition {
  90461. /**
  90462. * Internal only - manager for action
  90463. * @hidden
  90464. */
  90465. _actionManager: ActionManager;
  90466. /**
  90467. * Internal only
  90468. * @hidden
  90469. */
  90470. _evaluationId: number;
  90471. /**
  90472. * Internal only
  90473. * @hidden
  90474. */
  90475. _currentResult: boolean;
  90476. /**
  90477. * Creates a new Condition
  90478. * @param actionManager the manager of the action the condition is applied to
  90479. */
  90480. constructor(actionManager: ActionManager);
  90481. /**
  90482. * Check if the current condition is valid
  90483. * @returns a boolean
  90484. */
  90485. isValid(): boolean;
  90486. /**
  90487. * Internal only
  90488. * @hidden
  90489. */
  90490. _getProperty(propertyPath: string): string;
  90491. /**
  90492. * Internal only
  90493. * @hidden
  90494. */
  90495. _getEffectiveTarget(target: any, propertyPath: string): any;
  90496. /**
  90497. * Serialize placeholder for child classes
  90498. * @returns the serialized object
  90499. */
  90500. serialize(): any;
  90501. /**
  90502. * Internal only
  90503. * @hidden
  90504. */
  90505. protected _serialize(serializedCondition: any): any;
  90506. }
  90507. /**
  90508. * Defines specific conditional operators as extensions of Condition
  90509. */
  90510. export class ValueCondition extends Condition {
  90511. /** path to specify the property of the target the conditional operator uses */
  90512. propertyPath: string;
  90513. /** the value compared by the conditional operator against the current value of the property */
  90514. value: any;
  90515. /** the conditional operator, default ValueCondition.IsEqual */
  90516. operator: number;
  90517. /**
  90518. * Internal only
  90519. * @hidden
  90520. */
  90521. private static _IsEqual;
  90522. /**
  90523. * Internal only
  90524. * @hidden
  90525. */
  90526. private static _IsDifferent;
  90527. /**
  90528. * Internal only
  90529. * @hidden
  90530. */
  90531. private static _IsGreater;
  90532. /**
  90533. * Internal only
  90534. * @hidden
  90535. */
  90536. private static _IsLesser;
  90537. /**
  90538. * returns the number for IsEqual
  90539. */
  90540. static get IsEqual(): number;
  90541. /**
  90542. * Returns the number for IsDifferent
  90543. */
  90544. static get IsDifferent(): number;
  90545. /**
  90546. * Returns the number for IsGreater
  90547. */
  90548. static get IsGreater(): number;
  90549. /**
  90550. * Returns the number for IsLesser
  90551. */
  90552. static get IsLesser(): number;
  90553. /**
  90554. * Internal only The action manager for the condition
  90555. * @hidden
  90556. */
  90557. _actionManager: ActionManager;
  90558. /**
  90559. * Internal only
  90560. * @hidden
  90561. */
  90562. private _target;
  90563. /**
  90564. * Internal only
  90565. * @hidden
  90566. */
  90567. private _effectiveTarget;
  90568. /**
  90569. * Internal only
  90570. * @hidden
  90571. */
  90572. private _property;
  90573. /**
  90574. * Creates a new ValueCondition
  90575. * @param actionManager manager for the action the condition applies to
  90576. * @param target for the action
  90577. * @param propertyPath path to specify the property of the target the conditional operator uses
  90578. * @param value the value compared by the conditional operator against the current value of the property
  90579. * @param operator the conditional operator, default ValueCondition.IsEqual
  90580. */
  90581. constructor(actionManager: ActionManager, target: any,
  90582. /** path to specify the property of the target the conditional operator uses */
  90583. propertyPath: string,
  90584. /** the value compared by the conditional operator against the current value of the property */
  90585. value: any,
  90586. /** the conditional operator, default ValueCondition.IsEqual */
  90587. operator?: number);
  90588. /**
  90589. * Compares the given value with the property value for the specified conditional operator
  90590. * @returns the result of the comparison
  90591. */
  90592. isValid(): boolean;
  90593. /**
  90594. * Serialize the ValueCondition into a JSON compatible object
  90595. * @returns serialization object
  90596. */
  90597. serialize(): any;
  90598. /**
  90599. * Gets the name of the conditional operator for the ValueCondition
  90600. * @param operator the conditional operator
  90601. * @returns the name
  90602. */
  90603. static GetOperatorName(operator: number): string;
  90604. }
  90605. /**
  90606. * Defines a predicate condition as an extension of Condition
  90607. */
  90608. export class PredicateCondition extends Condition {
  90609. /** defines the predicate function used to validate the condition */
  90610. predicate: () => boolean;
  90611. /**
  90612. * Internal only - manager for action
  90613. * @hidden
  90614. */
  90615. _actionManager: ActionManager;
  90616. /**
  90617. * Creates a new PredicateCondition
  90618. * @param actionManager manager for the action the condition applies to
  90619. * @param predicate defines the predicate function used to validate the condition
  90620. */
  90621. constructor(actionManager: ActionManager,
  90622. /** defines the predicate function used to validate the condition */
  90623. predicate: () => boolean);
  90624. /**
  90625. * @returns the validity of the predicate condition
  90626. */
  90627. isValid(): boolean;
  90628. }
  90629. /**
  90630. * Defines a state condition as an extension of Condition
  90631. */
  90632. export class StateCondition extends Condition {
  90633. /** Value to compare with target state */
  90634. value: string;
  90635. /**
  90636. * Internal only - manager for action
  90637. * @hidden
  90638. */
  90639. _actionManager: ActionManager;
  90640. /**
  90641. * Internal only
  90642. * @hidden
  90643. */
  90644. private _target;
  90645. /**
  90646. * Creates a new StateCondition
  90647. * @param actionManager manager for the action the condition applies to
  90648. * @param target of the condition
  90649. * @param value to compare with target state
  90650. */
  90651. constructor(actionManager: ActionManager, target: any,
  90652. /** Value to compare with target state */
  90653. value: string);
  90654. /**
  90655. * Gets a boolean indicating if the current condition is met
  90656. * @returns the validity of the state
  90657. */
  90658. isValid(): boolean;
  90659. /**
  90660. * Serialize the StateCondition into a JSON compatible object
  90661. * @returns serialization object
  90662. */
  90663. serialize(): any;
  90664. }
  90665. }
  90666. declare module BABYLON {
  90667. /**
  90668. * This defines an action responsible to toggle a boolean once triggered.
  90669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90670. */
  90671. export class SwitchBooleanAction extends Action {
  90672. /**
  90673. * The path to the boolean property in the target object
  90674. */
  90675. propertyPath: string;
  90676. private _target;
  90677. private _effectiveTarget;
  90678. private _property;
  90679. /**
  90680. * Instantiate the action
  90681. * @param triggerOptions defines the trigger options
  90682. * @param target defines the object containing the boolean
  90683. * @param propertyPath defines the path to the boolean property in the target object
  90684. * @param condition defines the trigger related conditions
  90685. */
  90686. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90687. /** @hidden */
  90688. _prepare(): void;
  90689. /**
  90690. * Execute the action toggle the boolean value.
  90691. */
  90692. execute(): void;
  90693. /**
  90694. * Serializes the actions and its related information.
  90695. * @param parent defines the object to serialize in
  90696. * @returns the serialized object
  90697. */
  90698. serialize(parent: any): any;
  90699. }
  90700. /**
  90701. * This defines an action responsible to set a the state field of the target
  90702. * to a desired value once triggered.
  90703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90704. */
  90705. export class SetStateAction extends Action {
  90706. /**
  90707. * The value to store in the state field.
  90708. */
  90709. value: string;
  90710. private _target;
  90711. /**
  90712. * Instantiate the action
  90713. * @param triggerOptions defines the trigger options
  90714. * @param target defines the object containing the state property
  90715. * @param value defines the value to store in the state field
  90716. * @param condition defines the trigger related conditions
  90717. */
  90718. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90719. /**
  90720. * Execute the action and store the value on the target state property.
  90721. */
  90722. execute(): void;
  90723. /**
  90724. * Serializes the actions and its related information.
  90725. * @param parent defines the object to serialize in
  90726. * @returns the serialized object
  90727. */
  90728. serialize(parent: any): any;
  90729. }
  90730. /**
  90731. * This defines an action responsible to set a property of the target
  90732. * to a desired value once triggered.
  90733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90734. */
  90735. export class SetValueAction extends Action {
  90736. /**
  90737. * The path of the property to set in the target.
  90738. */
  90739. propertyPath: string;
  90740. /**
  90741. * The value to set in the property
  90742. */
  90743. value: any;
  90744. private _target;
  90745. private _effectiveTarget;
  90746. private _property;
  90747. /**
  90748. * Instantiate the action
  90749. * @param triggerOptions defines the trigger options
  90750. * @param target defines the object containing the property
  90751. * @param propertyPath defines the path of the property to set in the target
  90752. * @param value defines the value to set in the property
  90753. * @param condition defines the trigger related conditions
  90754. */
  90755. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90756. /** @hidden */
  90757. _prepare(): void;
  90758. /**
  90759. * Execute the action and set the targetted property to the desired value.
  90760. */
  90761. execute(): void;
  90762. /**
  90763. * Serializes the actions and its related information.
  90764. * @param parent defines the object to serialize in
  90765. * @returns the serialized object
  90766. */
  90767. serialize(parent: any): any;
  90768. }
  90769. /**
  90770. * This defines an action responsible to increment the target value
  90771. * to a desired value once triggered.
  90772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90773. */
  90774. export class IncrementValueAction extends Action {
  90775. /**
  90776. * The path of the property to increment in the target.
  90777. */
  90778. propertyPath: string;
  90779. /**
  90780. * The value we should increment the property by.
  90781. */
  90782. value: any;
  90783. private _target;
  90784. private _effectiveTarget;
  90785. private _property;
  90786. /**
  90787. * Instantiate the action
  90788. * @param triggerOptions defines the trigger options
  90789. * @param target defines the object containing the property
  90790. * @param propertyPath defines the path of the property to increment in the target
  90791. * @param value defines the value value we should increment the property by
  90792. * @param condition defines the trigger related conditions
  90793. */
  90794. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90795. /** @hidden */
  90796. _prepare(): void;
  90797. /**
  90798. * Execute the action and increment the target of the value amount.
  90799. */
  90800. execute(): void;
  90801. /**
  90802. * Serializes the actions and its related information.
  90803. * @param parent defines the object to serialize in
  90804. * @returns the serialized object
  90805. */
  90806. serialize(parent: any): any;
  90807. }
  90808. /**
  90809. * This defines an action responsible to start an animation once triggered.
  90810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90811. */
  90812. export class PlayAnimationAction extends Action {
  90813. /**
  90814. * Where the animation should start (animation frame)
  90815. */
  90816. from: number;
  90817. /**
  90818. * Where the animation should stop (animation frame)
  90819. */
  90820. to: number;
  90821. /**
  90822. * Define if the animation should loop or stop after the first play.
  90823. */
  90824. loop?: boolean;
  90825. private _target;
  90826. /**
  90827. * Instantiate the action
  90828. * @param triggerOptions defines the trigger options
  90829. * @param target defines the target animation or animation name
  90830. * @param from defines from where the animation should start (animation frame)
  90831. * @param end defines where the animation should stop (animation frame)
  90832. * @param loop defines if the animation should loop or stop after the first play
  90833. * @param condition defines the trigger related conditions
  90834. */
  90835. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90836. /** @hidden */
  90837. _prepare(): void;
  90838. /**
  90839. * Execute the action and play the animation.
  90840. */
  90841. execute(): void;
  90842. /**
  90843. * Serializes the actions and its related information.
  90844. * @param parent defines the object to serialize in
  90845. * @returns the serialized object
  90846. */
  90847. serialize(parent: any): any;
  90848. }
  90849. /**
  90850. * This defines an action responsible to stop an animation once triggered.
  90851. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90852. */
  90853. export class StopAnimationAction extends Action {
  90854. private _target;
  90855. /**
  90856. * Instantiate the action
  90857. * @param triggerOptions defines the trigger options
  90858. * @param target defines the target animation or animation name
  90859. * @param condition defines the trigger related conditions
  90860. */
  90861. constructor(triggerOptions: any, target: any, condition?: Condition);
  90862. /** @hidden */
  90863. _prepare(): void;
  90864. /**
  90865. * Execute the action and stop the animation.
  90866. */
  90867. execute(): void;
  90868. /**
  90869. * Serializes the actions and its related information.
  90870. * @param parent defines the object to serialize in
  90871. * @returns the serialized object
  90872. */
  90873. serialize(parent: any): any;
  90874. }
  90875. /**
  90876. * This defines an action responsible that does nothing once triggered.
  90877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90878. */
  90879. export class DoNothingAction extends Action {
  90880. /**
  90881. * Instantiate the action
  90882. * @param triggerOptions defines the trigger options
  90883. * @param condition defines the trigger related conditions
  90884. */
  90885. constructor(triggerOptions?: any, condition?: Condition);
  90886. /**
  90887. * Execute the action and do nothing.
  90888. */
  90889. execute(): void;
  90890. /**
  90891. * Serializes the actions and its related information.
  90892. * @param parent defines the object to serialize in
  90893. * @returns the serialized object
  90894. */
  90895. serialize(parent: any): any;
  90896. }
  90897. /**
  90898. * This defines an action responsible to trigger several actions once triggered.
  90899. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90900. */
  90901. export class CombineAction extends Action {
  90902. /**
  90903. * The list of aggregated animations to run.
  90904. */
  90905. children: Action[];
  90906. /**
  90907. * Instantiate the action
  90908. * @param triggerOptions defines the trigger options
  90909. * @param children defines the list of aggregated animations to run
  90910. * @param condition defines the trigger related conditions
  90911. */
  90912. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90913. /** @hidden */
  90914. _prepare(): void;
  90915. /**
  90916. * Execute the action and executes all the aggregated actions.
  90917. */
  90918. execute(evt: ActionEvent): void;
  90919. /**
  90920. * Serializes the actions and its related information.
  90921. * @param parent defines the object to serialize in
  90922. * @returns the serialized object
  90923. */
  90924. serialize(parent: any): any;
  90925. }
  90926. /**
  90927. * This defines an action responsible to run code (external event) once triggered.
  90928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90929. */
  90930. export class ExecuteCodeAction extends Action {
  90931. /**
  90932. * The callback function to run.
  90933. */
  90934. func: (evt: ActionEvent) => void;
  90935. /**
  90936. * Instantiate the action
  90937. * @param triggerOptions defines the trigger options
  90938. * @param func defines the callback function to run
  90939. * @param condition defines the trigger related conditions
  90940. */
  90941. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90942. /**
  90943. * Execute the action and run the attached code.
  90944. */
  90945. execute(evt: ActionEvent): void;
  90946. }
  90947. /**
  90948. * This defines an action responsible to set the parent property of the target once triggered.
  90949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90950. */
  90951. export class SetParentAction extends Action {
  90952. private _parent;
  90953. private _target;
  90954. /**
  90955. * Instantiate the action
  90956. * @param triggerOptions defines the trigger options
  90957. * @param target defines the target containing the parent property
  90958. * @param parent defines from where the animation should start (animation frame)
  90959. * @param condition defines the trigger related conditions
  90960. */
  90961. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90962. /** @hidden */
  90963. _prepare(): void;
  90964. /**
  90965. * Execute the action and set the parent property.
  90966. */
  90967. execute(): void;
  90968. /**
  90969. * Serializes the actions and its related information.
  90970. * @param parent defines the object to serialize in
  90971. * @returns the serialized object
  90972. */
  90973. serialize(parent: any): any;
  90974. }
  90975. }
  90976. declare module BABYLON {
  90977. /**
  90978. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90979. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90981. */
  90982. export class ActionManager extends AbstractActionManager {
  90983. /**
  90984. * Nothing
  90985. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90986. */
  90987. static readonly NothingTrigger: number;
  90988. /**
  90989. * On pick
  90990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90991. */
  90992. static readonly OnPickTrigger: number;
  90993. /**
  90994. * On left pick
  90995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90996. */
  90997. static readonly OnLeftPickTrigger: number;
  90998. /**
  90999. * On right pick
  91000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91001. */
  91002. static readonly OnRightPickTrigger: number;
  91003. /**
  91004. * On center pick
  91005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91006. */
  91007. static readonly OnCenterPickTrigger: number;
  91008. /**
  91009. * On pick down
  91010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91011. */
  91012. static readonly OnPickDownTrigger: number;
  91013. /**
  91014. * On double pick
  91015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91016. */
  91017. static readonly OnDoublePickTrigger: number;
  91018. /**
  91019. * On pick up
  91020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91021. */
  91022. static readonly OnPickUpTrigger: number;
  91023. /**
  91024. * On pick out.
  91025. * This trigger will only be raised if you also declared a OnPickDown
  91026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91027. */
  91028. static readonly OnPickOutTrigger: number;
  91029. /**
  91030. * On long press
  91031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91032. */
  91033. static readonly OnLongPressTrigger: number;
  91034. /**
  91035. * On pointer over
  91036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91037. */
  91038. static readonly OnPointerOverTrigger: number;
  91039. /**
  91040. * On pointer out
  91041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91042. */
  91043. static readonly OnPointerOutTrigger: number;
  91044. /**
  91045. * On every frame
  91046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91047. */
  91048. static readonly OnEveryFrameTrigger: number;
  91049. /**
  91050. * On intersection enter
  91051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91052. */
  91053. static readonly OnIntersectionEnterTrigger: number;
  91054. /**
  91055. * On intersection exit
  91056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91057. */
  91058. static readonly OnIntersectionExitTrigger: number;
  91059. /**
  91060. * On key down
  91061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91062. */
  91063. static readonly OnKeyDownTrigger: number;
  91064. /**
  91065. * On key up
  91066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91067. */
  91068. static readonly OnKeyUpTrigger: number;
  91069. private _scene;
  91070. /**
  91071. * Creates a new action manager
  91072. * @param scene defines the hosting scene
  91073. */
  91074. constructor(scene: Scene);
  91075. /**
  91076. * Releases all associated resources
  91077. */
  91078. dispose(): void;
  91079. /**
  91080. * Gets hosting scene
  91081. * @returns the hosting scene
  91082. */
  91083. getScene(): Scene;
  91084. /**
  91085. * Does this action manager handles actions of any of the given triggers
  91086. * @param triggers defines the triggers to be tested
  91087. * @return a boolean indicating whether one (or more) of the triggers is handled
  91088. */
  91089. hasSpecificTriggers(triggers: number[]): boolean;
  91090. /**
  91091. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91092. * speed.
  91093. * @param triggerA defines the trigger to be tested
  91094. * @param triggerB defines the trigger to be tested
  91095. * @return a boolean indicating whether one (or more) of the triggers is handled
  91096. */
  91097. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91098. /**
  91099. * Does this action manager handles actions of a given trigger
  91100. * @param trigger defines the trigger to be tested
  91101. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91102. * @return whether the trigger is handled
  91103. */
  91104. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91105. /**
  91106. * Does this action manager has pointer triggers
  91107. */
  91108. get hasPointerTriggers(): boolean;
  91109. /**
  91110. * Does this action manager has pick triggers
  91111. */
  91112. get hasPickTriggers(): boolean;
  91113. /**
  91114. * Registers an action to this action manager
  91115. * @param action defines the action to be registered
  91116. * @return the action amended (prepared) after registration
  91117. */
  91118. registerAction(action: IAction): Nullable<IAction>;
  91119. /**
  91120. * Unregisters an action to this action manager
  91121. * @param action defines the action to be unregistered
  91122. * @return a boolean indicating whether the action has been unregistered
  91123. */
  91124. unregisterAction(action: IAction): Boolean;
  91125. /**
  91126. * Process a specific trigger
  91127. * @param trigger defines the trigger to process
  91128. * @param evt defines the event details to be processed
  91129. */
  91130. processTrigger(trigger: number, evt?: IActionEvent): void;
  91131. /** @hidden */
  91132. _getEffectiveTarget(target: any, propertyPath: string): any;
  91133. /** @hidden */
  91134. _getProperty(propertyPath: string): string;
  91135. /**
  91136. * Serialize this manager to a JSON object
  91137. * @param name defines the property name to store this manager
  91138. * @returns a JSON representation of this manager
  91139. */
  91140. serialize(name: string): any;
  91141. /**
  91142. * Creates a new ActionManager from a JSON data
  91143. * @param parsedActions defines the JSON data to read from
  91144. * @param object defines the hosting mesh
  91145. * @param scene defines the hosting scene
  91146. */
  91147. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91148. /**
  91149. * Get a trigger name by index
  91150. * @param trigger defines the trigger index
  91151. * @returns a trigger name
  91152. */
  91153. static GetTriggerName(trigger: number): string;
  91154. }
  91155. }
  91156. declare module BABYLON {
  91157. /**
  91158. * Class used to represent a sprite
  91159. * @see http://doc.babylonjs.com/babylon101/sprites
  91160. */
  91161. export class Sprite {
  91162. /** defines the name */
  91163. name: string;
  91164. /** Gets or sets the current world position */
  91165. position: Vector3;
  91166. /** Gets or sets the main color */
  91167. color: Color4;
  91168. /** Gets or sets the width */
  91169. width: number;
  91170. /** Gets or sets the height */
  91171. height: number;
  91172. /** Gets or sets rotation angle */
  91173. angle: number;
  91174. /** Gets or sets the cell index in the sprite sheet */
  91175. cellIndex: number;
  91176. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91177. cellRef: string;
  91178. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91179. invertU: number;
  91180. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91181. invertV: number;
  91182. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91183. disposeWhenFinishedAnimating: boolean;
  91184. /** Gets the list of attached animations */
  91185. animations: Animation[];
  91186. /** Gets or sets a boolean indicating if the sprite can be picked */
  91187. isPickable: boolean;
  91188. /**
  91189. * Gets or sets the associated action manager
  91190. */
  91191. actionManager: Nullable<ActionManager>;
  91192. private _animationStarted;
  91193. private _loopAnimation;
  91194. private _fromIndex;
  91195. private _toIndex;
  91196. private _delay;
  91197. private _direction;
  91198. private _manager;
  91199. private _time;
  91200. private _onAnimationEnd;
  91201. /**
  91202. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91203. */
  91204. isVisible: boolean;
  91205. /**
  91206. * Gets or sets the sprite size
  91207. */
  91208. get size(): number;
  91209. set size(value: number);
  91210. /**
  91211. * Creates a new Sprite
  91212. * @param name defines the name
  91213. * @param manager defines the manager
  91214. */
  91215. constructor(
  91216. /** defines the name */
  91217. name: string, manager: ISpriteManager);
  91218. /**
  91219. * Starts an animation
  91220. * @param from defines the initial key
  91221. * @param to defines the end key
  91222. * @param loop defines if the animation must loop
  91223. * @param delay defines the start delay (in ms)
  91224. * @param onAnimationEnd defines a callback to call when animation ends
  91225. */
  91226. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  91227. /** Stops current animation (if any) */
  91228. stopAnimation(): void;
  91229. /** @hidden */
  91230. _animate(deltaTime: number): void;
  91231. /** Release associated resources */
  91232. dispose(): void;
  91233. }
  91234. }
  91235. declare module BABYLON {
  91236. /**
  91237. * Information about the result of picking within a scene
  91238. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91239. */
  91240. export class PickingInfo {
  91241. /** @hidden */
  91242. _pickingUnavailable: boolean;
  91243. /**
  91244. * If the pick collided with an object
  91245. */
  91246. hit: boolean;
  91247. /**
  91248. * Distance away where the pick collided
  91249. */
  91250. distance: number;
  91251. /**
  91252. * The location of pick collision
  91253. */
  91254. pickedPoint: Nullable<Vector3>;
  91255. /**
  91256. * The mesh corresponding the the pick collision
  91257. */
  91258. pickedMesh: Nullable<AbstractMesh>;
  91259. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91260. bu: number;
  91261. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91262. bv: number;
  91263. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91264. faceId: number;
  91265. /** Id of the the submesh that was picked */
  91266. subMeshId: number;
  91267. /** If a sprite was picked, this will be the sprite the pick collided with */
  91268. pickedSprite: Nullable<Sprite>;
  91269. /**
  91270. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91271. */
  91272. originMesh: Nullable<AbstractMesh>;
  91273. /**
  91274. * The ray that was used to perform the picking.
  91275. */
  91276. ray: Nullable<Ray>;
  91277. /**
  91278. * Gets the normal correspodning to the face the pick collided with
  91279. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91280. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91281. * @returns The normal correspodning to the face the pick collided with
  91282. */
  91283. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91284. /**
  91285. * Gets the texture coordinates of where the pick occured
  91286. * @returns the vector containing the coordnates of the texture
  91287. */
  91288. getTextureCoordinates(): Nullable<Vector2>;
  91289. }
  91290. }
  91291. declare module BABYLON {
  91292. /**
  91293. * Gather the list of pointer event types as constants.
  91294. */
  91295. export class PointerEventTypes {
  91296. /**
  91297. * 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.
  91298. */
  91299. static readonly POINTERDOWN: number;
  91300. /**
  91301. * The pointerup event is fired when a pointer is no longer active.
  91302. */
  91303. static readonly POINTERUP: number;
  91304. /**
  91305. * The pointermove event is fired when a pointer changes coordinates.
  91306. */
  91307. static readonly POINTERMOVE: number;
  91308. /**
  91309. * The pointerwheel event is fired when a mouse wheel has been rotated.
  91310. */
  91311. static readonly POINTERWHEEL: number;
  91312. /**
  91313. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  91314. */
  91315. static readonly POINTERPICK: number;
  91316. /**
  91317. * The pointertap event is fired when a the object has been touched and released without drag.
  91318. */
  91319. static readonly POINTERTAP: number;
  91320. /**
  91321. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  91322. */
  91323. static readonly POINTERDOUBLETAP: number;
  91324. }
  91325. /**
  91326. * Base class of pointer info types.
  91327. */
  91328. export class PointerInfoBase {
  91329. /**
  91330. * Defines the type of event (PointerEventTypes)
  91331. */
  91332. type: number;
  91333. /**
  91334. * Defines the related dom event
  91335. */
  91336. event: PointerEvent | MouseWheelEvent;
  91337. /**
  91338. * Instantiates the base class of pointers info.
  91339. * @param type Defines the type of event (PointerEventTypes)
  91340. * @param event Defines the related dom event
  91341. */
  91342. constructor(
  91343. /**
  91344. * Defines the type of event (PointerEventTypes)
  91345. */
  91346. type: number,
  91347. /**
  91348. * Defines the related dom event
  91349. */
  91350. event: PointerEvent | MouseWheelEvent);
  91351. }
  91352. /**
  91353. * This class is used to store pointer related info for the onPrePointerObservable event.
  91354. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  91355. */
  91356. export class PointerInfoPre extends PointerInfoBase {
  91357. /**
  91358. * Ray from a pointer if availible (eg. 6dof controller)
  91359. */
  91360. ray: Nullable<Ray>;
  91361. /**
  91362. * Defines the local position of the pointer on the canvas.
  91363. */
  91364. localPosition: Vector2;
  91365. /**
  91366. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  91367. */
  91368. skipOnPointerObservable: boolean;
  91369. /**
  91370. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  91371. * @param type Defines the type of event (PointerEventTypes)
  91372. * @param event Defines the related dom event
  91373. * @param localX Defines the local x coordinates of the pointer when the event occured
  91374. * @param localY Defines the local y coordinates of the pointer when the event occured
  91375. */
  91376. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  91377. }
  91378. /**
  91379. * This type contains all the data related to a pointer event in Babylon.js.
  91380. * 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.
  91381. */
  91382. export class PointerInfo extends PointerInfoBase {
  91383. /**
  91384. * Defines the picking info associated to the info (if any)\
  91385. */
  91386. pickInfo: Nullable<PickingInfo>;
  91387. /**
  91388. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  91389. * @param type Defines the type of event (PointerEventTypes)
  91390. * @param event Defines the related dom event
  91391. * @param pickInfo Defines the picking info associated to the info (if any)\
  91392. */
  91393. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  91394. /**
  91395. * Defines the picking info associated to the info (if any)\
  91396. */
  91397. pickInfo: Nullable<PickingInfo>);
  91398. }
  91399. /**
  91400. * Data relating to a touch event on the screen.
  91401. */
  91402. export interface PointerTouch {
  91403. /**
  91404. * X coordinate of touch.
  91405. */
  91406. x: number;
  91407. /**
  91408. * Y coordinate of touch.
  91409. */
  91410. y: number;
  91411. /**
  91412. * Id of touch. Unique for each finger.
  91413. */
  91414. pointerId: number;
  91415. /**
  91416. * Event type passed from DOM.
  91417. */
  91418. type: any;
  91419. }
  91420. }
  91421. declare module BABYLON {
  91422. /**
  91423. * Manage the mouse inputs to control the movement of a free camera.
  91424. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91425. */
  91426. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  91427. /**
  91428. * Define if touch is enabled in the mouse input
  91429. */
  91430. touchEnabled: boolean;
  91431. /**
  91432. * Defines the camera the input is attached to.
  91433. */
  91434. camera: FreeCamera;
  91435. /**
  91436. * Defines the buttons associated with the input to handle camera move.
  91437. */
  91438. buttons: number[];
  91439. /**
  91440. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  91441. */
  91442. angularSensibility: number;
  91443. private _pointerInput;
  91444. private _onMouseMove;
  91445. private _observer;
  91446. private previousPosition;
  91447. /**
  91448. * Observable for when a pointer move event occurs containing the move offset
  91449. */
  91450. onPointerMovedObservable: Observable<{
  91451. offsetX: number;
  91452. offsetY: number;
  91453. }>;
  91454. /**
  91455. * @hidden
  91456. * If the camera should be rotated automatically based on pointer movement
  91457. */
  91458. _allowCameraRotation: boolean;
  91459. /**
  91460. * Manage the mouse inputs to control the movement of a free camera.
  91461. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91462. * @param touchEnabled Defines if touch is enabled or not
  91463. */
  91464. constructor(
  91465. /**
  91466. * Define if touch is enabled in the mouse input
  91467. */
  91468. touchEnabled?: boolean);
  91469. /**
  91470. * Attach the input controls to a specific dom element to get the input from.
  91471. * @param element Defines the element the controls should be listened from
  91472. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91473. */
  91474. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91475. /**
  91476. * Called on JS contextmenu event.
  91477. * Override this method to provide functionality.
  91478. */
  91479. protected onContextMenu(evt: PointerEvent): void;
  91480. /**
  91481. * Detach the current controls from the specified dom element.
  91482. * @param element Defines the element to stop listening the inputs from
  91483. */
  91484. detachControl(element: Nullable<HTMLElement>): void;
  91485. /**
  91486. * Gets the class name of the current intput.
  91487. * @returns the class name
  91488. */
  91489. getClassName(): string;
  91490. /**
  91491. * Get the friendly name associated with the input class.
  91492. * @returns the input friendly name
  91493. */
  91494. getSimpleName(): string;
  91495. }
  91496. }
  91497. declare module BABYLON {
  91498. /**
  91499. * Manage the touch inputs to control the movement of a free camera.
  91500. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91501. */
  91502. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  91503. /**
  91504. * Defines the camera the input is attached to.
  91505. */
  91506. camera: FreeCamera;
  91507. /**
  91508. * Defines the touch sensibility for rotation.
  91509. * The higher the faster.
  91510. */
  91511. touchAngularSensibility: number;
  91512. /**
  91513. * Defines the touch sensibility for move.
  91514. * The higher the faster.
  91515. */
  91516. touchMoveSensibility: number;
  91517. private _offsetX;
  91518. private _offsetY;
  91519. private _pointerPressed;
  91520. private _pointerInput;
  91521. private _observer;
  91522. private _onLostFocus;
  91523. /**
  91524. * Attach the input controls to a specific dom element to get the input from.
  91525. * @param element Defines the element the controls should be listened from
  91526. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91527. */
  91528. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91529. /**
  91530. * Detach the current controls from the specified dom element.
  91531. * @param element Defines the element to stop listening the inputs from
  91532. */
  91533. detachControl(element: Nullable<HTMLElement>): void;
  91534. /**
  91535. * Update the current camera state depending on the inputs that have been used this frame.
  91536. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91537. */
  91538. checkInputs(): void;
  91539. /**
  91540. * Gets the class name of the current intput.
  91541. * @returns the class name
  91542. */
  91543. getClassName(): string;
  91544. /**
  91545. * Get the friendly name associated with the input class.
  91546. * @returns the input friendly name
  91547. */
  91548. getSimpleName(): string;
  91549. }
  91550. }
  91551. declare module BABYLON {
  91552. /**
  91553. * Default Inputs manager for the FreeCamera.
  91554. * It groups all the default supported inputs for ease of use.
  91555. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91556. */
  91557. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  91558. /**
  91559. * @hidden
  91560. */
  91561. _mouseInput: Nullable<FreeCameraMouseInput>;
  91562. /**
  91563. * Instantiates a new FreeCameraInputsManager.
  91564. * @param camera Defines the camera the inputs belong to
  91565. */
  91566. constructor(camera: FreeCamera);
  91567. /**
  91568. * Add keyboard input support to the input manager.
  91569. * @returns the current input manager
  91570. */
  91571. addKeyboard(): FreeCameraInputsManager;
  91572. /**
  91573. * Add mouse input support to the input manager.
  91574. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  91575. * @returns the current input manager
  91576. */
  91577. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  91578. /**
  91579. * Removes the mouse input support from the manager
  91580. * @returns the current input manager
  91581. */
  91582. removeMouse(): FreeCameraInputsManager;
  91583. /**
  91584. * Add touch input support to the input manager.
  91585. * @returns the current input manager
  91586. */
  91587. addTouch(): FreeCameraInputsManager;
  91588. /**
  91589. * Remove all attached input methods from a camera
  91590. */
  91591. clear(): void;
  91592. }
  91593. }
  91594. declare module BABYLON {
  91595. /**
  91596. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91597. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  91598. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91599. */
  91600. export class FreeCamera extends TargetCamera {
  91601. /**
  91602. * Define the collision ellipsoid of the camera.
  91603. * This is helpful to simulate a camera body like the player body around the camera
  91604. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91605. */
  91606. ellipsoid: Vector3;
  91607. /**
  91608. * Define an offset for the position of the ellipsoid around the camera.
  91609. * This can be helpful to determine the center of the body near the gravity center of the body
  91610. * instead of its head.
  91611. */
  91612. ellipsoidOffset: Vector3;
  91613. /**
  91614. * Enable or disable collisions of the camera with the rest of the scene objects.
  91615. */
  91616. checkCollisions: boolean;
  91617. /**
  91618. * Enable or disable gravity on the camera.
  91619. */
  91620. applyGravity: boolean;
  91621. /**
  91622. * Define the input manager associated to the camera.
  91623. */
  91624. inputs: FreeCameraInputsManager;
  91625. /**
  91626. * Gets the input sensibility for a mouse input. (default is 2000.0)
  91627. * Higher values reduce sensitivity.
  91628. */
  91629. get angularSensibility(): number;
  91630. /**
  91631. * Sets the input sensibility for a mouse input. (default is 2000.0)
  91632. * Higher values reduce sensitivity.
  91633. */
  91634. set angularSensibility(value: number);
  91635. /**
  91636. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  91637. */
  91638. get keysUp(): number[];
  91639. set keysUp(value: number[]);
  91640. /**
  91641. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  91642. */
  91643. get keysDown(): number[];
  91644. set keysDown(value: number[]);
  91645. /**
  91646. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  91647. */
  91648. get keysLeft(): number[];
  91649. set keysLeft(value: number[]);
  91650. /**
  91651. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  91652. */
  91653. get keysRight(): number[];
  91654. set keysRight(value: number[]);
  91655. /**
  91656. * Event raised when the camera collide with a mesh in the scene.
  91657. */
  91658. onCollide: (collidedMesh: AbstractMesh) => void;
  91659. private _collider;
  91660. private _needMoveForGravity;
  91661. private _oldPosition;
  91662. private _diffPosition;
  91663. private _newPosition;
  91664. /** @hidden */
  91665. _localDirection: Vector3;
  91666. /** @hidden */
  91667. _transformedDirection: Vector3;
  91668. /**
  91669. * Instantiates a Free Camera.
  91670. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91671. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  91672. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91673. * @param name Define the name of the camera in the scene
  91674. * @param position Define the start position of the camera in the scene
  91675. * @param scene Define the scene the camera belongs to
  91676. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91677. */
  91678. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91679. /**
  91680. * Attached controls to the current camera.
  91681. * @param element Defines the element the controls should be listened from
  91682. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91683. */
  91684. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91685. /**
  91686. * Detach the current controls from the camera.
  91687. * The camera will stop reacting to inputs.
  91688. * @param element Defines the element to stop listening the inputs from
  91689. */
  91690. detachControl(element: HTMLElement): void;
  91691. private _collisionMask;
  91692. /**
  91693. * Define a collision mask to limit the list of object the camera can collide with
  91694. */
  91695. get collisionMask(): number;
  91696. set collisionMask(mask: number);
  91697. /** @hidden */
  91698. _collideWithWorld(displacement: Vector3): void;
  91699. private _onCollisionPositionChange;
  91700. /** @hidden */
  91701. _checkInputs(): void;
  91702. /** @hidden */
  91703. _decideIfNeedsToMove(): boolean;
  91704. /** @hidden */
  91705. _updatePosition(): void;
  91706. /**
  91707. * Destroy the camera and release the current resources hold by it.
  91708. */
  91709. dispose(): void;
  91710. /**
  91711. * Gets the current object class name.
  91712. * @return the class name
  91713. */
  91714. getClassName(): string;
  91715. }
  91716. }
  91717. declare module BABYLON {
  91718. /**
  91719. * Represents a gamepad control stick position
  91720. */
  91721. export class StickValues {
  91722. /**
  91723. * The x component of the control stick
  91724. */
  91725. x: number;
  91726. /**
  91727. * The y component of the control stick
  91728. */
  91729. y: number;
  91730. /**
  91731. * Initializes the gamepad x and y control stick values
  91732. * @param x The x component of the gamepad control stick value
  91733. * @param y The y component of the gamepad control stick value
  91734. */
  91735. constructor(
  91736. /**
  91737. * The x component of the control stick
  91738. */
  91739. x: number,
  91740. /**
  91741. * The y component of the control stick
  91742. */
  91743. y: number);
  91744. }
  91745. /**
  91746. * An interface which manages callbacks for gamepad button changes
  91747. */
  91748. export interface GamepadButtonChanges {
  91749. /**
  91750. * Called when a gamepad has been changed
  91751. */
  91752. changed: boolean;
  91753. /**
  91754. * Called when a gamepad press event has been triggered
  91755. */
  91756. pressChanged: boolean;
  91757. /**
  91758. * Called when a touch event has been triggered
  91759. */
  91760. touchChanged: boolean;
  91761. /**
  91762. * Called when a value has changed
  91763. */
  91764. valueChanged: boolean;
  91765. }
  91766. /**
  91767. * Represents a gamepad
  91768. */
  91769. export class Gamepad {
  91770. /**
  91771. * The id of the gamepad
  91772. */
  91773. id: string;
  91774. /**
  91775. * The index of the gamepad
  91776. */
  91777. index: number;
  91778. /**
  91779. * The browser gamepad
  91780. */
  91781. browserGamepad: any;
  91782. /**
  91783. * Specifies what type of gamepad this represents
  91784. */
  91785. type: number;
  91786. private _leftStick;
  91787. private _rightStick;
  91788. /** @hidden */
  91789. _isConnected: boolean;
  91790. private _leftStickAxisX;
  91791. private _leftStickAxisY;
  91792. private _rightStickAxisX;
  91793. private _rightStickAxisY;
  91794. /**
  91795. * Triggered when the left control stick has been changed
  91796. */
  91797. private _onleftstickchanged;
  91798. /**
  91799. * Triggered when the right control stick has been changed
  91800. */
  91801. private _onrightstickchanged;
  91802. /**
  91803. * Represents a gamepad controller
  91804. */
  91805. static GAMEPAD: number;
  91806. /**
  91807. * Represents a generic controller
  91808. */
  91809. static GENERIC: number;
  91810. /**
  91811. * Represents an XBox controller
  91812. */
  91813. static XBOX: number;
  91814. /**
  91815. * Represents a pose-enabled controller
  91816. */
  91817. static POSE_ENABLED: number;
  91818. /**
  91819. * Represents an Dual Shock controller
  91820. */
  91821. static DUALSHOCK: number;
  91822. /**
  91823. * Specifies whether the left control stick should be Y-inverted
  91824. */
  91825. protected _invertLeftStickY: boolean;
  91826. /**
  91827. * Specifies if the gamepad has been connected
  91828. */
  91829. get isConnected(): boolean;
  91830. /**
  91831. * Initializes the gamepad
  91832. * @param id The id of the gamepad
  91833. * @param index The index of the gamepad
  91834. * @param browserGamepad The browser gamepad
  91835. * @param leftStickX The x component of the left joystick
  91836. * @param leftStickY The y component of the left joystick
  91837. * @param rightStickX The x component of the right joystick
  91838. * @param rightStickY The y component of the right joystick
  91839. */
  91840. constructor(
  91841. /**
  91842. * The id of the gamepad
  91843. */
  91844. id: string,
  91845. /**
  91846. * The index of the gamepad
  91847. */
  91848. index: number,
  91849. /**
  91850. * The browser gamepad
  91851. */
  91852. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  91853. /**
  91854. * Callback triggered when the left joystick has changed
  91855. * @param callback
  91856. */
  91857. onleftstickchanged(callback: (values: StickValues) => void): void;
  91858. /**
  91859. * Callback triggered when the right joystick has changed
  91860. * @param callback
  91861. */
  91862. onrightstickchanged(callback: (values: StickValues) => void): void;
  91863. /**
  91864. * Gets the left joystick
  91865. */
  91866. get leftStick(): StickValues;
  91867. /**
  91868. * Sets the left joystick values
  91869. */
  91870. set leftStick(newValues: StickValues);
  91871. /**
  91872. * Gets the right joystick
  91873. */
  91874. get rightStick(): StickValues;
  91875. /**
  91876. * Sets the right joystick value
  91877. */
  91878. set rightStick(newValues: StickValues);
  91879. /**
  91880. * Updates the gamepad joystick positions
  91881. */
  91882. update(): void;
  91883. /**
  91884. * Disposes the gamepad
  91885. */
  91886. dispose(): void;
  91887. }
  91888. /**
  91889. * Represents a generic gamepad
  91890. */
  91891. export class GenericPad extends Gamepad {
  91892. private _buttons;
  91893. private _onbuttondown;
  91894. private _onbuttonup;
  91895. /**
  91896. * Observable triggered when a button has been pressed
  91897. */
  91898. onButtonDownObservable: Observable<number>;
  91899. /**
  91900. * Observable triggered when a button has been released
  91901. */
  91902. onButtonUpObservable: Observable<number>;
  91903. /**
  91904. * Callback triggered when a button has been pressed
  91905. * @param callback Called when a button has been pressed
  91906. */
  91907. onbuttondown(callback: (buttonPressed: number) => void): void;
  91908. /**
  91909. * Callback triggered when a button has been released
  91910. * @param callback Called when a button has been released
  91911. */
  91912. onbuttonup(callback: (buttonReleased: number) => void): void;
  91913. /**
  91914. * Initializes the generic gamepad
  91915. * @param id The id of the generic gamepad
  91916. * @param index The index of the generic gamepad
  91917. * @param browserGamepad The browser gamepad
  91918. */
  91919. constructor(id: string, index: number, browserGamepad: any);
  91920. private _setButtonValue;
  91921. /**
  91922. * Updates the generic gamepad
  91923. */
  91924. update(): void;
  91925. /**
  91926. * Disposes the generic gamepad
  91927. */
  91928. dispose(): void;
  91929. }
  91930. }
  91931. declare module BABYLON {
  91932. /**
  91933. * Defines the types of pose enabled controllers that are supported
  91934. */
  91935. export enum PoseEnabledControllerType {
  91936. /**
  91937. * HTC Vive
  91938. */
  91939. VIVE = 0,
  91940. /**
  91941. * Oculus Rift
  91942. */
  91943. OCULUS = 1,
  91944. /**
  91945. * Windows mixed reality
  91946. */
  91947. WINDOWS = 2,
  91948. /**
  91949. * Samsung gear VR
  91950. */
  91951. GEAR_VR = 3,
  91952. /**
  91953. * Google Daydream
  91954. */
  91955. DAYDREAM = 4,
  91956. /**
  91957. * Generic
  91958. */
  91959. GENERIC = 5
  91960. }
  91961. /**
  91962. * Defines the MutableGamepadButton interface for the state of a gamepad button
  91963. */
  91964. export interface MutableGamepadButton {
  91965. /**
  91966. * Value of the button/trigger
  91967. */
  91968. value: number;
  91969. /**
  91970. * If the button/trigger is currently touched
  91971. */
  91972. touched: boolean;
  91973. /**
  91974. * If the button/trigger is currently pressed
  91975. */
  91976. pressed: boolean;
  91977. }
  91978. /**
  91979. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  91980. * @hidden
  91981. */
  91982. export interface ExtendedGamepadButton extends GamepadButton {
  91983. /**
  91984. * If the button/trigger is currently pressed
  91985. */
  91986. readonly pressed: boolean;
  91987. /**
  91988. * If the button/trigger is currently touched
  91989. */
  91990. readonly touched: boolean;
  91991. /**
  91992. * Value of the button/trigger
  91993. */
  91994. readonly value: number;
  91995. }
  91996. /** @hidden */
  91997. export interface _GamePadFactory {
  91998. /**
  91999. * Returns whether or not the current gamepad can be created for this type of controller.
  92000. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92001. * @returns true if it can be created, otherwise false
  92002. */
  92003. canCreate(gamepadInfo: any): boolean;
  92004. /**
  92005. * Creates a new instance of the Gamepad.
  92006. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92007. * @returns the new gamepad instance
  92008. */
  92009. create(gamepadInfo: any): Gamepad;
  92010. }
  92011. /**
  92012. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92013. */
  92014. export class PoseEnabledControllerHelper {
  92015. /** @hidden */
  92016. static _ControllerFactories: _GamePadFactory[];
  92017. /** @hidden */
  92018. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  92019. /**
  92020. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92021. * @param vrGamepad the gamepad to initialized
  92022. * @returns a vr controller of the type the gamepad identified as
  92023. */
  92024. static InitiateController(vrGamepad: any): Gamepad;
  92025. }
  92026. /**
  92027. * Defines the PoseEnabledController object that contains state of a vr capable controller
  92028. */
  92029. export class PoseEnabledController extends Gamepad implements PoseControlled {
  92030. /**
  92031. * If the controller is used in a webXR session
  92032. */
  92033. isXR: boolean;
  92034. private _deviceRoomPosition;
  92035. private _deviceRoomRotationQuaternion;
  92036. /**
  92037. * The device position in babylon space
  92038. */
  92039. devicePosition: Vector3;
  92040. /**
  92041. * The device rotation in babylon space
  92042. */
  92043. deviceRotationQuaternion: Quaternion;
  92044. /**
  92045. * The scale factor of the device in babylon space
  92046. */
  92047. deviceScaleFactor: number;
  92048. /**
  92049. * (Likely devicePosition should be used instead) The device position in its room space
  92050. */
  92051. position: Vector3;
  92052. /**
  92053. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  92054. */
  92055. rotationQuaternion: Quaternion;
  92056. /**
  92057. * The type of controller (Eg. Windows mixed reality)
  92058. */
  92059. controllerType: PoseEnabledControllerType;
  92060. protected _calculatedPosition: Vector3;
  92061. private _calculatedRotation;
  92062. /**
  92063. * The raw pose from the device
  92064. */
  92065. rawPose: DevicePose;
  92066. private _trackPosition;
  92067. private _maxRotationDistFromHeadset;
  92068. private _draggedRoomRotation;
  92069. /**
  92070. * @hidden
  92071. */
  92072. _disableTrackPosition(fixedPosition: Vector3): void;
  92073. /**
  92074. * Internal, the mesh attached to the controller
  92075. * @hidden
  92076. */
  92077. _mesh: Nullable<AbstractMesh>;
  92078. private _poseControlledCamera;
  92079. private _leftHandSystemQuaternion;
  92080. /**
  92081. * Internal, matrix used to convert room space to babylon space
  92082. * @hidden
  92083. */
  92084. _deviceToWorld: Matrix;
  92085. /**
  92086. * Node to be used when casting a ray from the controller
  92087. * @hidden
  92088. */
  92089. _pointingPoseNode: Nullable<TransformNode>;
  92090. /**
  92091. * Name of the child mesh that can be used to cast a ray from the controller
  92092. */
  92093. static readonly POINTING_POSE: string;
  92094. /**
  92095. * Creates a new PoseEnabledController from a gamepad
  92096. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  92097. */
  92098. constructor(browserGamepad: any);
  92099. private _workingMatrix;
  92100. /**
  92101. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  92102. */
  92103. update(): void;
  92104. /**
  92105. * Updates only the pose device and mesh without doing any button event checking
  92106. */
  92107. protected _updatePoseAndMesh(): void;
  92108. /**
  92109. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  92110. * @param poseData raw pose fromthe device
  92111. */
  92112. updateFromDevice(poseData: DevicePose): void;
  92113. /**
  92114. * @hidden
  92115. */
  92116. _meshAttachedObservable: Observable<AbstractMesh>;
  92117. /**
  92118. * Attaches a mesh to the controller
  92119. * @param mesh the mesh to be attached
  92120. */
  92121. attachToMesh(mesh: AbstractMesh): void;
  92122. /**
  92123. * Attaches the controllers mesh to a camera
  92124. * @param camera the camera the mesh should be attached to
  92125. */
  92126. attachToPoseControlledCamera(camera: TargetCamera): void;
  92127. /**
  92128. * Disposes of the controller
  92129. */
  92130. dispose(): void;
  92131. /**
  92132. * The mesh that is attached to the controller
  92133. */
  92134. get mesh(): Nullable<AbstractMesh>;
  92135. /**
  92136. * Gets the ray of the controller in the direction the controller is pointing
  92137. * @param length the length the resulting ray should be
  92138. * @returns a ray in the direction the controller is pointing
  92139. */
  92140. getForwardRay(length?: number): Ray;
  92141. }
  92142. }
  92143. declare module BABYLON {
  92144. /**
  92145. * Defines the WebVRController object that represents controllers tracked in 3D space
  92146. */
  92147. export abstract class WebVRController extends PoseEnabledController {
  92148. /**
  92149. * Internal, the default controller model for the controller
  92150. */
  92151. protected _defaultModel: Nullable<AbstractMesh>;
  92152. /**
  92153. * Fired when the trigger state has changed
  92154. */
  92155. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  92156. /**
  92157. * Fired when the main button state has changed
  92158. */
  92159. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92160. /**
  92161. * Fired when the secondary button state has changed
  92162. */
  92163. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92164. /**
  92165. * Fired when the pad state has changed
  92166. */
  92167. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  92168. /**
  92169. * Fired when controllers stick values have changed
  92170. */
  92171. onPadValuesChangedObservable: Observable<StickValues>;
  92172. /**
  92173. * Array of button availible on the controller
  92174. */
  92175. protected _buttons: Array<MutableGamepadButton>;
  92176. private _onButtonStateChange;
  92177. /**
  92178. * Fired when a controller button's state has changed
  92179. * @param callback the callback containing the button that was modified
  92180. */
  92181. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  92182. /**
  92183. * X and Y axis corresponding to the controllers joystick
  92184. */
  92185. pad: StickValues;
  92186. /**
  92187. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  92188. */
  92189. hand: string;
  92190. /**
  92191. * The default controller model for the controller
  92192. */
  92193. get defaultModel(): Nullable<AbstractMesh>;
  92194. /**
  92195. * Creates a new WebVRController from a gamepad
  92196. * @param vrGamepad the gamepad that the WebVRController should be created from
  92197. */
  92198. constructor(vrGamepad: any);
  92199. /**
  92200. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  92201. */
  92202. update(): void;
  92203. /**
  92204. * Function to be called when a button is modified
  92205. */
  92206. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  92207. /**
  92208. * Loads a mesh and attaches it to the controller
  92209. * @param scene the scene the mesh should be added to
  92210. * @param meshLoaded callback for when the mesh has been loaded
  92211. */
  92212. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  92213. private _setButtonValue;
  92214. private _changes;
  92215. private _checkChanges;
  92216. /**
  92217. * Disposes of th webVRCOntroller
  92218. */
  92219. dispose(): void;
  92220. }
  92221. }
  92222. declare module BABYLON {
  92223. /**
  92224. * The HemisphericLight simulates the ambient environment light,
  92225. * so the passed direction is the light reflection direction, not the incoming direction.
  92226. */
  92227. export class HemisphericLight extends Light {
  92228. /**
  92229. * The groundColor is the light in the opposite direction to the one specified during creation.
  92230. * 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.
  92231. */
  92232. groundColor: Color3;
  92233. /**
  92234. * The light reflection direction, not the incoming direction.
  92235. */
  92236. direction: Vector3;
  92237. /**
  92238. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  92239. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  92240. * The HemisphericLight can't cast shadows.
  92241. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92242. * @param name The friendly name of the light
  92243. * @param direction The direction of the light reflection
  92244. * @param scene The scene the light belongs to
  92245. */
  92246. constructor(name: string, direction: Vector3, scene: Scene);
  92247. protected _buildUniformLayout(): void;
  92248. /**
  92249. * Returns the string "HemisphericLight".
  92250. * @return The class name
  92251. */
  92252. getClassName(): string;
  92253. /**
  92254. * Sets the HemisphericLight direction towards the passed target (Vector3).
  92255. * Returns the updated direction.
  92256. * @param target The target the direction should point to
  92257. * @return The computed direction
  92258. */
  92259. setDirectionToTarget(target: Vector3): Vector3;
  92260. /**
  92261. * Returns the shadow generator associated to the light.
  92262. * @returns Always null for hemispheric lights because it does not support shadows.
  92263. */
  92264. getShadowGenerator(): Nullable<IShadowGenerator>;
  92265. /**
  92266. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  92267. * @param effect The effect to update
  92268. * @param lightIndex The index of the light in the effect to update
  92269. * @returns The hemispheric light
  92270. */
  92271. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  92272. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  92273. /**
  92274. * Computes the world matrix of the node
  92275. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92276. * @param useWasUpdatedFlag defines a reserved property
  92277. * @returns the world matrix
  92278. */
  92279. computeWorldMatrix(): Matrix;
  92280. /**
  92281. * Returns the integer 3.
  92282. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  92283. */
  92284. getTypeID(): number;
  92285. /**
  92286. * Prepares the list of defines specific to the light type.
  92287. * @param defines the list of defines
  92288. * @param lightIndex defines the index of the light for the effect
  92289. */
  92290. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  92291. }
  92292. }
  92293. declare module BABYLON {
  92294. /** @hidden */
  92295. export var vrMultiviewToSingleviewPixelShader: {
  92296. name: string;
  92297. shader: string;
  92298. };
  92299. }
  92300. declare module BABYLON {
  92301. /**
  92302. * Renders to multiple views with a single draw call
  92303. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  92304. */
  92305. export class MultiviewRenderTarget extends RenderTargetTexture {
  92306. /**
  92307. * Creates a multiview render target
  92308. * @param scene scene used with the render target
  92309. * @param size the size of the render target (used for each view)
  92310. */
  92311. constructor(scene: Scene, size?: number | {
  92312. width: number;
  92313. height: number;
  92314. } | {
  92315. ratio: number;
  92316. });
  92317. /**
  92318. * @hidden
  92319. * @param faceIndex the face index, if its a cube texture
  92320. */
  92321. _bindFrameBuffer(faceIndex?: number): void;
  92322. /**
  92323. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  92324. * @returns the view count
  92325. */
  92326. getViewCount(): number;
  92327. }
  92328. }
  92329. declare module BABYLON {
  92330. /**
  92331. * Represents a camera frustum
  92332. */
  92333. export class Frustum {
  92334. /**
  92335. * Gets the planes representing the frustum
  92336. * @param transform matrix to be applied to the returned planes
  92337. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  92338. */
  92339. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  92340. /**
  92341. * Gets the near frustum plane transformed by the transform matrix
  92342. * @param transform transformation matrix to be applied to the resulting frustum plane
  92343. * @param frustumPlane the resuling frustum plane
  92344. */
  92345. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92346. /**
  92347. * Gets the far frustum plane transformed by the transform matrix
  92348. * @param transform transformation matrix to be applied to the resulting frustum plane
  92349. * @param frustumPlane the resuling frustum plane
  92350. */
  92351. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92352. /**
  92353. * Gets the left frustum plane transformed by the transform matrix
  92354. * @param transform transformation matrix to be applied to the resulting frustum plane
  92355. * @param frustumPlane the resuling frustum plane
  92356. */
  92357. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92358. /**
  92359. * Gets the right frustum plane transformed by the transform matrix
  92360. * @param transform transformation matrix to be applied to the resulting frustum plane
  92361. * @param frustumPlane the resuling frustum plane
  92362. */
  92363. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92364. /**
  92365. * Gets the top frustum plane transformed by the transform matrix
  92366. * @param transform transformation matrix to be applied to the resulting frustum plane
  92367. * @param frustumPlane the resuling frustum plane
  92368. */
  92369. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92370. /**
  92371. * Gets the bottom frustum plane transformed by the transform matrix
  92372. * @param transform transformation matrix to be applied to the resulting frustum plane
  92373. * @param frustumPlane the resuling frustum plane
  92374. */
  92375. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92376. /**
  92377. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  92378. * @param transform transformation matrix to be applied to the resulting frustum planes
  92379. * @param frustumPlanes the resuling frustum planes
  92380. */
  92381. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  92382. }
  92383. }
  92384. declare module BABYLON {
  92385. interface Engine {
  92386. /**
  92387. * Creates a new multiview render target
  92388. * @param width defines the width of the texture
  92389. * @param height defines the height of the texture
  92390. * @returns the created multiview texture
  92391. */
  92392. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  92393. /**
  92394. * Binds a multiview framebuffer to be drawn to
  92395. * @param multiviewTexture texture to bind
  92396. */
  92397. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  92398. }
  92399. interface Camera {
  92400. /**
  92401. * @hidden
  92402. * 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)
  92403. */
  92404. _useMultiviewToSingleView: boolean;
  92405. /**
  92406. * @hidden
  92407. * 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)
  92408. */
  92409. _multiviewTexture: Nullable<RenderTargetTexture>;
  92410. /**
  92411. * @hidden
  92412. * ensures the multiview texture of the camera exists and has the specified width/height
  92413. * @param width height to set on the multiview texture
  92414. * @param height width to set on the multiview texture
  92415. */
  92416. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  92417. }
  92418. interface Scene {
  92419. /** @hidden */
  92420. _transformMatrixR: Matrix;
  92421. /** @hidden */
  92422. _multiviewSceneUbo: Nullable<UniformBuffer>;
  92423. /** @hidden */
  92424. _createMultiviewUbo(): void;
  92425. /** @hidden */
  92426. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  92427. /** @hidden */
  92428. _renderMultiviewToSingleView(camera: Camera): void;
  92429. }
  92430. }
  92431. declare module BABYLON {
  92432. /**
  92433. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  92434. * This will not be used for webXR as it supports displaying texture arrays directly
  92435. */
  92436. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  92437. /**
  92438. * Initializes a VRMultiviewToSingleview
  92439. * @param name name of the post process
  92440. * @param camera camera to be applied to
  92441. * @param scaleFactor scaling factor to the size of the output texture
  92442. */
  92443. constructor(name: string, camera: Camera, scaleFactor: number);
  92444. }
  92445. }
  92446. declare module BABYLON {
  92447. /**
  92448. * Interface used to define additional presentation attributes
  92449. */
  92450. export interface IVRPresentationAttributes {
  92451. /**
  92452. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  92453. */
  92454. highRefreshRate: boolean;
  92455. /**
  92456. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  92457. */
  92458. foveationLevel: number;
  92459. }
  92460. interface Engine {
  92461. /** @hidden */
  92462. _vrDisplay: any;
  92463. /** @hidden */
  92464. _vrSupported: boolean;
  92465. /** @hidden */
  92466. _oldSize: Size;
  92467. /** @hidden */
  92468. _oldHardwareScaleFactor: number;
  92469. /** @hidden */
  92470. _vrExclusivePointerMode: boolean;
  92471. /** @hidden */
  92472. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  92473. /** @hidden */
  92474. _onVRDisplayPointerRestricted: () => void;
  92475. /** @hidden */
  92476. _onVRDisplayPointerUnrestricted: () => void;
  92477. /** @hidden */
  92478. _onVrDisplayConnect: Nullable<(display: any) => void>;
  92479. /** @hidden */
  92480. _onVrDisplayDisconnect: Nullable<() => void>;
  92481. /** @hidden */
  92482. _onVrDisplayPresentChange: Nullable<() => void>;
  92483. /**
  92484. * Observable signaled when VR display mode changes
  92485. */
  92486. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  92487. /**
  92488. * Observable signaled when VR request present is complete
  92489. */
  92490. onVRRequestPresentComplete: Observable<boolean>;
  92491. /**
  92492. * Observable signaled when VR request present starts
  92493. */
  92494. onVRRequestPresentStart: Observable<Engine>;
  92495. /**
  92496. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  92497. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  92498. */
  92499. isInVRExclusivePointerMode: boolean;
  92500. /**
  92501. * Gets a boolean indicating if a webVR device was detected
  92502. * @returns true if a webVR device was detected
  92503. */
  92504. isVRDevicePresent(): boolean;
  92505. /**
  92506. * Gets the current webVR device
  92507. * @returns the current webVR device (or null)
  92508. */
  92509. getVRDevice(): any;
  92510. /**
  92511. * Initializes a webVR display and starts listening to display change events
  92512. * The onVRDisplayChangedObservable will be notified upon these changes
  92513. * @returns A promise containing a VRDisplay and if vr is supported
  92514. */
  92515. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  92516. /** @hidden */
  92517. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  92518. /**
  92519. * Gets or sets the presentation attributes used to configure VR rendering
  92520. */
  92521. vrPresentationAttributes?: IVRPresentationAttributes;
  92522. /**
  92523. * Call this function to switch to webVR mode
  92524. * Will do nothing if webVR is not supported or if there is no webVR device
  92525. * @param options the webvr options provided to the camera. mainly used for multiview
  92526. * @see http://doc.babylonjs.com/how_to/webvr_camera
  92527. */
  92528. enableVR(options: WebVROptions): void;
  92529. /** @hidden */
  92530. _onVRFullScreenTriggered(): void;
  92531. }
  92532. }
  92533. declare module BABYLON {
  92534. /**
  92535. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  92536. * IMPORTANT!! The data is right-hand data.
  92537. * @export
  92538. * @interface DevicePose
  92539. */
  92540. export interface DevicePose {
  92541. /**
  92542. * The position of the device, values in array are [x,y,z].
  92543. */
  92544. readonly position: Nullable<Float32Array>;
  92545. /**
  92546. * The linearVelocity of the device, values in array are [x,y,z].
  92547. */
  92548. readonly linearVelocity: Nullable<Float32Array>;
  92549. /**
  92550. * The linearAcceleration of the device, values in array are [x,y,z].
  92551. */
  92552. readonly linearAcceleration: Nullable<Float32Array>;
  92553. /**
  92554. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  92555. */
  92556. readonly orientation: Nullable<Float32Array>;
  92557. /**
  92558. * The angularVelocity of the device, values in array are [x,y,z].
  92559. */
  92560. readonly angularVelocity: Nullable<Float32Array>;
  92561. /**
  92562. * The angularAcceleration of the device, values in array are [x,y,z].
  92563. */
  92564. readonly angularAcceleration: Nullable<Float32Array>;
  92565. }
  92566. /**
  92567. * Interface representing a pose controlled object in Babylon.
  92568. * A pose controlled object has both regular pose values as well as pose values
  92569. * from an external device such as a VR head mounted display
  92570. */
  92571. export interface PoseControlled {
  92572. /**
  92573. * The position of the object in babylon space.
  92574. */
  92575. position: Vector3;
  92576. /**
  92577. * The rotation quaternion of the object in babylon space.
  92578. */
  92579. rotationQuaternion: Quaternion;
  92580. /**
  92581. * The position of the device in babylon space.
  92582. */
  92583. devicePosition?: Vector3;
  92584. /**
  92585. * The rotation quaternion of the device in babylon space.
  92586. */
  92587. deviceRotationQuaternion: Quaternion;
  92588. /**
  92589. * The raw pose coming from the device.
  92590. */
  92591. rawPose: Nullable<DevicePose>;
  92592. /**
  92593. * The scale of the device to be used when translating from device space to babylon space.
  92594. */
  92595. deviceScaleFactor: number;
  92596. /**
  92597. * Updates the poseControlled values based on the input device pose.
  92598. * @param poseData the pose data to update the object with
  92599. */
  92600. updateFromDevice(poseData: DevicePose): void;
  92601. }
  92602. /**
  92603. * Set of options to customize the webVRCamera
  92604. */
  92605. export interface WebVROptions {
  92606. /**
  92607. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  92608. */
  92609. trackPosition?: boolean;
  92610. /**
  92611. * Sets the scale of the vrDevice in babylon space. (default: 1)
  92612. */
  92613. positionScale?: number;
  92614. /**
  92615. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  92616. */
  92617. displayName?: string;
  92618. /**
  92619. * Should the native controller meshes be initialized. (default: true)
  92620. */
  92621. controllerMeshes?: boolean;
  92622. /**
  92623. * Creating a default HemiLight only on controllers. (default: true)
  92624. */
  92625. defaultLightingOnControllers?: boolean;
  92626. /**
  92627. * If you don't want to use the default VR button of the helper. (default: false)
  92628. */
  92629. useCustomVRButton?: boolean;
  92630. /**
  92631. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  92632. */
  92633. customVRButton?: HTMLButtonElement;
  92634. /**
  92635. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  92636. */
  92637. rayLength?: number;
  92638. /**
  92639. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  92640. */
  92641. defaultHeight?: number;
  92642. /**
  92643. * If multiview should be used if availible (default: false)
  92644. */
  92645. useMultiview?: boolean;
  92646. }
  92647. /**
  92648. * This represents a WebVR camera.
  92649. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  92650. * @example http://doc.babylonjs.com/how_to/webvr_camera
  92651. */
  92652. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  92653. private webVROptions;
  92654. /**
  92655. * @hidden
  92656. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  92657. */
  92658. _vrDevice: any;
  92659. /**
  92660. * The rawPose of the vrDevice.
  92661. */
  92662. rawPose: Nullable<DevicePose>;
  92663. private _onVREnabled;
  92664. private _specsVersion;
  92665. private _attached;
  92666. private _frameData;
  92667. protected _descendants: Array<Node>;
  92668. private _deviceRoomPosition;
  92669. /** @hidden */
  92670. _deviceRoomRotationQuaternion: Quaternion;
  92671. private _standingMatrix;
  92672. /**
  92673. * Represents device position in babylon space.
  92674. */
  92675. devicePosition: Vector3;
  92676. /**
  92677. * Represents device rotation in babylon space.
  92678. */
  92679. deviceRotationQuaternion: Quaternion;
  92680. /**
  92681. * The scale of the device to be used when translating from device space to babylon space.
  92682. */
  92683. deviceScaleFactor: number;
  92684. private _deviceToWorld;
  92685. private _worldToDevice;
  92686. /**
  92687. * References to the webVR controllers for the vrDevice.
  92688. */
  92689. controllers: Array<WebVRController>;
  92690. /**
  92691. * Emits an event when a controller is attached.
  92692. */
  92693. onControllersAttachedObservable: Observable<WebVRController[]>;
  92694. /**
  92695. * Emits an event when a controller's mesh has been loaded;
  92696. */
  92697. onControllerMeshLoadedObservable: Observable<WebVRController>;
  92698. /**
  92699. * Emits an event when the HMD's pose has been updated.
  92700. */
  92701. onPoseUpdatedFromDeviceObservable: Observable<any>;
  92702. private _poseSet;
  92703. /**
  92704. * If the rig cameras be used as parent instead of this camera.
  92705. */
  92706. rigParenting: boolean;
  92707. private _lightOnControllers;
  92708. private _defaultHeight?;
  92709. /**
  92710. * Instantiates a WebVRFreeCamera.
  92711. * @param name The name of the WebVRFreeCamera
  92712. * @param position The starting anchor position for the camera
  92713. * @param scene The scene the camera belongs to
  92714. * @param webVROptions a set of customizable options for the webVRCamera
  92715. */
  92716. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  92717. /**
  92718. * Gets the device distance from the ground in meters.
  92719. * @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.
  92720. */
  92721. deviceDistanceToRoomGround(): number;
  92722. /**
  92723. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92724. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  92725. */
  92726. useStandingMatrix(callback?: (bool: boolean) => void): void;
  92727. /**
  92728. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92729. * @returns A promise with a boolean set to if the standing matrix is supported.
  92730. */
  92731. useStandingMatrixAsync(): Promise<boolean>;
  92732. /**
  92733. * Disposes the camera
  92734. */
  92735. dispose(): void;
  92736. /**
  92737. * Gets a vrController by name.
  92738. * @param name The name of the controller to retreive
  92739. * @returns the controller matching the name specified or null if not found
  92740. */
  92741. getControllerByName(name: string): Nullable<WebVRController>;
  92742. private _leftController;
  92743. /**
  92744. * The controller corresponding to the users left hand.
  92745. */
  92746. get leftController(): Nullable<WebVRController>;
  92747. private _rightController;
  92748. /**
  92749. * The controller corresponding to the users right hand.
  92750. */
  92751. get rightController(): Nullable<WebVRController>;
  92752. /**
  92753. * Casts a ray forward from the vrCamera's gaze.
  92754. * @param length Length of the ray (default: 100)
  92755. * @returns the ray corresponding to the gaze
  92756. */
  92757. getForwardRay(length?: number): Ray;
  92758. /**
  92759. * @hidden
  92760. * Updates the camera based on device's frame data
  92761. */
  92762. _checkInputs(): void;
  92763. /**
  92764. * Updates the poseControlled values based on the input device pose.
  92765. * @param poseData Pose coming from the device
  92766. */
  92767. updateFromDevice(poseData: DevicePose): void;
  92768. private _htmlElementAttached;
  92769. private _detachIfAttached;
  92770. /**
  92771. * WebVR's attach control will start broadcasting frames to the device.
  92772. * Note that in certain browsers (chrome for example) this function must be called
  92773. * within a user-interaction callback. Example:
  92774. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  92775. *
  92776. * @param element html element to attach the vrDevice to
  92777. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  92778. */
  92779. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92780. /**
  92781. * Detaches the camera from the html element and disables VR
  92782. *
  92783. * @param element html element to detach from
  92784. */
  92785. detachControl(element: HTMLElement): void;
  92786. /**
  92787. * @returns the name of this class
  92788. */
  92789. getClassName(): string;
  92790. /**
  92791. * Calls resetPose on the vrDisplay
  92792. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  92793. */
  92794. resetToCurrentRotation(): void;
  92795. /**
  92796. * @hidden
  92797. * Updates the rig cameras (left and right eye)
  92798. */
  92799. _updateRigCameras(): void;
  92800. private _workingVector;
  92801. private _oneVector;
  92802. private _workingMatrix;
  92803. private updateCacheCalled;
  92804. private _correctPositionIfNotTrackPosition;
  92805. /**
  92806. * @hidden
  92807. * Updates the cached values of the camera
  92808. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  92809. */
  92810. _updateCache(ignoreParentClass?: boolean): void;
  92811. /**
  92812. * @hidden
  92813. * Get current device position in babylon world
  92814. */
  92815. _computeDevicePosition(): void;
  92816. /**
  92817. * Updates the current device position and rotation in the babylon world
  92818. */
  92819. update(): void;
  92820. /**
  92821. * @hidden
  92822. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  92823. * @returns an identity matrix
  92824. */
  92825. _getViewMatrix(): Matrix;
  92826. private _tmpMatrix;
  92827. /**
  92828. * This function is called by the two RIG cameras.
  92829. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  92830. * @hidden
  92831. */
  92832. _getWebVRViewMatrix(): Matrix;
  92833. /** @hidden */
  92834. _getWebVRProjectionMatrix(): Matrix;
  92835. private _onGamepadConnectedObserver;
  92836. private _onGamepadDisconnectedObserver;
  92837. private _updateCacheWhenTrackingDisabledObserver;
  92838. /**
  92839. * Initializes the controllers and their meshes
  92840. */
  92841. initControllers(): void;
  92842. }
  92843. }
  92844. declare module BABYLON {
  92845. /**
  92846. * Size options for a post process
  92847. */
  92848. export type PostProcessOptions = {
  92849. width: number;
  92850. height: number;
  92851. };
  92852. /**
  92853. * PostProcess can be used to apply a shader to a texture after it has been rendered
  92854. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  92855. */
  92856. export class PostProcess {
  92857. /** Name of the PostProcess. */
  92858. name: string;
  92859. /**
  92860. * Gets or sets the unique id of the post process
  92861. */
  92862. uniqueId: number;
  92863. /**
  92864. * Width of the texture to apply the post process on
  92865. */
  92866. width: number;
  92867. /**
  92868. * Height of the texture to apply the post process on
  92869. */
  92870. height: number;
  92871. /**
  92872. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  92873. * @hidden
  92874. */
  92875. _outputTexture: Nullable<InternalTexture>;
  92876. /**
  92877. * Sampling mode used by the shader
  92878. * See https://doc.babylonjs.com/classes/3.1/texture
  92879. */
  92880. renderTargetSamplingMode: number;
  92881. /**
  92882. * Clear color to use when screen clearing
  92883. */
  92884. clearColor: Color4;
  92885. /**
  92886. * If the buffer needs to be cleared before applying the post process. (default: true)
  92887. * Should be set to false if shader will overwrite all previous pixels.
  92888. */
  92889. autoClear: boolean;
  92890. /**
  92891. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  92892. */
  92893. alphaMode: number;
  92894. /**
  92895. * Sets the setAlphaBlendConstants of the babylon engine
  92896. */
  92897. alphaConstants: Color4;
  92898. /**
  92899. * Animations to be used for the post processing
  92900. */
  92901. animations: Animation[];
  92902. /**
  92903. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  92904. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  92905. */
  92906. enablePixelPerfectMode: boolean;
  92907. /**
  92908. * Force the postprocess to be applied without taking in account viewport
  92909. */
  92910. forceFullscreenViewport: boolean;
  92911. /**
  92912. * List of inspectable custom properties (used by the Inspector)
  92913. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92914. */
  92915. inspectableCustomProperties: IInspectable[];
  92916. /**
  92917. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  92918. *
  92919. * | Value | Type | Description |
  92920. * | ----- | ----------------------------------- | ----------- |
  92921. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  92922. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  92923. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  92924. *
  92925. */
  92926. scaleMode: number;
  92927. /**
  92928. * Force textures to be a power of two (default: false)
  92929. */
  92930. alwaysForcePOT: boolean;
  92931. private _samples;
  92932. /**
  92933. * Number of sample textures (default: 1)
  92934. */
  92935. get samples(): number;
  92936. set samples(n: number);
  92937. /**
  92938. * Modify the scale of the post process to be the same as the viewport (default: false)
  92939. */
  92940. adaptScaleToCurrentViewport: boolean;
  92941. private _camera;
  92942. private _scene;
  92943. private _engine;
  92944. private _options;
  92945. private _reusable;
  92946. private _textureType;
  92947. private _textureFormat;
  92948. /**
  92949. * Smart array of input and output textures for the post process.
  92950. * @hidden
  92951. */
  92952. _textures: SmartArray<InternalTexture>;
  92953. /**
  92954. * The index in _textures that corresponds to the output texture.
  92955. * @hidden
  92956. */
  92957. _currentRenderTextureInd: number;
  92958. private _effect;
  92959. private _samplers;
  92960. private _fragmentUrl;
  92961. private _vertexUrl;
  92962. private _parameters;
  92963. private _scaleRatio;
  92964. protected _indexParameters: any;
  92965. private _shareOutputWithPostProcess;
  92966. private _texelSize;
  92967. private _forcedOutputTexture;
  92968. /**
  92969. * Returns the fragment url or shader name used in the post process.
  92970. * @returns the fragment url or name in the shader store.
  92971. */
  92972. getEffectName(): string;
  92973. /**
  92974. * An event triggered when the postprocess is activated.
  92975. */
  92976. onActivateObservable: Observable<Camera>;
  92977. private _onActivateObserver;
  92978. /**
  92979. * A function that is added to the onActivateObservable
  92980. */
  92981. set onActivate(callback: Nullable<(camera: Camera) => void>);
  92982. /**
  92983. * An event triggered when the postprocess changes its size.
  92984. */
  92985. onSizeChangedObservable: Observable<PostProcess>;
  92986. private _onSizeChangedObserver;
  92987. /**
  92988. * A function that is added to the onSizeChangedObservable
  92989. */
  92990. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  92991. /**
  92992. * An event triggered when the postprocess applies its effect.
  92993. */
  92994. onApplyObservable: Observable<Effect>;
  92995. private _onApplyObserver;
  92996. /**
  92997. * A function that is added to the onApplyObservable
  92998. */
  92999. set onApply(callback: (effect: Effect) => void);
  93000. /**
  93001. * An event triggered before rendering the postprocess
  93002. */
  93003. onBeforeRenderObservable: Observable<Effect>;
  93004. private _onBeforeRenderObserver;
  93005. /**
  93006. * A function that is added to the onBeforeRenderObservable
  93007. */
  93008. set onBeforeRender(callback: (effect: Effect) => void);
  93009. /**
  93010. * An event triggered after rendering the postprocess
  93011. */
  93012. onAfterRenderObservable: Observable<Effect>;
  93013. private _onAfterRenderObserver;
  93014. /**
  93015. * A function that is added to the onAfterRenderObservable
  93016. */
  93017. set onAfterRender(callback: (efect: Effect) => void);
  93018. /**
  93019. * 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
  93020. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  93021. */
  93022. get inputTexture(): InternalTexture;
  93023. set inputTexture(value: InternalTexture);
  93024. /**
  93025. * Gets the camera which post process is applied to.
  93026. * @returns The camera the post process is applied to.
  93027. */
  93028. getCamera(): Camera;
  93029. /**
  93030. * Gets the texel size of the postprocess.
  93031. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  93032. */
  93033. get texelSize(): Vector2;
  93034. /**
  93035. * Creates a new instance PostProcess
  93036. * @param name The name of the PostProcess.
  93037. * @param fragmentUrl The url of the fragment shader to be used.
  93038. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  93039. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  93040. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93041. * @param camera The camera to apply the render pass to.
  93042. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93043. * @param engine The engine which the post process will be applied. (default: current engine)
  93044. * @param reusable If the post process can be reused on the same frame. (default: false)
  93045. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  93046. * @param textureType Type of textures used when performing the post process. (default: 0)
  93047. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  93048. * @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
  93049. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  93050. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  93051. */
  93052. constructor(
  93053. /** Name of the PostProcess. */
  93054. 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);
  93055. /**
  93056. * Gets a string idenfifying the name of the class
  93057. * @returns "PostProcess" string
  93058. */
  93059. getClassName(): string;
  93060. /**
  93061. * Gets the engine which this post process belongs to.
  93062. * @returns The engine the post process was enabled with.
  93063. */
  93064. getEngine(): Engine;
  93065. /**
  93066. * The effect that is created when initializing the post process.
  93067. * @returns The created effect corresponding the the postprocess.
  93068. */
  93069. getEffect(): Effect;
  93070. /**
  93071. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  93072. * @param postProcess The post process to share the output with.
  93073. * @returns This post process.
  93074. */
  93075. shareOutputWith(postProcess: PostProcess): PostProcess;
  93076. /**
  93077. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  93078. * This should be called if the post process that shares output with this post process is disabled/disposed.
  93079. */
  93080. useOwnOutput(): void;
  93081. /**
  93082. * Updates the effect with the current post process compile time values and recompiles the shader.
  93083. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93084. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93085. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93086. * @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
  93087. * @param onCompiled Called when the shader has been compiled.
  93088. * @param onError Called if there is an error when compiling a shader.
  93089. */
  93090. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93091. /**
  93092. * The post process is reusable if it can be used multiple times within one frame.
  93093. * @returns If the post process is reusable
  93094. */
  93095. isReusable(): boolean;
  93096. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  93097. markTextureDirty(): void;
  93098. /**
  93099. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  93100. * 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.
  93101. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  93102. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  93103. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  93104. * @returns The target texture that was bound to be written to.
  93105. */
  93106. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  93107. /**
  93108. * If the post process is supported.
  93109. */
  93110. get isSupported(): boolean;
  93111. /**
  93112. * The aspect ratio of the output texture.
  93113. */
  93114. get aspectRatio(): number;
  93115. /**
  93116. * Get a value indicating if the post-process is ready to be used
  93117. * @returns true if the post-process is ready (shader is compiled)
  93118. */
  93119. isReady(): boolean;
  93120. /**
  93121. * Binds all textures and uniforms to the shader, this will be run on every pass.
  93122. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  93123. */
  93124. apply(): Nullable<Effect>;
  93125. private _disposeTextures;
  93126. /**
  93127. * Disposes the post process.
  93128. * @param camera The camera to dispose the post process on.
  93129. */
  93130. dispose(camera?: Camera): void;
  93131. }
  93132. }
  93133. declare module BABYLON {
  93134. /** @hidden */
  93135. export var kernelBlurVaryingDeclaration: {
  93136. name: string;
  93137. shader: string;
  93138. };
  93139. }
  93140. declare module BABYLON {
  93141. /** @hidden */
  93142. export var kernelBlurFragment: {
  93143. name: string;
  93144. shader: string;
  93145. };
  93146. }
  93147. declare module BABYLON {
  93148. /** @hidden */
  93149. export var kernelBlurFragment2: {
  93150. name: string;
  93151. shader: string;
  93152. };
  93153. }
  93154. declare module BABYLON {
  93155. /** @hidden */
  93156. export var kernelBlurPixelShader: {
  93157. name: string;
  93158. shader: string;
  93159. };
  93160. }
  93161. declare module BABYLON {
  93162. /** @hidden */
  93163. export var kernelBlurVertex: {
  93164. name: string;
  93165. shader: string;
  93166. };
  93167. }
  93168. declare module BABYLON {
  93169. /** @hidden */
  93170. export var kernelBlurVertexShader: {
  93171. name: string;
  93172. shader: string;
  93173. };
  93174. }
  93175. declare module BABYLON {
  93176. /**
  93177. * The Blur Post Process which blurs an image based on a kernel and direction.
  93178. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  93179. */
  93180. export class BlurPostProcess extends PostProcess {
  93181. /** The direction in which to blur the image. */
  93182. direction: Vector2;
  93183. private blockCompilation;
  93184. protected _kernel: number;
  93185. protected _idealKernel: number;
  93186. protected _packedFloat: boolean;
  93187. private _staticDefines;
  93188. /**
  93189. * Sets the length in pixels of the blur sample region
  93190. */
  93191. set kernel(v: number);
  93192. /**
  93193. * Gets the length in pixels of the blur sample region
  93194. */
  93195. get kernel(): number;
  93196. /**
  93197. * Sets wether or not the blur needs to unpack/repack floats
  93198. */
  93199. set packedFloat(v: boolean);
  93200. /**
  93201. * Gets wether or not the blur is unpacking/repacking floats
  93202. */
  93203. get packedFloat(): boolean;
  93204. /**
  93205. * Creates a new instance BlurPostProcess
  93206. * @param name The name of the effect.
  93207. * @param direction The direction in which to blur the image.
  93208. * @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.
  93209. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93210. * @param camera The camera to apply the render pass to.
  93211. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93212. * @param engine The engine which the post process will be applied. (default: current engine)
  93213. * @param reusable If the post process can be reused on the same frame. (default: false)
  93214. * @param textureType Type of textures used when performing the post process. (default: 0)
  93215. * @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)
  93216. */
  93217. constructor(name: string,
  93218. /** The direction in which to blur the image. */
  93219. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  93220. /**
  93221. * Updates the effect with the current post process compile time values and recompiles the shader.
  93222. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93223. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93224. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93225. * @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
  93226. * @param onCompiled Called when the shader has been compiled.
  93227. * @param onError Called if there is an error when compiling a shader.
  93228. */
  93229. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93230. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93231. /**
  93232. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  93233. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  93234. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  93235. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  93236. * The gaps between physical kernels are compensated for in the weighting of the samples
  93237. * @param idealKernel Ideal blur kernel.
  93238. * @return Nearest best kernel.
  93239. */
  93240. protected _nearestBestKernel(idealKernel: number): number;
  93241. /**
  93242. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  93243. * @param x The point on the Gaussian distribution to sample.
  93244. * @return the value of the Gaussian function at x.
  93245. */
  93246. protected _gaussianWeight(x: number): number;
  93247. /**
  93248. * Generates a string that can be used as a floating point number in GLSL.
  93249. * @param x Value to print.
  93250. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  93251. * @return GLSL float string.
  93252. */
  93253. protected _glslFloat(x: number, decimalFigures?: number): string;
  93254. }
  93255. }
  93256. declare module BABYLON {
  93257. /**
  93258. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93259. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93260. * You can then easily use it as a reflectionTexture on a flat surface.
  93261. * In case the surface is not a plane, please consider relying on reflection probes.
  93262. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93263. */
  93264. export class MirrorTexture extends RenderTargetTexture {
  93265. private scene;
  93266. /**
  93267. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  93268. * 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.
  93269. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93270. */
  93271. mirrorPlane: Plane;
  93272. /**
  93273. * Define the blur ratio used to blur the reflection if needed.
  93274. */
  93275. set blurRatio(value: number);
  93276. get blurRatio(): number;
  93277. /**
  93278. * Define the adaptive blur kernel used to blur the reflection if needed.
  93279. * This will autocompute the closest best match for the `blurKernel`
  93280. */
  93281. set adaptiveBlurKernel(value: number);
  93282. /**
  93283. * Define the blur kernel used to blur the reflection if needed.
  93284. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93285. */
  93286. set blurKernel(value: number);
  93287. /**
  93288. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  93289. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93290. */
  93291. set blurKernelX(value: number);
  93292. get blurKernelX(): number;
  93293. /**
  93294. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  93295. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93296. */
  93297. set blurKernelY(value: number);
  93298. get blurKernelY(): number;
  93299. private _autoComputeBlurKernel;
  93300. protected _onRatioRescale(): void;
  93301. private _updateGammaSpace;
  93302. private _imageProcessingConfigChangeObserver;
  93303. private _transformMatrix;
  93304. private _mirrorMatrix;
  93305. private _savedViewMatrix;
  93306. private _blurX;
  93307. private _blurY;
  93308. private _adaptiveBlurKernel;
  93309. private _blurKernelX;
  93310. private _blurKernelY;
  93311. private _blurRatio;
  93312. /**
  93313. * Instantiates a Mirror Texture.
  93314. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93315. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93316. * You can then easily use it as a reflectionTexture on a flat surface.
  93317. * In case the surface is not a plane, please consider relying on reflection probes.
  93318. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93319. * @param name
  93320. * @param size
  93321. * @param scene
  93322. * @param generateMipMaps
  93323. * @param type
  93324. * @param samplingMode
  93325. * @param generateDepthBuffer
  93326. */
  93327. constructor(name: string, size: number | {
  93328. width: number;
  93329. height: number;
  93330. } | {
  93331. ratio: number;
  93332. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  93333. private _preparePostProcesses;
  93334. /**
  93335. * Clone the mirror texture.
  93336. * @returns the cloned texture
  93337. */
  93338. clone(): MirrorTexture;
  93339. /**
  93340. * Serialize the texture to a JSON representation you could use in Parse later on
  93341. * @returns the serialized JSON representation
  93342. */
  93343. serialize(): any;
  93344. /**
  93345. * Dispose the texture and release its associated resources.
  93346. */
  93347. dispose(): void;
  93348. }
  93349. }
  93350. declare module BABYLON {
  93351. /**
  93352. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93353. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93354. */
  93355. export class Texture extends BaseTexture {
  93356. /**
  93357. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  93358. */
  93359. static SerializeBuffers: boolean;
  93360. /** @hidden */
  93361. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  93362. /** @hidden */
  93363. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  93364. /** @hidden */
  93365. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  93366. /** nearest is mag = nearest and min = nearest and mip = linear */
  93367. static readonly NEAREST_SAMPLINGMODE: number;
  93368. /** nearest is mag = nearest and min = nearest and mip = linear */
  93369. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  93370. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93371. static readonly BILINEAR_SAMPLINGMODE: number;
  93372. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93373. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  93374. /** Trilinear is mag = linear and min = linear and mip = linear */
  93375. static readonly TRILINEAR_SAMPLINGMODE: number;
  93376. /** Trilinear is mag = linear and min = linear and mip = linear */
  93377. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  93378. /** mag = nearest and min = nearest and mip = nearest */
  93379. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  93380. /** mag = nearest and min = linear and mip = nearest */
  93381. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  93382. /** mag = nearest and min = linear and mip = linear */
  93383. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  93384. /** mag = nearest and min = linear and mip = none */
  93385. static readonly NEAREST_LINEAR: number;
  93386. /** mag = nearest and min = nearest and mip = none */
  93387. static readonly NEAREST_NEAREST: number;
  93388. /** mag = linear and min = nearest and mip = nearest */
  93389. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  93390. /** mag = linear and min = nearest and mip = linear */
  93391. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  93392. /** mag = linear and min = linear and mip = none */
  93393. static readonly LINEAR_LINEAR: number;
  93394. /** mag = linear and min = nearest and mip = none */
  93395. static readonly LINEAR_NEAREST: number;
  93396. /** Explicit coordinates mode */
  93397. static readonly EXPLICIT_MODE: number;
  93398. /** Spherical coordinates mode */
  93399. static readonly SPHERICAL_MODE: number;
  93400. /** Planar coordinates mode */
  93401. static readonly PLANAR_MODE: number;
  93402. /** Cubic coordinates mode */
  93403. static readonly CUBIC_MODE: number;
  93404. /** Projection coordinates mode */
  93405. static readonly PROJECTION_MODE: number;
  93406. /** Inverse Cubic coordinates mode */
  93407. static readonly SKYBOX_MODE: number;
  93408. /** Inverse Cubic coordinates mode */
  93409. static readonly INVCUBIC_MODE: number;
  93410. /** Equirectangular coordinates mode */
  93411. static readonly EQUIRECTANGULAR_MODE: number;
  93412. /** Equirectangular Fixed coordinates mode */
  93413. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  93414. /** Equirectangular Fixed Mirrored coordinates mode */
  93415. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93416. /** Texture is not repeating outside of 0..1 UVs */
  93417. static readonly CLAMP_ADDRESSMODE: number;
  93418. /** Texture is repeating outside of 0..1 UVs */
  93419. static readonly WRAP_ADDRESSMODE: number;
  93420. /** Texture is repeating and mirrored */
  93421. static readonly MIRROR_ADDRESSMODE: number;
  93422. /**
  93423. * 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
  93424. */
  93425. static UseSerializedUrlIfAny: boolean;
  93426. /**
  93427. * Define the url of the texture.
  93428. */
  93429. url: Nullable<string>;
  93430. /**
  93431. * Define an offset on the texture to offset the u coordinates of the UVs
  93432. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93433. */
  93434. uOffset: number;
  93435. /**
  93436. * Define an offset on the texture to offset the v coordinates of the UVs
  93437. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93438. */
  93439. vOffset: number;
  93440. /**
  93441. * Define an offset on the texture to scale the u coordinates of the UVs
  93442. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93443. */
  93444. uScale: number;
  93445. /**
  93446. * Define an offset on the texture to scale the v coordinates of the UVs
  93447. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93448. */
  93449. vScale: number;
  93450. /**
  93451. * Define an offset on the texture to rotate around the u coordinates of the UVs
  93452. * @see http://doc.babylonjs.com/how_to/more_materials
  93453. */
  93454. uAng: number;
  93455. /**
  93456. * Define an offset on the texture to rotate around the v coordinates of the UVs
  93457. * @see http://doc.babylonjs.com/how_to/more_materials
  93458. */
  93459. vAng: number;
  93460. /**
  93461. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  93462. * @see http://doc.babylonjs.com/how_to/more_materials
  93463. */
  93464. wAng: number;
  93465. /**
  93466. * Defines the center of rotation (U)
  93467. */
  93468. uRotationCenter: number;
  93469. /**
  93470. * Defines the center of rotation (V)
  93471. */
  93472. vRotationCenter: number;
  93473. /**
  93474. * Defines the center of rotation (W)
  93475. */
  93476. wRotationCenter: number;
  93477. /**
  93478. * Are mip maps generated for this texture or not.
  93479. */
  93480. get noMipmap(): boolean;
  93481. /**
  93482. * List of inspectable custom properties (used by the Inspector)
  93483. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93484. */
  93485. inspectableCustomProperties: Nullable<IInspectable[]>;
  93486. private _noMipmap;
  93487. /** @hidden */
  93488. _invertY: boolean;
  93489. private _rowGenerationMatrix;
  93490. private _cachedTextureMatrix;
  93491. private _projectionModeMatrix;
  93492. private _t0;
  93493. private _t1;
  93494. private _t2;
  93495. private _cachedUOffset;
  93496. private _cachedVOffset;
  93497. private _cachedUScale;
  93498. private _cachedVScale;
  93499. private _cachedUAng;
  93500. private _cachedVAng;
  93501. private _cachedWAng;
  93502. private _cachedProjectionMatrixId;
  93503. private _cachedCoordinatesMode;
  93504. /** @hidden */
  93505. protected _initialSamplingMode: number;
  93506. /** @hidden */
  93507. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  93508. private _deleteBuffer;
  93509. protected _format: Nullable<number>;
  93510. private _delayedOnLoad;
  93511. private _delayedOnError;
  93512. private _mimeType?;
  93513. /**
  93514. * Observable triggered once the texture has been loaded.
  93515. */
  93516. onLoadObservable: Observable<Texture>;
  93517. protected _isBlocking: boolean;
  93518. /**
  93519. * Is the texture preventing material to render while loading.
  93520. * If false, a default texture will be used instead of the loading one during the preparation step.
  93521. */
  93522. set isBlocking(value: boolean);
  93523. get isBlocking(): boolean;
  93524. /**
  93525. * Get the current sampling mode associated with the texture.
  93526. */
  93527. get samplingMode(): number;
  93528. /**
  93529. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  93530. */
  93531. get invertY(): boolean;
  93532. /**
  93533. * Instantiates a new texture.
  93534. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93535. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93536. * @param url defines the url of the picture to load as a texture
  93537. * @param scene defines the scene or engine the texture will belong to
  93538. * @param noMipmap defines if the texture will require mip maps or not
  93539. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  93540. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93541. * @param onLoad defines a callback triggered when the texture has been loaded
  93542. * @param onError defines a callback triggered when an error occurred during the loading session
  93543. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  93544. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  93545. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93546. * @param mimeType defines an optional mime type information
  93547. */
  93548. 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);
  93549. /**
  93550. * Update the url (and optional buffer) of this texture if url was null during construction.
  93551. * @param url the url of the texture
  93552. * @param buffer the buffer of the texture (defaults to null)
  93553. * @param onLoad callback called when the texture is loaded (defaults to null)
  93554. */
  93555. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  93556. /**
  93557. * Finish the loading sequence of a texture flagged as delayed load.
  93558. * @hidden
  93559. */
  93560. delayLoad(): void;
  93561. private _prepareRowForTextureGeneration;
  93562. /**
  93563. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  93564. * @returns the transform matrix of the texture.
  93565. */
  93566. getTextureMatrix(uBase?: number): Matrix;
  93567. /**
  93568. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  93569. * @returns The reflection texture transform
  93570. */
  93571. getReflectionTextureMatrix(): Matrix;
  93572. /**
  93573. * Clones the texture.
  93574. * @returns the cloned texture
  93575. */
  93576. clone(): Texture;
  93577. /**
  93578. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93579. * @returns The JSON representation of the texture
  93580. */
  93581. serialize(): any;
  93582. /**
  93583. * Get the current class name of the texture useful for serialization or dynamic coding.
  93584. * @returns "Texture"
  93585. */
  93586. getClassName(): string;
  93587. /**
  93588. * Dispose the texture and release its associated resources.
  93589. */
  93590. dispose(): void;
  93591. /**
  93592. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  93593. * @param parsedTexture Define the JSON representation of the texture
  93594. * @param scene Define the scene the parsed texture should be instantiated in
  93595. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  93596. * @returns The parsed texture if successful
  93597. */
  93598. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  93599. /**
  93600. * Creates a texture from its base 64 representation.
  93601. * @param data Define the base64 payload without the data: prefix
  93602. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93603. * @param scene Define the scene the texture should belong to
  93604. * @param noMipmap Forces the texture to not create mip map information if true
  93605. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93606. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93607. * @param onLoad define a callback triggered when the texture has been loaded
  93608. * @param onError define a callback triggered when an error occurred during the loading session
  93609. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93610. * @returns the created texture
  93611. */
  93612. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  93613. /**
  93614. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  93615. * @param data Define the base64 payload without the data: prefix
  93616. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93617. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  93618. * @param scene Define the scene the texture should belong to
  93619. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  93620. * @param noMipmap Forces the texture to not create mip map information if true
  93621. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93622. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93623. * @param onLoad define a callback triggered when the texture has been loaded
  93624. * @param onError define a callback triggered when an error occurred during the loading session
  93625. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93626. * @returns the created texture
  93627. */
  93628. 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;
  93629. }
  93630. }
  93631. declare module BABYLON {
  93632. /**
  93633. * PostProcessManager is used to manage one or more post processes or post process pipelines
  93634. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93635. */
  93636. export class PostProcessManager {
  93637. private _scene;
  93638. private _indexBuffer;
  93639. private _vertexBuffers;
  93640. /**
  93641. * Creates a new instance PostProcess
  93642. * @param scene The scene that the post process is associated with.
  93643. */
  93644. constructor(scene: Scene);
  93645. private _prepareBuffers;
  93646. private _buildIndexBuffer;
  93647. /**
  93648. * Rebuilds the vertex buffers of the manager.
  93649. * @hidden
  93650. */
  93651. _rebuild(): void;
  93652. /**
  93653. * Prepares a frame to be run through a post process.
  93654. * @param sourceTexture The input texture to the post procesess. (default: null)
  93655. * @param postProcesses An array of post processes to be run. (default: null)
  93656. * @returns True if the post processes were able to be run.
  93657. * @hidden
  93658. */
  93659. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  93660. /**
  93661. * Manually render a set of post processes to a texture.
  93662. * @param postProcesses An array of post processes to be run.
  93663. * @param targetTexture The target texture to render to.
  93664. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  93665. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  93666. * @param lodLevel defines which lod of the texture to render to
  93667. */
  93668. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  93669. /**
  93670. * Finalize the result of the output of the postprocesses.
  93671. * @param doNotPresent If true the result will not be displayed to the screen.
  93672. * @param targetTexture The target texture to render to.
  93673. * @param faceIndex The index of the face to bind the target texture to.
  93674. * @param postProcesses The array of post processes to render.
  93675. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  93676. * @hidden
  93677. */
  93678. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  93679. /**
  93680. * Disposes of the post process manager.
  93681. */
  93682. dispose(): void;
  93683. }
  93684. }
  93685. declare module BABYLON {
  93686. /**
  93687. * This Helps creating a texture that will be created from a camera in your scene.
  93688. * It is basically a dynamic texture that could be used to create special effects for instance.
  93689. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  93690. */
  93691. export class RenderTargetTexture extends Texture {
  93692. isCube: boolean;
  93693. /**
  93694. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  93695. */
  93696. static readonly REFRESHRATE_RENDER_ONCE: number;
  93697. /**
  93698. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  93699. */
  93700. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  93701. /**
  93702. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  93703. * the central point of your effect and can save a lot of performances.
  93704. */
  93705. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  93706. /**
  93707. * Use this predicate to dynamically define the list of mesh you want to render.
  93708. * If set, the renderList property will be overwritten.
  93709. */
  93710. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  93711. private _renderList;
  93712. /**
  93713. * Use this list to define the list of mesh you want to render.
  93714. */
  93715. get renderList(): Nullable<Array<AbstractMesh>>;
  93716. set renderList(value: Nullable<Array<AbstractMesh>>);
  93717. /**
  93718. * Use this function to overload the renderList array at rendering time.
  93719. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  93720. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  93721. * the cube (if the RTT is a cube, else layerOrFace=0).
  93722. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  93723. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  93724. * hold dummy elements!
  93725. */
  93726. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  93727. private _hookArray;
  93728. /**
  93729. * Define if particles should be rendered in your texture.
  93730. */
  93731. renderParticles: boolean;
  93732. /**
  93733. * Define if sprites should be rendered in your texture.
  93734. */
  93735. renderSprites: boolean;
  93736. /**
  93737. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  93738. */
  93739. coordinatesMode: number;
  93740. /**
  93741. * Define the camera used to render the texture.
  93742. */
  93743. activeCamera: Nullable<Camera>;
  93744. /**
  93745. * Override the render function of the texture with your own one.
  93746. */
  93747. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  93748. /**
  93749. * Define if camera post processes should be use while rendering the texture.
  93750. */
  93751. useCameraPostProcesses: boolean;
  93752. /**
  93753. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  93754. */
  93755. ignoreCameraViewport: boolean;
  93756. private _postProcessManager;
  93757. private _postProcesses;
  93758. private _resizeObserver;
  93759. /**
  93760. * An event triggered when the texture is unbind.
  93761. */
  93762. onBeforeBindObservable: Observable<RenderTargetTexture>;
  93763. /**
  93764. * An event triggered when the texture is unbind.
  93765. */
  93766. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  93767. private _onAfterUnbindObserver;
  93768. /**
  93769. * Set a after unbind callback in the texture.
  93770. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  93771. */
  93772. set onAfterUnbind(callback: () => void);
  93773. /**
  93774. * An event triggered before rendering the texture
  93775. */
  93776. onBeforeRenderObservable: Observable<number>;
  93777. private _onBeforeRenderObserver;
  93778. /**
  93779. * Set a before render callback in the texture.
  93780. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  93781. */
  93782. set onBeforeRender(callback: (faceIndex: number) => void);
  93783. /**
  93784. * An event triggered after rendering the texture
  93785. */
  93786. onAfterRenderObservable: Observable<number>;
  93787. private _onAfterRenderObserver;
  93788. /**
  93789. * Set a after render callback in the texture.
  93790. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  93791. */
  93792. set onAfterRender(callback: (faceIndex: number) => void);
  93793. /**
  93794. * An event triggered after the texture clear
  93795. */
  93796. onClearObservable: Observable<Engine>;
  93797. private _onClearObserver;
  93798. /**
  93799. * Set a clear callback in the texture.
  93800. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  93801. */
  93802. set onClear(callback: (Engine: Engine) => void);
  93803. /**
  93804. * An event triggered when the texture is resized.
  93805. */
  93806. onResizeObservable: Observable<RenderTargetTexture>;
  93807. /**
  93808. * Define the clear color of the Render Target if it should be different from the scene.
  93809. */
  93810. clearColor: Color4;
  93811. protected _size: number | {
  93812. width: number;
  93813. height: number;
  93814. layers?: number;
  93815. };
  93816. protected _initialSizeParameter: number | {
  93817. width: number;
  93818. height: number;
  93819. } | {
  93820. ratio: number;
  93821. };
  93822. protected _sizeRatio: Nullable<number>;
  93823. /** @hidden */
  93824. _generateMipMaps: boolean;
  93825. protected _renderingManager: RenderingManager;
  93826. /** @hidden */
  93827. _waitingRenderList: string[];
  93828. protected _doNotChangeAspectRatio: boolean;
  93829. protected _currentRefreshId: number;
  93830. protected _refreshRate: number;
  93831. protected _textureMatrix: Matrix;
  93832. protected _samples: number;
  93833. protected _renderTargetOptions: RenderTargetCreationOptions;
  93834. /**
  93835. * Gets render target creation options that were used.
  93836. */
  93837. get renderTargetOptions(): RenderTargetCreationOptions;
  93838. protected _engine: Engine;
  93839. protected _onRatioRescale(): void;
  93840. /**
  93841. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  93842. * It must define where the camera used to render the texture is set
  93843. */
  93844. boundingBoxPosition: Vector3;
  93845. private _boundingBoxSize;
  93846. /**
  93847. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  93848. * When defined, the cubemap will switch to local mode
  93849. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  93850. * @example https://www.babylonjs-playground.com/#RNASML
  93851. */
  93852. set boundingBoxSize(value: Vector3);
  93853. get boundingBoxSize(): Vector3;
  93854. /**
  93855. * In case the RTT has been created with a depth texture, get the associated
  93856. * depth texture.
  93857. * Otherwise, return null.
  93858. */
  93859. get depthStencilTexture(): Nullable<InternalTexture>;
  93860. /**
  93861. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  93862. * or used a shadow, depth texture...
  93863. * @param name The friendly name of the texture
  93864. * @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)
  93865. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  93866. * @param generateMipMaps True if mip maps need to be generated after render.
  93867. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  93868. * @param type The type of the buffer in the RTT (int, half float, float...)
  93869. * @param isCube True if a cube texture needs to be created
  93870. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  93871. * @param generateDepthBuffer True to generate a depth buffer
  93872. * @param generateStencilBuffer True to generate a stencil buffer
  93873. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  93874. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  93875. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93876. */
  93877. constructor(name: string, size: number | {
  93878. width: number;
  93879. height: number;
  93880. layers?: number;
  93881. } | {
  93882. ratio: number;
  93883. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  93884. /**
  93885. * Creates a depth stencil texture.
  93886. * This is only available in WebGL 2 or with the depth texture extension available.
  93887. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  93888. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  93889. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  93890. */
  93891. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  93892. private _processSizeParameter;
  93893. /**
  93894. * Define the number of samples to use in case of MSAA.
  93895. * It defaults to one meaning no MSAA has been enabled.
  93896. */
  93897. get samples(): number;
  93898. set samples(value: number);
  93899. /**
  93900. * Resets the refresh counter of the texture and start bak from scratch.
  93901. * Could be useful to regenerate the texture if it is setup to render only once.
  93902. */
  93903. resetRefreshCounter(): void;
  93904. /**
  93905. * Define the refresh rate of the texture or the rendering frequency.
  93906. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  93907. */
  93908. get refreshRate(): number;
  93909. set refreshRate(value: number);
  93910. /**
  93911. * Adds a post process to the render target rendering passes.
  93912. * @param postProcess define the post process to add
  93913. */
  93914. addPostProcess(postProcess: PostProcess): void;
  93915. /**
  93916. * Clear all the post processes attached to the render target
  93917. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  93918. */
  93919. clearPostProcesses(dispose?: boolean): void;
  93920. /**
  93921. * Remove one of the post process from the list of attached post processes to the texture
  93922. * @param postProcess define the post process to remove from the list
  93923. */
  93924. removePostProcess(postProcess: PostProcess): void;
  93925. /** @hidden */
  93926. _shouldRender(): boolean;
  93927. /**
  93928. * Gets the actual render size of the texture.
  93929. * @returns the width of the render size
  93930. */
  93931. getRenderSize(): number;
  93932. /**
  93933. * Gets the actual render width of the texture.
  93934. * @returns the width of the render size
  93935. */
  93936. getRenderWidth(): number;
  93937. /**
  93938. * Gets the actual render height of the texture.
  93939. * @returns the height of the render size
  93940. */
  93941. getRenderHeight(): number;
  93942. /**
  93943. * Gets the actual number of layers of the texture.
  93944. * @returns the number of layers
  93945. */
  93946. getRenderLayers(): number;
  93947. /**
  93948. * Get if the texture can be rescaled or not.
  93949. */
  93950. get canRescale(): boolean;
  93951. /**
  93952. * Resize the texture using a ratio.
  93953. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  93954. */
  93955. scale(ratio: number): void;
  93956. /**
  93957. * Get the texture reflection matrix used to rotate/transform the reflection.
  93958. * @returns the reflection matrix
  93959. */
  93960. getReflectionTextureMatrix(): Matrix;
  93961. /**
  93962. * Resize the texture to a new desired size.
  93963. * Be carrefull as it will recreate all the data in the new texture.
  93964. * @param size Define the new size. It can be:
  93965. * - a number for squared texture,
  93966. * - an object containing { width: number, height: number }
  93967. * - or an object containing a ratio { ratio: number }
  93968. */
  93969. resize(size: number | {
  93970. width: number;
  93971. height: number;
  93972. } | {
  93973. ratio: number;
  93974. }): void;
  93975. private _defaultRenderListPrepared;
  93976. /**
  93977. * Renders all the objects from the render list into the texture.
  93978. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  93979. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  93980. */
  93981. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  93982. private _bestReflectionRenderTargetDimension;
  93983. private _prepareRenderingManager;
  93984. /**
  93985. * @hidden
  93986. * @param faceIndex face index to bind to if this is a cubetexture
  93987. * @param layer defines the index of the texture to bind in the array
  93988. */
  93989. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  93990. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  93991. private renderToTarget;
  93992. /**
  93993. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93994. * This allowed control for front to back rendering or reversly depending of the special needs.
  93995. *
  93996. * @param renderingGroupId The rendering group id corresponding to its index
  93997. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93998. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93999. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94000. */
  94001. 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;
  94002. /**
  94003. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94004. *
  94005. * @param renderingGroupId The rendering group id corresponding to its index
  94006. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94007. */
  94008. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  94009. /**
  94010. * Clones the texture.
  94011. * @returns the cloned texture
  94012. */
  94013. clone(): RenderTargetTexture;
  94014. /**
  94015. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94016. * @returns The JSON representation of the texture
  94017. */
  94018. serialize(): any;
  94019. /**
  94020. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  94021. */
  94022. disposeFramebufferObjects(): void;
  94023. /**
  94024. * Dispose the texture and release its associated resources.
  94025. */
  94026. dispose(): void;
  94027. /** @hidden */
  94028. _rebuild(): void;
  94029. /**
  94030. * Clear the info related to rendering groups preventing retention point in material dispose.
  94031. */
  94032. freeRenderingGroups(): void;
  94033. /**
  94034. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  94035. * @returns the view count
  94036. */
  94037. getViewCount(): number;
  94038. }
  94039. }
  94040. declare module BABYLON {
  94041. /**
  94042. * Options for compiling materials.
  94043. */
  94044. export interface IMaterialCompilationOptions {
  94045. /**
  94046. * Defines whether clip planes are enabled.
  94047. */
  94048. clipPlane: boolean;
  94049. /**
  94050. * Defines whether instances are enabled.
  94051. */
  94052. useInstances: boolean;
  94053. }
  94054. /**
  94055. * Base class for the main features of a material in Babylon.js
  94056. */
  94057. export class Material implements IAnimatable {
  94058. /**
  94059. * Returns the triangle fill mode
  94060. */
  94061. static readonly TriangleFillMode: number;
  94062. /**
  94063. * Returns the wireframe mode
  94064. */
  94065. static readonly WireFrameFillMode: number;
  94066. /**
  94067. * Returns the point fill mode
  94068. */
  94069. static readonly PointFillMode: number;
  94070. /**
  94071. * Returns the point list draw mode
  94072. */
  94073. static readonly PointListDrawMode: number;
  94074. /**
  94075. * Returns the line list draw mode
  94076. */
  94077. static readonly LineListDrawMode: number;
  94078. /**
  94079. * Returns the line loop draw mode
  94080. */
  94081. static readonly LineLoopDrawMode: number;
  94082. /**
  94083. * Returns the line strip draw mode
  94084. */
  94085. static readonly LineStripDrawMode: number;
  94086. /**
  94087. * Returns the triangle strip draw mode
  94088. */
  94089. static readonly TriangleStripDrawMode: number;
  94090. /**
  94091. * Returns the triangle fan draw mode
  94092. */
  94093. static readonly TriangleFanDrawMode: number;
  94094. /**
  94095. * Stores the clock-wise side orientation
  94096. */
  94097. static readonly ClockWiseSideOrientation: number;
  94098. /**
  94099. * Stores the counter clock-wise side orientation
  94100. */
  94101. static readonly CounterClockWiseSideOrientation: number;
  94102. /**
  94103. * The dirty texture flag value
  94104. */
  94105. static readonly TextureDirtyFlag: number;
  94106. /**
  94107. * The dirty light flag value
  94108. */
  94109. static readonly LightDirtyFlag: number;
  94110. /**
  94111. * The dirty fresnel flag value
  94112. */
  94113. static readonly FresnelDirtyFlag: number;
  94114. /**
  94115. * The dirty attribute flag value
  94116. */
  94117. static readonly AttributesDirtyFlag: number;
  94118. /**
  94119. * The dirty misc flag value
  94120. */
  94121. static readonly MiscDirtyFlag: number;
  94122. /**
  94123. * The all dirty flag value
  94124. */
  94125. static readonly AllDirtyFlag: number;
  94126. /**
  94127. * The ID of the material
  94128. */
  94129. id: string;
  94130. /**
  94131. * Gets or sets the unique id of the material
  94132. */
  94133. uniqueId: number;
  94134. /**
  94135. * The name of the material
  94136. */
  94137. name: string;
  94138. /**
  94139. * Gets or sets user defined metadata
  94140. */
  94141. metadata: any;
  94142. /**
  94143. * For internal use only. Please do not use.
  94144. */
  94145. reservedDataStore: any;
  94146. /**
  94147. * Specifies if the ready state should be checked on each call
  94148. */
  94149. checkReadyOnEveryCall: boolean;
  94150. /**
  94151. * Specifies if the ready state should be checked once
  94152. */
  94153. checkReadyOnlyOnce: boolean;
  94154. /**
  94155. * The state of the material
  94156. */
  94157. state: string;
  94158. /**
  94159. * The alpha value of the material
  94160. */
  94161. protected _alpha: number;
  94162. /**
  94163. * List of inspectable custom properties (used by the Inspector)
  94164. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94165. */
  94166. inspectableCustomProperties: IInspectable[];
  94167. /**
  94168. * Sets the alpha value of the material
  94169. */
  94170. set alpha(value: number);
  94171. /**
  94172. * Gets the alpha value of the material
  94173. */
  94174. get alpha(): number;
  94175. /**
  94176. * Specifies if back face culling is enabled
  94177. */
  94178. protected _backFaceCulling: boolean;
  94179. /**
  94180. * Sets the back-face culling state
  94181. */
  94182. set backFaceCulling(value: boolean);
  94183. /**
  94184. * Gets the back-face culling state
  94185. */
  94186. get backFaceCulling(): boolean;
  94187. /**
  94188. * Stores the value for side orientation
  94189. */
  94190. sideOrientation: number;
  94191. /**
  94192. * Callback triggered when the material is compiled
  94193. */
  94194. onCompiled: Nullable<(effect: Effect) => void>;
  94195. /**
  94196. * Callback triggered when an error occurs
  94197. */
  94198. onError: Nullable<(effect: Effect, errors: string) => void>;
  94199. /**
  94200. * Callback triggered to get the render target textures
  94201. */
  94202. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  94203. /**
  94204. * Gets a boolean indicating that current material needs to register RTT
  94205. */
  94206. get hasRenderTargetTextures(): boolean;
  94207. /**
  94208. * Specifies if the material should be serialized
  94209. */
  94210. doNotSerialize: boolean;
  94211. /**
  94212. * @hidden
  94213. */
  94214. _storeEffectOnSubMeshes: boolean;
  94215. /**
  94216. * Stores the animations for the material
  94217. */
  94218. animations: Nullable<Array<Animation>>;
  94219. /**
  94220. * An event triggered when the material is disposed
  94221. */
  94222. onDisposeObservable: Observable<Material>;
  94223. /**
  94224. * An observer which watches for dispose events
  94225. */
  94226. private _onDisposeObserver;
  94227. private _onUnBindObservable;
  94228. /**
  94229. * Called during a dispose event
  94230. */
  94231. set onDispose(callback: () => void);
  94232. private _onBindObservable;
  94233. /**
  94234. * An event triggered when the material is bound
  94235. */
  94236. get onBindObservable(): Observable<AbstractMesh>;
  94237. /**
  94238. * An observer which watches for bind events
  94239. */
  94240. private _onBindObserver;
  94241. /**
  94242. * Called during a bind event
  94243. */
  94244. set onBind(callback: (Mesh: AbstractMesh) => void);
  94245. /**
  94246. * An event triggered when the material is unbound
  94247. */
  94248. get onUnBindObservable(): Observable<Material>;
  94249. /**
  94250. * Stores the value of the alpha mode
  94251. */
  94252. private _alphaMode;
  94253. /**
  94254. * Sets the value of the alpha mode.
  94255. *
  94256. * | Value | Type | Description |
  94257. * | --- | --- | --- |
  94258. * | 0 | ALPHA_DISABLE | |
  94259. * | 1 | ALPHA_ADD | |
  94260. * | 2 | ALPHA_COMBINE | |
  94261. * | 3 | ALPHA_SUBTRACT | |
  94262. * | 4 | ALPHA_MULTIPLY | |
  94263. * | 5 | ALPHA_MAXIMIZED | |
  94264. * | 6 | ALPHA_ONEONE | |
  94265. * | 7 | ALPHA_PREMULTIPLIED | |
  94266. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  94267. * | 9 | ALPHA_INTERPOLATE | |
  94268. * | 10 | ALPHA_SCREENMODE | |
  94269. *
  94270. */
  94271. set alphaMode(value: number);
  94272. /**
  94273. * Gets the value of the alpha mode
  94274. */
  94275. get alphaMode(): number;
  94276. /**
  94277. * Stores the state of the need depth pre-pass value
  94278. */
  94279. private _needDepthPrePass;
  94280. /**
  94281. * Sets the need depth pre-pass value
  94282. */
  94283. set needDepthPrePass(value: boolean);
  94284. /**
  94285. * Gets the depth pre-pass value
  94286. */
  94287. get needDepthPrePass(): boolean;
  94288. /**
  94289. * Specifies if depth writing should be disabled
  94290. */
  94291. disableDepthWrite: boolean;
  94292. /**
  94293. * Specifies if depth writing should be forced
  94294. */
  94295. forceDepthWrite: boolean;
  94296. /**
  94297. * Specifies the depth function that should be used. 0 means the default engine function
  94298. */
  94299. depthFunction: number;
  94300. /**
  94301. * Specifies if there should be a separate pass for culling
  94302. */
  94303. separateCullingPass: boolean;
  94304. /**
  94305. * Stores the state specifing if fog should be enabled
  94306. */
  94307. private _fogEnabled;
  94308. /**
  94309. * Sets the state for enabling fog
  94310. */
  94311. set fogEnabled(value: boolean);
  94312. /**
  94313. * Gets the value of the fog enabled state
  94314. */
  94315. get fogEnabled(): boolean;
  94316. /**
  94317. * Stores the size of points
  94318. */
  94319. pointSize: number;
  94320. /**
  94321. * Stores the z offset value
  94322. */
  94323. zOffset: number;
  94324. /**
  94325. * Gets a value specifying if wireframe mode is enabled
  94326. */
  94327. get wireframe(): boolean;
  94328. /**
  94329. * Sets the state of wireframe mode
  94330. */
  94331. set wireframe(value: boolean);
  94332. /**
  94333. * Gets the value specifying if point clouds are enabled
  94334. */
  94335. get pointsCloud(): boolean;
  94336. /**
  94337. * Sets the state of point cloud mode
  94338. */
  94339. set pointsCloud(value: boolean);
  94340. /**
  94341. * Gets the material fill mode
  94342. */
  94343. get fillMode(): number;
  94344. /**
  94345. * Sets the material fill mode
  94346. */
  94347. set fillMode(value: number);
  94348. /**
  94349. * @hidden
  94350. * Stores the effects for the material
  94351. */
  94352. _effect: Nullable<Effect>;
  94353. /**
  94354. * Specifies if uniform buffers should be used
  94355. */
  94356. private _useUBO;
  94357. /**
  94358. * Stores a reference to the scene
  94359. */
  94360. private _scene;
  94361. /**
  94362. * Stores the fill mode state
  94363. */
  94364. private _fillMode;
  94365. /**
  94366. * Specifies if the depth write state should be cached
  94367. */
  94368. private _cachedDepthWriteState;
  94369. /**
  94370. * Specifies if the depth function state should be cached
  94371. */
  94372. private _cachedDepthFunctionState;
  94373. /**
  94374. * Stores the uniform buffer
  94375. */
  94376. protected _uniformBuffer: UniformBuffer;
  94377. /** @hidden */
  94378. _indexInSceneMaterialArray: number;
  94379. /** @hidden */
  94380. meshMap: Nullable<{
  94381. [id: string]: AbstractMesh | undefined;
  94382. }>;
  94383. /**
  94384. * Creates a material instance
  94385. * @param name defines the name of the material
  94386. * @param scene defines the scene to reference
  94387. * @param doNotAdd specifies if the material should be added to the scene
  94388. */
  94389. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  94390. /**
  94391. * Returns a string representation of the current material
  94392. * @param fullDetails defines a boolean indicating which levels of logging is desired
  94393. * @returns a string with material information
  94394. */
  94395. toString(fullDetails?: boolean): string;
  94396. /**
  94397. * Gets the class name of the material
  94398. * @returns a string with the class name of the material
  94399. */
  94400. getClassName(): string;
  94401. /**
  94402. * Specifies if updates for the material been locked
  94403. */
  94404. get isFrozen(): boolean;
  94405. /**
  94406. * Locks updates for the material
  94407. */
  94408. freeze(): void;
  94409. /**
  94410. * Unlocks updates for the material
  94411. */
  94412. unfreeze(): void;
  94413. /**
  94414. * Specifies if the material is ready to be used
  94415. * @param mesh defines the mesh to check
  94416. * @param useInstances specifies if instances should be used
  94417. * @returns a boolean indicating if the material is ready to be used
  94418. */
  94419. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94420. /**
  94421. * Specifies that the submesh is ready to be used
  94422. * @param mesh defines the mesh to check
  94423. * @param subMesh defines which submesh to check
  94424. * @param useInstances specifies that instances should be used
  94425. * @returns a boolean indicating that the submesh is ready or not
  94426. */
  94427. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94428. /**
  94429. * Returns the material effect
  94430. * @returns the effect associated with the material
  94431. */
  94432. getEffect(): Nullable<Effect>;
  94433. /**
  94434. * Returns the current scene
  94435. * @returns a Scene
  94436. */
  94437. getScene(): Scene;
  94438. /**
  94439. * Specifies if the material will require alpha blending
  94440. * @returns a boolean specifying if alpha blending is needed
  94441. */
  94442. needAlphaBlending(): boolean;
  94443. /**
  94444. * Specifies if the mesh will require alpha blending
  94445. * @param mesh defines the mesh to check
  94446. * @returns a boolean specifying if alpha blending is needed for the mesh
  94447. */
  94448. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  94449. /**
  94450. * Specifies if this material should be rendered in alpha test mode
  94451. * @returns a boolean specifying if an alpha test is needed.
  94452. */
  94453. needAlphaTesting(): boolean;
  94454. /**
  94455. * Gets the texture used for the alpha test
  94456. * @returns the texture to use for alpha testing
  94457. */
  94458. getAlphaTestTexture(): Nullable<BaseTexture>;
  94459. /**
  94460. * Marks the material to indicate that it needs to be re-calculated
  94461. */
  94462. markDirty(): void;
  94463. /** @hidden */
  94464. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  94465. /**
  94466. * Binds the material to the mesh
  94467. * @param world defines the world transformation matrix
  94468. * @param mesh defines the mesh to bind the material to
  94469. */
  94470. bind(world: Matrix, mesh?: Mesh): void;
  94471. /**
  94472. * Binds the submesh to the material
  94473. * @param world defines the world transformation matrix
  94474. * @param mesh defines the mesh containing the submesh
  94475. * @param subMesh defines the submesh to bind the material to
  94476. */
  94477. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94478. /**
  94479. * Binds the world matrix to the material
  94480. * @param world defines the world transformation matrix
  94481. */
  94482. bindOnlyWorldMatrix(world: Matrix): void;
  94483. /**
  94484. * Binds the scene's uniform buffer to the effect.
  94485. * @param effect defines the effect to bind to the scene uniform buffer
  94486. * @param sceneUbo defines the uniform buffer storing scene data
  94487. */
  94488. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  94489. /**
  94490. * Binds the view matrix to the effect
  94491. * @param effect defines the effect to bind the view matrix to
  94492. */
  94493. bindView(effect: Effect): void;
  94494. /**
  94495. * Binds the view projection matrix to the effect
  94496. * @param effect defines the effect to bind the view projection matrix to
  94497. */
  94498. bindViewProjection(effect: Effect): void;
  94499. /**
  94500. * Specifies if material alpha testing should be turned on for the mesh
  94501. * @param mesh defines the mesh to check
  94502. */
  94503. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  94504. /**
  94505. * Processes to execute after binding the material to a mesh
  94506. * @param mesh defines the rendered mesh
  94507. */
  94508. protected _afterBind(mesh?: Mesh): void;
  94509. /**
  94510. * Unbinds the material from the mesh
  94511. */
  94512. unbind(): void;
  94513. /**
  94514. * Gets the active textures from the material
  94515. * @returns an array of textures
  94516. */
  94517. getActiveTextures(): BaseTexture[];
  94518. /**
  94519. * Specifies if the material uses a texture
  94520. * @param texture defines the texture to check against the material
  94521. * @returns a boolean specifying if the material uses the texture
  94522. */
  94523. hasTexture(texture: BaseTexture): boolean;
  94524. /**
  94525. * Makes a duplicate of the material, and gives it a new name
  94526. * @param name defines the new name for the duplicated material
  94527. * @returns the cloned material
  94528. */
  94529. clone(name: string): Nullable<Material>;
  94530. /**
  94531. * Gets the meshes bound to the material
  94532. * @returns an array of meshes bound to the material
  94533. */
  94534. getBindedMeshes(): AbstractMesh[];
  94535. /**
  94536. * Force shader compilation
  94537. * @param mesh defines the mesh associated with this material
  94538. * @param onCompiled defines a function to execute once the material is compiled
  94539. * @param options defines the options to configure the compilation
  94540. * @param onError defines a function to execute if the material fails compiling
  94541. */
  94542. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  94543. /**
  94544. * Force shader compilation
  94545. * @param mesh defines the mesh that will use this material
  94546. * @param options defines additional options for compiling the shaders
  94547. * @returns a promise that resolves when the compilation completes
  94548. */
  94549. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  94550. private static readonly _AllDirtyCallBack;
  94551. private static readonly _ImageProcessingDirtyCallBack;
  94552. private static readonly _TextureDirtyCallBack;
  94553. private static readonly _FresnelDirtyCallBack;
  94554. private static readonly _MiscDirtyCallBack;
  94555. private static readonly _LightsDirtyCallBack;
  94556. private static readonly _AttributeDirtyCallBack;
  94557. private static _FresnelAndMiscDirtyCallBack;
  94558. private static _TextureAndMiscDirtyCallBack;
  94559. private static readonly _DirtyCallbackArray;
  94560. private static readonly _RunDirtyCallBacks;
  94561. /**
  94562. * Marks a define in the material to indicate that it needs to be re-computed
  94563. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  94564. */
  94565. markAsDirty(flag: number): void;
  94566. /**
  94567. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  94568. * @param func defines a function which checks material defines against the submeshes
  94569. */
  94570. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  94571. /**
  94572. * Indicates that we need to re-calculated for all submeshes
  94573. */
  94574. protected _markAllSubMeshesAsAllDirty(): void;
  94575. /**
  94576. * Indicates that image processing needs to be re-calculated for all submeshes
  94577. */
  94578. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  94579. /**
  94580. * Indicates that textures need to be re-calculated for all submeshes
  94581. */
  94582. protected _markAllSubMeshesAsTexturesDirty(): void;
  94583. /**
  94584. * Indicates that fresnel needs to be re-calculated for all submeshes
  94585. */
  94586. protected _markAllSubMeshesAsFresnelDirty(): void;
  94587. /**
  94588. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  94589. */
  94590. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  94591. /**
  94592. * Indicates that lights need to be re-calculated for all submeshes
  94593. */
  94594. protected _markAllSubMeshesAsLightsDirty(): void;
  94595. /**
  94596. * Indicates that attributes need to be re-calculated for all submeshes
  94597. */
  94598. protected _markAllSubMeshesAsAttributesDirty(): void;
  94599. /**
  94600. * Indicates that misc needs to be re-calculated for all submeshes
  94601. */
  94602. protected _markAllSubMeshesAsMiscDirty(): void;
  94603. /**
  94604. * Indicates that textures and misc need to be re-calculated for all submeshes
  94605. */
  94606. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  94607. /**
  94608. * Disposes the material
  94609. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94610. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94611. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94612. */
  94613. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94614. /** @hidden */
  94615. private releaseVertexArrayObject;
  94616. /**
  94617. * Serializes this material
  94618. * @returns the serialized material object
  94619. */
  94620. serialize(): any;
  94621. /**
  94622. * Creates a material from parsed material data
  94623. * @param parsedMaterial defines parsed material data
  94624. * @param scene defines the hosting scene
  94625. * @param rootUrl defines the root URL to use to load textures
  94626. * @returns a new material
  94627. */
  94628. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  94629. }
  94630. }
  94631. declare module BABYLON {
  94632. /**
  94633. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94634. * separate meshes. This can be use to improve performances.
  94635. * @see http://doc.babylonjs.com/how_to/multi_materials
  94636. */
  94637. export class MultiMaterial extends Material {
  94638. private _subMaterials;
  94639. /**
  94640. * Gets or Sets the list of Materials used within the multi material.
  94641. * They need to be ordered according to the submeshes order in the associated mesh
  94642. */
  94643. get subMaterials(): Nullable<Material>[];
  94644. set subMaterials(value: Nullable<Material>[]);
  94645. /**
  94646. * Function used to align with Node.getChildren()
  94647. * @returns the list of Materials used within the multi material
  94648. */
  94649. getChildren(): Nullable<Material>[];
  94650. /**
  94651. * Instantiates a new Multi Material
  94652. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94653. * separate meshes. This can be use to improve performances.
  94654. * @see http://doc.babylonjs.com/how_to/multi_materials
  94655. * @param name Define the name in the scene
  94656. * @param scene Define the scene the material belongs to
  94657. */
  94658. constructor(name: string, scene: Scene);
  94659. private _hookArray;
  94660. /**
  94661. * Get one of the submaterial by its index in the submaterials array
  94662. * @param index The index to look the sub material at
  94663. * @returns The Material if the index has been defined
  94664. */
  94665. getSubMaterial(index: number): Nullable<Material>;
  94666. /**
  94667. * Get the list of active textures for the whole sub materials list.
  94668. * @returns All the textures that will be used during the rendering
  94669. */
  94670. getActiveTextures(): BaseTexture[];
  94671. /**
  94672. * Gets the current class name of the material e.g. "MultiMaterial"
  94673. * Mainly use in serialization.
  94674. * @returns the class name
  94675. */
  94676. getClassName(): string;
  94677. /**
  94678. * Checks if the material is ready to render the requested sub mesh
  94679. * @param mesh Define the mesh the submesh belongs to
  94680. * @param subMesh Define the sub mesh to look readyness for
  94681. * @param useInstances Define whether or not the material is used with instances
  94682. * @returns true if ready, otherwise false
  94683. */
  94684. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94685. /**
  94686. * Clones the current material and its related sub materials
  94687. * @param name Define the name of the newly cloned material
  94688. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  94689. * @returns the cloned material
  94690. */
  94691. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  94692. /**
  94693. * Serializes the materials into a JSON representation.
  94694. * @returns the JSON representation
  94695. */
  94696. serialize(): any;
  94697. /**
  94698. * Dispose the material and release its associated resources
  94699. * @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)
  94700. * @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)
  94701. * @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)
  94702. */
  94703. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  94704. /**
  94705. * Creates a MultiMaterial from parsed MultiMaterial data.
  94706. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  94707. * @param scene defines the hosting scene
  94708. * @returns a new MultiMaterial
  94709. */
  94710. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  94711. }
  94712. }
  94713. declare module BABYLON {
  94714. /**
  94715. * Base class for submeshes
  94716. */
  94717. export class BaseSubMesh {
  94718. /** @hidden */
  94719. _materialDefines: Nullable<MaterialDefines>;
  94720. /** @hidden */
  94721. _materialEffect: Nullable<Effect>;
  94722. /**
  94723. * Gets material defines used by the effect associated to the sub mesh
  94724. */
  94725. get materialDefines(): Nullable<MaterialDefines>;
  94726. /**
  94727. * Sets material defines used by the effect associated to the sub mesh
  94728. */
  94729. set materialDefines(defines: Nullable<MaterialDefines>);
  94730. /**
  94731. * Gets associated effect
  94732. */
  94733. get effect(): Nullable<Effect>;
  94734. /**
  94735. * Sets associated effect (effect used to render this submesh)
  94736. * @param effect defines the effect to associate with
  94737. * @param defines defines the set of defines used to compile this effect
  94738. */
  94739. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  94740. }
  94741. /**
  94742. * Defines a subdivision inside a mesh
  94743. */
  94744. export class SubMesh extends BaseSubMesh implements ICullable {
  94745. /** the material index to use */
  94746. materialIndex: number;
  94747. /** vertex index start */
  94748. verticesStart: number;
  94749. /** vertices count */
  94750. verticesCount: number;
  94751. /** index start */
  94752. indexStart: number;
  94753. /** indices count */
  94754. indexCount: number;
  94755. /** @hidden */
  94756. _linesIndexCount: number;
  94757. private _mesh;
  94758. private _renderingMesh;
  94759. private _boundingInfo;
  94760. private _linesIndexBuffer;
  94761. /** @hidden */
  94762. _lastColliderWorldVertices: Nullable<Vector3[]>;
  94763. /** @hidden */
  94764. _trianglePlanes: Plane[];
  94765. /** @hidden */
  94766. _lastColliderTransformMatrix: Nullable<Matrix>;
  94767. /** @hidden */
  94768. _renderId: number;
  94769. /** @hidden */
  94770. _alphaIndex: number;
  94771. /** @hidden */
  94772. _distanceToCamera: number;
  94773. /** @hidden */
  94774. _id: number;
  94775. private _currentMaterial;
  94776. /**
  94777. * Add a new submesh to a mesh
  94778. * @param materialIndex defines the material index to use
  94779. * @param verticesStart defines vertex index start
  94780. * @param verticesCount defines vertices count
  94781. * @param indexStart defines index start
  94782. * @param indexCount defines indices count
  94783. * @param mesh defines the parent mesh
  94784. * @param renderingMesh defines an optional rendering mesh
  94785. * @param createBoundingBox defines if bounding box should be created for this submesh
  94786. * @returns the new submesh
  94787. */
  94788. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  94789. /**
  94790. * Creates a new submesh
  94791. * @param materialIndex defines the material index to use
  94792. * @param verticesStart defines vertex index start
  94793. * @param verticesCount defines vertices count
  94794. * @param indexStart defines index start
  94795. * @param indexCount defines indices count
  94796. * @param mesh defines the parent mesh
  94797. * @param renderingMesh defines an optional rendering mesh
  94798. * @param createBoundingBox defines if bounding box should be created for this submesh
  94799. */
  94800. constructor(
  94801. /** the material index to use */
  94802. materialIndex: number,
  94803. /** vertex index start */
  94804. verticesStart: number,
  94805. /** vertices count */
  94806. verticesCount: number,
  94807. /** index start */
  94808. indexStart: number,
  94809. /** indices count */
  94810. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  94811. /**
  94812. * Returns true if this submesh covers the entire parent mesh
  94813. * @ignorenaming
  94814. */
  94815. get IsGlobal(): boolean;
  94816. /**
  94817. * Returns the submesh BoudingInfo object
  94818. * @returns current bounding info (or mesh's one if the submesh is global)
  94819. */
  94820. getBoundingInfo(): BoundingInfo;
  94821. /**
  94822. * Sets the submesh BoundingInfo
  94823. * @param boundingInfo defines the new bounding info to use
  94824. * @returns the SubMesh
  94825. */
  94826. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  94827. /**
  94828. * Returns the mesh of the current submesh
  94829. * @return the parent mesh
  94830. */
  94831. getMesh(): AbstractMesh;
  94832. /**
  94833. * Returns the rendering mesh of the submesh
  94834. * @returns the rendering mesh (could be different from parent mesh)
  94835. */
  94836. getRenderingMesh(): Mesh;
  94837. /**
  94838. * Returns the submesh material
  94839. * @returns null or the current material
  94840. */
  94841. getMaterial(): Nullable<Material>;
  94842. /**
  94843. * Sets a new updated BoundingInfo object to the submesh
  94844. * @param data defines an optional position array to use to determine the bounding info
  94845. * @returns the SubMesh
  94846. */
  94847. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  94848. /** @hidden */
  94849. _checkCollision(collider: Collider): boolean;
  94850. /**
  94851. * Updates the submesh BoundingInfo
  94852. * @param world defines the world matrix to use to update the bounding info
  94853. * @returns the submesh
  94854. */
  94855. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  94856. /**
  94857. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  94858. * @param frustumPlanes defines the frustum planes
  94859. * @returns true if the submesh is intersecting with the frustum
  94860. */
  94861. isInFrustum(frustumPlanes: Plane[]): boolean;
  94862. /**
  94863. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  94864. * @param frustumPlanes defines the frustum planes
  94865. * @returns true if the submesh is inside the frustum
  94866. */
  94867. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94868. /**
  94869. * Renders the submesh
  94870. * @param enableAlphaMode defines if alpha needs to be used
  94871. * @returns the submesh
  94872. */
  94873. render(enableAlphaMode: boolean): SubMesh;
  94874. /**
  94875. * @hidden
  94876. */
  94877. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  94878. /**
  94879. * Checks if the submesh intersects with a ray
  94880. * @param ray defines the ray to test
  94881. * @returns true is the passed ray intersects the submesh bounding box
  94882. */
  94883. canIntersects(ray: Ray): boolean;
  94884. /**
  94885. * Intersects current submesh with a ray
  94886. * @param ray defines the ray to test
  94887. * @param positions defines mesh's positions array
  94888. * @param indices defines mesh's indices array
  94889. * @param fastCheck defines if only bounding info should be used
  94890. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94891. * @returns intersection info or null if no intersection
  94892. */
  94893. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  94894. /** @hidden */
  94895. private _intersectLines;
  94896. /** @hidden */
  94897. private _intersectUnIndexedLines;
  94898. /** @hidden */
  94899. private _intersectTriangles;
  94900. /** @hidden */
  94901. private _intersectUnIndexedTriangles;
  94902. /** @hidden */
  94903. _rebuild(): void;
  94904. /**
  94905. * Creates a new submesh from the passed mesh
  94906. * @param newMesh defines the new hosting mesh
  94907. * @param newRenderingMesh defines an optional rendering mesh
  94908. * @returns the new submesh
  94909. */
  94910. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  94911. /**
  94912. * Release associated resources
  94913. */
  94914. dispose(): void;
  94915. /**
  94916. * Gets the class name
  94917. * @returns the string "SubMesh".
  94918. */
  94919. getClassName(): string;
  94920. /**
  94921. * Creates a new submesh from indices data
  94922. * @param materialIndex the index of the main mesh material
  94923. * @param startIndex the index where to start the copy in the mesh indices array
  94924. * @param indexCount the number of indices to copy then from the startIndex
  94925. * @param mesh the main mesh to create the submesh from
  94926. * @param renderingMesh the optional rendering mesh
  94927. * @returns a new submesh
  94928. */
  94929. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  94930. }
  94931. }
  94932. declare module BABYLON {
  94933. /**
  94934. * Class used to represent data loading progression
  94935. */
  94936. export class SceneLoaderFlags {
  94937. private static _ForceFullSceneLoadingForIncremental;
  94938. private static _ShowLoadingScreen;
  94939. private static _CleanBoneMatrixWeights;
  94940. private static _loggingLevel;
  94941. /**
  94942. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  94943. */
  94944. static get ForceFullSceneLoadingForIncremental(): boolean;
  94945. static set ForceFullSceneLoadingForIncremental(value: boolean);
  94946. /**
  94947. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  94948. */
  94949. static get ShowLoadingScreen(): boolean;
  94950. static set ShowLoadingScreen(value: boolean);
  94951. /**
  94952. * Defines the current logging level (while loading the scene)
  94953. * @ignorenaming
  94954. */
  94955. static get loggingLevel(): number;
  94956. static set loggingLevel(value: number);
  94957. /**
  94958. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  94959. */
  94960. static get CleanBoneMatrixWeights(): boolean;
  94961. static set CleanBoneMatrixWeights(value: boolean);
  94962. }
  94963. }
  94964. declare module BABYLON {
  94965. /**
  94966. * Class used to store geometry data (vertex buffers + index buffer)
  94967. */
  94968. export class Geometry implements IGetSetVerticesData {
  94969. /**
  94970. * Gets or sets the ID of the geometry
  94971. */
  94972. id: string;
  94973. /**
  94974. * Gets or sets the unique ID of the geometry
  94975. */
  94976. uniqueId: number;
  94977. /**
  94978. * Gets the delay loading state of the geometry (none by default which means not delayed)
  94979. */
  94980. delayLoadState: number;
  94981. /**
  94982. * Gets the file containing the data to load when running in delay load state
  94983. */
  94984. delayLoadingFile: Nullable<string>;
  94985. /**
  94986. * Callback called when the geometry is updated
  94987. */
  94988. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  94989. private _scene;
  94990. private _engine;
  94991. private _meshes;
  94992. private _totalVertices;
  94993. /** @hidden */
  94994. _indices: IndicesArray;
  94995. /** @hidden */
  94996. _vertexBuffers: {
  94997. [key: string]: VertexBuffer;
  94998. };
  94999. private _isDisposed;
  95000. private _extend;
  95001. private _boundingBias;
  95002. /** @hidden */
  95003. _delayInfo: Array<string>;
  95004. private _indexBuffer;
  95005. private _indexBufferIsUpdatable;
  95006. /** @hidden */
  95007. _boundingInfo: Nullable<BoundingInfo>;
  95008. /** @hidden */
  95009. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  95010. /** @hidden */
  95011. _softwareSkinningFrameId: number;
  95012. private _vertexArrayObjects;
  95013. private _updatable;
  95014. /** @hidden */
  95015. _positions: Nullable<Vector3[]>;
  95016. /**
  95017. * 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
  95018. */
  95019. get boundingBias(): Vector2;
  95020. /**
  95021. * 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
  95022. */
  95023. set boundingBias(value: Vector2);
  95024. /**
  95025. * Static function used to attach a new empty geometry to a mesh
  95026. * @param mesh defines the mesh to attach the geometry to
  95027. * @returns the new Geometry
  95028. */
  95029. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  95030. /**
  95031. * Creates a new geometry
  95032. * @param id defines the unique ID
  95033. * @param scene defines the hosting scene
  95034. * @param vertexData defines the VertexData used to get geometry data
  95035. * @param updatable defines if geometry must be updatable (false by default)
  95036. * @param mesh defines the mesh that will be associated with the geometry
  95037. */
  95038. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  95039. /**
  95040. * Gets the current extend of the geometry
  95041. */
  95042. get extend(): {
  95043. minimum: Vector3;
  95044. maximum: Vector3;
  95045. };
  95046. /**
  95047. * Gets the hosting scene
  95048. * @returns the hosting Scene
  95049. */
  95050. getScene(): Scene;
  95051. /**
  95052. * Gets the hosting engine
  95053. * @returns the hosting Engine
  95054. */
  95055. getEngine(): Engine;
  95056. /**
  95057. * Defines if the geometry is ready to use
  95058. * @returns true if the geometry is ready to be used
  95059. */
  95060. isReady(): boolean;
  95061. /**
  95062. * Gets a value indicating that the geometry should not be serialized
  95063. */
  95064. get doNotSerialize(): boolean;
  95065. /** @hidden */
  95066. _rebuild(): void;
  95067. /**
  95068. * Affects all geometry data in one call
  95069. * @param vertexData defines the geometry data
  95070. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  95071. */
  95072. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  95073. /**
  95074. * Set specific vertex data
  95075. * @param kind defines the data kind (Position, normal, etc...)
  95076. * @param data defines the vertex data to use
  95077. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95078. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95079. */
  95080. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  95081. /**
  95082. * Removes a specific vertex data
  95083. * @param kind defines the data kind (Position, normal, etc...)
  95084. */
  95085. removeVerticesData(kind: string): void;
  95086. /**
  95087. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  95088. * @param buffer defines the vertex buffer to use
  95089. * @param totalVertices defines the total number of vertices for position kind (could be null)
  95090. */
  95091. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  95092. /**
  95093. * Update a specific vertex buffer
  95094. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  95095. * It will do nothing if the buffer is not updatable
  95096. * @param kind defines the data kind (Position, normal, etc...)
  95097. * @param data defines the data to use
  95098. * @param offset defines the offset in the target buffer where to store the data
  95099. * @param useBytes set to true if the offset is in bytes
  95100. */
  95101. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  95102. /**
  95103. * Update a specific vertex buffer
  95104. * This function will create a new buffer if the current one is not updatable
  95105. * @param kind defines the data kind (Position, normal, etc...)
  95106. * @param data defines the data to use
  95107. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  95108. */
  95109. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  95110. private _updateBoundingInfo;
  95111. /** @hidden */
  95112. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  95113. /**
  95114. * Gets total number of vertices
  95115. * @returns the total number of vertices
  95116. */
  95117. getTotalVertices(): number;
  95118. /**
  95119. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95120. * @param kind defines the data kind (Position, normal, etc...)
  95121. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95122. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95123. * @returns a float array containing vertex data
  95124. */
  95125. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95126. /**
  95127. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  95128. * @param kind defines the data kind (Position, normal, etc...)
  95129. * @returns true if the vertex buffer with the specified kind is updatable
  95130. */
  95131. isVertexBufferUpdatable(kind: string): boolean;
  95132. /**
  95133. * Gets a specific vertex buffer
  95134. * @param kind defines the data kind (Position, normal, etc...)
  95135. * @returns a VertexBuffer
  95136. */
  95137. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95138. /**
  95139. * Returns all vertex buffers
  95140. * @return an object holding all vertex buffers indexed by kind
  95141. */
  95142. getVertexBuffers(): Nullable<{
  95143. [key: string]: VertexBuffer;
  95144. }>;
  95145. /**
  95146. * Gets a boolean indicating if specific vertex buffer is present
  95147. * @param kind defines the data kind (Position, normal, etc...)
  95148. * @returns true if data is present
  95149. */
  95150. isVerticesDataPresent(kind: string): boolean;
  95151. /**
  95152. * Gets a list of all attached data kinds (Position, normal, etc...)
  95153. * @returns a list of string containing all kinds
  95154. */
  95155. getVerticesDataKinds(): string[];
  95156. /**
  95157. * Update index buffer
  95158. * @param indices defines the indices to store in the index buffer
  95159. * @param offset defines the offset in the target buffer where to store the data
  95160. * @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)
  95161. */
  95162. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  95163. /**
  95164. * Creates a new index buffer
  95165. * @param indices defines the indices to store in the index buffer
  95166. * @param totalVertices defines the total number of vertices (could be null)
  95167. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95168. */
  95169. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  95170. /**
  95171. * Return the total number of indices
  95172. * @returns the total number of indices
  95173. */
  95174. getTotalIndices(): number;
  95175. /**
  95176. * Gets the index buffer array
  95177. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95178. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95179. * @returns the index buffer array
  95180. */
  95181. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95182. /**
  95183. * Gets the index buffer
  95184. * @return the index buffer
  95185. */
  95186. getIndexBuffer(): Nullable<DataBuffer>;
  95187. /** @hidden */
  95188. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  95189. /**
  95190. * Release the associated resources for a specific mesh
  95191. * @param mesh defines the source mesh
  95192. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  95193. */
  95194. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  95195. /**
  95196. * Apply current geometry to a given mesh
  95197. * @param mesh defines the mesh to apply geometry to
  95198. */
  95199. applyToMesh(mesh: Mesh): void;
  95200. private _updateExtend;
  95201. private _applyToMesh;
  95202. private notifyUpdate;
  95203. /**
  95204. * Load the geometry if it was flagged as delay loaded
  95205. * @param scene defines the hosting scene
  95206. * @param onLoaded defines a callback called when the geometry is loaded
  95207. */
  95208. load(scene: Scene, onLoaded?: () => void): void;
  95209. private _queueLoad;
  95210. /**
  95211. * Invert the geometry to move from a right handed system to a left handed one.
  95212. */
  95213. toLeftHanded(): void;
  95214. /** @hidden */
  95215. _resetPointsArrayCache(): void;
  95216. /** @hidden */
  95217. _generatePointsArray(): boolean;
  95218. /**
  95219. * Gets a value indicating if the geometry is disposed
  95220. * @returns true if the geometry was disposed
  95221. */
  95222. isDisposed(): boolean;
  95223. private _disposeVertexArrayObjects;
  95224. /**
  95225. * Free all associated resources
  95226. */
  95227. dispose(): void;
  95228. /**
  95229. * Clone the current geometry into a new geometry
  95230. * @param id defines the unique ID of the new geometry
  95231. * @returns a new geometry object
  95232. */
  95233. copy(id: string): Geometry;
  95234. /**
  95235. * Serialize the current geometry info (and not the vertices data) into a JSON object
  95236. * @return a JSON representation of the current geometry data (without the vertices data)
  95237. */
  95238. serialize(): any;
  95239. private toNumberArray;
  95240. /**
  95241. * Serialize all vertices data into a JSON oject
  95242. * @returns a JSON representation of the current geometry data
  95243. */
  95244. serializeVerticeData(): any;
  95245. /**
  95246. * Extracts a clone of a mesh geometry
  95247. * @param mesh defines the source mesh
  95248. * @param id defines the unique ID of the new geometry object
  95249. * @returns the new geometry object
  95250. */
  95251. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  95252. /**
  95253. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  95254. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95255. * Be aware Math.random() could cause collisions, but:
  95256. * "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"
  95257. * @returns a string containing a new GUID
  95258. */
  95259. static RandomId(): string;
  95260. /** @hidden */
  95261. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  95262. private static _CleanMatricesWeights;
  95263. /**
  95264. * Create a new geometry from persisted data (Using .babylon file format)
  95265. * @param parsedVertexData defines the persisted data
  95266. * @param scene defines the hosting scene
  95267. * @param rootUrl defines the root url to use to load assets (like delayed data)
  95268. * @returns the new geometry object
  95269. */
  95270. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  95271. }
  95272. }
  95273. declare module BABYLON {
  95274. /**
  95275. * Define an interface for all classes that will get and set the data on vertices
  95276. */
  95277. export interface IGetSetVerticesData {
  95278. /**
  95279. * Gets a boolean indicating if specific vertex data is present
  95280. * @param kind defines the vertex data kind to use
  95281. * @returns true is data kind is present
  95282. */
  95283. isVerticesDataPresent(kind: string): boolean;
  95284. /**
  95285. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95286. * @param kind defines the data kind (Position, normal, etc...)
  95287. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95288. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95289. * @returns a float array containing vertex data
  95290. */
  95291. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95292. /**
  95293. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95294. * @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.
  95295. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95296. * @returns the indices array or an empty array if the mesh has no geometry
  95297. */
  95298. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95299. /**
  95300. * Set specific vertex data
  95301. * @param kind defines the data kind (Position, normal, etc...)
  95302. * @param data defines the vertex data to use
  95303. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95304. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95305. */
  95306. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  95307. /**
  95308. * Update a specific associated vertex buffer
  95309. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95310. * - VertexBuffer.PositionKind
  95311. * - VertexBuffer.UVKind
  95312. * - VertexBuffer.UV2Kind
  95313. * - VertexBuffer.UV3Kind
  95314. * - VertexBuffer.UV4Kind
  95315. * - VertexBuffer.UV5Kind
  95316. * - VertexBuffer.UV6Kind
  95317. * - VertexBuffer.ColorKind
  95318. * - VertexBuffer.MatricesIndicesKind
  95319. * - VertexBuffer.MatricesIndicesExtraKind
  95320. * - VertexBuffer.MatricesWeightsKind
  95321. * - VertexBuffer.MatricesWeightsExtraKind
  95322. * @param data defines the data source
  95323. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95324. * @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)
  95325. */
  95326. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  95327. /**
  95328. * Creates a new index buffer
  95329. * @param indices defines the indices to store in the index buffer
  95330. * @param totalVertices defines the total number of vertices (could be null)
  95331. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95332. */
  95333. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  95334. }
  95335. /**
  95336. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  95337. */
  95338. export class VertexData {
  95339. /**
  95340. * Mesh side orientation : usually the external or front surface
  95341. */
  95342. static readonly FRONTSIDE: number;
  95343. /**
  95344. * Mesh side orientation : usually the internal or back surface
  95345. */
  95346. static readonly BACKSIDE: number;
  95347. /**
  95348. * Mesh side orientation : both internal and external or front and back surfaces
  95349. */
  95350. static readonly DOUBLESIDE: number;
  95351. /**
  95352. * Mesh side orientation : by default, `FRONTSIDE`
  95353. */
  95354. static readonly DEFAULTSIDE: number;
  95355. /**
  95356. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  95357. */
  95358. positions: Nullable<FloatArray>;
  95359. /**
  95360. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  95361. */
  95362. normals: Nullable<FloatArray>;
  95363. /**
  95364. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  95365. */
  95366. tangents: Nullable<FloatArray>;
  95367. /**
  95368. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95369. */
  95370. uvs: Nullable<FloatArray>;
  95371. /**
  95372. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95373. */
  95374. uvs2: Nullable<FloatArray>;
  95375. /**
  95376. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95377. */
  95378. uvs3: Nullable<FloatArray>;
  95379. /**
  95380. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95381. */
  95382. uvs4: Nullable<FloatArray>;
  95383. /**
  95384. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95385. */
  95386. uvs5: Nullable<FloatArray>;
  95387. /**
  95388. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95389. */
  95390. uvs6: Nullable<FloatArray>;
  95391. /**
  95392. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  95393. */
  95394. colors: Nullable<FloatArray>;
  95395. /**
  95396. * 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).
  95397. */
  95398. matricesIndices: Nullable<FloatArray>;
  95399. /**
  95400. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  95401. */
  95402. matricesWeights: Nullable<FloatArray>;
  95403. /**
  95404. * An array extending the number of possible indices
  95405. */
  95406. matricesIndicesExtra: Nullable<FloatArray>;
  95407. /**
  95408. * An array extending the number of possible weights when the number of indices is extended
  95409. */
  95410. matricesWeightsExtra: Nullable<FloatArray>;
  95411. /**
  95412. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  95413. */
  95414. indices: Nullable<IndicesArray>;
  95415. /**
  95416. * Uses the passed data array to set the set the values for the specified kind of data
  95417. * @param data a linear array of floating numbers
  95418. * @param kind the type of data that is being set, eg positions, colors etc
  95419. */
  95420. set(data: FloatArray, kind: string): void;
  95421. /**
  95422. * Associates the vertexData to the passed Mesh.
  95423. * Sets it as updatable or not (default `false`)
  95424. * @param mesh the mesh the vertexData is applied to
  95425. * @param updatable when used and having the value true allows new data to update the vertexData
  95426. * @returns the VertexData
  95427. */
  95428. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  95429. /**
  95430. * Associates the vertexData to the passed Geometry.
  95431. * Sets it as updatable or not (default `false`)
  95432. * @param geometry the geometry the vertexData is applied to
  95433. * @param updatable when used and having the value true allows new data to update the vertexData
  95434. * @returns VertexData
  95435. */
  95436. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  95437. /**
  95438. * Updates the associated mesh
  95439. * @param mesh the mesh to be updated
  95440. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95441. * @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
  95442. * @returns VertexData
  95443. */
  95444. updateMesh(mesh: Mesh): VertexData;
  95445. /**
  95446. * Updates the associated geometry
  95447. * @param geometry the geometry to be updated
  95448. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95449. * @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
  95450. * @returns VertexData.
  95451. */
  95452. updateGeometry(geometry: Geometry): VertexData;
  95453. private _applyTo;
  95454. private _update;
  95455. /**
  95456. * Transforms each position and each normal of the vertexData according to the passed Matrix
  95457. * @param matrix the transforming matrix
  95458. * @returns the VertexData
  95459. */
  95460. transform(matrix: Matrix): VertexData;
  95461. /**
  95462. * Merges the passed VertexData into the current one
  95463. * @param other the VertexData to be merged into the current one
  95464. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  95465. * @returns the modified VertexData
  95466. */
  95467. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  95468. private _mergeElement;
  95469. private _validate;
  95470. /**
  95471. * Serializes the VertexData
  95472. * @returns a serialized object
  95473. */
  95474. serialize(): any;
  95475. /**
  95476. * Extracts the vertexData from a mesh
  95477. * @param mesh the mesh from which to extract the VertexData
  95478. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  95479. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95480. * @returns the object VertexData associated to the passed mesh
  95481. */
  95482. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95483. /**
  95484. * Extracts the vertexData from the geometry
  95485. * @param geometry the geometry from which to extract the VertexData
  95486. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  95487. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95488. * @returns the object VertexData associated to the passed mesh
  95489. */
  95490. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95491. private static _ExtractFrom;
  95492. /**
  95493. * Creates the VertexData for a Ribbon
  95494. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  95495. * * pathArray array of paths, each of which an array of successive Vector3
  95496. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  95497. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  95498. * * 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
  95499. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95500. * * 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)
  95501. * * 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)
  95502. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  95503. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  95504. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  95505. * @returns the VertexData of the ribbon
  95506. */
  95507. static CreateRibbon(options: {
  95508. pathArray: Vector3[][];
  95509. closeArray?: boolean;
  95510. closePath?: boolean;
  95511. offset?: number;
  95512. sideOrientation?: number;
  95513. frontUVs?: Vector4;
  95514. backUVs?: Vector4;
  95515. invertUV?: boolean;
  95516. uvs?: Vector2[];
  95517. colors?: Color4[];
  95518. }): VertexData;
  95519. /**
  95520. * Creates the VertexData for a box
  95521. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95522. * * size sets the width, height and depth of the box to the value of size, optional default 1
  95523. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  95524. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  95525. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  95526. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95527. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95528. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95529. * * 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)
  95530. * * 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)
  95531. * @returns the VertexData of the box
  95532. */
  95533. static CreateBox(options: {
  95534. size?: number;
  95535. width?: number;
  95536. height?: number;
  95537. depth?: number;
  95538. faceUV?: Vector4[];
  95539. faceColors?: Color4[];
  95540. sideOrientation?: number;
  95541. frontUVs?: Vector4;
  95542. backUVs?: Vector4;
  95543. }): VertexData;
  95544. /**
  95545. * Creates the VertexData for a tiled box
  95546. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95547. * * faceTiles sets the pattern, tile size and number of tiles for a face
  95548. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95549. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95550. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95551. * @returns the VertexData of the box
  95552. */
  95553. static CreateTiledBox(options: {
  95554. pattern?: number;
  95555. width?: number;
  95556. height?: number;
  95557. depth?: number;
  95558. tileSize?: number;
  95559. tileWidth?: number;
  95560. tileHeight?: number;
  95561. alignHorizontal?: number;
  95562. alignVertical?: number;
  95563. faceUV?: Vector4[];
  95564. faceColors?: Color4[];
  95565. sideOrientation?: number;
  95566. }): VertexData;
  95567. /**
  95568. * Creates the VertexData for a tiled plane
  95569. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95570. * * pattern a limited pattern arrangement depending on the number
  95571. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  95572. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  95573. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  95574. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95575. * * 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)
  95576. * * 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)
  95577. * @returns the VertexData of the tiled plane
  95578. */
  95579. static CreateTiledPlane(options: {
  95580. pattern?: number;
  95581. tileSize?: number;
  95582. tileWidth?: number;
  95583. tileHeight?: number;
  95584. size?: number;
  95585. width?: number;
  95586. height?: number;
  95587. alignHorizontal?: number;
  95588. alignVertical?: number;
  95589. sideOrientation?: number;
  95590. frontUVs?: Vector4;
  95591. backUVs?: Vector4;
  95592. }): VertexData;
  95593. /**
  95594. * Creates the VertexData for an ellipsoid, defaults to a sphere
  95595. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95596. * * segments sets the number of horizontal strips optional, default 32
  95597. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  95598. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  95599. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  95600. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  95601. * * 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
  95602. * * 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
  95603. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95604. * * 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)
  95605. * * 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)
  95606. * @returns the VertexData of the ellipsoid
  95607. */
  95608. static CreateSphere(options: {
  95609. segments?: number;
  95610. diameter?: number;
  95611. diameterX?: number;
  95612. diameterY?: number;
  95613. diameterZ?: number;
  95614. arc?: number;
  95615. slice?: number;
  95616. sideOrientation?: number;
  95617. frontUVs?: Vector4;
  95618. backUVs?: Vector4;
  95619. }): VertexData;
  95620. /**
  95621. * Creates the VertexData for a cylinder, cone or prism
  95622. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95623. * * height sets the height (y direction) of the cylinder, optional, default 2
  95624. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  95625. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  95626. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  95627. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95628. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  95629. * * 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
  95630. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95631. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95632. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  95633. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  95634. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95635. * * 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)
  95636. * * 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)
  95637. * @returns the VertexData of the cylinder, cone or prism
  95638. */
  95639. static CreateCylinder(options: {
  95640. height?: number;
  95641. diameterTop?: number;
  95642. diameterBottom?: number;
  95643. diameter?: number;
  95644. tessellation?: number;
  95645. subdivisions?: number;
  95646. arc?: number;
  95647. faceColors?: Color4[];
  95648. faceUV?: Vector4[];
  95649. hasRings?: boolean;
  95650. enclose?: boolean;
  95651. sideOrientation?: number;
  95652. frontUVs?: Vector4;
  95653. backUVs?: Vector4;
  95654. }): VertexData;
  95655. /**
  95656. * Creates the VertexData for a torus
  95657. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95658. * * diameter the diameter of the torus, optional default 1
  95659. * * thickness the diameter of the tube forming the torus, optional default 0.5
  95660. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95661. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95662. * * 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)
  95663. * * 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)
  95664. * @returns the VertexData of the torus
  95665. */
  95666. static CreateTorus(options: {
  95667. diameter?: number;
  95668. thickness?: number;
  95669. tessellation?: number;
  95670. sideOrientation?: number;
  95671. frontUVs?: Vector4;
  95672. backUVs?: Vector4;
  95673. }): VertexData;
  95674. /**
  95675. * Creates the VertexData of the LineSystem
  95676. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  95677. * - lines an array of lines, each line being an array of successive Vector3
  95678. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  95679. * @returns the VertexData of the LineSystem
  95680. */
  95681. static CreateLineSystem(options: {
  95682. lines: Vector3[][];
  95683. colors?: Nullable<Color4[][]>;
  95684. }): VertexData;
  95685. /**
  95686. * Create the VertexData for a DashedLines
  95687. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  95688. * - points an array successive Vector3
  95689. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  95690. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  95691. * - dashNb the intended total number of dashes, optional, default 200
  95692. * @returns the VertexData for the DashedLines
  95693. */
  95694. static CreateDashedLines(options: {
  95695. points: Vector3[];
  95696. dashSize?: number;
  95697. gapSize?: number;
  95698. dashNb?: number;
  95699. }): VertexData;
  95700. /**
  95701. * Creates the VertexData for a Ground
  95702. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95703. * - width the width (x direction) of the ground, optional, default 1
  95704. * - height the height (z direction) of the ground, optional, default 1
  95705. * - subdivisions the number of subdivisions per side, optional, default 1
  95706. * @returns the VertexData of the Ground
  95707. */
  95708. static CreateGround(options: {
  95709. width?: number;
  95710. height?: number;
  95711. subdivisions?: number;
  95712. subdivisionsX?: number;
  95713. subdivisionsY?: number;
  95714. }): VertexData;
  95715. /**
  95716. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  95717. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95718. * * xmin the ground minimum X coordinate, optional, default -1
  95719. * * zmin the ground minimum Z coordinate, optional, default -1
  95720. * * xmax the ground maximum X coordinate, optional, default 1
  95721. * * zmax the ground maximum Z coordinate, optional, default 1
  95722. * * 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}
  95723. * * 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}
  95724. * @returns the VertexData of the TiledGround
  95725. */
  95726. static CreateTiledGround(options: {
  95727. xmin: number;
  95728. zmin: number;
  95729. xmax: number;
  95730. zmax: number;
  95731. subdivisions?: {
  95732. w: number;
  95733. h: number;
  95734. };
  95735. precision?: {
  95736. w: number;
  95737. h: number;
  95738. };
  95739. }): VertexData;
  95740. /**
  95741. * Creates the VertexData of the Ground designed from a heightmap
  95742. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  95743. * * width the width (x direction) of the ground
  95744. * * height the height (z direction) of the ground
  95745. * * subdivisions the number of subdivisions per side
  95746. * * minHeight the minimum altitude on the ground, optional, default 0
  95747. * * maxHeight the maximum altitude on the ground, optional default 1
  95748. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  95749. * * buffer the array holding the image color data
  95750. * * bufferWidth the width of image
  95751. * * bufferHeight the height of image
  95752. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  95753. * @returns the VertexData of the Ground designed from a heightmap
  95754. */
  95755. static CreateGroundFromHeightMap(options: {
  95756. width: number;
  95757. height: number;
  95758. subdivisions: number;
  95759. minHeight: number;
  95760. maxHeight: number;
  95761. colorFilter: Color3;
  95762. buffer: Uint8Array;
  95763. bufferWidth: number;
  95764. bufferHeight: number;
  95765. alphaFilter: number;
  95766. }): VertexData;
  95767. /**
  95768. * Creates the VertexData for a Plane
  95769. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  95770. * * size sets the width and height of the plane to the value of size, optional default 1
  95771. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  95772. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  95773. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95774. * * 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)
  95775. * * 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)
  95776. * @returns the VertexData of the box
  95777. */
  95778. static CreatePlane(options: {
  95779. size?: number;
  95780. width?: number;
  95781. height?: number;
  95782. sideOrientation?: number;
  95783. frontUVs?: Vector4;
  95784. backUVs?: Vector4;
  95785. }): VertexData;
  95786. /**
  95787. * Creates the VertexData of the Disc or regular Polygon
  95788. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  95789. * * radius the radius of the disc, optional default 0.5
  95790. * * tessellation the number of polygon sides, optional, default 64
  95791. * * 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
  95792. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95793. * * 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)
  95794. * * 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)
  95795. * @returns the VertexData of the box
  95796. */
  95797. static CreateDisc(options: {
  95798. radius?: number;
  95799. tessellation?: number;
  95800. arc?: number;
  95801. sideOrientation?: number;
  95802. frontUVs?: Vector4;
  95803. backUVs?: Vector4;
  95804. }): VertexData;
  95805. /**
  95806. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  95807. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  95808. * @param polygon a mesh built from polygonTriangulation.build()
  95809. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95810. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95811. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95812. * @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)
  95813. * @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)
  95814. * @returns the VertexData of the Polygon
  95815. */
  95816. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  95817. /**
  95818. * Creates the VertexData of the IcoSphere
  95819. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  95820. * * radius the radius of the IcoSphere, optional default 1
  95821. * * radiusX allows stretching in the x direction, optional, default radius
  95822. * * radiusY allows stretching in the y direction, optional, default radius
  95823. * * radiusZ allows stretching in the z direction, optional, default radius
  95824. * * flat when true creates a flat shaded mesh, optional, default true
  95825. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95826. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95827. * * 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)
  95828. * * 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)
  95829. * @returns the VertexData of the IcoSphere
  95830. */
  95831. static CreateIcoSphere(options: {
  95832. radius?: number;
  95833. radiusX?: number;
  95834. radiusY?: number;
  95835. radiusZ?: number;
  95836. flat?: boolean;
  95837. subdivisions?: number;
  95838. sideOrientation?: number;
  95839. frontUVs?: Vector4;
  95840. backUVs?: Vector4;
  95841. }): VertexData;
  95842. /**
  95843. * Creates the VertexData for a Polyhedron
  95844. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  95845. * * type provided types are:
  95846. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  95847. * * 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)
  95848. * * size the size of the IcoSphere, optional default 1
  95849. * * sizeX allows stretching in the x direction, optional, default size
  95850. * * sizeY allows stretching in the y direction, optional, default size
  95851. * * sizeZ allows stretching in the z direction, optional, default size
  95852. * * 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
  95853. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95854. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95855. * * flat when true creates a flat shaded mesh, optional, default true
  95856. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95857. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95858. * * 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)
  95859. * * 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)
  95860. * @returns the VertexData of the Polyhedron
  95861. */
  95862. static CreatePolyhedron(options: {
  95863. type?: number;
  95864. size?: number;
  95865. sizeX?: number;
  95866. sizeY?: number;
  95867. sizeZ?: number;
  95868. custom?: any;
  95869. faceUV?: Vector4[];
  95870. faceColors?: Color4[];
  95871. flat?: boolean;
  95872. sideOrientation?: number;
  95873. frontUVs?: Vector4;
  95874. backUVs?: Vector4;
  95875. }): VertexData;
  95876. /**
  95877. * Creates the VertexData for a TorusKnot
  95878. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  95879. * * radius the radius of the torus knot, optional, default 2
  95880. * * tube the thickness of the tube, optional, default 0.5
  95881. * * radialSegments the number of sides on each tube segments, optional, default 32
  95882. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  95883. * * p the number of windings around the z axis, optional, default 2
  95884. * * q the number of windings around the x axis, optional, default 3
  95885. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95886. * * 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)
  95887. * * 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)
  95888. * @returns the VertexData of the Torus Knot
  95889. */
  95890. static CreateTorusKnot(options: {
  95891. radius?: number;
  95892. tube?: number;
  95893. radialSegments?: number;
  95894. tubularSegments?: number;
  95895. p?: number;
  95896. q?: number;
  95897. sideOrientation?: number;
  95898. frontUVs?: Vector4;
  95899. backUVs?: Vector4;
  95900. }): VertexData;
  95901. /**
  95902. * Compute normals for given positions and indices
  95903. * @param positions an array of vertex positions, [...., x, y, z, ......]
  95904. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  95905. * @param normals an array of vertex normals, [...., x, y, z, ......]
  95906. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  95907. * * facetNormals : optional array of facet normals (vector3)
  95908. * * facetPositions : optional array of facet positions (vector3)
  95909. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  95910. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  95911. * * bInfo : optional bounding info, required for facetPartitioning computation
  95912. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  95913. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  95914. * * useRightHandedSystem: optional boolean to for right handed system computation
  95915. * * depthSort : optional boolean to enable the facet depth sort computation
  95916. * * distanceTo : optional Vector3 to compute the facet depth from this location
  95917. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  95918. */
  95919. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  95920. facetNormals?: any;
  95921. facetPositions?: any;
  95922. facetPartitioning?: any;
  95923. ratio?: number;
  95924. bInfo?: any;
  95925. bbSize?: Vector3;
  95926. subDiv?: any;
  95927. useRightHandedSystem?: boolean;
  95928. depthSort?: boolean;
  95929. distanceTo?: Vector3;
  95930. depthSortedFacets?: any;
  95931. }): void;
  95932. /** @hidden */
  95933. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  95934. /**
  95935. * Applies VertexData created from the imported parameters to the geometry
  95936. * @param parsedVertexData the parsed data from an imported file
  95937. * @param geometry the geometry to apply the VertexData to
  95938. */
  95939. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  95940. }
  95941. }
  95942. declare module BABYLON {
  95943. /**
  95944. * Defines a target to use with MorphTargetManager
  95945. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95946. */
  95947. export class MorphTarget implements IAnimatable {
  95948. /** defines the name of the target */
  95949. name: string;
  95950. /**
  95951. * Gets or sets the list of animations
  95952. */
  95953. animations: Animation[];
  95954. private _scene;
  95955. private _positions;
  95956. private _normals;
  95957. private _tangents;
  95958. private _uvs;
  95959. private _influence;
  95960. private _uniqueId;
  95961. /**
  95962. * Observable raised when the influence changes
  95963. */
  95964. onInfluenceChanged: Observable<boolean>;
  95965. /** @hidden */
  95966. _onDataLayoutChanged: Observable<void>;
  95967. /**
  95968. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  95969. */
  95970. get influence(): number;
  95971. set influence(influence: number);
  95972. /**
  95973. * Gets or sets the id of the morph Target
  95974. */
  95975. id: string;
  95976. private _animationPropertiesOverride;
  95977. /**
  95978. * Gets or sets the animation properties override
  95979. */
  95980. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95981. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95982. /**
  95983. * Creates a new MorphTarget
  95984. * @param name defines the name of the target
  95985. * @param influence defines the influence to use
  95986. * @param scene defines the scene the morphtarget belongs to
  95987. */
  95988. constructor(
  95989. /** defines the name of the target */
  95990. name: string, influence?: number, scene?: Nullable<Scene>);
  95991. /**
  95992. * Gets the unique ID of this manager
  95993. */
  95994. get uniqueId(): number;
  95995. /**
  95996. * Gets a boolean defining if the target contains position data
  95997. */
  95998. get hasPositions(): boolean;
  95999. /**
  96000. * Gets a boolean defining if the target contains normal data
  96001. */
  96002. get hasNormals(): boolean;
  96003. /**
  96004. * Gets a boolean defining if the target contains tangent data
  96005. */
  96006. get hasTangents(): boolean;
  96007. /**
  96008. * Gets a boolean defining if the target contains texture coordinates data
  96009. */
  96010. get hasUVs(): boolean;
  96011. /**
  96012. * Affects position data to this target
  96013. * @param data defines the position data to use
  96014. */
  96015. setPositions(data: Nullable<FloatArray>): void;
  96016. /**
  96017. * Gets the position data stored in this target
  96018. * @returns a FloatArray containing the position data (or null if not present)
  96019. */
  96020. getPositions(): Nullable<FloatArray>;
  96021. /**
  96022. * Affects normal data to this target
  96023. * @param data defines the normal data to use
  96024. */
  96025. setNormals(data: Nullable<FloatArray>): void;
  96026. /**
  96027. * Gets the normal data stored in this target
  96028. * @returns a FloatArray containing the normal data (or null if not present)
  96029. */
  96030. getNormals(): Nullable<FloatArray>;
  96031. /**
  96032. * Affects tangent data to this target
  96033. * @param data defines the tangent data to use
  96034. */
  96035. setTangents(data: Nullable<FloatArray>): void;
  96036. /**
  96037. * Gets the tangent data stored in this target
  96038. * @returns a FloatArray containing the tangent data (or null if not present)
  96039. */
  96040. getTangents(): Nullable<FloatArray>;
  96041. /**
  96042. * Affects texture coordinates data to this target
  96043. * @param data defines the texture coordinates data to use
  96044. */
  96045. setUVs(data: Nullable<FloatArray>): void;
  96046. /**
  96047. * Gets the texture coordinates data stored in this target
  96048. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  96049. */
  96050. getUVs(): Nullable<FloatArray>;
  96051. /**
  96052. * Clone the current target
  96053. * @returns a new MorphTarget
  96054. */
  96055. clone(): MorphTarget;
  96056. /**
  96057. * Serializes the current target into a Serialization object
  96058. * @returns the serialized object
  96059. */
  96060. serialize(): any;
  96061. /**
  96062. * Returns the string "MorphTarget"
  96063. * @returns "MorphTarget"
  96064. */
  96065. getClassName(): string;
  96066. /**
  96067. * Creates a new target from serialized data
  96068. * @param serializationObject defines the serialized data to use
  96069. * @returns a new MorphTarget
  96070. */
  96071. static Parse(serializationObject: any): MorphTarget;
  96072. /**
  96073. * Creates a MorphTarget from mesh data
  96074. * @param mesh defines the source mesh
  96075. * @param name defines the name to use for the new target
  96076. * @param influence defines the influence to attach to the target
  96077. * @returns a new MorphTarget
  96078. */
  96079. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  96080. }
  96081. }
  96082. declare module BABYLON {
  96083. /**
  96084. * This class is used to deform meshes using morphing between different targets
  96085. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96086. */
  96087. export class MorphTargetManager {
  96088. private _targets;
  96089. private _targetInfluenceChangedObservers;
  96090. private _targetDataLayoutChangedObservers;
  96091. private _activeTargets;
  96092. private _scene;
  96093. private _influences;
  96094. private _supportsNormals;
  96095. private _supportsTangents;
  96096. private _supportsUVs;
  96097. private _vertexCount;
  96098. private _uniqueId;
  96099. private _tempInfluences;
  96100. /**
  96101. * Gets or sets a boolean indicating if normals must be morphed
  96102. */
  96103. enableNormalMorphing: boolean;
  96104. /**
  96105. * Gets or sets a boolean indicating if tangents must be morphed
  96106. */
  96107. enableTangentMorphing: boolean;
  96108. /**
  96109. * Gets or sets a boolean indicating if UV must be morphed
  96110. */
  96111. enableUVMorphing: boolean;
  96112. /**
  96113. * Creates a new MorphTargetManager
  96114. * @param scene defines the current scene
  96115. */
  96116. constructor(scene?: Nullable<Scene>);
  96117. /**
  96118. * Gets the unique ID of this manager
  96119. */
  96120. get uniqueId(): number;
  96121. /**
  96122. * Gets the number of vertices handled by this manager
  96123. */
  96124. get vertexCount(): number;
  96125. /**
  96126. * Gets a boolean indicating if this manager supports morphing of normals
  96127. */
  96128. get supportsNormals(): boolean;
  96129. /**
  96130. * Gets a boolean indicating if this manager supports morphing of tangents
  96131. */
  96132. get supportsTangents(): boolean;
  96133. /**
  96134. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  96135. */
  96136. get supportsUVs(): boolean;
  96137. /**
  96138. * Gets the number of targets stored in this manager
  96139. */
  96140. get numTargets(): number;
  96141. /**
  96142. * Gets the number of influencers (ie. the number of targets with influences > 0)
  96143. */
  96144. get numInfluencers(): number;
  96145. /**
  96146. * Gets the list of influences (one per target)
  96147. */
  96148. get influences(): Float32Array;
  96149. /**
  96150. * Gets the active target at specified index. An active target is a target with an influence > 0
  96151. * @param index defines the index to check
  96152. * @returns the requested target
  96153. */
  96154. getActiveTarget(index: number): MorphTarget;
  96155. /**
  96156. * Gets the target at specified index
  96157. * @param index defines the index to check
  96158. * @returns the requested target
  96159. */
  96160. getTarget(index: number): MorphTarget;
  96161. /**
  96162. * Add a new target to this manager
  96163. * @param target defines the target to add
  96164. */
  96165. addTarget(target: MorphTarget): void;
  96166. /**
  96167. * Removes a target from the manager
  96168. * @param target defines the target to remove
  96169. */
  96170. removeTarget(target: MorphTarget): void;
  96171. /**
  96172. * Clone the current manager
  96173. * @returns a new MorphTargetManager
  96174. */
  96175. clone(): MorphTargetManager;
  96176. /**
  96177. * Serializes the current manager into a Serialization object
  96178. * @returns the serialized object
  96179. */
  96180. serialize(): any;
  96181. private _syncActiveTargets;
  96182. /**
  96183. * Syncrhonize the targets with all the meshes using this morph target manager
  96184. */
  96185. synchronize(): void;
  96186. /**
  96187. * Creates a new MorphTargetManager from serialized data
  96188. * @param serializationObject defines the serialized data
  96189. * @param scene defines the hosting scene
  96190. * @returns the new MorphTargetManager
  96191. */
  96192. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  96193. }
  96194. }
  96195. declare module BABYLON {
  96196. /**
  96197. * Class used to represent a specific level of detail of a mesh
  96198. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96199. */
  96200. export class MeshLODLevel {
  96201. /** Defines the distance where this level should start being displayed */
  96202. distance: number;
  96203. /** Defines the mesh to use to render this level */
  96204. mesh: Nullable<Mesh>;
  96205. /**
  96206. * Creates a new LOD level
  96207. * @param distance defines the distance where this level should star being displayed
  96208. * @param mesh defines the mesh to use to render this level
  96209. */
  96210. constructor(
  96211. /** Defines the distance where this level should start being displayed */
  96212. distance: number,
  96213. /** Defines the mesh to use to render this level */
  96214. mesh: Nullable<Mesh>);
  96215. }
  96216. }
  96217. declare module BABYLON {
  96218. /**
  96219. * Mesh representing the gorund
  96220. */
  96221. export class GroundMesh extends Mesh {
  96222. /** If octree should be generated */
  96223. generateOctree: boolean;
  96224. private _heightQuads;
  96225. /** @hidden */
  96226. _subdivisionsX: number;
  96227. /** @hidden */
  96228. _subdivisionsY: number;
  96229. /** @hidden */
  96230. _width: number;
  96231. /** @hidden */
  96232. _height: number;
  96233. /** @hidden */
  96234. _minX: number;
  96235. /** @hidden */
  96236. _maxX: number;
  96237. /** @hidden */
  96238. _minZ: number;
  96239. /** @hidden */
  96240. _maxZ: number;
  96241. constructor(name: string, scene: Scene);
  96242. /**
  96243. * "GroundMesh"
  96244. * @returns "GroundMesh"
  96245. */
  96246. getClassName(): string;
  96247. /**
  96248. * The minimum of x and y subdivisions
  96249. */
  96250. get subdivisions(): number;
  96251. /**
  96252. * X subdivisions
  96253. */
  96254. get subdivisionsX(): number;
  96255. /**
  96256. * Y subdivisions
  96257. */
  96258. get subdivisionsY(): number;
  96259. /**
  96260. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  96261. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96262. * @param chunksCount the number of subdivisions for x and y
  96263. * @param octreeBlocksSize (Default: 32)
  96264. */
  96265. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  96266. /**
  96267. * Returns a height (y) value in the Worl system :
  96268. * the ground altitude at the coordinates (x, z) expressed in the World system.
  96269. * @param x x coordinate
  96270. * @param z z coordinate
  96271. * @returns the ground y position if (x, z) are outside the ground surface.
  96272. */
  96273. getHeightAtCoordinates(x: number, z: number): number;
  96274. /**
  96275. * Returns a normalized vector (Vector3) orthogonal to the ground
  96276. * at the ground coordinates (x, z) expressed in the World system.
  96277. * @param x x coordinate
  96278. * @param z z coordinate
  96279. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  96280. */
  96281. getNormalAtCoordinates(x: number, z: number): Vector3;
  96282. /**
  96283. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  96284. * at the ground coordinates (x, z) expressed in the World system.
  96285. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  96286. * @param x x coordinate
  96287. * @param z z coordinate
  96288. * @param ref vector to store the result
  96289. * @returns the GroundMesh.
  96290. */
  96291. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  96292. /**
  96293. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  96294. * if the ground has been updated.
  96295. * This can be used in the render loop.
  96296. * @returns the GroundMesh.
  96297. */
  96298. updateCoordinateHeights(): GroundMesh;
  96299. private _getFacetAt;
  96300. private _initHeightQuads;
  96301. private _computeHeightQuads;
  96302. /**
  96303. * Serializes this ground mesh
  96304. * @param serializationObject object to write serialization to
  96305. */
  96306. serialize(serializationObject: any): void;
  96307. /**
  96308. * Parses a serialized ground mesh
  96309. * @param parsedMesh the serialized mesh
  96310. * @param scene the scene to create the ground mesh in
  96311. * @returns the created ground mesh
  96312. */
  96313. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  96314. }
  96315. }
  96316. declare module BABYLON {
  96317. /**
  96318. * Interface for Physics-Joint data
  96319. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96320. */
  96321. export interface PhysicsJointData {
  96322. /**
  96323. * The main pivot of the joint
  96324. */
  96325. mainPivot?: Vector3;
  96326. /**
  96327. * The connected pivot of the joint
  96328. */
  96329. connectedPivot?: Vector3;
  96330. /**
  96331. * The main axis of the joint
  96332. */
  96333. mainAxis?: Vector3;
  96334. /**
  96335. * The connected axis of the joint
  96336. */
  96337. connectedAxis?: Vector3;
  96338. /**
  96339. * The collision of the joint
  96340. */
  96341. collision?: boolean;
  96342. /**
  96343. * Native Oimo/Cannon/Energy data
  96344. */
  96345. nativeParams?: any;
  96346. }
  96347. /**
  96348. * This is a holder class for the physics joint created by the physics plugin
  96349. * It holds a set of functions to control the underlying joint
  96350. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96351. */
  96352. export class PhysicsJoint {
  96353. /**
  96354. * The type of the physics joint
  96355. */
  96356. type: number;
  96357. /**
  96358. * The data for the physics joint
  96359. */
  96360. jointData: PhysicsJointData;
  96361. private _physicsJoint;
  96362. protected _physicsPlugin: IPhysicsEnginePlugin;
  96363. /**
  96364. * Initializes the physics joint
  96365. * @param type The type of the physics joint
  96366. * @param jointData The data for the physics joint
  96367. */
  96368. constructor(
  96369. /**
  96370. * The type of the physics joint
  96371. */
  96372. type: number,
  96373. /**
  96374. * The data for the physics joint
  96375. */
  96376. jointData: PhysicsJointData);
  96377. /**
  96378. * Gets the physics joint
  96379. */
  96380. get physicsJoint(): any;
  96381. /**
  96382. * Sets the physics joint
  96383. */
  96384. set physicsJoint(newJoint: any);
  96385. /**
  96386. * Sets the physics plugin
  96387. */
  96388. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  96389. /**
  96390. * Execute a function that is physics-plugin specific.
  96391. * @param {Function} func the function that will be executed.
  96392. * It accepts two parameters: the physics world and the physics joint
  96393. */
  96394. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  96395. /**
  96396. * Distance-Joint type
  96397. */
  96398. static DistanceJoint: number;
  96399. /**
  96400. * Hinge-Joint type
  96401. */
  96402. static HingeJoint: number;
  96403. /**
  96404. * Ball-and-Socket joint type
  96405. */
  96406. static BallAndSocketJoint: number;
  96407. /**
  96408. * Wheel-Joint type
  96409. */
  96410. static WheelJoint: number;
  96411. /**
  96412. * Slider-Joint type
  96413. */
  96414. static SliderJoint: number;
  96415. /**
  96416. * Prismatic-Joint type
  96417. */
  96418. static PrismaticJoint: number;
  96419. /**
  96420. * Universal-Joint type
  96421. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  96422. */
  96423. static UniversalJoint: number;
  96424. /**
  96425. * Hinge-Joint 2 type
  96426. */
  96427. static Hinge2Joint: number;
  96428. /**
  96429. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  96430. */
  96431. static PointToPointJoint: number;
  96432. /**
  96433. * Spring-Joint type
  96434. */
  96435. static SpringJoint: number;
  96436. /**
  96437. * Lock-Joint type
  96438. */
  96439. static LockJoint: number;
  96440. }
  96441. /**
  96442. * A class representing a physics distance joint
  96443. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96444. */
  96445. export class DistanceJoint extends PhysicsJoint {
  96446. /**
  96447. *
  96448. * @param jointData The data for the Distance-Joint
  96449. */
  96450. constructor(jointData: DistanceJointData);
  96451. /**
  96452. * Update the predefined distance.
  96453. * @param maxDistance The maximum preferred distance
  96454. * @param minDistance The minimum preferred distance
  96455. */
  96456. updateDistance(maxDistance: number, minDistance?: number): void;
  96457. }
  96458. /**
  96459. * Represents a Motor-Enabled Joint
  96460. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96461. */
  96462. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  96463. /**
  96464. * Initializes the Motor-Enabled Joint
  96465. * @param type The type of the joint
  96466. * @param jointData The physica joint data for the joint
  96467. */
  96468. constructor(type: number, jointData: PhysicsJointData);
  96469. /**
  96470. * Set the motor values.
  96471. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96472. * @param force the force to apply
  96473. * @param maxForce max force for this motor.
  96474. */
  96475. setMotor(force?: number, maxForce?: number): void;
  96476. /**
  96477. * Set the motor's limits.
  96478. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96479. * @param upperLimit The upper limit of the motor
  96480. * @param lowerLimit The lower limit of the motor
  96481. */
  96482. setLimit(upperLimit: number, lowerLimit?: number): void;
  96483. }
  96484. /**
  96485. * This class represents a single physics Hinge-Joint
  96486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96487. */
  96488. export class HingeJoint extends MotorEnabledJoint {
  96489. /**
  96490. * Initializes the Hinge-Joint
  96491. * @param jointData The joint data for the Hinge-Joint
  96492. */
  96493. constructor(jointData: PhysicsJointData);
  96494. /**
  96495. * Set the motor values.
  96496. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96497. * @param {number} force the force to apply
  96498. * @param {number} maxForce max force for this motor.
  96499. */
  96500. setMotor(force?: number, maxForce?: number): void;
  96501. /**
  96502. * Set the motor's limits.
  96503. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96504. * @param upperLimit The upper limit of the motor
  96505. * @param lowerLimit The lower limit of the motor
  96506. */
  96507. setLimit(upperLimit: number, lowerLimit?: number): void;
  96508. }
  96509. /**
  96510. * This class represents a dual hinge physics joint (same as wheel joint)
  96511. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96512. */
  96513. export class Hinge2Joint extends MotorEnabledJoint {
  96514. /**
  96515. * Initializes the Hinge2-Joint
  96516. * @param jointData The joint data for the Hinge2-Joint
  96517. */
  96518. constructor(jointData: PhysicsJointData);
  96519. /**
  96520. * Set the motor values.
  96521. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96522. * @param {number} targetSpeed the speed the motor is to reach
  96523. * @param {number} maxForce max force for this motor.
  96524. * @param {motorIndex} the motor's index, 0 or 1.
  96525. */
  96526. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  96527. /**
  96528. * Set the motor limits.
  96529. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96530. * @param {number} upperLimit the upper limit
  96531. * @param {number} lowerLimit lower limit
  96532. * @param {motorIndex} the motor's index, 0 or 1.
  96533. */
  96534. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96535. }
  96536. /**
  96537. * Interface for a motor enabled joint
  96538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96539. */
  96540. export interface IMotorEnabledJoint {
  96541. /**
  96542. * Physics joint
  96543. */
  96544. physicsJoint: any;
  96545. /**
  96546. * Sets the motor of the motor-enabled joint
  96547. * @param force The force of the motor
  96548. * @param maxForce The maximum force of the motor
  96549. * @param motorIndex The index of the motor
  96550. */
  96551. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  96552. /**
  96553. * Sets the limit of the motor
  96554. * @param upperLimit The upper limit of the motor
  96555. * @param lowerLimit The lower limit of the motor
  96556. * @param motorIndex The index of the motor
  96557. */
  96558. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96559. }
  96560. /**
  96561. * Joint data for a Distance-Joint
  96562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96563. */
  96564. export interface DistanceJointData extends PhysicsJointData {
  96565. /**
  96566. * Max distance the 2 joint objects can be apart
  96567. */
  96568. maxDistance: number;
  96569. }
  96570. /**
  96571. * Joint data from a spring joint
  96572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96573. */
  96574. export interface SpringJointData extends PhysicsJointData {
  96575. /**
  96576. * Length of the spring
  96577. */
  96578. length: number;
  96579. /**
  96580. * Stiffness of the spring
  96581. */
  96582. stiffness: number;
  96583. /**
  96584. * Damping of the spring
  96585. */
  96586. damping: number;
  96587. /** this callback will be called when applying the force to the impostors. */
  96588. forceApplicationCallback: () => void;
  96589. }
  96590. }
  96591. declare module BABYLON {
  96592. /**
  96593. * Holds the data for the raycast result
  96594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96595. */
  96596. export class PhysicsRaycastResult {
  96597. private _hasHit;
  96598. private _hitDistance;
  96599. private _hitNormalWorld;
  96600. private _hitPointWorld;
  96601. private _rayFromWorld;
  96602. private _rayToWorld;
  96603. /**
  96604. * Gets if there was a hit
  96605. */
  96606. get hasHit(): boolean;
  96607. /**
  96608. * Gets the distance from the hit
  96609. */
  96610. get hitDistance(): number;
  96611. /**
  96612. * Gets the hit normal/direction in the world
  96613. */
  96614. get hitNormalWorld(): Vector3;
  96615. /**
  96616. * Gets the hit point in the world
  96617. */
  96618. get hitPointWorld(): Vector3;
  96619. /**
  96620. * Gets the ray "start point" of the ray in the world
  96621. */
  96622. get rayFromWorld(): Vector3;
  96623. /**
  96624. * Gets the ray "end point" of the ray in the world
  96625. */
  96626. get rayToWorld(): Vector3;
  96627. /**
  96628. * Sets the hit data (normal & point in world space)
  96629. * @param hitNormalWorld defines the normal in world space
  96630. * @param hitPointWorld defines the point in world space
  96631. */
  96632. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  96633. /**
  96634. * Sets the distance from the start point to the hit point
  96635. * @param distance
  96636. */
  96637. setHitDistance(distance: number): void;
  96638. /**
  96639. * Calculates the distance manually
  96640. */
  96641. calculateHitDistance(): void;
  96642. /**
  96643. * Resets all the values to default
  96644. * @param from The from point on world space
  96645. * @param to The to point on world space
  96646. */
  96647. reset(from?: Vector3, to?: Vector3): void;
  96648. }
  96649. /**
  96650. * Interface for the size containing width and height
  96651. */
  96652. interface IXYZ {
  96653. /**
  96654. * X
  96655. */
  96656. x: number;
  96657. /**
  96658. * Y
  96659. */
  96660. y: number;
  96661. /**
  96662. * Z
  96663. */
  96664. z: number;
  96665. }
  96666. }
  96667. declare module BABYLON {
  96668. /**
  96669. * Interface used to describe a physics joint
  96670. */
  96671. export interface PhysicsImpostorJoint {
  96672. /** Defines the main impostor to which the joint is linked */
  96673. mainImpostor: PhysicsImpostor;
  96674. /** Defines the impostor that is connected to the main impostor using this joint */
  96675. connectedImpostor: PhysicsImpostor;
  96676. /** Defines the joint itself */
  96677. joint: PhysicsJoint;
  96678. }
  96679. /** @hidden */
  96680. export interface IPhysicsEnginePlugin {
  96681. world: any;
  96682. name: string;
  96683. setGravity(gravity: Vector3): void;
  96684. setTimeStep(timeStep: number): void;
  96685. getTimeStep(): number;
  96686. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  96687. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96688. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96689. generatePhysicsBody(impostor: PhysicsImpostor): void;
  96690. removePhysicsBody(impostor: PhysicsImpostor): void;
  96691. generateJoint(joint: PhysicsImpostorJoint): void;
  96692. removeJoint(joint: PhysicsImpostorJoint): void;
  96693. isSupported(): boolean;
  96694. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  96695. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  96696. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96697. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96698. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96699. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96700. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  96701. getBodyMass(impostor: PhysicsImpostor): number;
  96702. getBodyFriction(impostor: PhysicsImpostor): number;
  96703. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  96704. getBodyRestitution(impostor: PhysicsImpostor): number;
  96705. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  96706. getBodyPressure?(impostor: PhysicsImpostor): number;
  96707. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  96708. getBodyStiffness?(impostor: PhysicsImpostor): number;
  96709. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  96710. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  96711. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  96712. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  96713. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  96714. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96715. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96716. sleepBody(impostor: PhysicsImpostor): void;
  96717. wakeUpBody(impostor: PhysicsImpostor): void;
  96718. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96719. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  96720. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  96721. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96722. getRadius(impostor: PhysicsImpostor): number;
  96723. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  96724. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  96725. dispose(): void;
  96726. }
  96727. /**
  96728. * Interface used to define a physics engine
  96729. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  96730. */
  96731. export interface IPhysicsEngine {
  96732. /**
  96733. * Gets the gravity vector used by the simulation
  96734. */
  96735. gravity: Vector3;
  96736. /**
  96737. * Sets the gravity vector used by the simulation
  96738. * @param gravity defines the gravity vector to use
  96739. */
  96740. setGravity(gravity: Vector3): void;
  96741. /**
  96742. * Set the time step of the physics engine.
  96743. * Default is 1/60.
  96744. * To slow it down, enter 1/600 for example.
  96745. * To speed it up, 1/30
  96746. * @param newTimeStep the new timestep to apply to this world.
  96747. */
  96748. setTimeStep(newTimeStep: number): void;
  96749. /**
  96750. * Get the time step of the physics engine.
  96751. * @returns the current time step
  96752. */
  96753. getTimeStep(): number;
  96754. /**
  96755. * Set the sub time step of the physics engine.
  96756. * Default is 0 meaning there is no sub steps
  96757. * To increase physics resolution precision, set a small value (like 1 ms)
  96758. * @param subTimeStep defines the new sub timestep used for physics resolution.
  96759. */
  96760. setSubTimeStep(subTimeStep: number): void;
  96761. /**
  96762. * Get the sub time step of the physics engine.
  96763. * @returns the current sub time step
  96764. */
  96765. getSubTimeStep(): number;
  96766. /**
  96767. * Release all resources
  96768. */
  96769. dispose(): void;
  96770. /**
  96771. * Gets the name of the current physics plugin
  96772. * @returns the name of the plugin
  96773. */
  96774. getPhysicsPluginName(): string;
  96775. /**
  96776. * Adding a new impostor for the impostor tracking.
  96777. * This will be done by the impostor itself.
  96778. * @param impostor the impostor to add
  96779. */
  96780. addImpostor(impostor: PhysicsImpostor): void;
  96781. /**
  96782. * Remove an impostor from the engine.
  96783. * This impostor and its mesh will not longer be updated by the physics engine.
  96784. * @param impostor the impostor to remove
  96785. */
  96786. removeImpostor(impostor: PhysicsImpostor): void;
  96787. /**
  96788. * Add a joint to the physics engine
  96789. * @param mainImpostor defines the main impostor to which the joint is added.
  96790. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  96791. * @param joint defines the joint that will connect both impostors.
  96792. */
  96793. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96794. /**
  96795. * Removes a joint from the simulation
  96796. * @param mainImpostor defines the impostor used with the joint
  96797. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  96798. * @param joint defines the joint to remove
  96799. */
  96800. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96801. /**
  96802. * Gets the current plugin used to run the simulation
  96803. * @returns current plugin
  96804. */
  96805. getPhysicsPlugin(): IPhysicsEnginePlugin;
  96806. /**
  96807. * Gets the list of physic impostors
  96808. * @returns an array of PhysicsImpostor
  96809. */
  96810. getImpostors(): Array<PhysicsImpostor>;
  96811. /**
  96812. * Gets the impostor for a physics enabled object
  96813. * @param object defines the object impersonated by the impostor
  96814. * @returns the PhysicsImpostor or null if not found
  96815. */
  96816. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96817. /**
  96818. * Gets the impostor for a physics body object
  96819. * @param body defines physics body used by the impostor
  96820. * @returns the PhysicsImpostor or null if not found
  96821. */
  96822. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  96823. /**
  96824. * Does a raycast in the physics world
  96825. * @param from when should the ray start?
  96826. * @param to when should the ray end?
  96827. * @returns PhysicsRaycastResult
  96828. */
  96829. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96830. /**
  96831. * Called by the scene. No need to call it.
  96832. * @param delta defines the timespam between frames
  96833. */
  96834. _step(delta: number): void;
  96835. }
  96836. }
  96837. declare module BABYLON {
  96838. /**
  96839. * The interface for the physics imposter parameters
  96840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96841. */
  96842. export interface PhysicsImpostorParameters {
  96843. /**
  96844. * The mass of the physics imposter
  96845. */
  96846. mass: number;
  96847. /**
  96848. * The friction of the physics imposter
  96849. */
  96850. friction?: number;
  96851. /**
  96852. * The coefficient of restitution of the physics imposter
  96853. */
  96854. restitution?: number;
  96855. /**
  96856. * The native options of the physics imposter
  96857. */
  96858. nativeOptions?: any;
  96859. /**
  96860. * Specifies if the parent should be ignored
  96861. */
  96862. ignoreParent?: boolean;
  96863. /**
  96864. * Specifies if bi-directional transformations should be disabled
  96865. */
  96866. disableBidirectionalTransformation?: boolean;
  96867. /**
  96868. * The pressure inside the physics imposter, soft object only
  96869. */
  96870. pressure?: number;
  96871. /**
  96872. * The stiffness the physics imposter, soft object only
  96873. */
  96874. stiffness?: number;
  96875. /**
  96876. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  96877. */
  96878. velocityIterations?: number;
  96879. /**
  96880. * The number of iterations used in maintaining consistent vertex positions, soft object only
  96881. */
  96882. positionIterations?: number;
  96883. /**
  96884. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  96885. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  96886. * Add to fix multiple points
  96887. */
  96888. fixedPoints?: number;
  96889. /**
  96890. * The collision margin around a soft object
  96891. */
  96892. margin?: number;
  96893. /**
  96894. * The collision margin around a soft object
  96895. */
  96896. damping?: number;
  96897. /**
  96898. * The path for a rope based on an extrusion
  96899. */
  96900. path?: any;
  96901. /**
  96902. * The shape of an extrusion used for a rope based on an extrusion
  96903. */
  96904. shape?: any;
  96905. }
  96906. /**
  96907. * Interface for a physics-enabled object
  96908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96909. */
  96910. export interface IPhysicsEnabledObject {
  96911. /**
  96912. * The position of the physics-enabled object
  96913. */
  96914. position: Vector3;
  96915. /**
  96916. * The rotation of the physics-enabled object
  96917. */
  96918. rotationQuaternion: Nullable<Quaternion>;
  96919. /**
  96920. * The scale of the physics-enabled object
  96921. */
  96922. scaling: Vector3;
  96923. /**
  96924. * The rotation of the physics-enabled object
  96925. */
  96926. rotation?: Vector3;
  96927. /**
  96928. * The parent of the physics-enabled object
  96929. */
  96930. parent?: any;
  96931. /**
  96932. * The bounding info of the physics-enabled object
  96933. * @returns The bounding info of the physics-enabled object
  96934. */
  96935. getBoundingInfo(): BoundingInfo;
  96936. /**
  96937. * Computes the world matrix
  96938. * @param force Specifies if the world matrix should be computed by force
  96939. * @returns A world matrix
  96940. */
  96941. computeWorldMatrix(force: boolean): Matrix;
  96942. /**
  96943. * Gets the world matrix
  96944. * @returns A world matrix
  96945. */
  96946. getWorldMatrix?(): Matrix;
  96947. /**
  96948. * Gets the child meshes
  96949. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  96950. * @returns An array of abstract meshes
  96951. */
  96952. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  96953. /**
  96954. * Gets the vertex data
  96955. * @param kind The type of vertex data
  96956. * @returns A nullable array of numbers, or a float32 array
  96957. */
  96958. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  96959. /**
  96960. * Gets the indices from the mesh
  96961. * @returns A nullable array of index arrays
  96962. */
  96963. getIndices?(): Nullable<IndicesArray>;
  96964. /**
  96965. * Gets the scene from the mesh
  96966. * @returns the indices array or null
  96967. */
  96968. getScene?(): Scene;
  96969. /**
  96970. * Gets the absolute position from the mesh
  96971. * @returns the absolute position
  96972. */
  96973. getAbsolutePosition(): Vector3;
  96974. /**
  96975. * Gets the absolute pivot point from the mesh
  96976. * @returns the absolute pivot point
  96977. */
  96978. getAbsolutePivotPoint(): Vector3;
  96979. /**
  96980. * Rotates the mesh
  96981. * @param axis The axis of rotation
  96982. * @param amount The amount of rotation
  96983. * @param space The space of the rotation
  96984. * @returns The rotation transform node
  96985. */
  96986. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  96987. /**
  96988. * Translates the mesh
  96989. * @param axis The axis of translation
  96990. * @param distance The distance of translation
  96991. * @param space The space of the translation
  96992. * @returns The transform node
  96993. */
  96994. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  96995. /**
  96996. * Sets the absolute position of the mesh
  96997. * @param absolutePosition The absolute position of the mesh
  96998. * @returns The transform node
  96999. */
  97000. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  97001. /**
  97002. * Gets the class name of the mesh
  97003. * @returns The class name
  97004. */
  97005. getClassName(): string;
  97006. }
  97007. /**
  97008. * Represents a physics imposter
  97009. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97010. */
  97011. export class PhysicsImpostor {
  97012. /**
  97013. * The physics-enabled object used as the physics imposter
  97014. */
  97015. object: IPhysicsEnabledObject;
  97016. /**
  97017. * The type of the physics imposter
  97018. */
  97019. type: number;
  97020. private _options;
  97021. private _scene?;
  97022. /**
  97023. * The default object size of the imposter
  97024. */
  97025. static DEFAULT_OBJECT_SIZE: Vector3;
  97026. /**
  97027. * The identity quaternion of the imposter
  97028. */
  97029. static IDENTITY_QUATERNION: Quaternion;
  97030. /** @hidden */
  97031. _pluginData: any;
  97032. private _physicsEngine;
  97033. private _physicsBody;
  97034. private _bodyUpdateRequired;
  97035. private _onBeforePhysicsStepCallbacks;
  97036. private _onAfterPhysicsStepCallbacks;
  97037. /** @hidden */
  97038. _onPhysicsCollideCallbacks: Array<{
  97039. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  97040. otherImpostors: Array<PhysicsImpostor>;
  97041. }>;
  97042. private _deltaPosition;
  97043. private _deltaRotation;
  97044. private _deltaRotationConjugated;
  97045. /** @hidden */
  97046. _isFromLine: boolean;
  97047. private _parent;
  97048. private _isDisposed;
  97049. private static _tmpVecs;
  97050. private static _tmpQuat;
  97051. /**
  97052. * Specifies if the physics imposter is disposed
  97053. */
  97054. get isDisposed(): boolean;
  97055. /**
  97056. * Gets the mass of the physics imposter
  97057. */
  97058. get mass(): number;
  97059. set mass(value: number);
  97060. /**
  97061. * Gets the coefficient of friction
  97062. */
  97063. get friction(): number;
  97064. /**
  97065. * Sets the coefficient of friction
  97066. */
  97067. set friction(value: number);
  97068. /**
  97069. * Gets the coefficient of restitution
  97070. */
  97071. get restitution(): number;
  97072. /**
  97073. * Sets the coefficient of restitution
  97074. */
  97075. set restitution(value: number);
  97076. /**
  97077. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  97078. */
  97079. get pressure(): number;
  97080. /**
  97081. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  97082. */
  97083. set pressure(value: number);
  97084. /**
  97085. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97086. */
  97087. get stiffness(): number;
  97088. /**
  97089. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97090. */
  97091. set stiffness(value: number);
  97092. /**
  97093. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97094. */
  97095. get velocityIterations(): number;
  97096. /**
  97097. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97098. */
  97099. set velocityIterations(value: number);
  97100. /**
  97101. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97102. */
  97103. get positionIterations(): number;
  97104. /**
  97105. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97106. */
  97107. set positionIterations(value: number);
  97108. /**
  97109. * The unique id of the physics imposter
  97110. * set by the physics engine when adding this impostor to the array
  97111. */
  97112. uniqueId: number;
  97113. /**
  97114. * @hidden
  97115. */
  97116. soft: boolean;
  97117. /**
  97118. * @hidden
  97119. */
  97120. segments: number;
  97121. private _joints;
  97122. /**
  97123. * Initializes the physics imposter
  97124. * @param object The physics-enabled object used as the physics imposter
  97125. * @param type The type of the physics imposter
  97126. * @param _options The options for the physics imposter
  97127. * @param _scene The Babylon scene
  97128. */
  97129. constructor(
  97130. /**
  97131. * The physics-enabled object used as the physics imposter
  97132. */
  97133. object: IPhysicsEnabledObject,
  97134. /**
  97135. * The type of the physics imposter
  97136. */
  97137. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  97138. /**
  97139. * This function will completly initialize this impostor.
  97140. * It will create a new body - but only if this mesh has no parent.
  97141. * If it has, this impostor will not be used other than to define the impostor
  97142. * of the child mesh.
  97143. * @hidden
  97144. */
  97145. _init(): void;
  97146. private _getPhysicsParent;
  97147. /**
  97148. * Should a new body be generated.
  97149. * @returns boolean specifying if body initialization is required
  97150. */
  97151. isBodyInitRequired(): boolean;
  97152. /**
  97153. * Sets the updated scaling
  97154. * @param updated Specifies if the scaling is updated
  97155. */
  97156. setScalingUpdated(): void;
  97157. /**
  97158. * Force a regeneration of this or the parent's impostor's body.
  97159. * Use under cautious - This will remove all joints already implemented.
  97160. */
  97161. forceUpdate(): void;
  97162. /**
  97163. * Gets the body that holds this impostor. Either its own, or its parent.
  97164. */
  97165. get physicsBody(): any;
  97166. /**
  97167. * Get the parent of the physics imposter
  97168. * @returns Physics imposter or null
  97169. */
  97170. get parent(): Nullable<PhysicsImpostor>;
  97171. /**
  97172. * Sets the parent of the physics imposter
  97173. */
  97174. set parent(value: Nullable<PhysicsImpostor>);
  97175. /**
  97176. * Set the physics body. Used mainly by the physics engine/plugin
  97177. */
  97178. set physicsBody(physicsBody: any);
  97179. /**
  97180. * Resets the update flags
  97181. */
  97182. resetUpdateFlags(): void;
  97183. /**
  97184. * Gets the object extend size
  97185. * @returns the object extend size
  97186. */
  97187. getObjectExtendSize(): Vector3;
  97188. /**
  97189. * Gets the object center
  97190. * @returns The object center
  97191. */
  97192. getObjectCenter(): Vector3;
  97193. /**
  97194. * Get a specific parameter from the options parameters
  97195. * @param paramName The object parameter name
  97196. * @returns The object parameter
  97197. */
  97198. getParam(paramName: string): any;
  97199. /**
  97200. * Sets a specific parameter in the options given to the physics plugin
  97201. * @param paramName The parameter name
  97202. * @param value The value of the parameter
  97203. */
  97204. setParam(paramName: string, value: number): void;
  97205. /**
  97206. * Specifically change the body's mass option. Won't recreate the physics body object
  97207. * @param mass The mass of the physics imposter
  97208. */
  97209. setMass(mass: number): void;
  97210. /**
  97211. * Gets the linear velocity
  97212. * @returns linear velocity or null
  97213. */
  97214. getLinearVelocity(): Nullable<Vector3>;
  97215. /**
  97216. * Sets the linear velocity
  97217. * @param velocity linear velocity or null
  97218. */
  97219. setLinearVelocity(velocity: Nullable<Vector3>): void;
  97220. /**
  97221. * Gets the angular velocity
  97222. * @returns angular velocity or null
  97223. */
  97224. getAngularVelocity(): Nullable<Vector3>;
  97225. /**
  97226. * Sets the angular velocity
  97227. * @param velocity The velocity or null
  97228. */
  97229. setAngularVelocity(velocity: Nullable<Vector3>): void;
  97230. /**
  97231. * Execute a function with the physics plugin native code
  97232. * Provide a function the will have two variables - the world object and the physics body object
  97233. * @param func The function to execute with the physics plugin native code
  97234. */
  97235. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  97236. /**
  97237. * Register a function that will be executed before the physics world is stepping forward
  97238. * @param func The function to execute before the physics world is stepped forward
  97239. */
  97240. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97241. /**
  97242. * Unregister a function that will be executed before the physics world is stepping forward
  97243. * @param func The function to execute before the physics world is stepped forward
  97244. */
  97245. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97246. /**
  97247. * Register a function that will be executed after the physics step
  97248. * @param func The function to execute after physics step
  97249. */
  97250. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97251. /**
  97252. * Unregisters a function that will be executed after the physics step
  97253. * @param func The function to execute after physics step
  97254. */
  97255. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97256. /**
  97257. * register a function that will be executed when this impostor collides against a different body
  97258. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  97259. * @param func Callback that is executed on collision
  97260. */
  97261. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  97262. /**
  97263. * Unregisters the physics imposter on contact
  97264. * @param collideAgainst The physics object to collide against
  97265. * @param func Callback to execute on collision
  97266. */
  97267. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  97268. private _tmpQuat;
  97269. private _tmpQuat2;
  97270. /**
  97271. * Get the parent rotation
  97272. * @returns The parent rotation
  97273. */
  97274. getParentsRotation(): Quaternion;
  97275. /**
  97276. * this function is executed by the physics engine.
  97277. */
  97278. beforeStep: () => void;
  97279. /**
  97280. * this function is executed by the physics engine
  97281. */
  97282. afterStep: () => void;
  97283. /**
  97284. * Legacy collision detection event support
  97285. */
  97286. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  97287. /**
  97288. * event and body object due to cannon's event-based architecture.
  97289. */
  97290. onCollide: (e: {
  97291. body: any;
  97292. }) => void;
  97293. /**
  97294. * Apply a force
  97295. * @param force The force to apply
  97296. * @param contactPoint The contact point for the force
  97297. * @returns The physics imposter
  97298. */
  97299. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97300. /**
  97301. * Apply an impulse
  97302. * @param force The impulse force
  97303. * @param contactPoint The contact point for the impulse force
  97304. * @returns The physics imposter
  97305. */
  97306. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97307. /**
  97308. * A help function to create a joint
  97309. * @param otherImpostor A physics imposter used to create a joint
  97310. * @param jointType The type of joint
  97311. * @param jointData The data for the joint
  97312. * @returns The physics imposter
  97313. */
  97314. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  97315. /**
  97316. * Add a joint to this impostor with a different impostor
  97317. * @param otherImpostor A physics imposter used to add a joint
  97318. * @param joint The joint to add
  97319. * @returns The physics imposter
  97320. */
  97321. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  97322. /**
  97323. * Add an anchor to a cloth impostor
  97324. * @param otherImpostor rigid impostor to anchor to
  97325. * @param width ratio across width from 0 to 1
  97326. * @param height ratio up height from 0 to 1
  97327. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  97328. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  97329. * @returns impostor the soft imposter
  97330. */
  97331. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97332. /**
  97333. * Add a hook to a rope impostor
  97334. * @param otherImpostor rigid impostor to anchor to
  97335. * @param length ratio across rope from 0 to 1
  97336. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  97337. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  97338. * @returns impostor the rope imposter
  97339. */
  97340. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97341. /**
  97342. * Will keep this body still, in a sleep mode.
  97343. * @returns the physics imposter
  97344. */
  97345. sleep(): PhysicsImpostor;
  97346. /**
  97347. * Wake the body up.
  97348. * @returns The physics imposter
  97349. */
  97350. wakeUp(): PhysicsImpostor;
  97351. /**
  97352. * Clones the physics imposter
  97353. * @param newObject The physics imposter clones to this physics-enabled object
  97354. * @returns A nullable physics imposter
  97355. */
  97356. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97357. /**
  97358. * Disposes the physics imposter
  97359. */
  97360. dispose(): void;
  97361. /**
  97362. * Sets the delta position
  97363. * @param position The delta position amount
  97364. */
  97365. setDeltaPosition(position: Vector3): void;
  97366. /**
  97367. * Sets the delta rotation
  97368. * @param rotation The delta rotation amount
  97369. */
  97370. setDeltaRotation(rotation: Quaternion): void;
  97371. /**
  97372. * Gets the box size of the physics imposter and stores the result in the input parameter
  97373. * @param result Stores the box size
  97374. * @returns The physics imposter
  97375. */
  97376. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  97377. /**
  97378. * Gets the radius of the physics imposter
  97379. * @returns Radius of the physics imposter
  97380. */
  97381. getRadius(): number;
  97382. /**
  97383. * Sync a bone with this impostor
  97384. * @param bone The bone to sync to the impostor.
  97385. * @param boneMesh The mesh that the bone is influencing.
  97386. * @param jointPivot The pivot of the joint / bone in local space.
  97387. * @param distToJoint Optional distance from the impostor to the joint.
  97388. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97389. */
  97390. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  97391. /**
  97392. * Sync impostor to a bone
  97393. * @param bone The bone that the impostor will be synced to.
  97394. * @param boneMesh The mesh that the bone is influencing.
  97395. * @param jointPivot The pivot of the joint / bone in local space.
  97396. * @param distToJoint Optional distance from the impostor to the joint.
  97397. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97398. * @param boneAxis Optional vector3 axis the bone is aligned with
  97399. */
  97400. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  97401. /**
  97402. * No-Imposter type
  97403. */
  97404. static NoImpostor: number;
  97405. /**
  97406. * Sphere-Imposter type
  97407. */
  97408. static SphereImpostor: number;
  97409. /**
  97410. * Box-Imposter type
  97411. */
  97412. static BoxImpostor: number;
  97413. /**
  97414. * Plane-Imposter type
  97415. */
  97416. static PlaneImpostor: number;
  97417. /**
  97418. * Mesh-imposter type
  97419. */
  97420. static MeshImpostor: number;
  97421. /**
  97422. * Capsule-Impostor type (Ammo.js plugin only)
  97423. */
  97424. static CapsuleImpostor: number;
  97425. /**
  97426. * Cylinder-Imposter type
  97427. */
  97428. static CylinderImpostor: number;
  97429. /**
  97430. * Particle-Imposter type
  97431. */
  97432. static ParticleImpostor: number;
  97433. /**
  97434. * Heightmap-Imposter type
  97435. */
  97436. static HeightmapImpostor: number;
  97437. /**
  97438. * ConvexHull-Impostor type (Ammo.js plugin only)
  97439. */
  97440. static ConvexHullImpostor: number;
  97441. /**
  97442. * Custom-Imposter type (Ammo.js plugin only)
  97443. */
  97444. static CustomImpostor: number;
  97445. /**
  97446. * Rope-Imposter type
  97447. */
  97448. static RopeImpostor: number;
  97449. /**
  97450. * Cloth-Imposter type
  97451. */
  97452. static ClothImpostor: number;
  97453. /**
  97454. * Softbody-Imposter type
  97455. */
  97456. static SoftbodyImpostor: number;
  97457. }
  97458. }
  97459. declare module BABYLON {
  97460. /**
  97461. * @hidden
  97462. **/
  97463. export class _CreationDataStorage {
  97464. closePath?: boolean;
  97465. closeArray?: boolean;
  97466. idx: number[];
  97467. dashSize: number;
  97468. gapSize: number;
  97469. path3D: Path3D;
  97470. pathArray: Vector3[][];
  97471. arc: number;
  97472. radius: number;
  97473. cap: number;
  97474. tessellation: number;
  97475. }
  97476. /**
  97477. * @hidden
  97478. **/
  97479. class _InstanceDataStorage {
  97480. visibleInstances: any;
  97481. batchCache: _InstancesBatch;
  97482. instancesBufferSize: number;
  97483. instancesBuffer: Nullable<Buffer>;
  97484. instancesData: Float32Array;
  97485. overridenInstanceCount: number;
  97486. isFrozen: boolean;
  97487. previousBatch: Nullable<_InstancesBatch>;
  97488. hardwareInstancedRendering: boolean;
  97489. sideOrientation: number;
  97490. manualUpdate: boolean;
  97491. }
  97492. /**
  97493. * @hidden
  97494. **/
  97495. export class _InstancesBatch {
  97496. mustReturn: boolean;
  97497. visibleInstances: Nullable<InstancedMesh[]>[];
  97498. renderSelf: boolean[];
  97499. hardwareInstancedRendering: boolean[];
  97500. }
  97501. /**
  97502. * Class used to represent renderable models
  97503. */
  97504. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  97505. /**
  97506. * Mesh side orientation : usually the external or front surface
  97507. */
  97508. static readonly FRONTSIDE: number;
  97509. /**
  97510. * Mesh side orientation : usually the internal or back surface
  97511. */
  97512. static readonly BACKSIDE: number;
  97513. /**
  97514. * Mesh side orientation : both internal and external or front and back surfaces
  97515. */
  97516. static readonly DOUBLESIDE: number;
  97517. /**
  97518. * Mesh side orientation : by default, `FRONTSIDE`
  97519. */
  97520. static readonly DEFAULTSIDE: number;
  97521. /**
  97522. * Mesh cap setting : no cap
  97523. */
  97524. static readonly NO_CAP: number;
  97525. /**
  97526. * Mesh cap setting : one cap at the beginning of the mesh
  97527. */
  97528. static readonly CAP_START: number;
  97529. /**
  97530. * Mesh cap setting : one cap at the end of the mesh
  97531. */
  97532. static readonly CAP_END: number;
  97533. /**
  97534. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  97535. */
  97536. static readonly CAP_ALL: number;
  97537. /**
  97538. * Mesh pattern setting : no flip or rotate
  97539. */
  97540. static readonly NO_FLIP: number;
  97541. /**
  97542. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  97543. */
  97544. static readonly FLIP_TILE: number;
  97545. /**
  97546. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  97547. */
  97548. static readonly ROTATE_TILE: number;
  97549. /**
  97550. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  97551. */
  97552. static readonly FLIP_ROW: number;
  97553. /**
  97554. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  97555. */
  97556. static readonly ROTATE_ROW: number;
  97557. /**
  97558. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  97559. */
  97560. static readonly FLIP_N_ROTATE_TILE: number;
  97561. /**
  97562. * Mesh pattern setting : rotate pattern and rotate
  97563. */
  97564. static readonly FLIP_N_ROTATE_ROW: number;
  97565. /**
  97566. * Mesh tile positioning : part tiles same on left/right or top/bottom
  97567. */
  97568. static readonly CENTER: number;
  97569. /**
  97570. * Mesh tile positioning : part tiles on left
  97571. */
  97572. static readonly LEFT: number;
  97573. /**
  97574. * Mesh tile positioning : part tiles on right
  97575. */
  97576. static readonly RIGHT: number;
  97577. /**
  97578. * Mesh tile positioning : part tiles on top
  97579. */
  97580. static readonly TOP: number;
  97581. /**
  97582. * Mesh tile positioning : part tiles on bottom
  97583. */
  97584. static readonly BOTTOM: number;
  97585. /**
  97586. * Gets the default side orientation.
  97587. * @param orientation the orientation to value to attempt to get
  97588. * @returns the default orientation
  97589. * @hidden
  97590. */
  97591. static _GetDefaultSideOrientation(orientation?: number): number;
  97592. private _internalMeshDataInfo;
  97593. /**
  97594. * An event triggered before rendering the mesh
  97595. */
  97596. get onBeforeRenderObservable(): Observable<Mesh>;
  97597. /**
  97598. * An event triggered before binding the mesh
  97599. */
  97600. get onBeforeBindObservable(): Observable<Mesh>;
  97601. /**
  97602. * An event triggered after rendering the mesh
  97603. */
  97604. get onAfterRenderObservable(): Observable<Mesh>;
  97605. /**
  97606. * An event triggered before drawing the mesh
  97607. */
  97608. get onBeforeDrawObservable(): Observable<Mesh>;
  97609. private _onBeforeDrawObserver;
  97610. /**
  97611. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  97612. */
  97613. set onBeforeDraw(callback: () => void);
  97614. get hasInstances(): boolean;
  97615. /**
  97616. * Gets the delay loading state of the mesh (when delay loading is turned on)
  97617. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  97618. */
  97619. delayLoadState: number;
  97620. /**
  97621. * Gets the list of instances created from this mesh
  97622. * it is not supposed to be modified manually.
  97623. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  97624. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97625. */
  97626. instances: InstancedMesh[];
  97627. /**
  97628. * Gets the file containing delay loading data for this mesh
  97629. */
  97630. delayLoadingFile: string;
  97631. /** @hidden */
  97632. _binaryInfo: any;
  97633. /**
  97634. * User defined function used to change how LOD level selection is done
  97635. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97636. */
  97637. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  97638. /**
  97639. * Gets or sets the morph target manager
  97640. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97641. */
  97642. get morphTargetManager(): Nullable<MorphTargetManager>;
  97643. set morphTargetManager(value: Nullable<MorphTargetManager>);
  97644. /** @hidden */
  97645. _creationDataStorage: Nullable<_CreationDataStorage>;
  97646. /** @hidden */
  97647. _geometry: Nullable<Geometry>;
  97648. /** @hidden */
  97649. _delayInfo: Array<string>;
  97650. /** @hidden */
  97651. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  97652. /** @hidden */
  97653. _instanceDataStorage: _InstanceDataStorage;
  97654. private _effectiveMaterial;
  97655. /** @hidden */
  97656. _shouldGenerateFlatShading: boolean;
  97657. /** @hidden */
  97658. _originalBuilderSideOrientation: number;
  97659. /**
  97660. * Use this property to change the original side orientation defined at construction time
  97661. */
  97662. overrideMaterialSideOrientation: Nullable<number>;
  97663. /**
  97664. * Gets the source mesh (the one used to clone this one from)
  97665. */
  97666. get source(): Nullable<Mesh>;
  97667. /**
  97668. * Gets or sets a boolean indicating that this mesh does not use index buffer
  97669. */
  97670. get isUnIndexed(): boolean;
  97671. set isUnIndexed(value: boolean);
  97672. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  97673. get worldMatrixInstancedBuffer(): Float32Array;
  97674. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  97675. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  97676. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  97677. /**
  97678. * @constructor
  97679. * @param name The value used by scene.getMeshByName() to do a lookup.
  97680. * @param scene The scene to add this mesh to.
  97681. * @param parent The parent of this mesh, if it has one
  97682. * @param source An optional Mesh from which geometry is shared, cloned.
  97683. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97684. * When false, achieved by calling a clone(), also passing False.
  97685. * This will make creation of children, recursive.
  97686. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  97687. */
  97688. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  97689. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  97690. doNotInstantiate: boolean;
  97691. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  97692. /**
  97693. * Gets the class name
  97694. * @returns the string "Mesh".
  97695. */
  97696. getClassName(): string;
  97697. /** @hidden */
  97698. get _isMesh(): boolean;
  97699. /**
  97700. * Returns a description of this mesh
  97701. * @param fullDetails define if full details about this mesh must be used
  97702. * @returns a descriptive string representing this mesh
  97703. */
  97704. toString(fullDetails?: boolean): string;
  97705. /** @hidden */
  97706. _unBindEffect(): void;
  97707. /**
  97708. * Gets a boolean indicating if this mesh has LOD
  97709. */
  97710. get hasLODLevels(): boolean;
  97711. /**
  97712. * Gets the list of MeshLODLevel associated with the current mesh
  97713. * @returns an array of MeshLODLevel
  97714. */
  97715. getLODLevels(): MeshLODLevel[];
  97716. private _sortLODLevels;
  97717. /**
  97718. * Add a mesh as LOD level triggered at the given distance.
  97719. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97720. * @param distance The distance from the center of the object to show this level
  97721. * @param mesh The mesh to be added as LOD level (can be null)
  97722. * @return This mesh (for chaining)
  97723. */
  97724. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  97725. /**
  97726. * Returns the LOD level mesh at the passed distance or null if not found.
  97727. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97728. * @param distance The distance from the center of the object to show this level
  97729. * @returns a Mesh or `null`
  97730. */
  97731. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  97732. /**
  97733. * Remove a mesh from the LOD array
  97734. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97735. * @param mesh defines the mesh to be removed
  97736. * @return This mesh (for chaining)
  97737. */
  97738. removeLODLevel(mesh: Mesh): Mesh;
  97739. /**
  97740. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  97741. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97742. * @param camera defines the camera to use to compute distance
  97743. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  97744. * @return This mesh (for chaining)
  97745. */
  97746. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  97747. /**
  97748. * Gets the mesh internal Geometry object
  97749. */
  97750. get geometry(): Nullable<Geometry>;
  97751. /**
  97752. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  97753. * @returns the total number of vertices
  97754. */
  97755. getTotalVertices(): number;
  97756. /**
  97757. * Returns the content of an associated vertex buffer
  97758. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97759. * - VertexBuffer.PositionKind
  97760. * - VertexBuffer.UVKind
  97761. * - VertexBuffer.UV2Kind
  97762. * - VertexBuffer.UV3Kind
  97763. * - VertexBuffer.UV4Kind
  97764. * - VertexBuffer.UV5Kind
  97765. * - VertexBuffer.UV6Kind
  97766. * - VertexBuffer.ColorKind
  97767. * - VertexBuffer.MatricesIndicesKind
  97768. * - VertexBuffer.MatricesIndicesExtraKind
  97769. * - VertexBuffer.MatricesWeightsKind
  97770. * - VertexBuffer.MatricesWeightsExtraKind
  97771. * @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
  97772. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  97773. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  97774. */
  97775. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97776. /**
  97777. * Returns the mesh VertexBuffer object from the requested `kind`
  97778. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97779. * - VertexBuffer.PositionKind
  97780. * - VertexBuffer.NormalKind
  97781. * - VertexBuffer.UVKind
  97782. * - VertexBuffer.UV2Kind
  97783. * - VertexBuffer.UV3Kind
  97784. * - VertexBuffer.UV4Kind
  97785. * - VertexBuffer.UV5Kind
  97786. * - VertexBuffer.UV6Kind
  97787. * - VertexBuffer.ColorKind
  97788. * - VertexBuffer.MatricesIndicesKind
  97789. * - VertexBuffer.MatricesIndicesExtraKind
  97790. * - VertexBuffer.MatricesWeightsKind
  97791. * - VertexBuffer.MatricesWeightsExtraKind
  97792. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  97793. */
  97794. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  97795. /**
  97796. * Tests if a specific vertex buffer is associated with this mesh
  97797. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97798. * - VertexBuffer.PositionKind
  97799. * - VertexBuffer.NormalKind
  97800. * - VertexBuffer.UVKind
  97801. * - VertexBuffer.UV2Kind
  97802. * - VertexBuffer.UV3Kind
  97803. * - VertexBuffer.UV4Kind
  97804. * - VertexBuffer.UV5Kind
  97805. * - VertexBuffer.UV6Kind
  97806. * - VertexBuffer.ColorKind
  97807. * - VertexBuffer.MatricesIndicesKind
  97808. * - VertexBuffer.MatricesIndicesExtraKind
  97809. * - VertexBuffer.MatricesWeightsKind
  97810. * - VertexBuffer.MatricesWeightsExtraKind
  97811. * @returns a boolean
  97812. */
  97813. isVerticesDataPresent(kind: string): boolean;
  97814. /**
  97815. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  97816. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97817. * - VertexBuffer.PositionKind
  97818. * - VertexBuffer.UVKind
  97819. * - VertexBuffer.UV2Kind
  97820. * - VertexBuffer.UV3Kind
  97821. * - VertexBuffer.UV4Kind
  97822. * - VertexBuffer.UV5Kind
  97823. * - VertexBuffer.UV6Kind
  97824. * - VertexBuffer.ColorKind
  97825. * - VertexBuffer.MatricesIndicesKind
  97826. * - VertexBuffer.MatricesIndicesExtraKind
  97827. * - VertexBuffer.MatricesWeightsKind
  97828. * - VertexBuffer.MatricesWeightsExtraKind
  97829. * @returns a boolean
  97830. */
  97831. isVertexBufferUpdatable(kind: string): boolean;
  97832. /**
  97833. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  97834. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97835. * - VertexBuffer.PositionKind
  97836. * - VertexBuffer.NormalKind
  97837. * - VertexBuffer.UVKind
  97838. * - VertexBuffer.UV2Kind
  97839. * - VertexBuffer.UV3Kind
  97840. * - VertexBuffer.UV4Kind
  97841. * - VertexBuffer.UV5Kind
  97842. * - VertexBuffer.UV6Kind
  97843. * - VertexBuffer.ColorKind
  97844. * - VertexBuffer.MatricesIndicesKind
  97845. * - VertexBuffer.MatricesIndicesExtraKind
  97846. * - VertexBuffer.MatricesWeightsKind
  97847. * - VertexBuffer.MatricesWeightsExtraKind
  97848. * @returns an array of strings
  97849. */
  97850. getVerticesDataKinds(): string[];
  97851. /**
  97852. * Returns a positive integer : the total number of indices in this mesh geometry.
  97853. * @returns the numner of indices or zero if the mesh has no geometry.
  97854. */
  97855. getTotalIndices(): number;
  97856. /**
  97857. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97858. * @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.
  97859. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  97860. * @returns the indices array or an empty array if the mesh has no geometry
  97861. */
  97862. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  97863. get isBlocked(): boolean;
  97864. /**
  97865. * Determine if the current mesh is ready to be rendered
  97866. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97867. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  97868. * @returns true if all associated assets are ready (material, textures, shaders)
  97869. */
  97870. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  97871. /**
  97872. * 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.
  97873. */
  97874. get areNormalsFrozen(): boolean;
  97875. /**
  97876. * 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.
  97877. * @returns the current mesh
  97878. */
  97879. freezeNormals(): Mesh;
  97880. /**
  97881. * 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
  97882. * @returns the current mesh
  97883. */
  97884. unfreezeNormals(): Mesh;
  97885. /**
  97886. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  97887. */
  97888. set overridenInstanceCount(count: number);
  97889. /** @hidden */
  97890. _preActivate(): Mesh;
  97891. /** @hidden */
  97892. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97893. /** @hidden */
  97894. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  97895. /**
  97896. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97897. * This means the mesh underlying bounding box and sphere are recomputed.
  97898. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97899. * @returns the current mesh
  97900. */
  97901. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  97902. /** @hidden */
  97903. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  97904. /**
  97905. * This function will subdivide the mesh into multiple submeshes
  97906. * @param count defines the expected number of submeshes
  97907. */
  97908. subdivide(count: number): void;
  97909. /**
  97910. * Copy a FloatArray into a specific associated vertex buffer
  97911. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97912. * - VertexBuffer.PositionKind
  97913. * - VertexBuffer.UVKind
  97914. * - VertexBuffer.UV2Kind
  97915. * - VertexBuffer.UV3Kind
  97916. * - VertexBuffer.UV4Kind
  97917. * - VertexBuffer.UV5Kind
  97918. * - VertexBuffer.UV6Kind
  97919. * - VertexBuffer.ColorKind
  97920. * - VertexBuffer.MatricesIndicesKind
  97921. * - VertexBuffer.MatricesIndicesExtraKind
  97922. * - VertexBuffer.MatricesWeightsKind
  97923. * - VertexBuffer.MatricesWeightsExtraKind
  97924. * @param data defines the data source
  97925. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97926. * @param stride defines the data stride size (can be null)
  97927. * @returns the current mesh
  97928. */
  97929. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97930. /**
  97931. * Delete a vertex buffer associated with this mesh
  97932. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  97933. * - VertexBuffer.PositionKind
  97934. * - VertexBuffer.UVKind
  97935. * - VertexBuffer.UV2Kind
  97936. * - VertexBuffer.UV3Kind
  97937. * - VertexBuffer.UV4Kind
  97938. * - VertexBuffer.UV5Kind
  97939. * - VertexBuffer.UV6Kind
  97940. * - VertexBuffer.ColorKind
  97941. * - VertexBuffer.MatricesIndicesKind
  97942. * - VertexBuffer.MatricesIndicesExtraKind
  97943. * - VertexBuffer.MatricesWeightsKind
  97944. * - VertexBuffer.MatricesWeightsExtraKind
  97945. */
  97946. removeVerticesData(kind: string): void;
  97947. /**
  97948. * Flags an associated vertex buffer as updatable
  97949. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  97950. * - VertexBuffer.PositionKind
  97951. * - VertexBuffer.UVKind
  97952. * - VertexBuffer.UV2Kind
  97953. * - VertexBuffer.UV3Kind
  97954. * - VertexBuffer.UV4Kind
  97955. * - VertexBuffer.UV5Kind
  97956. * - VertexBuffer.UV6Kind
  97957. * - VertexBuffer.ColorKind
  97958. * - VertexBuffer.MatricesIndicesKind
  97959. * - VertexBuffer.MatricesIndicesExtraKind
  97960. * - VertexBuffer.MatricesWeightsKind
  97961. * - VertexBuffer.MatricesWeightsExtraKind
  97962. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97963. */
  97964. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  97965. /**
  97966. * Sets the mesh global Vertex Buffer
  97967. * @param buffer defines the buffer to use
  97968. * @returns the current mesh
  97969. */
  97970. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  97971. /**
  97972. * Update a specific associated vertex buffer
  97973. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97974. * - VertexBuffer.PositionKind
  97975. * - VertexBuffer.UVKind
  97976. * - VertexBuffer.UV2Kind
  97977. * - VertexBuffer.UV3Kind
  97978. * - VertexBuffer.UV4Kind
  97979. * - VertexBuffer.UV5Kind
  97980. * - VertexBuffer.UV6Kind
  97981. * - VertexBuffer.ColorKind
  97982. * - VertexBuffer.MatricesIndicesKind
  97983. * - VertexBuffer.MatricesIndicesExtraKind
  97984. * - VertexBuffer.MatricesWeightsKind
  97985. * - VertexBuffer.MatricesWeightsExtraKind
  97986. * @param data defines the data source
  97987. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  97988. * @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)
  97989. * @returns the current mesh
  97990. */
  97991. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  97992. /**
  97993. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  97994. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  97995. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  97996. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  97997. * @returns the current mesh
  97998. */
  97999. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  98000. /**
  98001. * Creates a un-shared specific occurence of the geometry for the mesh.
  98002. * @returns the current mesh
  98003. */
  98004. makeGeometryUnique(): Mesh;
  98005. /**
  98006. * Set the index buffer of this mesh
  98007. * @param indices defines the source data
  98008. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  98009. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  98010. * @returns the current mesh
  98011. */
  98012. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  98013. /**
  98014. * Update the current index buffer
  98015. * @param indices defines the source data
  98016. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98017. * @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)
  98018. * @returns the current mesh
  98019. */
  98020. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98021. /**
  98022. * Invert the geometry to move from a right handed system to a left handed one.
  98023. * @returns the current mesh
  98024. */
  98025. toLeftHanded(): Mesh;
  98026. /** @hidden */
  98027. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  98028. /** @hidden */
  98029. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  98030. /**
  98031. * Registers for this mesh a javascript function called just before the rendering process
  98032. * @param func defines the function to call before rendering this mesh
  98033. * @returns the current mesh
  98034. */
  98035. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98036. /**
  98037. * Disposes a previously registered javascript function called before the rendering
  98038. * @param func defines the function to remove
  98039. * @returns the current mesh
  98040. */
  98041. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98042. /**
  98043. * Registers for this mesh a javascript function called just after the rendering is complete
  98044. * @param func defines the function to call after rendering this mesh
  98045. * @returns the current mesh
  98046. */
  98047. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98048. /**
  98049. * Disposes a previously registered javascript function called after the rendering.
  98050. * @param func defines the function to remove
  98051. * @returns the current mesh
  98052. */
  98053. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98054. /** @hidden */
  98055. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  98056. /** @hidden */
  98057. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  98058. /** @hidden */
  98059. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  98060. /** @hidden */
  98061. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  98062. /** @hidden */
  98063. _rebuild(): void;
  98064. /** @hidden */
  98065. _freeze(): void;
  98066. /** @hidden */
  98067. _unFreeze(): void;
  98068. /**
  98069. * 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
  98070. * @param subMesh defines the subMesh to render
  98071. * @param enableAlphaMode defines if alpha mode can be changed
  98072. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  98073. * @returns the current mesh
  98074. */
  98075. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  98076. private _onBeforeDraw;
  98077. /**
  98078. * Renormalize the mesh and patch it up if there are no weights
  98079. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  98080. * However in the case of zero weights then we set just a single influence to 1.
  98081. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  98082. */
  98083. cleanMatrixWeights(): void;
  98084. private normalizeSkinFourWeights;
  98085. private normalizeSkinWeightsAndExtra;
  98086. /**
  98087. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  98088. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  98089. * the user know there was an issue with importing the mesh
  98090. * @returns a validation object with skinned, valid and report string
  98091. */
  98092. validateSkinning(): {
  98093. skinned: boolean;
  98094. valid: boolean;
  98095. report: string;
  98096. };
  98097. /** @hidden */
  98098. _checkDelayState(): Mesh;
  98099. private _queueLoad;
  98100. /**
  98101. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98102. * A mesh is in the frustum if its bounding box intersects the frustum
  98103. * @param frustumPlanes defines the frustum to test
  98104. * @returns true if the mesh is in the frustum planes
  98105. */
  98106. isInFrustum(frustumPlanes: Plane[]): boolean;
  98107. /**
  98108. * Sets the mesh material by the material or multiMaterial `id` property
  98109. * @param id is a string identifying the material or the multiMaterial
  98110. * @returns the current mesh
  98111. */
  98112. setMaterialByID(id: string): Mesh;
  98113. /**
  98114. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  98115. * @returns an array of IAnimatable
  98116. */
  98117. getAnimatables(): IAnimatable[];
  98118. /**
  98119. * Modifies the mesh geometry according to the passed transformation matrix.
  98120. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  98121. * The mesh normals are modified using the same transformation.
  98122. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98123. * @param transform defines the transform matrix to use
  98124. * @see http://doc.babylonjs.com/resources/baking_transformations
  98125. * @returns the current mesh
  98126. */
  98127. bakeTransformIntoVertices(transform: Matrix): Mesh;
  98128. /**
  98129. * Modifies the mesh geometry according to its own current World Matrix.
  98130. * The mesh World Matrix is then reset.
  98131. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  98132. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98133. * @see http://doc.babylonjs.com/resources/baking_transformations
  98134. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  98135. * @returns the current mesh
  98136. */
  98137. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  98138. /** @hidden */
  98139. get _positions(): Nullable<Vector3[]>;
  98140. /** @hidden */
  98141. _resetPointsArrayCache(): Mesh;
  98142. /** @hidden */
  98143. _generatePointsArray(): boolean;
  98144. /**
  98145. * Returns a new Mesh object generated from the current mesh properties.
  98146. * This method must not get confused with createInstance()
  98147. * @param name is a string, the name given to the new mesh
  98148. * @param newParent can be any Node object (default `null`)
  98149. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  98150. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  98151. * @returns a new mesh
  98152. */
  98153. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  98154. /**
  98155. * Releases resources associated with this mesh.
  98156. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98157. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98158. */
  98159. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98160. /** @hidden */
  98161. _disposeInstanceSpecificData(): void;
  98162. /**
  98163. * Modifies the mesh geometry according to a displacement map.
  98164. * 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.
  98165. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98166. * @param url is a string, the URL from the image file is to be downloaded.
  98167. * @param minHeight is the lower limit of the displacement.
  98168. * @param maxHeight is the upper limit of the displacement.
  98169. * @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.
  98170. * @param uvOffset is an optional vector2 used to offset UV.
  98171. * @param uvScale is an optional vector2 used to scale UV.
  98172. * @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.
  98173. * @returns the Mesh.
  98174. */
  98175. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98176. /**
  98177. * Modifies the mesh geometry according to a displacementMap buffer.
  98178. * 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.
  98179. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98180. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  98181. * @param heightMapWidth is the width of the buffer image.
  98182. * @param heightMapHeight is the height of the buffer image.
  98183. * @param minHeight is the lower limit of the displacement.
  98184. * @param maxHeight is the upper limit of the displacement.
  98185. * @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.
  98186. * @param uvOffset is an optional vector2 used to offset UV.
  98187. * @param uvScale is an optional vector2 used to scale UV.
  98188. * @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.
  98189. * @returns the Mesh.
  98190. */
  98191. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98192. /**
  98193. * Modify the mesh to get a flat shading rendering.
  98194. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  98195. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  98196. * @returns current mesh
  98197. */
  98198. convertToFlatShadedMesh(): Mesh;
  98199. /**
  98200. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  98201. * In other words, more vertices, no more indices and a single bigger VBO.
  98202. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  98203. * @returns current mesh
  98204. */
  98205. convertToUnIndexedMesh(): Mesh;
  98206. /**
  98207. * Inverses facet orientations.
  98208. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98209. * @param flipNormals will also inverts the normals
  98210. * @returns current mesh
  98211. */
  98212. flipFaces(flipNormals?: boolean): Mesh;
  98213. /**
  98214. * Increase the number of facets and hence vertices in a mesh
  98215. * Vertex normals are interpolated from existing vertex normals
  98216. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98217. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  98218. */
  98219. increaseVertices(numberPerEdge: number): void;
  98220. /**
  98221. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  98222. * This will undo any application of covertToFlatShadedMesh
  98223. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98224. */
  98225. forceSharedVertices(): void;
  98226. /** @hidden */
  98227. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  98228. /** @hidden */
  98229. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  98230. /**
  98231. * Creates a new InstancedMesh object from the mesh model.
  98232. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98233. * @param name defines the name of the new instance
  98234. * @returns a new InstancedMesh
  98235. */
  98236. createInstance(name: string): InstancedMesh;
  98237. /**
  98238. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  98239. * After this call, all the mesh instances have the same submeshes than the current mesh.
  98240. * @returns the current mesh
  98241. */
  98242. synchronizeInstances(): Mesh;
  98243. /**
  98244. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  98245. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  98246. * This should be used together with the simplification to avoid disappearing triangles.
  98247. * @param successCallback an optional success callback to be called after the optimization finished.
  98248. * @returns the current mesh
  98249. */
  98250. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  98251. /**
  98252. * Serialize current mesh
  98253. * @param serializationObject defines the object which will receive the serialization data
  98254. */
  98255. serialize(serializationObject: any): void;
  98256. /** @hidden */
  98257. _syncGeometryWithMorphTargetManager(): void;
  98258. /** @hidden */
  98259. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  98260. /**
  98261. * Returns a new Mesh object parsed from the source provided.
  98262. * @param parsedMesh is the source
  98263. * @param scene defines the hosting scene
  98264. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  98265. * @returns a new Mesh
  98266. */
  98267. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  98268. /**
  98269. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  98270. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98271. * @param name defines the name of the mesh to create
  98272. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  98273. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  98274. * @param closePath creates a seam between the first and the last points of each path of the path array
  98275. * @param offset is taken in account only if the `pathArray` is containing a single path
  98276. * @param scene defines the hosting scene
  98277. * @param updatable defines if the mesh must be flagged as updatable
  98278. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98279. * @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)
  98280. * @returns a new Mesh
  98281. */
  98282. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98283. /**
  98284. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  98285. * @param name defines the name of the mesh to create
  98286. * @param radius sets the radius size (float) of the polygon (default 0.5)
  98287. * @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
  98288. * @param scene defines the hosting scene
  98289. * @param updatable defines if the mesh must be flagged as updatable
  98290. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98291. * @returns a new Mesh
  98292. */
  98293. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98294. /**
  98295. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  98296. * @param name defines the name of the mesh to create
  98297. * @param size sets the size (float) of each box side (default 1)
  98298. * @param scene defines the hosting scene
  98299. * @param updatable defines if the mesh must be flagged as updatable
  98300. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98301. * @returns a new Mesh
  98302. */
  98303. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98304. /**
  98305. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  98306. * @param name defines the name of the mesh to create
  98307. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98308. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98309. * @param scene defines the hosting scene
  98310. * @param updatable defines if the mesh must be flagged as updatable
  98311. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98312. * @returns a new Mesh
  98313. */
  98314. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98315. /**
  98316. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  98317. * @param name defines the name of the mesh to create
  98318. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98319. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98320. * @param scene defines the hosting scene
  98321. * @returns a new Mesh
  98322. */
  98323. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  98324. /**
  98325. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  98326. * @param name defines the name of the mesh to create
  98327. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  98328. * @param diameterTop set the top cap diameter (floats, default 1)
  98329. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  98330. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  98331. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  98332. * @param scene defines the hosting scene
  98333. * @param updatable defines if the mesh must be flagged as updatable
  98334. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98335. * @returns a new Mesh
  98336. */
  98337. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  98338. /**
  98339. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  98340. * @param name defines the name of the mesh to create
  98341. * @param diameter sets the diameter size (float) of the torus (default 1)
  98342. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  98343. * @param tessellation sets the number of torus sides (postive integer, default 16)
  98344. * @param scene defines the hosting scene
  98345. * @param updatable defines if the mesh must be flagged as updatable
  98346. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98347. * @returns a new Mesh
  98348. */
  98349. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98350. /**
  98351. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  98352. * @param name defines the name of the mesh to create
  98353. * @param radius sets the global radius size (float) of the torus knot (default 2)
  98354. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  98355. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  98356. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  98357. * @param p the number of windings on X axis (positive integers, default 2)
  98358. * @param q the number of windings on Y axis (positive integers, default 3)
  98359. * @param scene defines the hosting scene
  98360. * @param updatable defines if the mesh must be flagged as updatable
  98361. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98362. * @returns a new Mesh
  98363. */
  98364. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98365. /**
  98366. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  98367. * @param name defines the name of the mesh to create
  98368. * @param points is an array successive Vector3
  98369. * @param scene defines the hosting scene
  98370. * @param updatable defines if the mesh must be flagged as updatable
  98371. * @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).
  98372. * @returns a new Mesh
  98373. */
  98374. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  98375. /**
  98376. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  98377. * @param name defines the name of the mesh to create
  98378. * @param points is an array successive Vector3
  98379. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  98380. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98381. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  98382. * @param scene defines the hosting scene
  98383. * @param updatable defines if the mesh must be flagged as updatable
  98384. * @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)
  98385. * @returns a new Mesh
  98386. */
  98387. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  98388. /**
  98389. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  98390. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  98391. * 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.
  98392. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98393. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98394. * Remember you can only change the shape positions, not their number when updating a polygon.
  98395. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  98396. * @param name defines the name of the mesh to create
  98397. * @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
  98398. * @param scene defines the hosting scene
  98399. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98400. * @param updatable defines if the mesh must be flagged as updatable
  98401. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98402. * @param earcutInjection can be used to inject your own earcut reference
  98403. * @returns a new Mesh
  98404. */
  98405. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98406. /**
  98407. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  98408. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  98409. * @param name defines the name of the mesh to create
  98410. * @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
  98411. * @param depth defines the height of extrusion
  98412. * @param scene defines the hosting scene
  98413. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98414. * @param updatable defines if the mesh must be flagged as updatable
  98415. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98416. * @param earcutInjection can be used to inject your own earcut reference
  98417. * @returns a new Mesh
  98418. */
  98419. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98420. /**
  98421. * Creates an extruded shape mesh.
  98422. * 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
  98423. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98424. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98425. * @param name defines the name of the mesh to create
  98426. * @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
  98427. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98428. * @param scale is the value to scale the shape
  98429. * @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
  98430. * @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
  98431. * @param scene defines the hosting scene
  98432. * @param updatable defines if the mesh must be flagged as updatable
  98433. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98434. * @param 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)
  98435. * @returns a new Mesh
  98436. */
  98437. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98438. /**
  98439. * Creates an custom extruded shape mesh.
  98440. * The custom extrusion is a parametric shape.
  98441. * It has no predefined shape. Its final shape will depend on the input parameters.
  98442. * Please consider using the same method from the MeshBuilder class instead
  98443. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98444. * @param name defines the name of the mesh to create
  98445. * @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
  98446. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98447. * @param scaleFunction is a custom Javascript function called on each path point
  98448. * @param rotationFunction is a custom Javascript function called on each path point
  98449. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  98450. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  98451. * @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
  98452. * @param scene defines the hosting scene
  98453. * @param updatable defines if the mesh must be flagged as updatable
  98454. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98455. * @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)
  98456. * @returns a new Mesh
  98457. */
  98458. 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;
  98459. /**
  98460. * Creates lathe mesh.
  98461. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  98462. * Please consider using the same method from the MeshBuilder class instead
  98463. * @param name defines the name of the mesh to create
  98464. * @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
  98465. * @param radius is the radius value of the lathe
  98466. * @param tessellation is the side number of the lathe.
  98467. * @param scene defines the hosting scene
  98468. * @param updatable defines if the mesh must be flagged as updatable
  98469. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98470. * @returns a new Mesh
  98471. */
  98472. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98473. /**
  98474. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  98475. * @param name defines the name of the mesh to create
  98476. * @param size sets the size (float) of both sides of the plane at once (default 1)
  98477. * @param scene defines the hosting scene
  98478. * @param updatable defines if the mesh must be flagged as updatable
  98479. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98480. * @returns a new Mesh
  98481. */
  98482. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98483. /**
  98484. * Creates a ground mesh.
  98485. * Please consider using the same method from the MeshBuilder class instead
  98486. * @param name defines the name of the mesh to create
  98487. * @param width set the width of the ground
  98488. * @param height set the height of the ground
  98489. * @param subdivisions sets the number of subdivisions per side
  98490. * @param scene defines the hosting scene
  98491. * @param updatable defines if the mesh must be flagged as updatable
  98492. * @returns a new Mesh
  98493. */
  98494. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  98495. /**
  98496. * Creates a tiled ground mesh.
  98497. * Please consider using the same method from the MeshBuilder class instead
  98498. * @param name defines the name of the mesh to create
  98499. * @param xmin set the ground minimum X coordinate
  98500. * @param zmin set the ground minimum Y coordinate
  98501. * @param xmax set the ground maximum X coordinate
  98502. * @param zmax set the ground maximum Z coordinate
  98503. * @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
  98504. * @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
  98505. * @param scene defines the hosting scene
  98506. * @param updatable defines if the mesh must be flagged as updatable
  98507. * @returns a new Mesh
  98508. */
  98509. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  98510. w: number;
  98511. h: number;
  98512. }, precision: {
  98513. w: number;
  98514. h: number;
  98515. }, scene: Scene, updatable?: boolean): Mesh;
  98516. /**
  98517. * Creates a ground mesh from a height map.
  98518. * Please consider using the same method from the MeshBuilder class instead
  98519. * @see http://doc.babylonjs.com/babylon101/height_map
  98520. * @param name defines the name of the mesh to create
  98521. * @param url sets the URL of the height map image resource
  98522. * @param width set the ground width size
  98523. * @param height set the ground height size
  98524. * @param subdivisions sets the number of subdivision per side
  98525. * @param minHeight is the minimum altitude on the ground
  98526. * @param maxHeight is the maximum altitude on the ground
  98527. * @param scene defines the hosting scene
  98528. * @param updatable defines if the mesh must be flagged as updatable
  98529. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  98530. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98531. * @returns a new Mesh
  98532. */
  98533. 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;
  98534. /**
  98535. * Creates a tube mesh.
  98536. * The tube is a parametric shape.
  98537. * It has no predefined shape. Its final shape will depend on the input parameters.
  98538. * Please consider using the same method from the MeshBuilder class instead
  98539. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98540. * @param name defines the name of the mesh to create
  98541. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  98542. * @param radius sets the tube radius size
  98543. * @param tessellation is the number of sides on the tubular surface
  98544. * @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
  98545. * @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
  98546. * @param scene defines the hosting scene
  98547. * @param updatable defines if the mesh must be flagged as updatable
  98548. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98549. * @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)
  98550. * @returns a new Mesh
  98551. */
  98552. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  98553. (i: number, distance: number): number;
  98554. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98555. /**
  98556. * Creates a polyhedron mesh.
  98557. * Please consider using the same method from the MeshBuilder class instead.
  98558. * * 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
  98559. * * The parameter `size` (positive float, default 1) sets the polygon size
  98560. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98561. * * 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`
  98562. * * 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
  98563. * * 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)`)
  98564. * * 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
  98565. * * 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
  98566. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98567. * * If you create a double-sided mesh, you can choose what parts of 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
  98568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98569. * @param name defines the name of the mesh to create
  98570. * @param options defines the options used to create the mesh
  98571. * @param scene defines the hosting scene
  98572. * @returns a new Mesh
  98573. */
  98574. static CreatePolyhedron(name: string, options: {
  98575. type?: number;
  98576. size?: number;
  98577. sizeX?: number;
  98578. sizeY?: number;
  98579. sizeZ?: number;
  98580. custom?: any;
  98581. faceUV?: Vector4[];
  98582. faceColors?: Color4[];
  98583. updatable?: boolean;
  98584. sideOrientation?: number;
  98585. }, scene: Scene): Mesh;
  98586. /**
  98587. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  98588. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  98589. * * 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`)
  98590. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  98591. * * 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
  98592. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98593. * * If you create a double-sided mesh, you can choose what parts of 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
  98594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98595. * @param name defines the name of the mesh
  98596. * @param options defines the options used to create the mesh
  98597. * @param scene defines the hosting scene
  98598. * @returns a new Mesh
  98599. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  98600. */
  98601. static CreateIcoSphere(name: string, options: {
  98602. radius?: number;
  98603. flat?: boolean;
  98604. subdivisions?: number;
  98605. sideOrientation?: number;
  98606. updatable?: boolean;
  98607. }, scene: Scene): Mesh;
  98608. /**
  98609. * Creates a decal mesh.
  98610. * Please consider using the same method from the MeshBuilder class instead.
  98611. * A decal is a mesh usually applied as a model onto the surface of another mesh
  98612. * @param name defines the name of the mesh
  98613. * @param sourceMesh defines the mesh receiving the decal
  98614. * @param position sets the position of the decal in world coordinates
  98615. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  98616. * @param size sets the decal scaling
  98617. * @param angle sets the angle to rotate the decal
  98618. * @returns a new Mesh
  98619. */
  98620. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  98621. /**
  98622. * Prepare internal position array for software CPU skinning
  98623. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  98624. */
  98625. setPositionsForCPUSkinning(): Float32Array;
  98626. /**
  98627. * Prepare internal normal array for software CPU skinning
  98628. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  98629. */
  98630. setNormalsForCPUSkinning(): Float32Array;
  98631. /**
  98632. * Updates the vertex buffer by applying transformation from the bones
  98633. * @param skeleton defines the skeleton to apply to current mesh
  98634. * @returns the current mesh
  98635. */
  98636. applySkeleton(skeleton: Skeleton): Mesh;
  98637. /**
  98638. * 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
  98639. * @param meshes defines the list of meshes to scan
  98640. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  98641. */
  98642. static MinMax(meshes: AbstractMesh[]): {
  98643. min: Vector3;
  98644. max: Vector3;
  98645. };
  98646. /**
  98647. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  98648. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  98649. * @returns a vector3
  98650. */
  98651. static Center(meshesOrMinMaxVector: {
  98652. min: Vector3;
  98653. max: Vector3;
  98654. } | AbstractMesh[]): Vector3;
  98655. /**
  98656. * Merge the array of meshes into a single mesh for performance reasons.
  98657. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  98658. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  98659. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  98660. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  98661. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  98662. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  98663. * @returns a new mesh
  98664. */
  98665. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  98666. /** @hidden */
  98667. addInstance(instance: InstancedMesh): void;
  98668. /** @hidden */
  98669. removeInstance(instance: InstancedMesh): void;
  98670. }
  98671. }
  98672. declare module BABYLON {
  98673. /**
  98674. * This is the base class of all the camera used in the application.
  98675. * @see http://doc.babylonjs.com/features/cameras
  98676. */
  98677. export class Camera extends Node {
  98678. /** @hidden */
  98679. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  98680. /**
  98681. * This is the default projection mode used by the cameras.
  98682. * It helps recreating a feeling of perspective and better appreciate depth.
  98683. * This is the best way to simulate real life cameras.
  98684. */
  98685. static readonly PERSPECTIVE_CAMERA: number;
  98686. /**
  98687. * This helps creating camera with an orthographic mode.
  98688. * 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.
  98689. */
  98690. static readonly ORTHOGRAPHIC_CAMERA: number;
  98691. /**
  98692. * This is the default FOV mode for perspective cameras.
  98693. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  98694. */
  98695. static readonly FOVMODE_VERTICAL_FIXED: number;
  98696. /**
  98697. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  98698. */
  98699. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  98700. /**
  98701. * This specifies ther is no need for a camera rig.
  98702. * Basically only one eye is rendered corresponding to the camera.
  98703. */
  98704. static readonly RIG_MODE_NONE: number;
  98705. /**
  98706. * Simulates a camera Rig with one blue eye and one red eye.
  98707. * This can be use with 3d blue and red glasses.
  98708. */
  98709. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  98710. /**
  98711. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  98712. */
  98713. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  98714. /**
  98715. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  98716. */
  98717. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  98718. /**
  98719. * Defines that both eyes of the camera will be rendered over under each other.
  98720. */
  98721. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  98722. /**
  98723. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  98724. */
  98725. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  98726. /**
  98727. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  98728. */
  98729. static readonly RIG_MODE_VR: number;
  98730. /**
  98731. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  98732. */
  98733. static readonly RIG_MODE_WEBVR: number;
  98734. /**
  98735. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  98736. */
  98737. static readonly RIG_MODE_CUSTOM: number;
  98738. /**
  98739. * Defines if by default attaching controls should prevent the default javascript event to continue.
  98740. */
  98741. static ForceAttachControlToAlwaysPreventDefault: boolean;
  98742. /**
  98743. * Define the input manager associated with the camera.
  98744. */
  98745. inputs: CameraInputsManager<Camera>;
  98746. /** @hidden */
  98747. _position: Vector3;
  98748. /**
  98749. * Define the current local position of the camera in the scene
  98750. */
  98751. get position(): Vector3;
  98752. set position(newPosition: Vector3);
  98753. /**
  98754. * The vector the camera should consider as up.
  98755. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  98756. */
  98757. upVector: Vector3;
  98758. /**
  98759. * Define the current limit on the left side for an orthographic camera
  98760. * In scene unit
  98761. */
  98762. orthoLeft: Nullable<number>;
  98763. /**
  98764. * Define the current limit on the right side for an orthographic camera
  98765. * In scene unit
  98766. */
  98767. orthoRight: Nullable<number>;
  98768. /**
  98769. * Define the current limit on the bottom side for an orthographic camera
  98770. * In scene unit
  98771. */
  98772. orthoBottom: Nullable<number>;
  98773. /**
  98774. * Define the current limit on the top side for an orthographic camera
  98775. * In scene unit
  98776. */
  98777. orthoTop: Nullable<number>;
  98778. /**
  98779. * Field Of View is set in Radians. (default is 0.8)
  98780. */
  98781. fov: number;
  98782. /**
  98783. * Define the minimum distance the camera can see from.
  98784. * This is important to note that the depth buffer are not infinite and the closer it starts
  98785. * the more your scene might encounter depth fighting issue.
  98786. */
  98787. minZ: number;
  98788. /**
  98789. * Define the maximum distance the camera can see to.
  98790. * This is important to note that the depth buffer are not infinite and the further it end
  98791. * the more your scene might encounter depth fighting issue.
  98792. */
  98793. maxZ: number;
  98794. /**
  98795. * Define the default inertia of the camera.
  98796. * This helps giving a smooth feeling to the camera movement.
  98797. */
  98798. inertia: number;
  98799. /**
  98800. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  98801. */
  98802. mode: number;
  98803. /**
  98804. * Define whether the camera is intermediate.
  98805. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  98806. */
  98807. isIntermediate: boolean;
  98808. /**
  98809. * Define the viewport of the camera.
  98810. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  98811. */
  98812. viewport: Viewport;
  98813. /**
  98814. * Restricts the camera to viewing objects with the same layerMask.
  98815. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  98816. */
  98817. layerMask: number;
  98818. /**
  98819. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  98820. */
  98821. fovMode: number;
  98822. /**
  98823. * Rig mode of the camera.
  98824. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  98825. * This is normally controlled byt the camera themselves as internal use.
  98826. */
  98827. cameraRigMode: number;
  98828. /**
  98829. * Defines the distance between both "eyes" in case of a RIG
  98830. */
  98831. interaxialDistance: number;
  98832. /**
  98833. * Defines if stereoscopic rendering is done side by side or over under.
  98834. */
  98835. isStereoscopicSideBySide: boolean;
  98836. /**
  98837. * 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
  98838. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  98839. * else in the scene. (Eg. security camera)
  98840. *
  98841. * 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)
  98842. */
  98843. customRenderTargets: RenderTargetTexture[];
  98844. /**
  98845. * When set, the camera will render to this render target instead of the default canvas
  98846. *
  98847. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  98848. */
  98849. outputRenderTarget: Nullable<RenderTargetTexture>;
  98850. /**
  98851. * Observable triggered when the camera view matrix has changed.
  98852. */
  98853. onViewMatrixChangedObservable: Observable<Camera>;
  98854. /**
  98855. * Observable triggered when the camera Projection matrix has changed.
  98856. */
  98857. onProjectionMatrixChangedObservable: Observable<Camera>;
  98858. /**
  98859. * Observable triggered when the inputs have been processed.
  98860. */
  98861. onAfterCheckInputsObservable: Observable<Camera>;
  98862. /**
  98863. * Observable triggered when reset has been called and applied to the camera.
  98864. */
  98865. onRestoreStateObservable: Observable<Camera>;
  98866. /**
  98867. * Is this camera a part of a rig system?
  98868. */
  98869. isRigCamera: boolean;
  98870. /**
  98871. * If isRigCamera set to true this will be set with the parent camera.
  98872. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  98873. */
  98874. rigParent?: Camera;
  98875. /** @hidden */
  98876. _cameraRigParams: any;
  98877. /** @hidden */
  98878. _rigCameras: Camera[];
  98879. /** @hidden */
  98880. _rigPostProcess: Nullable<PostProcess>;
  98881. protected _webvrViewMatrix: Matrix;
  98882. /** @hidden */
  98883. _skipRendering: boolean;
  98884. /** @hidden */
  98885. _projectionMatrix: Matrix;
  98886. /** @hidden */
  98887. _postProcesses: Nullable<PostProcess>[];
  98888. /** @hidden */
  98889. _activeMeshes: SmartArray<AbstractMesh>;
  98890. protected _globalPosition: Vector3;
  98891. /** @hidden */
  98892. _computedViewMatrix: Matrix;
  98893. private _doNotComputeProjectionMatrix;
  98894. private _transformMatrix;
  98895. private _frustumPlanes;
  98896. private _refreshFrustumPlanes;
  98897. private _storedFov;
  98898. private _stateStored;
  98899. /**
  98900. * Instantiates a new camera object.
  98901. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  98902. * @see http://doc.babylonjs.com/features/cameras
  98903. * @param name Defines the name of the camera in the scene
  98904. * @param position Defines the position of the camera
  98905. * @param scene Defines the scene the camera belongs too
  98906. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  98907. */
  98908. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98909. /**
  98910. * Store current camera state (fov, position, etc..)
  98911. * @returns the camera
  98912. */
  98913. storeState(): Camera;
  98914. /**
  98915. * Restores the camera state values if it has been stored. You must call storeState() first
  98916. */
  98917. protected _restoreStateValues(): boolean;
  98918. /**
  98919. * Restored camera state. You must call storeState() first.
  98920. * @returns true if restored and false otherwise
  98921. */
  98922. restoreState(): boolean;
  98923. /**
  98924. * Gets the class name of the camera.
  98925. * @returns the class name
  98926. */
  98927. getClassName(): string;
  98928. /** @hidden */
  98929. readonly _isCamera: boolean;
  98930. /**
  98931. * Gets a string representation of the camera useful for debug purpose.
  98932. * @param fullDetails Defines that a more verboe level of logging is required
  98933. * @returns the string representation
  98934. */
  98935. toString(fullDetails?: boolean): string;
  98936. /**
  98937. * Gets the current world space position of the camera.
  98938. */
  98939. get globalPosition(): Vector3;
  98940. /**
  98941. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  98942. * @returns the active meshe list
  98943. */
  98944. getActiveMeshes(): SmartArray<AbstractMesh>;
  98945. /**
  98946. * Check whether a mesh is part of the current active mesh list of the camera
  98947. * @param mesh Defines the mesh to check
  98948. * @returns true if active, false otherwise
  98949. */
  98950. isActiveMesh(mesh: Mesh): boolean;
  98951. /**
  98952. * Is this camera ready to be used/rendered
  98953. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  98954. * @return true if the camera is ready
  98955. */
  98956. isReady(completeCheck?: boolean): boolean;
  98957. /** @hidden */
  98958. _initCache(): void;
  98959. /** @hidden */
  98960. _updateCache(ignoreParentClass?: boolean): void;
  98961. /** @hidden */
  98962. _isSynchronized(): boolean;
  98963. /** @hidden */
  98964. _isSynchronizedViewMatrix(): boolean;
  98965. /** @hidden */
  98966. _isSynchronizedProjectionMatrix(): boolean;
  98967. /**
  98968. * Attach the input controls to a specific dom element to get the input from.
  98969. * @param element Defines the element the controls should be listened from
  98970. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98971. */
  98972. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98973. /**
  98974. * Detach the current controls from the specified dom element.
  98975. * @param element Defines the element to stop listening the inputs from
  98976. */
  98977. detachControl(element: HTMLElement): void;
  98978. /**
  98979. * Update the camera state according to the different inputs gathered during the frame.
  98980. */
  98981. update(): void;
  98982. /** @hidden */
  98983. _checkInputs(): void;
  98984. /** @hidden */
  98985. get rigCameras(): Camera[];
  98986. /**
  98987. * Gets the post process used by the rig cameras
  98988. */
  98989. get rigPostProcess(): Nullable<PostProcess>;
  98990. /**
  98991. * Internal, gets the first post proces.
  98992. * @returns the first post process to be run on this camera.
  98993. */
  98994. _getFirstPostProcess(): Nullable<PostProcess>;
  98995. private _cascadePostProcessesToRigCams;
  98996. /**
  98997. * Attach a post process to the camera.
  98998. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98999. * @param postProcess The post process to attach to the camera
  99000. * @param insertAt The position of the post process in case several of them are in use in the scene
  99001. * @returns the position the post process has been inserted at
  99002. */
  99003. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  99004. /**
  99005. * Detach a post process to the camera.
  99006. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99007. * @param postProcess The post process to detach from the camera
  99008. */
  99009. detachPostProcess(postProcess: PostProcess): void;
  99010. /**
  99011. * Gets the current world matrix of the camera
  99012. */
  99013. getWorldMatrix(): Matrix;
  99014. /** @hidden */
  99015. _getViewMatrix(): Matrix;
  99016. /**
  99017. * Gets the current view matrix of the camera.
  99018. * @param force forces the camera to recompute the matrix without looking at the cached state
  99019. * @returns the view matrix
  99020. */
  99021. getViewMatrix(force?: boolean): Matrix;
  99022. /**
  99023. * Freeze the projection matrix.
  99024. * It will prevent the cache check of the camera projection compute and can speed up perf
  99025. * if no parameter of the camera are meant to change
  99026. * @param projection Defines manually a projection if necessary
  99027. */
  99028. freezeProjectionMatrix(projection?: Matrix): void;
  99029. /**
  99030. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  99031. */
  99032. unfreezeProjectionMatrix(): void;
  99033. /**
  99034. * Gets the current projection matrix of the camera.
  99035. * @param force forces the camera to recompute the matrix without looking at the cached state
  99036. * @returns the projection matrix
  99037. */
  99038. getProjectionMatrix(force?: boolean): Matrix;
  99039. /**
  99040. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  99041. * @returns a Matrix
  99042. */
  99043. getTransformationMatrix(): Matrix;
  99044. private _updateFrustumPlanes;
  99045. /**
  99046. * Checks if a cullable object (mesh...) is in the camera frustum
  99047. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  99048. * @param target The object to check
  99049. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  99050. * @returns true if the object is in frustum otherwise false
  99051. */
  99052. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  99053. /**
  99054. * Checks if a cullable object (mesh...) is in the camera frustum
  99055. * Unlike isInFrustum this cheks the full bounding box
  99056. * @param target The object to check
  99057. * @returns true if the object is in frustum otherwise false
  99058. */
  99059. isCompletelyInFrustum(target: ICullable): boolean;
  99060. /**
  99061. * Gets a ray in the forward direction from the camera.
  99062. * @param length Defines the length of the ray to create
  99063. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  99064. * @param origin Defines the start point of the ray which defaults to the camera position
  99065. * @returns the forward ray
  99066. */
  99067. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  99068. /**
  99069. * Releases resources associated with this node.
  99070. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99071. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99072. */
  99073. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99074. /** @hidden */
  99075. _isLeftCamera: boolean;
  99076. /**
  99077. * Gets the left camera of a rig setup in case of Rigged Camera
  99078. */
  99079. get isLeftCamera(): boolean;
  99080. /** @hidden */
  99081. _isRightCamera: boolean;
  99082. /**
  99083. * Gets the right camera of a rig setup in case of Rigged Camera
  99084. */
  99085. get isRightCamera(): boolean;
  99086. /**
  99087. * Gets the left camera of a rig setup in case of Rigged Camera
  99088. */
  99089. get leftCamera(): Nullable<FreeCamera>;
  99090. /**
  99091. * Gets the right camera of a rig setup in case of Rigged Camera
  99092. */
  99093. get rightCamera(): Nullable<FreeCamera>;
  99094. /**
  99095. * Gets the left camera target of a rig setup in case of Rigged Camera
  99096. * @returns the target position
  99097. */
  99098. getLeftTarget(): Nullable<Vector3>;
  99099. /**
  99100. * Gets the right camera target of a rig setup in case of Rigged Camera
  99101. * @returns the target position
  99102. */
  99103. getRightTarget(): Nullable<Vector3>;
  99104. /**
  99105. * @hidden
  99106. */
  99107. setCameraRigMode(mode: number, rigParams: any): void;
  99108. /** @hidden */
  99109. static _setStereoscopicRigMode(camera: Camera): void;
  99110. /** @hidden */
  99111. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  99112. /** @hidden */
  99113. static _setVRRigMode(camera: Camera, rigParams: any): void;
  99114. /** @hidden */
  99115. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  99116. /** @hidden */
  99117. _getVRProjectionMatrix(): Matrix;
  99118. protected _updateCameraRotationMatrix(): void;
  99119. protected _updateWebVRCameraRotationMatrix(): void;
  99120. /**
  99121. * This function MUST be overwritten by the different WebVR cameras available.
  99122. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99123. * @hidden
  99124. */
  99125. _getWebVRProjectionMatrix(): Matrix;
  99126. /**
  99127. * This function MUST be overwritten by the different WebVR cameras available.
  99128. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99129. * @hidden
  99130. */
  99131. _getWebVRViewMatrix(): Matrix;
  99132. /** @hidden */
  99133. setCameraRigParameter(name: string, value: any): void;
  99134. /**
  99135. * needs to be overridden by children so sub has required properties to be copied
  99136. * @hidden
  99137. */
  99138. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99139. /**
  99140. * May need to be overridden by children
  99141. * @hidden
  99142. */
  99143. _updateRigCameras(): void;
  99144. /** @hidden */
  99145. _setupInputs(): void;
  99146. /**
  99147. * Serialiaze the camera setup to a json represention
  99148. * @returns the JSON representation
  99149. */
  99150. serialize(): any;
  99151. /**
  99152. * Clones the current camera.
  99153. * @param name The cloned camera name
  99154. * @returns the cloned camera
  99155. */
  99156. clone(name: string): Camera;
  99157. /**
  99158. * Gets the direction of the camera relative to a given local axis.
  99159. * @param localAxis Defines the reference axis to provide a relative direction.
  99160. * @return the direction
  99161. */
  99162. getDirection(localAxis: Vector3): Vector3;
  99163. /**
  99164. * Returns the current camera absolute rotation
  99165. */
  99166. get absoluteRotation(): Quaternion;
  99167. /**
  99168. * Gets the direction of the camera relative to a given local axis into a passed vector.
  99169. * @param localAxis Defines the reference axis to provide a relative direction.
  99170. * @param result Defines the vector to store the result in
  99171. */
  99172. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  99173. /**
  99174. * Gets a camera constructor for a given camera type
  99175. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  99176. * @param name The name of the camera the result will be able to instantiate
  99177. * @param scene The scene the result will construct the camera in
  99178. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  99179. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  99180. * @returns a factory method to construc the camera
  99181. */
  99182. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  99183. /**
  99184. * Compute the world matrix of the camera.
  99185. * @returns the camera world matrix
  99186. */
  99187. computeWorldMatrix(): Matrix;
  99188. /**
  99189. * Parse a JSON and creates the camera from the parsed information
  99190. * @param parsedCamera The JSON to parse
  99191. * @param scene The scene to instantiate the camera in
  99192. * @returns the newly constructed camera
  99193. */
  99194. static Parse(parsedCamera: any, scene: Scene): Camera;
  99195. }
  99196. }
  99197. declare module BABYLON {
  99198. /**
  99199. * Class containing static functions to help procedurally build meshes
  99200. */
  99201. export class DiscBuilder {
  99202. /**
  99203. * Creates a plane polygonal mesh. By default, this is a disc
  99204. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  99205. * * 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
  99206. * * 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
  99207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99210. * @param name defines the name of the mesh
  99211. * @param options defines the options used to create the mesh
  99212. * @param scene defines the hosting scene
  99213. * @returns the plane polygonal mesh
  99214. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  99215. */
  99216. static CreateDisc(name: string, options: {
  99217. radius?: number;
  99218. tessellation?: number;
  99219. arc?: number;
  99220. updatable?: boolean;
  99221. sideOrientation?: number;
  99222. frontUVs?: Vector4;
  99223. backUVs?: Vector4;
  99224. }, scene?: Nullable<Scene>): Mesh;
  99225. }
  99226. }
  99227. declare module BABYLON {
  99228. /**
  99229. * This represents all the required information to add a fresnel effect on a material:
  99230. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99231. */
  99232. export class FresnelParameters {
  99233. private _isEnabled;
  99234. /**
  99235. * Define if the fresnel effect is enable or not.
  99236. */
  99237. get isEnabled(): boolean;
  99238. set isEnabled(value: boolean);
  99239. /**
  99240. * Define the color used on edges (grazing angle)
  99241. */
  99242. leftColor: Color3;
  99243. /**
  99244. * Define the color used on center
  99245. */
  99246. rightColor: Color3;
  99247. /**
  99248. * Define bias applied to computed fresnel term
  99249. */
  99250. bias: number;
  99251. /**
  99252. * Defined the power exponent applied to fresnel term
  99253. */
  99254. power: number;
  99255. /**
  99256. * Clones the current fresnel and its valuues
  99257. * @returns a clone fresnel configuration
  99258. */
  99259. clone(): FresnelParameters;
  99260. /**
  99261. * Serializes the current fresnel parameters to a JSON representation.
  99262. * @return the JSON serialization
  99263. */
  99264. serialize(): any;
  99265. /**
  99266. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99267. * @param parsedFresnelParameters Define the JSON representation
  99268. * @returns the parsed parameters
  99269. */
  99270. static Parse(parsedFresnelParameters: any): FresnelParameters;
  99271. }
  99272. }
  99273. declare module BABYLON {
  99274. /**
  99275. * Base class of materials working in push mode in babylon JS
  99276. * @hidden
  99277. */
  99278. export class PushMaterial extends Material {
  99279. protected _activeEffect: Effect;
  99280. protected _normalMatrix: Matrix;
  99281. /**
  99282. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  99283. * This means that the material can keep using a previous shader while a new one is being compiled.
  99284. * This is mostly used when shader parallel compilation is supported (true by default)
  99285. */
  99286. allowShaderHotSwapping: boolean;
  99287. constructor(name: string, scene: Scene);
  99288. getEffect(): Effect;
  99289. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99290. /**
  99291. * Binds the given world matrix to the active effect
  99292. *
  99293. * @param world the matrix to bind
  99294. */
  99295. bindOnlyWorldMatrix(world: Matrix): void;
  99296. /**
  99297. * Binds the given normal matrix to the active effect
  99298. *
  99299. * @param normalMatrix the matrix to bind
  99300. */
  99301. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99302. bind(world: Matrix, mesh?: Mesh): void;
  99303. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99304. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99305. }
  99306. }
  99307. declare module BABYLON {
  99308. /**
  99309. * This groups all the flags used to control the materials channel.
  99310. */
  99311. export class MaterialFlags {
  99312. private static _DiffuseTextureEnabled;
  99313. /**
  99314. * Are diffuse textures enabled in the application.
  99315. */
  99316. static get DiffuseTextureEnabled(): boolean;
  99317. static set DiffuseTextureEnabled(value: boolean);
  99318. private static _AmbientTextureEnabled;
  99319. /**
  99320. * Are ambient textures enabled in the application.
  99321. */
  99322. static get AmbientTextureEnabled(): boolean;
  99323. static set AmbientTextureEnabled(value: boolean);
  99324. private static _OpacityTextureEnabled;
  99325. /**
  99326. * Are opacity textures enabled in the application.
  99327. */
  99328. static get OpacityTextureEnabled(): boolean;
  99329. static set OpacityTextureEnabled(value: boolean);
  99330. private static _ReflectionTextureEnabled;
  99331. /**
  99332. * Are reflection textures enabled in the application.
  99333. */
  99334. static get ReflectionTextureEnabled(): boolean;
  99335. static set ReflectionTextureEnabled(value: boolean);
  99336. private static _EmissiveTextureEnabled;
  99337. /**
  99338. * Are emissive textures enabled in the application.
  99339. */
  99340. static get EmissiveTextureEnabled(): boolean;
  99341. static set EmissiveTextureEnabled(value: boolean);
  99342. private static _SpecularTextureEnabled;
  99343. /**
  99344. * Are specular textures enabled in the application.
  99345. */
  99346. static get SpecularTextureEnabled(): boolean;
  99347. static set SpecularTextureEnabled(value: boolean);
  99348. private static _BumpTextureEnabled;
  99349. /**
  99350. * Are bump textures enabled in the application.
  99351. */
  99352. static get BumpTextureEnabled(): boolean;
  99353. static set BumpTextureEnabled(value: boolean);
  99354. private static _LightmapTextureEnabled;
  99355. /**
  99356. * Are lightmap textures enabled in the application.
  99357. */
  99358. static get LightmapTextureEnabled(): boolean;
  99359. static set LightmapTextureEnabled(value: boolean);
  99360. private static _RefractionTextureEnabled;
  99361. /**
  99362. * Are refraction textures enabled in the application.
  99363. */
  99364. static get RefractionTextureEnabled(): boolean;
  99365. static set RefractionTextureEnabled(value: boolean);
  99366. private static _ColorGradingTextureEnabled;
  99367. /**
  99368. * Are color grading textures enabled in the application.
  99369. */
  99370. static get ColorGradingTextureEnabled(): boolean;
  99371. static set ColorGradingTextureEnabled(value: boolean);
  99372. private static _FresnelEnabled;
  99373. /**
  99374. * Are fresnels enabled in the application.
  99375. */
  99376. static get FresnelEnabled(): boolean;
  99377. static set FresnelEnabled(value: boolean);
  99378. private static _ClearCoatTextureEnabled;
  99379. /**
  99380. * Are clear coat textures enabled in the application.
  99381. */
  99382. static get ClearCoatTextureEnabled(): boolean;
  99383. static set ClearCoatTextureEnabled(value: boolean);
  99384. private static _ClearCoatBumpTextureEnabled;
  99385. /**
  99386. * Are clear coat bump textures enabled in the application.
  99387. */
  99388. static get ClearCoatBumpTextureEnabled(): boolean;
  99389. static set ClearCoatBumpTextureEnabled(value: boolean);
  99390. private static _ClearCoatTintTextureEnabled;
  99391. /**
  99392. * Are clear coat tint textures enabled in the application.
  99393. */
  99394. static get ClearCoatTintTextureEnabled(): boolean;
  99395. static set ClearCoatTintTextureEnabled(value: boolean);
  99396. private static _SheenTextureEnabled;
  99397. /**
  99398. * Are sheen textures enabled in the application.
  99399. */
  99400. static get SheenTextureEnabled(): boolean;
  99401. static set SheenTextureEnabled(value: boolean);
  99402. private static _AnisotropicTextureEnabled;
  99403. /**
  99404. * Are anisotropic textures enabled in the application.
  99405. */
  99406. static get AnisotropicTextureEnabled(): boolean;
  99407. static set AnisotropicTextureEnabled(value: boolean);
  99408. private static _ThicknessTextureEnabled;
  99409. /**
  99410. * Are thickness textures enabled in the application.
  99411. */
  99412. static get ThicknessTextureEnabled(): boolean;
  99413. static set ThicknessTextureEnabled(value: boolean);
  99414. }
  99415. }
  99416. declare module BABYLON {
  99417. /** @hidden */
  99418. export var defaultFragmentDeclaration: {
  99419. name: string;
  99420. shader: string;
  99421. };
  99422. }
  99423. declare module BABYLON {
  99424. /** @hidden */
  99425. export var defaultUboDeclaration: {
  99426. name: string;
  99427. shader: string;
  99428. };
  99429. }
  99430. declare module BABYLON {
  99431. /** @hidden */
  99432. export var lightFragmentDeclaration: {
  99433. name: string;
  99434. shader: string;
  99435. };
  99436. }
  99437. declare module BABYLON {
  99438. /** @hidden */
  99439. export var lightUboDeclaration: {
  99440. name: string;
  99441. shader: string;
  99442. };
  99443. }
  99444. declare module BABYLON {
  99445. /** @hidden */
  99446. export var lightsFragmentFunctions: {
  99447. name: string;
  99448. shader: string;
  99449. };
  99450. }
  99451. declare module BABYLON {
  99452. /** @hidden */
  99453. export var shadowsFragmentFunctions: {
  99454. name: string;
  99455. shader: string;
  99456. };
  99457. }
  99458. declare module BABYLON {
  99459. /** @hidden */
  99460. export var fresnelFunction: {
  99461. name: string;
  99462. shader: string;
  99463. };
  99464. }
  99465. declare module BABYLON {
  99466. /** @hidden */
  99467. export var reflectionFunction: {
  99468. name: string;
  99469. shader: string;
  99470. };
  99471. }
  99472. declare module BABYLON {
  99473. /** @hidden */
  99474. export var bumpFragmentFunctions: {
  99475. name: string;
  99476. shader: string;
  99477. };
  99478. }
  99479. declare module BABYLON {
  99480. /** @hidden */
  99481. export var logDepthDeclaration: {
  99482. name: string;
  99483. shader: string;
  99484. };
  99485. }
  99486. declare module BABYLON {
  99487. /** @hidden */
  99488. export var bumpFragment: {
  99489. name: string;
  99490. shader: string;
  99491. };
  99492. }
  99493. declare module BABYLON {
  99494. /** @hidden */
  99495. export var depthPrePass: {
  99496. name: string;
  99497. shader: string;
  99498. };
  99499. }
  99500. declare module BABYLON {
  99501. /** @hidden */
  99502. export var lightFragment: {
  99503. name: string;
  99504. shader: string;
  99505. };
  99506. }
  99507. declare module BABYLON {
  99508. /** @hidden */
  99509. export var logDepthFragment: {
  99510. name: string;
  99511. shader: string;
  99512. };
  99513. }
  99514. declare module BABYLON {
  99515. /** @hidden */
  99516. export var defaultPixelShader: {
  99517. name: string;
  99518. shader: string;
  99519. };
  99520. }
  99521. declare module BABYLON {
  99522. /** @hidden */
  99523. export var defaultVertexDeclaration: {
  99524. name: string;
  99525. shader: string;
  99526. };
  99527. }
  99528. declare module BABYLON {
  99529. /** @hidden */
  99530. export var bumpVertexDeclaration: {
  99531. name: string;
  99532. shader: string;
  99533. };
  99534. }
  99535. declare module BABYLON {
  99536. /** @hidden */
  99537. export var bumpVertex: {
  99538. name: string;
  99539. shader: string;
  99540. };
  99541. }
  99542. declare module BABYLON {
  99543. /** @hidden */
  99544. export var fogVertex: {
  99545. name: string;
  99546. shader: string;
  99547. };
  99548. }
  99549. declare module BABYLON {
  99550. /** @hidden */
  99551. export var shadowsVertex: {
  99552. name: string;
  99553. shader: string;
  99554. };
  99555. }
  99556. declare module BABYLON {
  99557. /** @hidden */
  99558. export var pointCloudVertex: {
  99559. name: string;
  99560. shader: string;
  99561. };
  99562. }
  99563. declare module BABYLON {
  99564. /** @hidden */
  99565. export var logDepthVertex: {
  99566. name: string;
  99567. shader: string;
  99568. };
  99569. }
  99570. declare module BABYLON {
  99571. /** @hidden */
  99572. export var defaultVertexShader: {
  99573. name: string;
  99574. shader: string;
  99575. };
  99576. }
  99577. declare module BABYLON {
  99578. /** @hidden */
  99579. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99580. MAINUV1: boolean;
  99581. MAINUV2: boolean;
  99582. DIFFUSE: boolean;
  99583. DIFFUSEDIRECTUV: number;
  99584. AMBIENT: boolean;
  99585. AMBIENTDIRECTUV: number;
  99586. OPACITY: boolean;
  99587. OPACITYDIRECTUV: number;
  99588. OPACITYRGB: boolean;
  99589. REFLECTION: boolean;
  99590. EMISSIVE: boolean;
  99591. EMISSIVEDIRECTUV: number;
  99592. SPECULAR: boolean;
  99593. SPECULARDIRECTUV: number;
  99594. BUMP: boolean;
  99595. BUMPDIRECTUV: number;
  99596. PARALLAX: boolean;
  99597. PARALLAXOCCLUSION: boolean;
  99598. SPECULAROVERALPHA: boolean;
  99599. CLIPPLANE: boolean;
  99600. CLIPPLANE2: boolean;
  99601. CLIPPLANE3: boolean;
  99602. CLIPPLANE4: boolean;
  99603. CLIPPLANE5: boolean;
  99604. CLIPPLANE6: boolean;
  99605. ALPHATEST: boolean;
  99606. DEPTHPREPASS: boolean;
  99607. ALPHAFROMDIFFUSE: boolean;
  99608. POINTSIZE: boolean;
  99609. FOG: boolean;
  99610. SPECULARTERM: boolean;
  99611. DIFFUSEFRESNEL: boolean;
  99612. OPACITYFRESNEL: boolean;
  99613. REFLECTIONFRESNEL: boolean;
  99614. REFRACTIONFRESNEL: boolean;
  99615. EMISSIVEFRESNEL: boolean;
  99616. FRESNEL: boolean;
  99617. NORMAL: boolean;
  99618. UV1: boolean;
  99619. UV2: boolean;
  99620. VERTEXCOLOR: boolean;
  99621. VERTEXALPHA: boolean;
  99622. NUM_BONE_INFLUENCERS: number;
  99623. BonesPerMesh: number;
  99624. BONETEXTURE: boolean;
  99625. INSTANCES: boolean;
  99626. GLOSSINESS: boolean;
  99627. ROUGHNESS: boolean;
  99628. EMISSIVEASILLUMINATION: boolean;
  99629. LINKEMISSIVEWITHDIFFUSE: boolean;
  99630. REFLECTIONFRESNELFROMSPECULAR: boolean;
  99631. LIGHTMAP: boolean;
  99632. LIGHTMAPDIRECTUV: number;
  99633. OBJECTSPACE_NORMALMAP: boolean;
  99634. USELIGHTMAPASSHADOWMAP: boolean;
  99635. REFLECTIONMAP_3D: boolean;
  99636. REFLECTIONMAP_SPHERICAL: boolean;
  99637. REFLECTIONMAP_PLANAR: boolean;
  99638. REFLECTIONMAP_CUBIC: boolean;
  99639. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  99640. REFLECTIONMAP_PROJECTION: boolean;
  99641. REFLECTIONMAP_SKYBOX: boolean;
  99642. REFLECTIONMAP_EXPLICIT: boolean;
  99643. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  99644. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  99645. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  99646. INVERTCUBICMAP: boolean;
  99647. LOGARITHMICDEPTH: boolean;
  99648. REFRACTION: boolean;
  99649. REFRACTIONMAP_3D: boolean;
  99650. REFLECTIONOVERALPHA: boolean;
  99651. TWOSIDEDLIGHTING: boolean;
  99652. SHADOWFLOAT: boolean;
  99653. MORPHTARGETS: boolean;
  99654. MORPHTARGETS_NORMAL: boolean;
  99655. MORPHTARGETS_TANGENT: boolean;
  99656. MORPHTARGETS_UV: boolean;
  99657. NUM_MORPH_INFLUENCERS: number;
  99658. NONUNIFORMSCALING: boolean;
  99659. PREMULTIPLYALPHA: boolean;
  99660. IMAGEPROCESSING: boolean;
  99661. VIGNETTE: boolean;
  99662. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99663. VIGNETTEBLENDMODEOPAQUE: boolean;
  99664. TONEMAPPING: boolean;
  99665. TONEMAPPING_ACES: boolean;
  99666. CONTRAST: boolean;
  99667. COLORCURVES: boolean;
  99668. COLORGRADING: boolean;
  99669. COLORGRADING3D: boolean;
  99670. SAMPLER3DGREENDEPTH: boolean;
  99671. SAMPLER3DBGRMAP: boolean;
  99672. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99673. MULTIVIEW: boolean;
  99674. /**
  99675. * If the reflection texture on this material is in linear color space
  99676. * @hidden
  99677. */
  99678. IS_REFLECTION_LINEAR: boolean;
  99679. /**
  99680. * If the refraction texture on this material is in linear color space
  99681. * @hidden
  99682. */
  99683. IS_REFRACTION_LINEAR: boolean;
  99684. EXPOSURE: boolean;
  99685. constructor();
  99686. setReflectionMode(modeToEnable: string): void;
  99687. }
  99688. /**
  99689. * This is the default material used in Babylon. It is the best trade off between quality
  99690. * and performances.
  99691. * @see http://doc.babylonjs.com/babylon101/materials
  99692. */
  99693. export class StandardMaterial extends PushMaterial {
  99694. private _diffuseTexture;
  99695. /**
  99696. * The basic texture of the material as viewed under a light.
  99697. */
  99698. diffuseTexture: Nullable<BaseTexture>;
  99699. private _ambientTexture;
  99700. /**
  99701. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  99702. */
  99703. ambientTexture: Nullable<BaseTexture>;
  99704. private _opacityTexture;
  99705. /**
  99706. * Define the transparency of the material from a texture.
  99707. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  99708. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  99709. */
  99710. opacityTexture: Nullable<BaseTexture>;
  99711. private _reflectionTexture;
  99712. /**
  99713. * Define the texture used to display the reflection.
  99714. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99715. */
  99716. reflectionTexture: Nullable<BaseTexture>;
  99717. private _emissiveTexture;
  99718. /**
  99719. * Define texture of the material as if self lit.
  99720. * This will be mixed in the final result even in the absence of light.
  99721. */
  99722. emissiveTexture: Nullable<BaseTexture>;
  99723. private _specularTexture;
  99724. /**
  99725. * Define how the color and intensity of the highlight given by the light in the material.
  99726. */
  99727. specularTexture: Nullable<BaseTexture>;
  99728. private _bumpTexture;
  99729. /**
  99730. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  99731. * 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.
  99732. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  99733. */
  99734. bumpTexture: Nullable<BaseTexture>;
  99735. private _lightmapTexture;
  99736. /**
  99737. * Complex lighting can be computationally expensive to compute at runtime.
  99738. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  99739. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  99740. */
  99741. lightmapTexture: Nullable<BaseTexture>;
  99742. private _refractionTexture;
  99743. /**
  99744. * Define the texture used to display the refraction.
  99745. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99746. */
  99747. refractionTexture: Nullable<BaseTexture>;
  99748. /**
  99749. * The color of the material lit by the environmental background lighting.
  99750. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  99751. */
  99752. ambientColor: Color3;
  99753. /**
  99754. * The basic color of the material as viewed under a light.
  99755. */
  99756. diffuseColor: Color3;
  99757. /**
  99758. * Define how the color and intensity of the highlight given by the light in the material.
  99759. */
  99760. specularColor: Color3;
  99761. /**
  99762. * Define the color of the material as if self lit.
  99763. * This will be mixed in the final result even in the absence of light.
  99764. */
  99765. emissiveColor: Color3;
  99766. /**
  99767. * Defines how sharp are the highlights in the material.
  99768. * The bigger the value the sharper giving a more glossy feeling to the result.
  99769. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  99770. */
  99771. specularPower: number;
  99772. private _useAlphaFromDiffuseTexture;
  99773. /**
  99774. * Does the transparency come from the diffuse texture alpha channel.
  99775. */
  99776. useAlphaFromDiffuseTexture: boolean;
  99777. private _useEmissiveAsIllumination;
  99778. /**
  99779. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  99780. */
  99781. useEmissiveAsIllumination: boolean;
  99782. private _linkEmissiveWithDiffuse;
  99783. /**
  99784. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  99785. * the emissive level when the final color is close to one.
  99786. */
  99787. linkEmissiveWithDiffuse: boolean;
  99788. private _useSpecularOverAlpha;
  99789. /**
  99790. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99791. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99792. */
  99793. useSpecularOverAlpha: boolean;
  99794. private _useReflectionOverAlpha;
  99795. /**
  99796. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99797. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99798. */
  99799. useReflectionOverAlpha: boolean;
  99800. private _disableLighting;
  99801. /**
  99802. * Does lights from the scene impacts this material.
  99803. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  99804. */
  99805. disableLighting: boolean;
  99806. private _useObjectSpaceNormalMap;
  99807. /**
  99808. * Allows using an object space normal map (instead of tangent space).
  99809. */
  99810. useObjectSpaceNormalMap: boolean;
  99811. private _useParallax;
  99812. /**
  99813. * Is parallax enabled or not.
  99814. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99815. */
  99816. useParallax: boolean;
  99817. private _useParallaxOcclusion;
  99818. /**
  99819. * Is parallax occlusion enabled or not.
  99820. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  99821. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99822. */
  99823. useParallaxOcclusion: boolean;
  99824. /**
  99825. * 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.
  99826. */
  99827. parallaxScaleBias: number;
  99828. private _roughness;
  99829. /**
  99830. * Helps to define how blurry the reflections should appears in the material.
  99831. */
  99832. roughness: number;
  99833. /**
  99834. * In case of refraction, define the value of the index of refraction.
  99835. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99836. */
  99837. indexOfRefraction: number;
  99838. /**
  99839. * Invert the refraction texture alongside the y axis.
  99840. * It can be useful with procedural textures or probe for instance.
  99841. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99842. */
  99843. invertRefractionY: boolean;
  99844. /**
  99845. * Defines the alpha limits in alpha test mode.
  99846. */
  99847. alphaCutOff: number;
  99848. private _useLightmapAsShadowmap;
  99849. /**
  99850. * In case of light mapping, define whether the map contains light or shadow informations.
  99851. */
  99852. useLightmapAsShadowmap: boolean;
  99853. private _diffuseFresnelParameters;
  99854. /**
  99855. * Define the diffuse fresnel parameters of the material.
  99856. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99857. */
  99858. diffuseFresnelParameters: FresnelParameters;
  99859. private _opacityFresnelParameters;
  99860. /**
  99861. * Define the opacity fresnel parameters of the material.
  99862. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99863. */
  99864. opacityFresnelParameters: FresnelParameters;
  99865. private _reflectionFresnelParameters;
  99866. /**
  99867. * Define the reflection fresnel parameters of the material.
  99868. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99869. */
  99870. reflectionFresnelParameters: FresnelParameters;
  99871. private _refractionFresnelParameters;
  99872. /**
  99873. * Define the refraction fresnel parameters of the material.
  99874. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99875. */
  99876. refractionFresnelParameters: FresnelParameters;
  99877. private _emissiveFresnelParameters;
  99878. /**
  99879. * Define the emissive fresnel parameters of the material.
  99880. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99881. */
  99882. emissiveFresnelParameters: FresnelParameters;
  99883. private _useReflectionFresnelFromSpecular;
  99884. /**
  99885. * If true automatically deducts the fresnels values from the material specularity.
  99886. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99887. */
  99888. useReflectionFresnelFromSpecular: boolean;
  99889. private _useGlossinessFromSpecularMapAlpha;
  99890. /**
  99891. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  99892. */
  99893. useGlossinessFromSpecularMapAlpha: boolean;
  99894. private _maxSimultaneousLights;
  99895. /**
  99896. * Defines the maximum number of lights that can be used in the material
  99897. */
  99898. maxSimultaneousLights: number;
  99899. private _invertNormalMapX;
  99900. /**
  99901. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99902. */
  99903. invertNormalMapX: boolean;
  99904. private _invertNormalMapY;
  99905. /**
  99906. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99907. */
  99908. invertNormalMapY: boolean;
  99909. private _twoSidedLighting;
  99910. /**
  99911. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99912. */
  99913. twoSidedLighting: boolean;
  99914. /**
  99915. * Default configuration related to image processing available in the standard Material.
  99916. */
  99917. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99918. /**
  99919. * Gets the image processing configuration used either in this material.
  99920. */
  99921. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99922. /**
  99923. * Sets the Default image processing configuration used either in the this material.
  99924. *
  99925. * If sets to null, the scene one is in use.
  99926. */
  99927. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99928. /**
  99929. * Keep track of the image processing observer to allow dispose and replace.
  99930. */
  99931. private _imageProcessingObserver;
  99932. /**
  99933. * Attaches a new image processing configuration to the Standard Material.
  99934. * @param configuration
  99935. */
  99936. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99937. /**
  99938. * Gets wether the color curves effect is enabled.
  99939. */
  99940. get cameraColorCurvesEnabled(): boolean;
  99941. /**
  99942. * Sets wether the color curves effect is enabled.
  99943. */
  99944. set cameraColorCurvesEnabled(value: boolean);
  99945. /**
  99946. * Gets wether the color grading effect is enabled.
  99947. */
  99948. get cameraColorGradingEnabled(): boolean;
  99949. /**
  99950. * Gets wether the color grading effect is enabled.
  99951. */
  99952. set cameraColorGradingEnabled(value: boolean);
  99953. /**
  99954. * Gets wether tonemapping is enabled or not.
  99955. */
  99956. get cameraToneMappingEnabled(): boolean;
  99957. /**
  99958. * Sets wether tonemapping is enabled or not
  99959. */
  99960. set cameraToneMappingEnabled(value: boolean);
  99961. /**
  99962. * The camera exposure used on this material.
  99963. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99964. * This corresponds to a photographic exposure.
  99965. */
  99966. get cameraExposure(): number;
  99967. /**
  99968. * The camera exposure used on this material.
  99969. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99970. * This corresponds to a photographic exposure.
  99971. */
  99972. set cameraExposure(value: number);
  99973. /**
  99974. * Gets The camera contrast used on this material.
  99975. */
  99976. get cameraContrast(): number;
  99977. /**
  99978. * Sets The camera contrast used on this material.
  99979. */
  99980. set cameraContrast(value: number);
  99981. /**
  99982. * Gets the Color Grading 2D Lookup Texture.
  99983. */
  99984. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  99985. /**
  99986. * Sets the Color Grading 2D Lookup Texture.
  99987. */
  99988. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  99989. /**
  99990. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99991. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99992. * 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;
  99993. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99994. */
  99995. get cameraColorCurves(): Nullable<ColorCurves>;
  99996. /**
  99997. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99998. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99999. * 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;
  100000. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100001. */
  100002. set cameraColorCurves(value: Nullable<ColorCurves>);
  100003. /**
  100004. * Custom callback helping to override the default shader used in the material.
  100005. */
  100006. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  100007. protected _renderTargets: SmartArray<RenderTargetTexture>;
  100008. protected _worldViewProjectionMatrix: Matrix;
  100009. protected _globalAmbientColor: Color3;
  100010. protected _useLogarithmicDepth: boolean;
  100011. protected _rebuildInParallel: boolean;
  100012. /**
  100013. * Instantiates a new standard material.
  100014. * This is the default material used in Babylon. It is the best trade off between quality
  100015. * and performances.
  100016. * @see http://doc.babylonjs.com/babylon101/materials
  100017. * @param name Define the name of the material in the scene
  100018. * @param scene Define the scene the material belong to
  100019. */
  100020. constructor(name: string, scene: Scene);
  100021. /**
  100022. * Gets a boolean indicating that current material needs to register RTT
  100023. */
  100024. get hasRenderTargetTextures(): boolean;
  100025. /**
  100026. * Gets the current class name of the material e.g. "StandardMaterial"
  100027. * Mainly use in serialization.
  100028. * @returns the class name
  100029. */
  100030. getClassName(): string;
  100031. /**
  100032. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  100033. * You can try switching to logarithmic depth.
  100034. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  100035. */
  100036. get useLogarithmicDepth(): boolean;
  100037. set useLogarithmicDepth(value: boolean);
  100038. /**
  100039. * Specifies if the material will require alpha blending
  100040. * @returns a boolean specifying if alpha blending is needed
  100041. */
  100042. needAlphaBlending(): boolean;
  100043. /**
  100044. * Specifies if this material should be rendered in alpha test mode
  100045. * @returns a boolean specifying if an alpha test is needed.
  100046. */
  100047. needAlphaTesting(): boolean;
  100048. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  100049. /**
  100050. * Get the texture used for alpha test purpose.
  100051. * @returns the diffuse texture in case of the standard material.
  100052. */
  100053. getAlphaTestTexture(): Nullable<BaseTexture>;
  100054. /**
  100055. * Get if the submesh is ready to be used and all its information available.
  100056. * Child classes can use it to update shaders
  100057. * @param mesh defines the mesh to check
  100058. * @param subMesh defines which submesh to check
  100059. * @param useInstances specifies that instances should be used
  100060. * @returns a boolean indicating that the submesh is ready or not
  100061. */
  100062. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100063. /**
  100064. * Builds the material UBO layouts.
  100065. * Used internally during the effect preparation.
  100066. */
  100067. buildUniformLayout(): void;
  100068. /**
  100069. * Unbinds the material from the mesh
  100070. */
  100071. unbind(): void;
  100072. /**
  100073. * Binds the submesh to this material by preparing the effect and shader to draw
  100074. * @param world defines the world transformation matrix
  100075. * @param mesh defines the mesh containing the submesh
  100076. * @param subMesh defines the submesh to bind the material to
  100077. */
  100078. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100079. /**
  100080. * Get the list of animatables in the material.
  100081. * @returns the list of animatables object used in the material
  100082. */
  100083. getAnimatables(): IAnimatable[];
  100084. /**
  100085. * Gets the active textures from the material
  100086. * @returns an array of textures
  100087. */
  100088. getActiveTextures(): BaseTexture[];
  100089. /**
  100090. * Specifies if the material uses a texture
  100091. * @param texture defines the texture to check against the material
  100092. * @returns a boolean specifying if the material uses the texture
  100093. */
  100094. hasTexture(texture: BaseTexture): boolean;
  100095. /**
  100096. * Disposes the material
  100097. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100098. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100099. */
  100100. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100101. /**
  100102. * Makes a duplicate of the material, and gives it a new name
  100103. * @param name defines the new name for the duplicated material
  100104. * @returns the cloned material
  100105. */
  100106. clone(name: string): StandardMaterial;
  100107. /**
  100108. * Serializes this material in a JSON representation
  100109. * @returns the serialized material object
  100110. */
  100111. serialize(): any;
  100112. /**
  100113. * Creates a standard material from parsed material data
  100114. * @param source defines the JSON representation of the material
  100115. * @param scene defines the hosting scene
  100116. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100117. * @returns a new standard material
  100118. */
  100119. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100120. /**
  100121. * Are diffuse textures enabled in the application.
  100122. */
  100123. static get DiffuseTextureEnabled(): boolean;
  100124. static set DiffuseTextureEnabled(value: boolean);
  100125. /**
  100126. * Are ambient textures enabled in the application.
  100127. */
  100128. static get AmbientTextureEnabled(): boolean;
  100129. static set AmbientTextureEnabled(value: boolean);
  100130. /**
  100131. * Are opacity textures enabled in the application.
  100132. */
  100133. static get OpacityTextureEnabled(): boolean;
  100134. static set OpacityTextureEnabled(value: boolean);
  100135. /**
  100136. * Are reflection textures enabled in the application.
  100137. */
  100138. static get ReflectionTextureEnabled(): boolean;
  100139. static set ReflectionTextureEnabled(value: boolean);
  100140. /**
  100141. * Are emissive textures enabled in the application.
  100142. */
  100143. static get EmissiveTextureEnabled(): boolean;
  100144. static set EmissiveTextureEnabled(value: boolean);
  100145. /**
  100146. * Are specular textures enabled in the application.
  100147. */
  100148. static get SpecularTextureEnabled(): boolean;
  100149. static set SpecularTextureEnabled(value: boolean);
  100150. /**
  100151. * Are bump textures enabled in the application.
  100152. */
  100153. static get BumpTextureEnabled(): boolean;
  100154. static set BumpTextureEnabled(value: boolean);
  100155. /**
  100156. * Are lightmap textures enabled in the application.
  100157. */
  100158. static get LightmapTextureEnabled(): boolean;
  100159. static set LightmapTextureEnabled(value: boolean);
  100160. /**
  100161. * Are refraction textures enabled in the application.
  100162. */
  100163. static get RefractionTextureEnabled(): boolean;
  100164. static set RefractionTextureEnabled(value: boolean);
  100165. /**
  100166. * Are color grading textures enabled in the application.
  100167. */
  100168. static get ColorGradingTextureEnabled(): boolean;
  100169. static set ColorGradingTextureEnabled(value: boolean);
  100170. /**
  100171. * Are fresnels enabled in the application.
  100172. */
  100173. static get FresnelEnabled(): boolean;
  100174. static set FresnelEnabled(value: boolean);
  100175. }
  100176. }
  100177. declare module BABYLON {
  100178. /**
  100179. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  100180. *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.
  100181. * The SPS is also a particle system. It provides some methods to manage the particles.
  100182. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  100183. *
  100184. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  100185. */
  100186. export class SolidParticleSystem implements IDisposable {
  100187. /**
  100188. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  100189. * Example : var p = SPS.particles[i];
  100190. */
  100191. particles: SolidParticle[];
  100192. /**
  100193. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  100194. */
  100195. nbParticles: number;
  100196. /**
  100197. * If the particles must ever face the camera (default false). Useful for planar particles.
  100198. */
  100199. billboard: boolean;
  100200. /**
  100201. * Recompute normals when adding a shape
  100202. */
  100203. recomputeNormals: boolean;
  100204. /**
  100205. * This a counter ofr your own usage. It's not set by any SPS functions.
  100206. */
  100207. counter: number;
  100208. /**
  100209. * The SPS name. This name is also given to the underlying mesh.
  100210. */
  100211. name: string;
  100212. /**
  100213. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  100214. */
  100215. mesh: Mesh;
  100216. /**
  100217. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  100218. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  100219. */
  100220. vars: any;
  100221. /**
  100222. * This array is populated when the SPS is set as 'pickable'.
  100223. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  100224. * Each element of this array is an object `{idx: int, faceId: int}`.
  100225. * `idx` is the picked particle index in the `SPS.particles` array
  100226. * `faceId` is the picked face index counted within this particle.
  100227. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100228. */
  100229. pickedParticles: {
  100230. idx: number;
  100231. faceId: number;
  100232. }[];
  100233. /**
  100234. * This array is populated when `enableDepthSort` is set to true.
  100235. * Each element of this array is an instance of the class DepthSortedParticle.
  100236. */
  100237. depthSortedParticles: DepthSortedParticle[];
  100238. /**
  100239. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  100240. * @hidden
  100241. */
  100242. _bSphereOnly: boolean;
  100243. /**
  100244. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  100245. * @hidden
  100246. */
  100247. _bSphereRadiusFactor: number;
  100248. private _scene;
  100249. private _positions;
  100250. private _indices;
  100251. private _normals;
  100252. private _colors;
  100253. private _uvs;
  100254. private _indices32;
  100255. private _positions32;
  100256. private _normals32;
  100257. private _fixedNormal32;
  100258. private _colors32;
  100259. private _uvs32;
  100260. private _index;
  100261. private _updatable;
  100262. private _pickable;
  100263. private _isVisibilityBoxLocked;
  100264. private _alwaysVisible;
  100265. private _depthSort;
  100266. private _expandable;
  100267. private _shapeCounter;
  100268. private _copy;
  100269. private _color;
  100270. private _computeParticleColor;
  100271. private _computeParticleTexture;
  100272. private _computeParticleRotation;
  100273. private _computeParticleVertex;
  100274. private _computeBoundingBox;
  100275. private _depthSortParticles;
  100276. private _camera;
  100277. private _mustUnrotateFixedNormals;
  100278. private _particlesIntersect;
  100279. private _needs32Bits;
  100280. private _isNotBuilt;
  100281. private _lastParticleId;
  100282. private _idxOfId;
  100283. private _multimaterialEnabled;
  100284. private _useModelMaterial;
  100285. private _indicesByMaterial;
  100286. private _materialIndexes;
  100287. private _depthSortFunction;
  100288. private _materialSortFunction;
  100289. private _materials;
  100290. private _multimaterial;
  100291. private _materialIndexesById;
  100292. private _defaultMaterial;
  100293. private _autoUpdateSubMeshes;
  100294. /**
  100295. * Creates a SPS (Solid Particle System) object.
  100296. * @param name (String) is the SPS name, this will be the underlying mesh name.
  100297. * @param scene (Scene) is the scene in which the SPS is added.
  100298. * @param options defines the options of the sps e.g.
  100299. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  100300. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  100301. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  100302. * * 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.
  100303. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  100304. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  100305. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  100306. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  100307. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  100308. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  100309. */
  100310. constructor(name: string, scene: Scene, options?: {
  100311. updatable?: boolean;
  100312. isPickable?: boolean;
  100313. enableDepthSort?: boolean;
  100314. particleIntersection?: boolean;
  100315. boundingSphereOnly?: boolean;
  100316. bSphereRadiusFactor?: number;
  100317. expandable?: boolean;
  100318. useModelMaterial?: boolean;
  100319. enableMultiMaterial?: boolean;
  100320. });
  100321. /**
  100322. * Builds the SPS underlying mesh. Returns a standard Mesh.
  100323. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  100324. * @returns the created mesh
  100325. */
  100326. buildMesh(): Mesh;
  100327. /**
  100328. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  100329. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  100330. * Thus the particles generated from `digest()` have their property `position` set yet.
  100331. * @param mesh ( Mesh ) is the mesh to be digested
  100332. * @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
  100333. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  100334. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  100335. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100336. * @returns the current SPS
  100337. */
  100338. digest(mesh: Mesh, options?: {
  100339. facetNb?: number;
  100340. number?: number;
  100341. delta?: number;
  100342. storage?: [];
  100343. }): SolidParticleSystem;
  100344. /**
  100345. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  100346. * @hidden
  100347. */
  100348. private _unrotateFixedNormals;
  100349. /**
  100350. * Resets the temporary working copy particle
  100351. * @hidden
  100352. */
  100353. private _resetCopy;
  100354. /**
  100355. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  100356. * @param p the current index in the positions array to be updated
  100357. * @param ind the current index in the indices array
  100358. * @param shape a Vector3 array, the shape geometry
  100359. * @param positions the positions array to be updated
  100360. * @param meshInd the shape indices array
  100361. * @param indices the indices array to be updated
  100362. * @param meshUV the shape uv array
  100363. * @param uvs the uv array to be updated
  100364. * @param meshCol the shape color array
  100365. * @param colors the color array to be updated
  100366. * @param meshNor the shape normals array
  100367. * @param normals the normals array to be updated
  100368. * @param idx the particle index
  100369. * @param idxInShape the particle index in its shape
  100370. * @param options the addShape() method passed options
  100371. * @model the particle model
  100372. * @hidden
  100373. */
  100374. private _meshBuilder;
  100375. /**
  100376. * Returns a shape Vector3 array from positions float array
  100377. * @param positions float array
  100378. * @returns a vector3 array
  100379. * @hidden
  100380. */
  100381. private _posToShape;
  100382. /**
  100383. * Returns a shapeUV array from a float uvs (array deep copy)
  100384. * @param uvs as a float array
  100385. * @returns a shapeUV array
  100386. * @hidden
  100387. */
  100388. private _uvsToShapeUV;
  100389. /**
  100390. * Adds a new particle object in the particles array
  100391. * @param idx particle index in particles array
  100392. * @param id particle id
  100393. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  100394. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  100395. * @param model particle ModelShape object
  100396. * @param shapeId model shape identifier
  100397. * @param idxInShape index of the particle in the current model
  100398. * @param bInfo model bounding info object
  100399. * @param storage target storage array, if any
  100400. * @hidden
  100401. */
  100402. private _addParticle;
  100403. /**
  100404. * Adds some particles to the SPS from the model shape. Returns the shape id.
  100405. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  100406. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  100407. * @param nb (positive integer) the number of particles to be created from this model
  100408. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  100409. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  100410. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100411. * @returns the number of shapes in the system
  100412. */
  100413. addShape(mesh: Mesh, nb: number, options?: {
  100414. positionFunction?: any;
  100415. vertexFunction?: any;
  100416. storage?: [];
  100417. }): number;
  100418. /**
  100419. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  100420. * @hidden
  100421. */
  100422. private _rebuildParticle;
  100423. /**
  100424. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  100425. * @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.
  100426. * @returns the SPS.
  100427. */
  100428. rebuildMesh(reset?: boolean): SolidParticleSystem;
  100429. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  100430. * Returns an array with the removed particles.
  100431. * 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.
  100432. * The SPS can't be empty so at least one particle needs to remain in place.
  100433. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  100434. * @param start index of the first particle to remove
  100435. * @param end index of the last particle to remove (included)
  100436. * @returns an array populated with the removed particles
  100437. */
  100438. removeParticles(start: number, end: number): SolidParticle[];
  100439. /**
  100440. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  100441. * @param solidParticleArray an array populated with Solid Particles objects
  100442. * @returns the SPS
  100443. */
  100444. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  100445. /**
  100446. * Creates a new particle and modifies the SPS mesh geometry :
  100447. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  100448. * - calls _addParticle() to populate the particle array
  100449. * factorized code from addShape() and insertParticlesFromArray()
  100450. * @param idx particle index in the particles array
  100451. * @param i particle index in its shape
  100452. * @param modelShape particle ModelShape object
  100453. * @param shape shape vertex array
  100454. * @param meshInd shape indices array
  100455. * @param meshUV shape uv array
  100456. * @param meshCol shape color array
  100457. * @param meshNor shape normals array
  100458. * @param bbInfo shape bounding info
  100459. * @param storage target particle storage
  100460. * @options addShape() passed options
  100461. * @hidden
  100462. */
  100463. private _insertNewParticle;
  100464. /**
  100465. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  100466. * This method calls `updateParticle()` for each particle of the SPS.
  100467. * For an animated SPS, it is usually called within the render loop.
  100468. * 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.
  100469. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  100470. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  100471. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  100472. * @returns the SPS.
  100473. */
  100474. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  100475. /**
  100476. * Disposes the SPS.
  100477. */
  100478. dispose(): void;
  100479. /**
  100480. * Returns a SolidParticle object from its identifier : particle.id
  100481. * @param id (integer) the particle Id
  100482. * @returns the searched particle or null if not found in the SPS.
  100483. */
  100484. getParticleById(id: number): Nullable<SolidParticle>;
  100485. /**
  100486. * Returns a new array populated with the particles having the passed shapeId.
  100487. * @param shapeId (integer) the shape identifier
  100488. * @returns a new solid particle array
  100489. */
  100490. getParticlesByShapeId(shapeId: number): SolidParticle[];
  100491. /**
  100492. * Populates the passed array "ref" with the particles having the passed shapeId.
  100493. * @param shapeId the shape identifier
  100494. * @returns the SPS
  100495. * @param ref
  100496. */
  100497. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  100498. /**
  100499. * Computes the required SubMeshes according the materials assigned to the particles.
  100500. * @returns the solid particle system.
  100501. * Does nothing if called before the SPS mesh is built.
  100502. */
  100503. computeSubMeshes(): SolidParticleSystem;
  100504. /**
  100505. * Sorts the solid particles by material when MultiMaterial is enabled.
  100506. * Updates the indices32 array.
  100507. * Updates the indicesByMaterial array.
  100508. * Updates the mesh indices array.
  100509. * @returns the SPS
  100510. * @hidden
  100511. */
  100512. private _sortParticlesByMaterial;
  100513. /**
  100514. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  100515. * @hidden
  100516. */
  100517. private _setMaterialIndexesById;
  100518. /**
  100519. * Returns an array with unique values of Materials from the passed array
  100520. * @param array the material array to be checked and filtered
  100521. * @hidden
  100522. */
  100523. private _filterUniqueMaterialId;
  100524. /**
  100525. * Sets a new Standard Material as _defaultMaterial if not already set.
  100526. * @hidden
  100527. */
  100528. private _setDefaultMaterial;
  100529. /**
  100530. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  100531. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100532. * @returns the SPS.
  100533. */
  100534. refreshVisibleSize(): SolidParticleSystem;
  100535. /**
  100536. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  100537. * @param size the size (float) of the visibility box
  100538. * note : this doesn't lock the SPS mesh bounding box.
  100539. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100540. */
  100541. setVisibilityBox(size: number): void;
  100542. /**
  100543. * Gets whether the SPS as always visible or not
  100544. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100545. */
  100546. get isAlwaysVisible(): boolean;
  100547. /**
  100548. * Sets the SPS as always visible or not
  100549. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100550. */
  100551. set isAlwaysVisible(val: boolean);
  100552. /**
  100553. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100554. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100555. */
  100556. set isVisibilityBoxLocked(val: boolean);
  100557. /**
  100558. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100559. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100560. */
  100561. get isVisibilityBoxLocked(): boolean;
  100562. /**
  100563. * Tells to `setParticles()` to compute the particle rotations or not.
  100564. * Default value : true. The SPS is faster when it's set to false.
  100565. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100566. */
  100567. set computeParticleRotation(val: boolean);
  100568. /**
  100569. * Tells to `setParticles()` to compute the particle colors or not.
  100570. * Default value : true. The SPS is faster when it's set to false.
  100571. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100572. */
  100573. set computeParticleColor(val: boolean);
  100574. set computeParticleTexture(val: boolean);
  100575. /**
  100576. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  100577. * Default value : false. The SPS is faster when it's set to false.
  100578. * Note : the particle custom vertex positions aren't stored values.
  100579. */
  100580. set computeParticleVertex(val: boolean);
  100581. /**
  100582. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  100583. */
  100584. set computeBoundingBox(val: boolean);
  100585. /**
  100586. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  100587. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100588. * Default : `true`
  100589. */
  100590. set depthSortParticles(val: boolean);
  100591. /**
  100592. * Gets if `setParticles()` computes the particle rotations or not.
  100593. * Default value : true. The SPS is faster when it's set to false.
  100594. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100595. */
  100596. get computeParticleRotation(): boolean;
  100597. /**
  100598. * Gets if `setParticles()` computes the particle colors or not.
  100599. * Default value : true. The SPS is faster when it's set to false.
  100600. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100601. */
  100602. get computeParticleColor(): boolean;
  100603. /**
  100604. * Gets if `setParticles()` computes the particle textures or not.
  100605. * Default value : true. The SPS is faster when it's set to false.
  100606. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  100607. */
  100608. get computeParticleTexture(): boolean;
  100609. /**
  100610. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  100611. * Default value : false. The SPS is faster when it's set to false.
  100612. * Note : the particle custom vertex positions aren't stored values.
  100613. */
  100614. get computeParticleVertex(): boolean;
  100615. /**
  100616. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  100617. */
  100618. get computeBoundingBox(): boolean;
  100619. /**
  100620. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  100621. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100622. * Default : `true`
  100623. */
  100624. get depthSortParticles(): boolean;
  100625. /**
  100626. * Gets if the SPS is created as expandable at construction time.
  100627. * Default : `false`
  100628. */
  100629. get expandable(): boolean;
  100630. /**
  100631. * Gets if the SPS supports the Multi Materials
  100632. */
  100633. get multimaterialEnabled(): boolean;
  100634. /**
  100635. * Gets if the SPS uses the model materials for its own multimaterial.
  100636. */
  100637. get useModelMaterial(): boolean;
  100638. /**
  100639. * The SPS used material array.
  100640. */
  100641. get materials(): Material[];
  100642. /**
  100643. * Sets the SPS MultiMaterial from the passed materials.
  100644. * Note : the passed array is internally copied and not used then by reference.
  100645. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  100646. */
  100647. setMultiMaterial(materials: Material[]): void;
  100648. /**
  100649. * The SPS computed multimaterial object
  100650. */
  100651. get multimaterial(): MultiMaterial;
  100652. set multimaterial(mm: MultiMaterial);
  100653. /**
  100654. * If the subMeshes must be updated on the next call to setParticles()
  100655. */
  100656. get autoUpdateSubMeshes(): boolean;
  100657. set autoUpdateSubMeshes(val: boolean);
  100658. /**
  100659. * This function does nothing. It may be overwritten to set all the particle first values.
  100660. * The SPS doesn't call this function, you may have to call it by your own.
  100661. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100662. */
  100663. initParticles(): void;
  100664. /**
  100665. * This function does nothing. It may be overwritten to recycle a particle.
  100666. * The SPS doesn't call this function, you may have to call it by your own.
  100667. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100668. * @param particle The particle to recycle
  100669. * @returns the recycled particle
  100670. */
  100671. recycleParticle(particle: SolidParticle): SolidParticle;
  100672. /**
  100673. * Updates a particle : this function should be overwritten by the user.
  100674. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  100675. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100676. * @example : just set a particle position or velocity and recycle conditions
  100677. * @param particle The particle to update
  100678. * @returns the updated particle
  100679. */
  100680. updateParticle(particle: SolidParticle): SolidParticle;
  100681. /**
  100682. * Updates a vertex of a particle : it can be overwritten by the user.
  100683. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  100684. * @param particle the current particle
  100685. * @param vertex the current index of the current particle
  100686. * @param pt the index of the current vertex in the particle shape
  100687. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  100688. * @example : just set a vertex particle position
  100689. * @returns the updated vertex
  100690. */
  100691. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  100692. /**
  100693. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  100694. * This does nothing and may be overwritten by the user.
  100695. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100696. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100697. * @param update the boolean update value actually passed to setParticles()
  100698. */
  100699. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100700. /**
  100701. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  100702. * This will be passed three parameters.
  100703. * This does nothing and may be overwritten by the user.
  100704. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100705. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100706. * @param update the boolean update value actually passed to setParticles()
  100707. */
  100708. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100709. }
  100710. }
  100711. declare module BABYLON {
  100712. /**
  100713. * Represents one particle of a solid particle system.
  100714. */
  100715. export class SolidParticle {
  100716. /**
  100717. * particle global index
  100718. */
  100719. idx: number;
  100720. /**
  100721. * particle identifier
  100722. */
  100723. id: number;
  100724. /**
  100725. * The color of the particle
  100726. */
  100727. color: Nullable<Color4>;
  100728. /**
  100729. * The world space position of the particle.
  100730. */
  100731. position: Vector3;
  100732. /**
  100733. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  100734. */
  100735. rotation: Vector3;
  100736. /**
  100737. * The world space rotation quaternion of the particle.
  100738. */
  100739. rotationQuaternion: Nullable<Quaternion>;
  100740. /**
  100741. * The scaling of the particle.
  100742. */
  100743. scaling: Vector3;
  100744. /**
  100745. * The uvs of the particle.
  100746. */
  100747. uvs: Vector4;
  100748. /**
  100749. * The current speed of the particle.
  100750. */
  100751. velocity: Vector3;
  100752. /**
  100753. * The pivot point in the particle local space.
  100754. */
  100755. pivot: Vector3;
  100756. /**
  100757. * Must the particle be translated from its pivot point in its local space ?
  100758. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  100759. * Default : false
  100760. */
  100761. translateFromPivot: boolean;
  100762. /**
  100763. * Is the particle active or not ?
  100764. */
  100765. alive: boolean;
  100766. /**
  100767. * Is the particle visible or not ?
  100768. */
  100769. isVisible: boolean;
  100770. /**
  100771. * Index of this particle in the global "positions" array (Internal use)
  100772. * @hidden
  100773. */
  100774. _pos: number;
  100775. /**
  100776. * @hidden Index of this particle in the global "indices" array (Internal use)
  100777. */
  100778. _ind: number;
  100779. /**
  100780. * @hidden ModelShape of this particle (Internal use)
  100781. */
  100782. _model: ModelShape;
  100783. /**
  100784. * ModelShape id of this particle
  100785. */
  100786. shapeId: number;
  100787. /**
  100788. * Index of the particle in its shape id
  100789. */
  100790. idxInShape: number;
  100791. /**
  100792. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  100793. */
  100794. _modelBoundingInfo: BoundingInfo;
  100795. /**
  100796. * @hidden Particle BoundingInfo object (Internal use)
  100797. */
  100798. _boundingInfo: BoundingInfo;
  100799. /**
  100800. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  100801. */
  100802. _sps: SolidParticleSystem;
  100803. /**
  100804. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  100805. */
  100806. _stillInvisible: boolean;
  100807. /**
  100808. * @hidden Last computed particle rotation matrix
  100809. */
  100810. _rotationMatrix: number[];
  100811. /**
  100812. * Parent particle Id, if any.
  100813. * Default null.
  100814. */
  100815. parentId: Nullable<number>;
  100816. /**
  100817. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  100818. */
  100819. materialIndex: Nullable<number>;
  100820. /**
  100821. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  100822. * The possible values are :
  100823. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100824. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100825. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100826. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100827. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100828. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  100829. * */
  100830. cullingStrategy: number;
  100831. /**
  100832. * @hidden Internal global position in the SPS.
  100833. */
  100834. _globalPosition: Vector3;
  100835. /**
  100836. * Creates a Solid Particle object.
  100837. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  100838. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  100839. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  100840. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  100841. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  100842. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  100843. * @param shapeId (integer) is the model shape identifier in the SPS.
  100844. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  100845. * @param sps defines the sps it is associated to
  100846. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  100847. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  100848. */
  100849. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  100850. /**
  100851. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  100852. * @param target the particle target
  100853. * @returns the current particle
  100854. */
  100855. copyToRef(target: SolidParticle): SolidParticle;
  100856. /**
  100857. * Legacy support, changed scale to scaling
  100858. */
  100859. get scale(): Vector3;
  100860. /**
  100861. * Legacy support, changed scale to scaling
  100862. */
  100863. set scale(scale: Vector3);
  100864. /**
  100865. * Legacy support, changed quaternion to rotationQuaternion
  100866. */
  100867. get quaternion(): Nullable<Quaternion>;
  100868. /**
  100869. * Legacy support, changed quaternion to rotationQuaternion
  100870. */
  100871. set quaternion(q: Nullable<Quaternion>);
  100872. /**
  100873. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  100874. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  100875. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  100876. * @returns true if it intersects
  100877. */
  100878. intersectsMesh(target: Mesh | SolidParticle): boolean;
  100879. /**
  100880. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  100881. * A particle is in the frustum if its bounding box intersects the frustum
  100882. * @param frustumPlanes defines the frustum to test
  100883. * @returns true if the particle is in the frustum planes
  100884. */
  100885. isInFrustum(frustumPlanes: Plane[]): boolean;
  100886. /**
  100887. * get the rotation matrix of the particle
  100888. * @hidden
  100889. */
  100890. getRotationMatrix(m: Matrix): void;
  100891. }
  100892. /**
  100893. * Represents the shape of the model used by one particle of a solid particle system.
  100894. * SPS internal tool, don't use it manually.
  100895. */
  100896. export class ModelShape {
  100897. /**
  100898. * The shape id
  100899. * @hidden
  100900. */
  100901. shapeID: number;
  100902. /**
  100903. * flat array of model positions (internal use)
  100904. * @hidden
  100905. */
  100906. _shape: Vector3[];
  100907. /**
  100908. * flat array of model UVs (internal use)
  100909. * @hidden
  100910. */
  100911. _shapeUV: number[];
  100912. /**
  100913. * color array of the model
  100914. * @hidden
  100915. */
  100916. _shapeColors: number[];
  100917. /**
  100918. * indices array of the model
  100919. * @hidden
  100920. */
  100921. _indices: number[];
  100922. /**
  100923. * normals array of the model
  100924. * @hidden
  100925. */
  100926. _normals: number[];
  100927. /**
  100928. * length of the shape in the model indices array (internal use)
  100929. * @hidden
  100930. */
  100931. _indicesLength: number;
  100932. /**
  100933. * Custom position function (internal use)
  100934. * @hidden
  100935. */
  100936. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  100937. /**
  100938. * Custom vertex function (internal use)
  100939. * @hidden
  100940. */
  100941. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  100942. /**
  100943. * Model material (internal use)
  100944. * @hidden
  100945. */
  100946. _material: Nullable<Material>;
  100947. /**
  100948. * 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.
  100949. * SPS internal tool, don't use it manually.
  100950. * @hidden
  100951. */
  100952. 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>);
  100953. }
  100954. /**
  100955. * Represents a Depth Sorted Particle in the solid particle system.
  100956. * @hidden
  100957. */
  100958. export class DepthSortedParticle {
  100959. /**
  100960. * Index of the particle in the "indices" array
  100961. */
  100962. ind: number;
  100963. /**
  100964. * Length of the particle shape in the "indices" array
  100965. */
  100966. indicesLength: number;
  100967. /**
  100968. * Squared distance from the particle to the camera
  100969. */
  100970. sqDistance: number;
  100971. /**
  100972. * Material index when used with MultiMaterials
  100973. */
  100974. materialIndex: number;
  100975. /**
  100976. * Creates a new sorted particle
  100977. * @param materialIndex
  100978. */
  100979. constructor(ind: number, indLength: number, materialIndex: number);
  100980. }
  100981. }
  100982. declare module BABYLON {
  100983. /**
  100984. * @hidden
  100985. */
  100986. export class _MeshCollisionData {
  100987. _checkCollisions: boolean;
  100988. _collisionMask: number;
  100989. _collisionGroup: number;
  100990. _collider: Nullable<Collider>;
  100991. _oldPositionForCollisions: Vector3;
  100992. _diffPositionForCollisions: Vector3;
  100993. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  100994. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  100995. }
  100996. }
  100997. declare module BABYLON {
  100998. /** @hidden */
  100999. class _FacetDataStorage {
  101000. facetPositions: Vector3[];
  101001. facetNormals: Vector3[];
  101002. facetPartitioning: number[][];
  101003. facetNb: number;
  101004. partitioningSubdivisions: number;
  101005. partitioningBBoxRatio: number;
  101006. facetDataEnabled: boolean;
  101007. facetParameters: any;
  101008. bbSize: Vector3;
  101009. subDiv: {
  101010. max: number;
  101011. X: number;
  101012. Y: number;
  101013. Z: number;
  101014. };
  101015. facetDepthSort: boolean;
  101016. facetDepthSortEnabled: boolean;
  101017. depthSortedIndices: IndicesArray;
  101018. depthSortedFacets: {
  101019. ind: number;
  101020. sqDistance: number;
  101021. }[];
  101022. facetDepthSortFunction: (f1: {
  101023. ind: number;
  101024. sqDistance: number;
  101025. }, f2: {
  101026. ind: number;
  101027. sqDistance: number;
  101028. }) => number;
  101029. facetDepthSortFrom: Vector3;
  101030. facetDepthSortOrigin: Vector3;
  101031. invertedMatrix: Matrix;
  101032. }
  101033. /**
  101034. * @hidden
  101035. **/
  101036. class _InternalAbstractMeshDataInfo {
  101037. _hasVertexAlpha: boolean;
  101038. _useVertexColors: boolean;
  101039. _numBoneInfluencers: number;
  101040. _applyFog: boolean;
  101041. _receiveShadows: boolean;
  101042. _facetData: _FacetDataStorage;
  101043. _visibility: number;
  101044. _skeleton: Nullable<Skeleton>;
  101045. _layerMask: number;
  101046. _computeBonesUsingShaders: boolean;
  101047. _isActive: boolean;
  101048. _onlyForInstances: boolean;
  101049. _isActiveIntermediate: boolean;
  101050. _onlyForInstancesIntermediate: boolean;
  101051. _actAsRegularMesh: boolean;
  101052. }
  101053. /**
  101054. * Class used to store all common mesh properties
  101055. */
  101056. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  101057. /** No occlusion */
  101058. static OCCLUSION_TYPE_NONE: number;
  101059. /** Occlusion set to optimisitic */
  101060. static OCCLUSION_TYPE_OPTIMISTIC: number;
  101061. /** Occlusion set to strict */
  101062. static OCCLUSION_TYPE_STRICT: number;
  101063. /** Use an accurante occlusion algorithm */
  101064. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  101065. /** Use a conservative occlusion algorithm */
  101066. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  101067. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  101068. * Test order :
  101069. * Is the bounding sphere outside the frustum ?
  101070. * If not, are the bounding box vertices outside the frustum ?
  101071. * It not, then the cullable object is in the frustum.
  101072. */
  101073. static readonly CULLINGSTRATEGY_STANDARD: number;
  101074. /** Culling strategy : Bounding Sphere Only.
  101075. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  101076. * It's also less accurate than the standard because some not visible objects can still be selected.
  101077. * Test : is the bounding sphere outside the frustum ?
  101078. * If not, then the cullable object is in the frustum.
  101079. */
  101080. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  101081. /** Culling strategy : Optimistic Inclusion.
  101082. * This in an inclusion test first, then the standard exclusion test.
  101083. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  101084. * 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.
  101085. * Anyway, it's as accurate as the standard strategy.
  101086. * Test :
  101087. * Is the cullable object bounding sphere center in the frustum ?
  101088. * If not, apply the default culling strategy.
  101089. */
  101090. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  101091. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  101092. * This in an inclusion test first, then the bounding sphere only exclusion test.
  101093. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  101094. * 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.
  101095. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  101096. * Test :
  101097. * Is the cullable object bounding sphere center in the frustum ?
  101098. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  101099. */
  101100. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  101101. /**
  101102. * No billboard
  101103. */
  101104. static get BILLBOARDMODE_NONE(): number;
  101105. /** Billboard on X axis */
  101106. static get BILLBOARDMODE_X(): number;
  101107. /** Billboard on Y axis */
  101108. static get BILLBOARDMODE_Y(): number;
  101109. /** Billboard on Z axis */
  101110. static get BILLBOARDMODE_Z(): number;
  101111. /** Billboard on all axes */
  101112. static get BILLBOARDMODE_ALL(): number;
  101113. /** Billboard on using position instead of orientation */
  101114. static get BILLBOARDMODE_USE_POSITION(): number;
  101115. /** @hidden */
  101116. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  101117. /**
  101118. * The culling strategy to use to check whether the mesh must be rendered or not.
  101119. * This value can be changed at any time and will be used on the next render mesh selection.
  101120. * The possible values are :
  101121. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101122. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101123. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101124. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101125. * Please read each static variable documentation to get details about the culling process.
  101126. * */
  101127. cullingStrategy: number;
  101128. /**
  101129. * Gets the number of facets in the mesh
  101130. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101131. */
  101132. get facetNb(): number;
  101133. /**
  101134. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  101135. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101136. */
  101137. get partitioningSubdivisions(): number;
  101138. set partitioningSubdivisions(nb: number);
  101139. /**
  101140. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  101141. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  101142. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101143. */
  101144. get partitioningBBoxRatio(): number;
  101145. set partitioningBBoxRatio(ratio: number);
  101146. /**
  101147. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  101148. * Works only for updatable meshes.
  101149. * Doesn't work with multi-materials
  101150. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101151. */
  101152. get mustDepthSortFacets(): boolean;
  101153. set mustDepthSortFacets(sort: boolean);
  101154. /**
  101155. * The location (Vector3) where the facet depth sort must be computed from.
  101156. * By default, the active camera position.
  101157. * Used only when facet depth sort is enabled
  101158. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101159. */
  101160. get facetDepthSortFrom(): Vector3;
  101161. set facetDepthSortFrom(location: Vector3);
  101162. /**
  101163. * gets a boolean indicating if facetData is enabled
  101164. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101165. */
  101166. get isFacetDataEnabled(): boolean;
  101167. /** @hidden */
  101168. _updateNonUniformScalingState(value: boolean): boolean;
  101169. /**
  101170. * An event triggered when this mesh collides with another one
  101171. */
  101172. onCollideObservable: Observable<AbstractMesh>;
  101173. /** Set a function to call when this mesh collides with another one */
  101174. set onCollide(callback: () => void);
  101175. /**
  101176. * An event triggered when the collision's position changes
  101177. */
  101178. onCollisionPositionChangeObservable: Observable<Vector3>;
  101179. /** Set a function to call when the collision's position changes */
  101180. set onCollisionPositionChange(callback: () => void);
  101181. /**
  101182. * An event triggered when material is changed
  101183. */
  101184. onMaterialChangedObservable: Observable<AbstractMesh>;
  101185. /**
  101186. * Gets or sets the orientation for POV movement & rotation
  101187. */
  101188. definedFacingForward: boolean;
  101189. /** @hidden */
  101190. _occlusionQuery: Nullable<WebGLQuery>;
  101191. /** @hidden */
  101192. _renderingGroup: Nullable<RenderingGroup>;
  101193. /**
  101194. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101195. */
  101196. get visibility(): number;
  101197. /**
  101198. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101199. */
  101200. set visibility(value: number);
  101201. /** Gets or sets the alpha index used to sort transparent meshes
  101202. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  101203. */
  101204. alphaIndex: number;
  101205. /**
  101206. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  101207. */
  101208. isVisible: boolean;
  101209. /**
  101210. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  101211. */
  101212. isPickable: boolean;
  101213. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  101214. showSubMeshesBoundingBox: boolean;
  101215. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  101216. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101217. */
  101218. isBlocker: boolean;
  101219. /**
  101220. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  101221. */
  101222. enablePointerMoveEvents: boolean;
  101223. /**
  101224. * Specifies the rendering group id for this mesh (0 by default)
  101225. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  101226. */
  101227. renderingGroupId: number;
  101228. private _material;
  101229. /** Gets or sets current material */
  101230. get material(): Nullable<Material>;
  101231. set material(value: Nullable<Material>);
  101232. /**
  101233. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  101234. * @see http://doc.babylonjs.com/babylon101/shadows
  101235. */
  101236. get receiveShadows(): boolean;
  101237. set receiveShadows(value: boolean);
  101238. /** Defines color to use when rendering outline */
  101239. outlineColor: Color3;
  101240. /** Define width to use when rendering outline */
  101241. outlineWidth: number;
  101242. /** Defines color to use when rendering overlay */
  101243. overlayColor: Color3;
  101244. /** Defines alpha to use when rendering overlay */
  101245. overlayAlpha: number;
  101246. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  101247. get hasVertexAlpha(): boolean;
  101248. set hasVertexAlpha(value: boolean);
  101249. /** 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) */
  101250. get useVertexColors(): boolean;
  101251. set useVertexColors(value: boolean);
  101252. /**
  101253. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  101254. */
  101255. get computeBonesUsingShaders(): boolean;
  101256. set computeBonesUsingShaders(value: boolean);
  101257. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  101258. get numBoneInfluencers(): number;
  101259. set numBoneInfluencers(value: number);
  101260. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  101261. get applyFog(): boolean;
  101262. set applyFog(value: boolean);
  101263. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  101264. useOctreeForRenderingSelection: boolean;
  101265. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  101266. useOctreeForPicking: boolean;
  101267. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  101268. useOctreeForCollisions: boolean;
  101269. /**
  101270. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  101271. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  101272. */
  101273. get layerMask(): number;
  101274. set layerMask(value: number);
  101275. /**
  101276. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  101277. */
  101278. alwaysSelectAsActiveMesh: boolean;
  101279. /**
  101280. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  101281. */
  101282. doNotSyncBoundingInfo: boolean;
  101283. /**
  101284. * Gets or sets the current action manager
  101285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101286. */
  101287. actionManager: Nullable<AbstractActionManager>;
  101288. private _meshCollisionData;
  101289. /**
  101290. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  101291. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101292. */
  101293. ellipsoid: Vector3;
  101294. /**
  101295. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  101296. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101297. */
  101298. ellipsoidOffset: Vector3;
  101299. /**
  101300. * Gets or sets a collision mask used to mask collisions (default is -1).
  101301. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101302. */
  101303. get collisionMask(): number;
  101304. set collisionMask(mask: number);
  101305. /**
  101306. * Gets or sets the current collision group mask (-1 by default).
  101307. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101308. */
  101309. get collisionGroup(): number;
  101310. set collisionGroup(mask: number);
  101311. /**
  101312. * Defines edge width used when edgesRenderer is enabled
  101313. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101314. */
  101315. edgesWidth: number;
  101316. /**
  101317. * Defines edge color used when edgesRenderer is enabled
  101318. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101319. */
  101320. edgesColor: Color4;
  101321. /** @hidden */
  101322. _edgesRenderer: Nullable<IEdgesRenderer>;
  101323. /** @hidden */
  101324. _masterMesh: Nullable<AbstractMesh>;
  101325. /** @hidden */
  101326. _boundingInfo: Nullable<BoundingInfo>;
  101327. /** @hidden */
  101328. _renderId: number;
  101329. /**
  101330. * Gets or sets the list of subMeshes
  101331. * @see http://doc.babylonjs.com/how_to/multi_materials
  101332. */
  101333. subMeshes: SubMesh[];
  101334. /** @hidden */
  101335. _intersectionsInProgress: AbstractMesh[];
  101336. /** @hidden */
  101337. _unIndexed: boolean;
  101338. /** @hidden */
  101339. _lightSources: Light[];
  101340. /** Gets the list of lights affecting that mesh */
  101341. get lightSources(): Light[];
  101342. /** @hidden */
  101343. get _positions(): Nullable<Vector3[]>;
  101344. /** @hidden */
  101345. _waitingData: {
  101346. lods: Nullable<any>;
  101347. actions: Nullable<any>;
  101348. freezeWorldMatrix: Nullable<boolean>;
  101349. };
  101350. /** @hidden */
  101351. _bonesTransformMatrices: Nullable<Float32Array>;
  101352. /** @hidden */
  101353. _transformMatrixTexture: Nullable<RawTexture>;
  101354. /**
  101355. * Gets or sets a skeleton to apply skining transformations
  101356. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101357. */
  101358. set skeleton(value: Nullable<Skeleton>);
  101359. get skeleton(): Nullable<Skeleton>;
  101360. /**
  101361. * An event triggered when the mesh is rebuilt.
  101362. */
  101363. onRebuildObservable: Observable<AbstractMesh>;
  101364. /**
  101365. * Creates a new AbstractMesh
  101366. * @param name defines the name of the mesh
  101367. * @param scene defines the hosting scene
  101368. */
  101369. constructor(name: string, scene?: Nullable<Scene>);
  101370. /**
  101371. * Returns the string "AbstractMesh"
  101372. * @returns "AbstractMesh"
  101373. */
  101374. getClassName(): string;
  101375. /**
  101376. * Gets a string representation of the current mesh
  101377. * @param fullDetails defines a boolean indicating if full details must be included
  101378. * @returns a string representation of the current mesh
  101379. */
  101380. toString(fullDetails?: boolean): string;
  101381. /**
  101382. * @hidden
  101383. */
  101384. protected _getEffectiveParent(): Nullable<Node>;
  101385. /** @hidden */
  101386. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101387. /** @hidden */
  101388. _rebuild(): void;
  101389. /** @hidden */
  101390. _resyncLightSources(): void;
  101391. /** @hidden */
  101392. _resyncLightSource(light: Light): void;
  101393. /** @hidden */
  101394. _unBindEffect(): void;
  101395. /** @hidden */
  101396. _removeLightSource(light: Light, dispose: boolean): void;
  101397. private _markSubMeshesAsDirty;
  101398. /** @hidden */
  101399. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  101400. /** @hidden */
  101401. _markSubMeshesAsAttributesDirty(): void;
  101402. /** @hidden */
  101403. _markSubMeshesAsMiscDirty(): void;
  101404. /**
  101405. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  101406. */
  101407. get scaling(): Vector3;
  101408. set scaling(newScaling: Vector3);
  101409. /**
  101410. * Returns true if the mesh is blocked. Implemented by child classes
  101411. */
  101412. get isBlocked(): boolean;
  101413. /**
  101414. * Returns the mesh itself by default. Implemented by child classes
  101415. * @param camera defines the camera to use to pick the right LOD level
  101416. * @returns the currentAbstractMesh
  101417. */
  101418. getLOD(camera: Camera): Nullable<AbstractMesh>;
  101419. /**
  101420. * Returns 0 by default. Implemented by child classes
  101421. * @returns an integer
  101422. */
  101423. getTotalVertices(): number;
  101424. /**
  101425. * Returns a positive integer : the total number of indices in this mesh geometry.
  101426. * @returns the numner of indices or zero if the mesh has no geometry.
  101427. */
  101428. getTotalIndices(): number;
  101429. /**
  101430. * Returns null by default. Implemented by child classes
  101431. * @returns null
  101432. */
  101433. getIndices(): Nullable<IndicesArray>;
  101434. /**
  101435. * Returns the array of the requested vertex data kind. Implemented by child classes
  101436. * @param kind defines the vertex data kind to use
  101437. * @returns null
  101438. */
  101439. getVerticesData(kind: string): Nullable<FloatArray>;
  101440. /**
  101441. * Sets the vertex data of the mesh geometry for the requested `kind`.
  101442. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  101443. * Note that a new underlying VertexBuffer object is created each call.
  101444. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  101445. * @param kind defines vertex data kind:
  101446. * * VertexBuffer.PositionKind
  101447. * * VertexBuffer.UVKind
  101448. * * VertexBuffer.UV2Kind
  101449. * * VertexBuffer.UV3Kind
  101450. * * VertexBuffer.UV4Kind
  101451. * * VertexBuffer.UV5Kind
  101452. * * VertexBuffer.UV6Kind
  101453. * * VertexBuffer.ColorKind
  101454. * * VertexBuffer.MatricesIndicesKind
  101455. * * VertexBuffer.MatricesIndicesExtraKind
  101456. * * VertexBuffer.MatricesWeightsKind
  101457. * * VertexBuffer.MatricesWeightsExtraKind
  101458. * @param data defines the data source
  101459. * @param updatable defines if the data must be flagged as updatable (or static)
  101460. * @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
  101461. * @returns the current mesh
  101462. */
  101463. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101464. /**
  101465. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  101466. * If the mesh has no geometry, it is simply returned as it is.
  101467. * @param kind defines vertex data kind:
  101468. * * VertexBuffer.PositionKind
  101469. * * VertexBuffer.UVKind
  101470. * * VertexBuffer.UV2Kind
  101471. * * VertexBuffer.UV3Kind
  101472. * * VertexBuffer.UV4Kind
  101473. * * VertexBuffer.UV5Kind
  101474. * * VertexBuffer.UV6Kind
  101475. * * VertexBuffer.ColorKind
  101476. * * VertexBuffer.MatricesIndicesKind
  101477. * * VertexBuffer.MatricesIndicesExtraKind
  101478. * * VertexBuffer.MatricesWeightsKind
  101479. * * VertexBuffer.MatricesWeightsExtraKind
  101480. * @param data defines the data source
  101481. * @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
  101482. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  101483. * @returns the current mesh
  101484. */
  101485. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101486. /**
  101487. * Sets the mesh indices,
  101488. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  101489. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  101490. * @param totalVertices Defines the total number of vertices
  101491. * @returns the current mesh
  101492. */
  101493. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  101494. /**
  101495. * Gets a boolean indicating if specific vertex data is present
  101496. * @param kind defines the vertex data kind to use
  101497. * @returns true is data kind is present
  101498. */
  101499. isVerticesDataPresent(kind: string): boolean;
  101500. /**
  101501. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  101502. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  101503. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  101504. * @returns a BoundingInfo
  101505. */
  101506. getBoundingInfo(): BoundingInfo;
  101507. /**
  101508. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  101509. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  101510. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  101511. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  101512. * @returns the current mesh
  101513. */
  101514. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  101515. /**
  101516. * Overwrite the current bounding info
  101517. * @param boundingInfo defines the new bounding info
  101518. * @returns the current mesh
  101519. */
  101520. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  101521. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  101522. get useBones(): boolean;
  101523. /** @hidden */
  101524. _preActivate(): void;
  101525. /** @hidden */
  101526. _preActivateForIntermediateRendering(renderId: number): void;
  101527. /** @hidden */
  101528. _activate(renderId: number, intermediateRendering: boolean): boolean;
  101529. /** @hidden */
  101530. _postActivate(): void;
  101531. /** @hidden */
  101532. _freeze(): void;
  101533. /** @hidden */
  101534. _unFreeze(): void;
  101535. /**
  101536. * Gets the current world matrix
  101537. * @returns a Matrix
  101538. */
  101539. getWorldMatrix(): Matrix;
  101540. /** @hidden */
  101541. _getWorldMatrixDeterminant(): number;
  101542. /**
  101543. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  101544. */
  101545. get isAnInstance(): boolean;
  101546. /**
  101547. * Gets a boolean indicating if this mesh has instances
  101548. */
  101549. get hasInstances(): boolean;
  101550. /**
  101551. * Perform relative position change from the point of view of behind the front of the mesh.
  101552. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101553. * Supports definition of mesh facing forward or backward
  101554. * @param amountRight defines the distance on the right axis
  101555. * @param amountUp defines the distance on the up axis
  101556. * @param amountForward defines the distance on the forward axis
  101557. * @returns the current mesh
  101558. */
  101559. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  101560. /**
  101561. * Calculate relative position change from the point of view of behind the front of the mesh.
  101562. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101563. * Supports definition of mesh facing forward or backward
  101564. * @param amountRight defines the distance on the right axis
  101565. * @param amountUp defines the distance on the up axis
  101566. * @param amountForward defines the distance on the forward axis
  101567. * @returns the new displacement vector
  101568. */
  101569. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  101570. /**
  101571. * Perform relative rotation change from the point of view of behind the front of the mesh.
  101572. * Supports definition of mesh facing forward or backward
  101573. * @param flipBack defines the flip
  101574. * @param twirlClockwise defines the twirl
  101575. * @param tiltRight defines the tilt
  101576. * @returns the current mesh
  101577. */
  101578. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  101579. /**
  101580. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  101581. * Supports definition of mesh facing forward or backward.
  101582. * @param flipBack defines the flip
  101583. * @param twirlClockwise defines the twirl
  101584. * @param tiltRight defines the tilt
  101585. * @returns the new rotation vector
  101586. */
  101587. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  101588. /**
  101589. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101590. * This means the mesh underlying bounding box and sphere are recomputed.
  101591. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101592. * @returns the current mesh
  101593. */
  101594. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  101595. /** @hidden */
  101596. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  101597. /** @hidden */
  101598. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  101599. /** @hidden */
  101600. _updateBoundingInfo(): AbstractMesh;
  101601. /** @hidden */
  101602. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  101603. /** @hidden */
  101604. protected _afterComputeWorldMatrix(): void;
  101605. /** @hidden */
  101606. get _effectiveMesh(): AbstractMesh;
  101607. /**
  101608. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101609. * A mesh is in the frustum if its bounding box intersects the frustum
  101610. * @param frustumPlanes defines the frustum to test
  101611. * @returns true if the mesh is in the frustum planes
  101612. */
  101613. isInFrustum(frustumPlanes: Plane[]): boolean;
  101614. /**
  101615. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  101616. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  101617. * @param frustumPlanes defines the frustum to test
  101618. * @returns true if the mesh is completely in the frustum planes
  101619. */
  101620. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101621. /**
  101622. * True if the mesh intersects another mesh or a SolidParticle object
  101623. * @param mesh defines a target mesh or SolidParticle to test
  101624. * @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)
  101625. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  101626. * @returns true if there is an intersection
  101627. */
  101628. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  101629. /**
  101630. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  101631. * @param point defines the point to test
  101632. * @returns true if there is an intersection
  101633. */
  101634. intersectsPoint(point: Vector3): boolean;
  101635. /**
  101636. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  101637. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101638. */
  101639. get checkCollisions(): boolean;
  101640. set checkCollisions(collisionEnabled: boolean);
  101641. /**
  101642. * Gets Collider object used to compute collisions (not physics)
  101643. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101644. */
  101645. get collider(): Nullable<Collider>;
  101646. /**
  101647. * Move the mesh using collision engine
  101648. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101649. * @param displacement defines the requested displacement vector
  101650. * @returns the current mesh
  101651. */
  101652. moveWithCollisions(displacement: Vector3): AbstractMesh;
  101653. private _onCollisionPositionChange;
  101654. /** @hidden */
  101655. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  101656. /** @hidden */
  101657. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  101658. /** @hidden */
  101659. _checkCollision(collider: Collider): AbstractMesh;
  101660. /** @hidden */
  101661. _generatePointsArray(): boolean;
  101662. /**
  101663. * Checks if the passed Ray intersects with the mesh
  101664. * @param ray defines the ray to use
  101665. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  101666. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101667. * @returns the picking info
  101668. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  101669. */
  101670. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  101671. /**
  101672. * Clones the current mesh
  101673. * @param name defines the mesh name
  101674. * @param newParent defines the new mesh parent
  101675. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  101676. * @returns the new mesh
  101677. */
  101678. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  101679. /**
  101680. * Disposes all the submeshes of the current meshnp
  101681. * @returns the current mesh
  101682. */
  101683. releaseSubMeshes(): AbstractMesh;
  101684. /**
  101685. * Releases resources associated with this abstract mesh.
  101686. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101687. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101688. */
  101689. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101690. /**
  101691. * Adds the passed mesh as a child to the current mesh
  101692. * @param mesh defines the child mesh
  101693. * @returns the current mesh
  101694. */
  101695. addChild(mesh: AbstractMesh): AbstractMesh;
  101696. /**
  101697. * Removes the passed mesh from the current mesh children list
  101698. * @param mesh defines the child mesh
  101699. * @returns the current mesh
  101700. */
  101701. removeChild(mesh: AbstractMesh): AbstractMesh;
  101702. /** @hidden */
  101703. private _initFacetData;
  101704. /**
  101705. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  101706. * This method can be called within the render loop.
  101707. * 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
  101708. * @returns the current mesh
  101709. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101710. */
  101711. updateFacetData(): AbstractMesh;
  101712. /**
  101713. * Returns the facetLocalNormals array.
  101714. * The normals are expressed in the mesh local spac
  101715. * @returns an array of Vector3
  101716. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101717. */
  101718. getFacetLocalNormals(): Vector3[];
  101719. /**
  101720. * Returns the facetLocalPositions array.
  101721. * The facet positions are expressed in the mesh local space
  101722. * @returns an array of Vector3
  101723. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101724. */
  101725. getFacetLocalPositions(): Vector3[];
  101726. /**
  101727. * Returns the facetLocalPartioning array
  101728. * @returns an array of array of numbers
  101729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101730. */
  101731. getFacetLocalPartitioning(): number[][];
  101732. /**
  101733. * Returns the i-th facet position in the world system.
  101734. * This method allocates a new Vector3 per call
  101735. * @param i defines the facet index
  101736. * @returns a new Vector3
  101737. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101738. */
  101739. getFacetPosition(i: number): Vector3;
  101740. /**
  101741. * Sets the reference Vector3 with the i-th facet position in the world system
  101742. * @param i defines the facet index
  101743. * @param ref defines the target vector
  101744. * @returns the current mesh
  101745. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101746. */
  101747. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  101748. /**
  101749. * Returns the i-th facet normal in the world system.
  101750. * This method allocates a new Vector3 per call
  101751. * @param i defines the facet index
  101752. * @returns a new Vector3
  101753. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101754. */
  101755. getFacetNormal(i: number): Vector3;
  101756. /**
  101757. * Sets the reference Vector3 with the i-th facet normal in the world system
  101758. * @param i defines the facet index
  101759. * @param ref defines the target vector
  101760. * @returns the current mesh
  101761. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101762. */
  101763. getFacetNormalToRef(i: number, ref: Vector3): this;
  101764. /**
  101765. * 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)
  101766. * @param x defines x coordinate
  101767. * @param y defines y coordinate
  101768. * @param z defines z coordinate
  101769. * @returns the array of facet indexes
  101770. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101771. */
  101772. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  101773. /**
  101774. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  101775. * @param projected sets as the (x,y,z) world projection on the facet
  101776. * @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
  101777. * @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
  101778. * @param x defines x coordinate
  101779. * @param y defines y coordinate
  101780. * @param z defines z coordinate
  101781. * @returns the face index if found (or null instead)
  101782. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101783. */
  101784. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101785. /**
  101786. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  101787. * @param projected sets as the (x,y,z) local projection on the facet
  101788. * @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
  101789. * @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
  101790. * @param x defines x coordinate
  101791. * @param y defines y coordinate
  101792. * @param z defines z coordinate
  101793. * @returns the face index if found (or null instead)
  101794. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101795. */
  101796. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101797. /**
  101798. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  101799. * @returns the parameters
  101800. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101801. */
  101802. getFacetDataParameters(): any;
  101803. /**
  101804. * Disables the feature FacetData and frees the related memory
  101805. * @returns the current mesh
  101806. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101807. */
  101808. disableFacetData(): AbstractMesh;
  101809. /**
  101810. * Updates the AbstractMesh indices array
  101811. * @param indices defines the data source
  101812. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101813. * @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)
  101814. * @returns the current mesh
  101815. */
  101816. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101817. /**
  101818. * Creates new normals data for the mesh
  101819. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  101820. * @returns the current mesh
  101821. */
  101822. createNormals(updatable: boolean): AbstractMesh;
  101823. /**
  101824. * Align the mesh with a normal
  101825. * @param normal defines the normal to use
  101826. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  101827. * @returns the current mesh
  101828. */
  101829. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  101830. /** @hidden */
  101831. _checkOcclusionQuery(): boolean;
  101832. /**
  101833. * Disables the mesh edge rendering mode
  101834. * @returns the currentAbstractMesh
  101835. */
  101836. disableEdgesRendering(): AbstractMesh;
  101837. /**
  101838. * Enables the edge rendering mode on the mesh.
  101839. * This mode makes the mesh edges visible
  101840. * @param epsilon defines the maximal distance between two angles to detect a face
  101841. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  101842. * @returns the currentAbstractMesh
  101843. * @see https://www.babylonjs-playground.com/#19O9TU#0
  101844. */
  101845. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  101846. }
  101847. }
  101848. declare module BABYLON {
  101849. /**
  101850. * Interface used to define ActionEvent
  101851. */
  101852. export interface IActionEvent {
  101853. /** The mesh or sprite that triggered the action */
  101854. source: any;
  101855. /** The X mouse cursor position at the time of the event */
  101856. pointerX: number;
  101857. /** The Y mouse cursor position at the time of the event */
  101858. pointerY: number;
  101859. /** The mesh that is currently pointed at (can be null) */
  101860. meshUnderPointer: Nullable<AbstractMesh>;
  101861. /** the original (browser) event that triggered the ActionEvent */
  101862. sourceEvent?: any;
  101863. /** additional data for the event */
  101864. additionalData?: any;
  101865. }
  101866. /**
  101867. * ActionEvent is the event being sent when an action is triggered.
  101868. */
  101869. export class ActionEvent implements IActionEvent {
  101870. /** The mesh or sprite that triggered the action */
  101871. source: any;
  101872. /** The X mouse cursor position at the time of the event */
  101873. pointerX: number;
  101874. /** The Y mouse cursor position at the time of the event */
  101875. pointerY: number;
  101876. /** The mesh that is currently pointed at (can be null) */
  101877. meshUnderPointer: Nullable<AbstractMesh>;
  101878. /** the original (browser) event that triggered the ActionEvent */
  101879. sourceEvent?: any;
  101880. /** additional data for the event */
  101881. additionalData?: any;
  101882. /**
  101883. * Creates a new ActionEvent
  101884. * @param source The mesh or sprite that triggered the action
  101885. * @param pointerX The X mouse cursor position at the time of the event
  101886. * @param pointerY The Y mouse cursor position at the time of the event
  101887. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  101888. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  101889. * @param additionalData additional data for the event
  101890. */
  101891. constructor(
  101892. /** The mesh or sprite that triggered the action */
  101893. source: any,
  101894. /** The X mouse cursor position at the time of the event */
  101895. pointerX: number,
  101896. /** The Y mouse cursor position at the time of the event */
  101897. pointerY: number,
  101898. /** The mesh that is currently pointed at (can be null) */
  101899. meshUnderPointer: Nullable<AbstractMesh>,
  101900. /** the original (browser) event that triggered the ActionEvent */
  101901. sourceEvent?: any,
  101902. /** additional data for the event */
  101903. additionalData?: any);
  101904. /**
  101905. * Helper function to auto-create an ActionEvent from a source mesh.
  101906. * @param source The source mesh that triggered the event
  101907. * @param evt The original (browser) event
  101908. * @param additionalData additional data for the event
  101909. * @returns the new ActionEvent
  101910. */
  101911. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  101912. /**
  101913. * Helper function to auto-create an ActionEvent from a source sprite
  101914. * @param source The source sprite that triggered the event
  101915. * @param scene Scene associated with the sprite
  101916. * @param evt The original (browser) event
  101917. * @param additionalData additional data for the event
  101918. * @returns the new ActionEvent
  101919. */
  101920. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  101921. /**
  101922. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  101923. * @param scene the scene where the event occurred
  101924. * @param evt The original (browser) event
  101925. * @returns the new ActionEvent
  101926. */
  101927. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  101928. /**
  101929. * Helper function to auto-create an ActionEvent from a primitive
  101930. * @param prim defines the target primitive
  101931. * @param pointerPos defines the pointer position
  101932. * @param evt The original (browser) event
  101933. * @param additionalData additional data for the event
  101934. * @returns the new ActionEvent
  101935. */
  101936. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  101937. }
  101938. }
  101939. declare module BABYLON {
  101940. /**
  101941. * Abstract class used to decouple action Manager from scene and meshes.
  101942. * Do not instantiate.
  101943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101944. */
  101945. export abstract class AbstractActionManager implements IDisposable {
  101946. /** Gets the list of active triggers */
  101947. static Triggers: {
  101948. [key: string]: number;
  101949. };
  101950. /** Gets the cursor to use when hovering items */
  101951. hoverCursor: string;
  101952. /** Gets the list of actions */
  101953. actions: IAction[];
  101954. /**
  101955. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  101956. */
  101957. isRecursive: boolean;
  101958. /**
  101959. * Releases all associated resources
  101960. */
  101961. abstract dispose(): void;
  101962. /**
  101963. * Does this action manager has pointer triggers
  101964. */
  101965. abstract get hasPointerTriggers(): boolean;
  101966. /**
  101967. * Does this action manager has pick triggers
  101968. */
  101969. abstract get hasPickTriggers(): boolean;
  101970. /**
  101971. * Process a specific trigger
  101972. * @param trigger defines the trigger to process
  101973. * @param evt defines the event details to be processed
  101974. */
  101975. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  101976. /**
  101977. * Does this action manager handles actions of any of the given triggers
  101978. * @param triggers defines the triggers to be tested
  101979. * @return a boolean indicating whether one (or more) of the triggers is handled
  101980. */
  101981. abstract hasSpecificTriggers(triggers: number[]): boolean;
  101982. /**
  101983. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  101984. * speed.
  101985. * @param triggerA defines the trigger to be tested
  101986. * @param triggerB defines the trigger to be tested
  101987. * @return a boolean indicating whether one (or more) of the triggers is handled
  101988. */
  101989. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  101990. /**
  101991. * Does this action manager handles actions of a given trigger
  101992. * @param trigger defines the trigger to be tested
  101993. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  101994. * @return whether the trigger is handled
  101995. */
  101996. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  101997. /**
  101998. * Serialize this manager to a JSON object
  101999. * @param name defines the property name to store this manager
  102000. * @returns a JSON representation of this manager
  102001. */
  102002. abstract serialize(name: string): any;
  102003. /**
  102004. * Registers an action to this action manager
  102005. * @param action defines the action to be registered
  102006. * @return the action amended (prepared) after registration
  102007. */
  102008. abstract registerAction(action: IAction): Nullable<IAction>;
  102009. /**
  102010. * Unregisters an action to this action manager
  102011. * @param action defines the action to be unregistered
  102012. * @return a boolean indicating whether the action has been unregistered
  102013. */
  102014. abstract unregisterAction(action: IAction): Boolean;
  102015. /**
  102016. * Does exist one action manager with at least one trigger
  102017. **/
  102018. static get HasTriggers(): boolean;
  102019. /**
  102020. * Does exist one action manager with at least one pick trigger
  102021. **/
  102022. static get HasPickTriggers(): boolean;
  102023. /**
  102024. * Does exist one action manager that handles actions of a given trigger
  102025. * @param trigger defines the trigger to be tested
  102026. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  102027. **/
  102028. static HasSpecificTrigger(trigger: number): boolean;
  102029. }
  102030. }
  102031. declare module BABYLON {
  102032. /**
  102033. * Defines how a node can be built from a string name.
  102034. */
  102035. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  102036. /**
  102037. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  102038. */
  102039. export class Node implements IBehaviorAware<Node> {
  102040. /** @hidden */
  102041. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  102042. private static _NodeConstructors;
  102043. /**
  102044. * Add a new node constructor
  102045. * @param type defines the type name of the node to construct
  102046. * @param constructorFunc defines the constructor function
  102047. */
  102048. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  102049. /**
  102050. * Returns a node constructor based on type name
  102051. * @param type defines the type name
  102052. * @param name defines the new node name
  102053. * @param scene defines the hosting scene
  102054. * @param options defines optional options to transmit to constructors
  102055. * @returns the new constructor or null
  102056. */
  102057. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  102058. /**
  102059. * Gets or sets the name of the node
  102060. */
  102061. name: string;
  102062. /**
  102063. * Gets or sets the id of the node
  102064. */
  102065. id: string;
  102066. /**
  102067. * Gets or sets the unique id of the node
  102068. */
  102069. uniqueId: number;
  102070. /**
  102071. * Gets or sets a string used to store user defined state for the node
  102072. */
  102073. state: string;
  102074. /**
  102075. * Gets or sets an object used to store user defined information for the node
  102076. */
  102077. metadata: any;
  102078. /**
  102079. * For internal use only. Please do not use.
  102080. */
  102081. reservedDataStore: any;
  102082. /**
  102083. * List of inspectable custom properties (used by the Inspector)
  102084. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102085. */
  102086. inspectableCustomProperties: IInspectable[];
  102087. private _doNotSerialize;
  102088. /**
  102089. * Gets or sets a boolean used to define if the node must be serialized
  102090. */
  102091. get doNotSerialize(): boolean;
  102092. set doNotSerialize(value: boolean);
  102093. /** @hidden */
  102094. _isDisposed: boolean;
  102095. /**
  102096. * Gets a list of Animations associated with the node
  102097. */
  102098. animations: Animation[];
  102099. protected _ranges: {
  102100. [name: string]: Nullable<AnimationRange>;
  102101. };
  102102. /**
  102103. * Callback raised when the node is ready to be used
  102104. */
  102105. onReady: Nullable<(node: Node) => void>;
  102106. private _isEnabled;
  102107. private _isParentEnabled;
  102108. private _isReady;
  102109. /** @hidden */
  102110. _currentRenderId: number;
  102111. private _parentUpdateId;
  102112. /** @hidden */
  102113. _childUpdateId: number;
  102114. /** @hidden */
  102115. _waitingParentId: Nullable<string>;
  102116. /** @hidden */
  102117. _scene: Scene;
  102118. /** @hidden */
  102119. _cache: any;
  102120. private _parentNode;
  102121. private _children;
  102122. /** @hidden */
  102123. _worldMatrix: Matrix;
  102124. /** @hidden */
  102125. _worldMatrixDeterminant: number;
  102126. /** @hidden */
  102127. _worldMatrixDeterminantIsDirty: boolean;
  102128. /** @hidden */
  102129. private _sceneRootNodesIndex;
  102130. /**
  102131. * Gets a boolean indicating if the node has been disposed
  102132. * @returns true if the node was disposed
  102133. */
  102134. isDisposed(): boolean;
  102135. /**
  102136. * Gets or sets the parent of the node (without keeping the current position in the scene)
  102137. * @see https://doc.babylonjs.com/how_to/parenting
  102138. */
  102139. set parent(parent: Nullable<Node>);
  102140. get parent(): Nullable<Node>;
  102141. /** @hidden */
  102142. _addToSceneRootNodes(): void;
  102143. /** @hidden */
  102144. _removeFromSceneRootNodes(): void;
  102145. private _animationPropertiesOverride;
  102146. /**
  102147. * Gets or sets the animation properties override
  102148. */
  102149. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102150. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102151. /**
  102152. * Gets a string idenfifying the name of the class
  102153. * @returns "Node" string
  102154. */
  102155. getClassName(): string;
  102156. /** @hidden */
  102157. readonly _isNode: boolean;
  102158. /**
  102159. * An event triggered when the mesh is disposed
  102160. */
  102161. onDisposeObservable: Observable<Node>;
  102162. private _onDisposeObserver;
  102163. /**
  102164. * Sets a callback that will be raised when the node will be disposed
  102165. */
  102166. set onDispose(callback: () => void);
  102167. /**
  102168. * Creates a new Node
  102169. * @param name the name and id to be given to this node
  102170. * @param scene the scene this node will be added to
  102171. */
  102172. constructor(name: string, scene?: Nullable<Scene>);
  102173. /**
  102174. * Gets the scene of the node
  102175. * @returns a scene
  102176. */
  102177. getScene(): Scene;
  102178. /**
  102179. * Gets the engine of the node
  102180. * @returns a Engine
  102181. */
  102182. getEngine(): Engine;
  102183. private _behaviors;
  102184. /**
  102185. * Attach a behavior to the node
  102186. * @see http://doc.babylonjs.com/features/behaviour
  102187. * @param behavior defines the behavior to attach
  102188. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  102189. * @returns the current Node
  102190. */
  102191. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  102192. /**
  102193. * Remove an attached behavior
  102194. * @see http://doc.babylonjs.com/features/behaviour
  102195. * @param behavior defines the behavior to attach
  102196. * @returns the current Node
  102197. */
  102198. removeBehavior(behavior: Behavior<Node>): Node;
  102199. /**
  102200. * Gets the list of attached behaviors
  102201. * @see http://doc.babylonjs.com/features/behaviour
  102202. */
  102203. get behaviors(): Behavior<Node>[];
  102204. /**
  102205. * Gets an attached behavior by name
  102206. * @param name defines the name of the behavior to look for
  102207. * @see http://doc.babylonjs.com/features/behaviour
  102208. * @returns null if behavior was not found else the requested behavior
  102209. */
  102210. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  102211. /**
  102212. * Returns the latest update of the World matrix
  102213. * @returns a Matrix
  102214. */
  102215. getWorldMatrix(): Matrix;
  102216. /** @hidden */
  102217. _getWorldMatrixDeterminant(): number;
  102218. /**
  102219. * Returns directly the latest state of the mesh World matrix.
  102220. * A Matrix is returned.
  102221. */
  102222. get worldMatrixFromCache(): Matrix;
  102223. /** @hidden */
  102224. _initCache(): void;
  102225. /** @hidden */
  102226. updateCache(force?: boolean): void;
  102227. /** @hidden */
  102228. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102229. /** @hidden */
  102230. _updateCache(ignoreParentClass?: boolean): void;
  102231. /** @hidden */
  102232. _isSynchronized(): boolean;
  102233. /** @hidden */
  102234. _markSyncedWithParent(): void;
  102235. /** @hidden */
  102236. isSynchronizedWithParent(): boolean;
  102237. /** @hidden */
  102238. isSynchronized(): boolean;
  102239. /**
  102240. * Is this node ready to be used/rendered
  102241. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  102242. * @return true if the node is ready
  102243. */
  102244. isReady(completeCheck?: boolean): boolean;
  102245. /**
  102246. * Is this node enabled?
  102247. * 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
  102248. * @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
  102249. * @return whether this node (and its parent) is enabled
  102250. */
  102251. isEnabled(checkAncestors?: boolean): boolean;
  102252. /** @hidden */
  102253. protected _syncParentEnabledState(): void;
  102254. /**
  102255. * Set the enabled state of this node
  102256. * @param value defines the new enabled state
  102257. */
  102258. setEnabled(value: boolean): void;
  102259. /**
  102260. * Is this node a descendant of the given node?
  102261. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  102262. * @param ancestor defines the parent node to inspect
  102263. * @returns a boolean indicating if this node is a descendant of the given node
  102264. */
  102265. isDescendantOf(ancestor: Node): boolean;
  102266. /** @hidden */
  102267. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  102268. /**
  102269. * Will return all nodes that have this node as ascendant
  102270. * @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
  102271. * @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
  102272. * @return all children nodes of all types
  102273. */
  102274. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  102275. /**
  102276. * Get all child-meshes of this node
  102277. * @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)
  102278. * @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
  102279. * @returns an array of AbstractMesh
  102280. */
  102281. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  102282. /**
  102283. * Get all direct children of this node
  102284. * @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
  102285. * @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)
  102286. * @returns an array of Node
  102287. */
  102288. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  102289. /** @hidden */
  102290. _setReady(state: boolean): void;
  102291. /**
  102292. * Get an animation by name
  102293. * @param name defines the name of the animation to look for
  102294. * @returns null if not found else the requested animation
  102295. */
  102296. getAnimationByName(name: string): Nullable<Animation>;
  102297. /**
  102298. * Creates an animation range for this node
  102299. * @param name defines the name of the range
  102300. * @param from defines the starting key
  102301. * @param to defines the end key
  102302. */
  102303. createAnimationRange(name: string, from: number, to: number): void;
  102304. /**
  102305. * Delete a specific animation range
  102306. * @param name defines the name of the range to delete
  102307. * @param deleteFrames defines if animation frames from the range must be deleted as well
  102308. */
  102309. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  102310. /**
  102311. * Get an animation range by name
  102312. * @param name defines the name of the animation range to look for
  102313. * @returns null if not found else the requested animation range
  102314. */
  102315. getAnimationRange(name: string): Nullable<AnimationRange>;
  102316. /**
  102317. * Gets the list of all animation ranges defined on this node
  102318. * @returns an array
  102319. */
  102320. getAnimationRanges(): Nullable<AnimationRange>[];
  102321. /**
  102322. * Will start the animation sequence
  102323. * @param name defines the range frames for animation sequence
  102324. * @param loop defines if the animation should loop (false by default)
  102325. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  102326. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  102327. * @returns the object created for this animation. If range does not exist, it will return null
  102328. */
  102329. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  102330. /**
  102331. * Serialize animation ranges into a JSON compatible object
  102332. * @returns serialization object
  102333. */
  102334. serializeAnimationRanges(): any;
  102335. /**
  102336. * Computes the world matrix of the node
  102337. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  102338. * @returns the world matrix
  102339. */
  102340. computeWorldMatrix(force?: boolean): Matrix;
  102341. /**
  102342. * Releases resources associated with this node.
  102343. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102344. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102345. */
  102346. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102347. /**
  102348. * Parse animation range data from a serialization object and store them into a given node
  102349. * @param node defines where to store the animation ranges
  102350. * @param parsedNode defines the serialization object to read data from
  102351. * @param scene defines the hosting scene
  102352. */
  102353. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  102354. /**
  102355. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  102356. * @param includeDescendants Include bounding info from descendants as well (true by default)
  102357. * @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
  102358. * @returns the new bounding vectors
  102359. */
  102360. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  102361. min: Vector3;
  102362. max: Vector3;
  102363. };
  102364. }
  102365. }
  102366. declare module BABYLON {
  102367. /**
  102368. * @hidden
  102369. */
  102370. export class _IAnimationState {
  102371. key: number;
  102372. repeatCount: number;
  102373. workValue?: any;
  102374. loopMode?: number;
  102375. offsetValue?: any;
  102376. highLimitValue?: any;
  102377. }
  102378. /**
  102379. * Class used to store any kind of animation
  102380. */
  102381. export class Animation {
  102382. /**Name of the animation */
  102383. name: string;
  102384. /**Property to animate */
  102385. targetProperty: string;
  102386. /**The frames per second of the animation */
  102387. framePerSecond: number;
  102388. /**The data type of the animation */
  102389. dataType: number;
  102390. /**The loop mode of the animation */
  102391. loopMode?: number | undefined;
  102392. /**Specifies if blending should be enabled */
  102393. enableBlending?: boolean | undefined;
  102394. /**
  102395. * Use matrix interpolation instead of using direct key value when animating matrices
  102396. */
  102397. static AllowMatricesInterpolation: boolean;
  102398. /**
  102399. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  102400. */
  102401. static AllowMatrixDecomposeForInterpolation: boolean;
  102402. /**
  102403. * Stores the key frames of the animation
  102404. */
  102405. private _keys;
  102406. /**
  102407. * Stores the easing function of the animation
  102408. */
  102409. private _easingFunction;
  102410. /**
  102411. * @hidden Internal use only
  102412. */
  102413. _runtimeAnimations: RuntimeAnimation[];
  102414. /**
  102415. * The set of event that will be linked to this animation
  102416. */
  102417. private _events;
  102418. /**
  102419. * Stores an array of target property paths
  102420. */
  102421. targetPropertyPath: string[];
  102422. /**
  102423. * Stores the blending speed of the animation
  102424. */
  102425. blendingSpeed: number;
  102426. /**
  102427. * Stores the animation ranges for the animation
  102428. */
  102429. private _ranges;
  102430. /**
  102431. * @hidden Internal use
  102432. */
  102433. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  102434. /**
  102435. * Sets up an animation
  102436. * @param property The property to animate
  102437. * @param animationType The animation type to apply
  102438. * @param framePerSecond The frames per second of the animation
  102439. * @param easingFunction The easing function used in the animation
  102440. * @returns The created animation
  102441. */
  102442. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  102443. /**
  102444. * Create and start an animation on a node
  102445. * @param name defines the name of the global animation that will be run on all nodes
  102446. * @param node defines the root node where the animation will take place
  102447. * @param targetProperty defines property to animate
  102448. * @param framePerSecond defines the number of frame per second yo use
  102449. * @param totalFrame defines the number of frames in total
  102450. * @param from defines the initial value
  102451. * @param to defines the final value
  102452. * @param loopMode defines which loop mode you want to use (off by default)
  102453. * @param easingFunction defines the easing function to use (linear by default)
  102454. * @param onAnimationEnd defines the callback to call when animation end
  102455. * @returns the animatable created for this animation
  102456. */
  102457. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102458. /**
  102459. * Create and start an animation on a node and its descendants
  102460. * @param name defines the name of the global animation that will be run on all nodes
  102461. * @param node defines the root node where the animation will take place
  102462. * @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
  102463. * @param targetProperty defines property to animate
  102464. * @param framePerSecond defines the number of frame per second to use
  102465. * @param totalFrame defines the number of frames in total
  102466. * @param from defines the initial value
  102467. * @param to defines the final value
  102468. * @param loopMode defines which loop mode you want to use (off by default)
  102469. * @param easingFunction defines the easing function to use (linear by default)
  102470. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  102471. * @returns the list of animatables created for all nodes
  102472. * @example https://www.babylonjs-playground.com/#MH0VLI
  102473. */
  102474. 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[]>;
  102475. /**
  102476. * Creates a new animation, merges it with the existing animations and starts it
  102477. * @param name Name of the animation
  102478. * @param node Node which contains the scene that begins the animations
  102479. * @param targetProperty Specifies which property to animate
  102480. * @param framePerSecond The frames per second of the animation
  102481. * @param totalFrame The total number of frames
  102482. * @param from The frame at the beginning of the animation
  102483. * @param to The frame at the end of the animation
  102484. * @param loopMode Specifies the loop mode of the animation
  102485. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  102486. * @param onAnimationEnd Callback to run once the animation is complete
  102487. * @returns Nullable animation
  102488. */
  102489. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102490. /**
  102491. * Transition property of an host to the target Value
  102492. * @param property The property to transition
  102493. * @param targetValue The target Value of the property
  102494. * @param host The object where the property to animate belongs
  102495. * @param scene Scene used to run the animation
  102496. * @param frameRate Framerate (in frame/s) to use
  102497. * @param transition The transition type we want to use
  102498. * @param duration The duration of the animation, in milliseconds
  102499. * @param onAnimationEnd Callback trigger at the end of the animation
  102500. * @returns Nullable animation
  102501. */
  102502. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  102503. /**
  102504. * Return the array of runtime animations currently using this animation
  102505. */
  102506. get runtimeAnimations(): RuntimeAnimation[];
  102507. /**
  102508. * Specifies if any of the runtime animations are currently running
  102509. */
  102510. get hasRunningRuntimeAnimations(): boolean;
  102511. /**
  102512. * Initializes the animation
  102513. * @param name Name of the animation
  102514. * @param targetProperty Property to animate
  102515. * @param framePerSecond The frames per second of the animation
  102516. * @param dataType The data type of the animation
  102517. * @param loopMode The loop mode of the animation
  102518. * @param enableBlending Specifies if blending should be enabled
  102519. */
  102520. constructor(
  102521. /**Name of the animation */
  102522. name: string,
  102523. /**Property to animate */
  102524. targetProperty: string,
  102525. /**The frames per second of the animation */
  102526. framePerSecond: number,
  102527. /**The data type of the animation */
  102528. dataType: number,
  102529. /**The loop mode of the animation */
  102530. loopMode?: number | undefined,
  102531. /**Specifies if blending should be enabled */
  102532. enableBlending?: boolean | undefined);
  102533. /**
  102534. * Converts the animation to a string
  102535. * @param fullDetails support for multiple levels of logging within scene loading
  102536. * @returns String form of the animation
  102537. */
  102538. toString(fullDetails?: boolean): string;
  102539. /**
  102540. * Add an event to this animation
  102541. * @param event Event to add
  102542. */
  102543. addEvent(event: AnimationEvent): void;
  102544. /**
  102545. * Remove all events found at the given frame
  102546. * @param frame The frame to remove events from
  102547. */
  102548. removeEvents(frame: number): void;
  102549. /**
  102550. * Retrieves all the events from the animation
  102551. * @returns Events from the animation
  102552. */
  102553. getEvents(): AnimationEvent[];
  102554. /**
  102555. * Creates an animation range
  102556. * @param name Name of the animation range
  102557. * @param from Starting frame of the animation range
  102558. * @param to Ending frame of the animation
  102559. */
  102560. createRange(name: string, from: number, to: number): void;
  102561. /**
  102562. * Deletes an animation range by name
  102563. * @param name Name of the animation range to delete
  102564. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  102565. */
  102566. deleteRange(name: string, deleteFrames?: boolean): void;
  102567. /**
  102568. * Gets the animation range by name, or null if not defined
  102569. * @param name Name of the animation range
  102570. * @returns Nullable animation range
  102571. */
  102572. getRange(name: string): Nullable<AnimationRange>;
  102573. /**
  102574. * Gets the key frames from the animation
  102575. * @returns The key frames of the animation
  102576. */
  102577. getKeys(): Array<IAnimationKey>;
  102578. /**
  102579. * Gets the highest frame rate of the animation
  102580. * @returns Highest frame rate of the animation
  102581. */
  102582. getHighestFrame(): number;
  102583. /**
  102584. * Gets the easing function of the animation
  102585. * @returns Easing function of the animation
  102586. */
  102587. getEasingFunction(): IEasingFunction;
  102588. /**
  102589. * Sets the easing function of the animation
  102590. * @param easingFunction A custom mathematical formula for animation
  102591. */
  102592. setEasingFunction(easingFunction: EasingFunction): void;
  102593. /**
  102594. * Interpolates a scalar linearly
  102595. * @param startValue Start value of the animation curve
  102596. * @param endValue End value of the animation curve
  102597. * @param gradient Scalar amount to interpolate
  102598. * @returns Interpolated scalar value
  102599. */
  102600. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  102601. /**
  102602. * Interpolates a scalar cubically
  102603. * @param startValue Start value of the animation curve
  102604. * @param outTangent End tangent of the animation
  102605. * @param endValue End value of the animation curve
  102606. * @param inTangent Start tangent of the animation curve
  102607. * @param gradient Scalar amount to interpolate
  102608. * @returns Interpolated scalar value
  102609. */
  102610. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  102611. /**
  102612. * Interpolates a quaternion using a spherical linear interpolation
  102613. * @param startValue Start value of the animation curve
  102614. * @param endValue End value of the animation curve
  102615. * @param gradient Scalar amount to interpolate
  102616. * @returns Interpolated quaternion value
  102617. */
  102618. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  102619. /**
  102620. * Interpolates a quaternion cubically
  102621. * @param startValue Start value of the animation curve
  102622. * @param outTangent End tangent of the animation curve
  102623. * @param endValue End value of the animation curve
  102624. * @param inTangent Start tangent of the animation curve
  102625. * @param gradient Scalar amount to interpolate
  102626. * @returns Interpolated quaternion value
  102627. */
  102628. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  102629. /**
  102630. * Interpolates a Vector3 linearl
  102631. * @param startValue Start value of the animation curve
  102632. * @param endValue End value of the animation curve
  102633. * @param gradient Scalar amount to interpolate
  102634. * @returns Interpolated scalar value
  102635. */
  102636. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  102637. /**
  102638. * Interpolates a Vector3 cubically
  102639. * @param startValue Start value of the animation curve
  102640. * @param outTangent End tangent of the animation
  102641. * @param endValue End value of the animation curve
  102642. * @param inTangent Start tangent of the animation curve
  102643. * @param gradient Scalar amount to interpolate
  102644. * @returns InterpolatedVector3 value
  102645. */
  102646. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  102647. /**
  102648. * Interpolates a Vector2 linearly
  102649. * @param startValue Start value of the animation curve
  102650. * @param endValue End value of the animation curve
  102651. * @param gradient Scalar amount to interpolate
  102652. * @returns Interpolated Vector2 value
  102653. */
  102654. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  102655. /**
  102656. * Interpolates a Vector2 cubically
  102657. * @param startValue Start value of the animation curve
  102658. * @param outTangent End tangent of the animation
  102659. * @param endValue End value of the animation curve
  102660. * @param inTangent Start tangent of the animation curve
  102661. * @param gradient Scalar amount to interpolate
  102662. * @returns Interpolated Vector2 value
  102663. */
  102664. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  102665. /**
  102666. * Interpolates a size linearly
  102667. * @param startValue Start value of the animation curve
  102668. * @param endValue End value of the animation curve
  102669. * @param gradient Scalar amount to interpolate
  102670. * @returns Interpolated Size value
  102671. */
  102672. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  102673. /**
  102674. * Interpolates a Color3 linearly
  102675. * @param startValue Start value of the animation curve
  102676. * @param endValue End value of the animation curve
  102677. * @param gradient Scalar amount to interpolate
  102678. * @returns Interpolated Color3 value
  102679. */
  102680. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  102681. /**
  102682. * Interpolates a Color4 linearly
  102683. * @param startValue Start value of the animation curve
  102684. * @param endValue End value of the animation curve
  102685. * @param gradient Scalar amount to interpolate
  102686. * @returns Interpolated Color3 value
  102687. */
  102688. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  102689. /**
  102690. * @hidden Internal use only
  102691. */
  102692. _getKeyValue(value: any): any;
  102693. /**
  102694. * @hidden Internal use only
  102695. */
  102696. _interpolate(currentFrame: number, state: _IAnimationState): any;
  102697. /**
  102698. * Defines the function to use to interpolate matrices
  102699. * @param startValue defines the start matrix
  102700. * @param endValue defines the end matrix
  102701. * @param gradient defines the gradient between both matrices
  102702. * @param result defines an optional target matrix where to store the interpolation
  102703. * @returns the interpolated matrix
  102704. */
  102705. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  102706. /**
  102707. * Makes a copy of the animation
  102708. * @returns Cloned animation
  102709. */
  102710. clone(): Animation;
  102711. /**
  102712. * Sets the key frames of the animation
  102713. * @param values The animation key frames to set
  102714. */
  102715. setKeys(values: Array<IAnimationKey>): void;
  102716. /**
  102717. * Serializes the animation to an object
  102718. * @returns Serialized object
  102719. */
  102720. serialize(): any;
  102721. /**
  102722. * Float animation type
  102723. */
  102724. static readonly ANIMATIONTYPE_FLOAT: number;
  102725. /**
  102726. * Vector3 animation type
  102727. */
  102728. static readonly ANIMATIONTYPE_VECTOR3: number;
  102729. /**
  102730. * Quaternion animation type
  102731. */
  102732. static readonly ANIMATIONTYPE_QUATERNION: number;
  102733. /**
  102734. * Matrix animation type
  102735. */
  102736. static readonly ANIMATIONTYPE_MATRIX: number;
  102737. /**
  102738. * Color3 animation type
  102739. */
  102740. static readonly ANIMATIONTYPE_COLOR3: number;
  102741. /**
  102742. * Color3 animation type
  102743. */
  102744. static readonly ANIMATIONTYPE_COLOR4: number;
  102745. /**
  102746. * Vector2 animation type
  102747. */
  102748. static readonly ANIMATIONTYPE_VECTOR2: number;
  102749. /**
  102750. * Size animation type
  102751. */
  102752. static readonly ANIMATIONTYPE_SIZE: number;
  102753. /**
  102754. * Relative Loop Mode
  102755. */
  102756. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  102757. /**
  102758. * Cycle Loop Mode
  102759. */
  102760. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  102761. /**
  102762. * Constant Loop Mode
  102763. */
  102764. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  102765. /** @hidden */
  102766. static _UniversalLerp(left: any, right: any, amount: number): any;
  102767. /**
  102768. * Parses an animation object and creates an animation
  102769. * @param parsedAnimation Parsed animation object
  102770. * @returns Animation object
  102771. */
  102772. static Parse(parsedAnimation: any): Animation;
  102773. /**
  102774. * Appends the serialized animations from the source animations
  102775. * @param source Source containing the animations
  102776. * @param destination Target to store the animations
  102777. */
  102778. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102779. }
  102780. }
  102781. declare module BABYLON {
  102782. /**
  102783. * Interface containing an array of animations
  102784. */
  102785. export interface IAnimatable {
  102786. /**
  102787. * Array of animations
  102788. */
  102789. animations: Nullable<Array<Animation>>;
  102790. }
  102791. }
  102792. declare module BABYLON {
  102793. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  102794. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102795. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102796. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102797. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102798. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102799. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102800. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102801. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102802. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102803. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102804. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102805. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102806. /**
  102807. * Decorator used to define property that can be serialized as reference to a camera
  102808. * @param sourceName defines the name of the property to decorate
  102809. */
  102810. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102811. /**
  102812. * Class used to help serialization objects
  102813. */
  102814. export class SerializationHelper {
  102815. /** @hidden */
  102816. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  102817. /** @hidden */
  102818. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  102819. /** @hidden */
  102820. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  102821. /** @hidden */
  102822. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  102823. /**
  102824. * Appends the serialized animations from the source animations
  102825. * @param source Source containing the animations
  102826. * @param destination Target to store the animations
  102827. */
  102828. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102829. /**
  102830. * Static function used to serialized a specific entity
  102831. * @param entity defines the entity to serialize
  102832. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  102833. * @returns a JSON compatible object representing the serialization of the entity
  102834. */
  102835. static Serialize<T>(entity: T, serializationObject?: any): any;
  102836. /**
  102837. * Creates a new entity from a serialization data object
  102838. * @param creationFunction defines a function used to instanciated the new entity
  102839. * @param source defines the source serialization data
  102840. * @param scene defines the hosting scene
  102841. * @param rootUrl defines the root url for resources
  102842. * @returns a new entity
  102843. */
  102844. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  102845. /**
  102846. * Clones an object
  102847. * @param creationFunction defines the function used to instanciate the new object
  102848. * @param source defines the source object
  102849. * @returns the cloned object
  102850. */
  102851. static Clone<T>(creationFunction: () => T, source: T): T;
  102852. /**
  102853. * Instanciates a new object based on a source one (some data will be shared between both object)
  102854. * @param creationFunction defines the function used to instanciate the new object
  102855. * @param source defines the source object
  102856. * @returns the new object
  102857. */
  102858. static Instanciate<T>(creationFunction: () => T, source: T): T;
  102859. }
  102860. }
  102861. declare module BABYLON {
  102862. /**
  102863. * Class used to manipulate GUIDs
  102864. */
  102865. export class GUID {
  102866. /**
  102867. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102868. * Be aware Math.random() could cause collisions, but:
  102869. * "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"
  102870. * @returns a pseudo random id
  102871. */
  102872. static RandomId(): string;
  102873. }
  102874. }
  102875. declare module BABYLON {
  102876. /**
  102877. * Base class of all the textures in babylon.
  102878. * It groups all the common properties the materials, post process, lights... might need
  102879. * in order to make a correct use of the texture.
  102880. */
  102881. export class BaseTexture implements IAnimatable {
  102882. /**
  102883. * Default anisotropic filtering level for the application.
  102884. * It is set to 4 as a good tradeoff between perf and quality.
  102885. */
  102886. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  102887. /**
  102888. * Gets or sets the unique id of the texture
  102889. */
  102890. uniqueId: number;
  102891. /**
  102892. * Define the name of the texture.
  102893. */
  102894. name: string;
  102895. /**
  102896. * Gets or sets an object used to store user defined information.
  102897. */
  102898. metadata: any;
  102899. /**
  102900. * For internal use only. Please do not use.
  102901. */
  102902. reservedDataStore: any;
  102903. private _hasAlpha;
  102904. /**
  102905. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  102906. */
  102907. set hasAlpha(value: boolean);
  102908. get hasAlpha(): boolean;
  102909. /**
  102910. * Defines if the alpha value should be determined via the rgb values.
  102911. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  102912. */
  102913. getAlphaFromRGB: boolean;
  102914. /**
  102915. * Intensity or strength of the texture.
  102916. * It is commonly used by materials to fine tune the intensity of the texture
  102917. */
  102918. level: number;
  102919. /**
  102920. * Define the UV chanel to use starting from 0 and defaulting to 0.
  102921. * This is part of the texture as textures usually maps to one uv set.
  102922. */
  102923. coordinatesIndex: number;
  102924. private _coordinatesMode;
  102925. /**
  102926. * How a texture is mapped.
  102927. *
  102928. * | Value | Type | Description |
  102929. * | ----- | ----------------------------------- | ----------- |
  102930. * | 0 | EXPLICIT_MODE | |
  102931. * | 1 | SPHERICAL_MODE | |
  102932. * | 2 | PLANAR_MODE | |
  102933. * | 3 | CUBIC_MODE | |
  102934. * | 4 | PROJECTION_MODE | |
  102935. * | 5 | SKYBOX_MODE | |
  102936. * | 6 | INVCUBIC_MODE | |
  102937. * | 7 | EQUIRECTANGULAR_MODE | |
  102938. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  102939. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  102940. */
  102941. set coordinatesMode(value: number);
  102942. get coordinatesMode(): number;
  102943. /**
  102944. * | Value | Type | Description |
  102945. * | ----- | ------------------ | ----------- |
  102946. * | 0 | CLAMP_ADDRESSMODE | |
  102947. * | 1 | WRAP_ADDRESSMODE | |
  102948. * | 2 | MIRROR_ADDRESSMODE | |
  102949. */
  102950. wrapU: number;
  102951. /**
  102952. * | Value | Type | Description |
  102953. * | ----- | ------------------ | ----------- |
  102954. * | 0 | CLAMP_ADDRESSMODE | |
  102955. * | 1 | WRAP_ADDRESSMODE | |
  102956. * | 2 | MIRROR_ADDRESSMODE | |
  102957. */
  102958. wrapV: number;
  102959. /**
  102960. * | Value | Type | Description |
  102961. * | ----- | ------------------ | ----------- |
  102962. * | 0 | CLAMP_ADDRESSMODE | |
  102963. * | 1 | WRAP_ADDRESSMODE | |
  102964. * | 2 | MIRROR_ADDRESSMODE | |
  102965. */
  102966. wrapR: number;
  102967. /**
  102968. * With compliant hardware and browser (supporting anisotropic filtering)
  102969. * this defines the level of anisotropic filtering in the texture.
  102970. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  102971. */
  102972. anisotropicFilteringLevel: number;
  102973. /**
  102974. * Define if the texture is a cube texture or if false a 2d texture.
  102975. */
  102976. get isCube(): boolean;
  102977. set isCube(value: boolean);
  102978. /**
  102979. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  102980. */
  102981. get is3D(): boolean;
  102982. set is3D(value: boolean);
  102983. /**
  102984. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  102985. */
  102986. get is2DArray(): boolean;
  102987. set is2DArray(value: boolean);
  102988. /**
  102989. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  102990. * HDR texture are usually stored in linear space.
  102991. * This only impacts the PBR and Background materials
  102992. */
  102993. gammaSpace: boolean;
  102994. /**
  102995. * Gets or sets whether or not the texture contains RGBD data.
  102996. */
  102997. get isRGBD(): boolean;
  102998. set isRGBD(value: boolean);
  102999. /**
  103000. * Is Z inverted in the texture (useful in a cube texture).
  103001. */
  103002. invertZ: boolean;
  103003. /**
  103004. * Are mip maps generated for this texture or not.
  103005. */
  103006. get noMipmap(): boolean;
  103007. /**
  103008. * @hidden
  103009. */
  103010. lodLevelInAlpha: boolean;
  103011. /**
  103012. * With prefiltered texture, defined the offset used during the prefiltering steps.
  103013. */
  103014. get lodGenerationOffset(): number;
  103015. set lodGenerationOffset(value: number);
  103016. /**
  103017. * With prefiltered texture, defined the scale used during the prefiltering steps.
  103018. */
  103019. get lodGenerationScale(): number;
  103020. set lodGenerationScale(value: number);
  103021. /**
  103022. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  103023. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  103024. * average roughness values.
  103025. */
  103026. get linearSpecularLOD(): boolean;
  103027. set linearSpecularLOD(value: boolean);
  103028. /**
  103029. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  103030. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  103031. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  103032. */
  103033. get irradianceTexture(): Nullable<BaseTexture>;
  103034. set irradianceTexture(value: Nullable<BaseTexture>);
  103035. /**
  103036. * Define if the texture is a render target.
  103037. */
  103038. isRenderTarget: boolean;
  103039. /**
  103040. * Define the unique id of the texture in the scene.
  103041. */
  103042. get uid(): string;
  103043. /**
  103044. * Return a string representation of the texture.
  103045. * @returns the texture as a string
  103046. */
  103047. toString(): string;
  103048. /**
  103049. * Get the class name of the texture.
  103050. * @returns "BaseTexture"
  103051. */
  103052. getClassName(): string;
  103053. /**
  103054. * Define the list of animation attached to the texture.
  103055. */
  103056. animations: Animation[];
  103057. /**
  103058. * An event triggered when the texture is disposed.
  103059. */
  103060. onDisposeObservable: Observable<BaseTexture>;
  103061. private _onDisposeObserver;
  103062. /**
  103063. * Callback triggered when the texture has been disposed.
  103064. * Kept for back compatibility, you can use the onDisposeObservable instead.
  103065. */
  103066. set onDispose(callback: () => void);
  103067. /**
  103068. * Define the current state of the loading sequence when in delayed load mode.
  103069. */
  103070. delayLoadState: number;
  103071. private _scene;
  103072. /** @hidden */
  103073. _texture: Nullable<InternalTexture>;
  103074. private _uid;
  103075. /**
  103076. * Define if the texture is preventinga material to render or not.
  103077. * If not and the texture is not ready, the engine will use a default black texture instead.
  103078. */
  103079. get isBlocking(): boolean;
  103080. /**
  103081. * Instantiates a new BaseTexture.
  103082. * Base class of all the textures in babylon.
  103083. * It groups all the common properties the materials, post process, lights... might need
  103084. * in order to make a correct use of the texture.
  103085. * @param scene Define the scene the texture blongs to
  103086. */
  103087. constructor(scene: Nullable<Scene>);
  103088. /**
  103089. * Get the scene the texture belongs to.
  103090. * @returns the scene or null if undefined
  103091. */
  103092. getScene(): Nullable<Scene>;
  103093. /**
  103094. * Get the texture transform matrix used to offset tile the texture for istance.
  103095. * @returns the transformation matrix
  103096. */
  103097. getTextureMatrix(): Matrix;
  103098. /**
  103099. * Get the texture reflection matrix used to rotate/transform the reflection.
  103100. * @returns the reflection matrix
  103101. */
  103102. getReflectionTextureMatrix(): Matrix;
  103103. /**
  103104. * Get the underlying lower level texture from Babylon.
  103105. * @returns the insternal texture
  103106. */
  103107. getInternalTexture(): Nullable<InternalTexture>;
  103108. /**
  103109. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  103110. * @returns true if ready or not blocking
  103111. */
  103112. isReadyOrNotBlocking(): boolean;
  103113. /**
  103114. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  103115. * @returns true if fully ready
  103116. */
  103117. isReady(): boolean;
  103118. private _cachedSize;
  103119. /**
  103120. * Get the size of the texture.
  103121. * @returns the texture size.
  103122. */
  103123. getSize(): ISize;
  103124. /**
  103125. * Get the base size of the texture.
  103126. * It can be different from the size if the texture has been resized for POT for instance
  103127. * @returns the base size
  103128. */
  103129. getBaseSize(): ISize;
  103130. /**
  103131. * Update the sampling mode of the texture.
  103132. * Default is Trilinear mode.
  103133. *
  103134. * | Value | Type | Description |
  103135. * | ----- | ------------------ | ----------- |
  103136. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  103137. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  103138. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  103139. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  103140. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  103141. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  103142. * | 7 | NEAREST_LINEAR | |
  103143. * | 8 | NEAREST_NEAREST | |
  103144. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  103145. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  103146. * | 11 | LINEAR_LINEAR | |
  103147. * | 12 | LINEAR_NEAREST | |
  103148. *
  103149. * > _mag_: magnification filter (close to the viewer)
  103150. * > _min_: minification filter (far from the viewer)
  103151. * > _mip_: filter used between mip map levels
  103152. *@param samplingMode Define the new sampling mode of the texture
  103153. */
  103154. updateSamplingMode(samplingMode: number): void;
  103155. /**
  103156. * Scales the texture if is `canRescale()`
  103157. * @param ratio the resize factor we want to use to rescale
  103158. */
  103159. scale(ratio: number): void;
  103160. /**
  103161. * Get if the texture can rescale.
  103162. */
  103163. get canRescale(): boolean;
  103164. /** @hidden */
  103165. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  103166. /** @hidden */
  103167. _rebuild(): void;
  103168. /**
  103169. * Triggers the load sequence in delayed load mode.
  103170. */
  103171. delayLoad(): void;
  103172. /**
  103173. * Clones the texture.
  103174. * @returns the cloned texture
  103175. */
  103176. clone(): Nullable<BaseTexture>;
  103177. /**
  103178. * Get the texture underlying type (INT, FLOAT...)
  103179. */
  103180. get textureType(): number;
  103181. /**
  103182. * Get the texture underlying format (RGB, RGBA...)
  103183. */
  103184. get textureFormat(): number;
  103185. /**
  103186. * Indicates that textures need to be re-calculated for all materials
  103187. */
  103188. protected _markAllSubMeshesAsTexturesDirty(): void;
  103189. /**
  103190. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  103191. * This will returns an RGBA array buffer containing either in values (0-255) or
  103192. * float values (0-1) depending of the underlying buffer type.
  103193. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  103194. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  103195. * @param buffer defines a user defined buffer to fill with data (can be null)
  103196. * @returns The Array buffer containing the pixels data.
  103197. */
  103198. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  103199. /**
  103200. * Release and destroy the underlying lower level texture aka internalTexture.
  103201. */
  103202. releaseInternalTexture(): void;
  103203. /** @hidden */
  103204. get _lodTextureHigh(): Nullable<BaseTexture>;
  103205. /** @hidden */
  103206. get _lodTextureMid(): Nullable<BaseTexture>;
  103207. /** @hidden */
  103208. get _lodTextureLow(): Nullable<BaseTexture>;
  103209. /**
  103210. * Dispose the texture and release its associated resources.
  103211. */
  103212. dispose(): void;
  103213. /**
  103214. * Serialize the texture into a JSON representation that can be parsed later on.
  103215. * @returns the JSON representation of the texture
  103216. */
  103217. serialize(): any;
  103218. /**
  103219. * Helper function to be called back once a list of texture contains only ready textures.
  103220. * @param textures Define the list of textures to wait for
  103221. * @param callback Define the callback triggered once the entire list will be ready
  103222. */
  103223. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  103224. }
  103225. }
  103226. declare module BABYLON {
  103227. /**
  103228. * Options to be used when creating an effect.
  103229. */
  103230. export interface IEffectCreationOptions {
  103231. /**
  103232. * Atrributes that will be used in the shader.
  103233. */
  103234. attributes: string[];
  103235. /**
  103236. * Uniform varible names that will be set in the shader.
  103237. */
  103238. uniformsNames: string[];
  103239. /**
  103240. * Uniform buffer variable names that will be set in the shader.
  103241. */
  103242. uniformBuffersNames: string[];
  103243. /**
  103244. * Sampler texture variable names that will be set in the shader.
  103245. */
  103246. samplers: string[];
  103247. /**
  103248. * Define statements that will be set in the shader.
  103249. */
  103250. defines: any;
  103251. /**
  103252. * Possible fallbacks for this effect to improve performance when needed.
  103253. */
  103254. fallbacks: Nullable<IEffectFallbacks>;
  103255. /**
  103256. * Callback that will be called when the shader is compiled.
  103257. */
  103258. onCompiled: Nullable<(effect: Effect) => void>;
  103259. /**
  103260. * Callback that will be called if an error occurs during shader compilation.
  103261. */
  103262. onError: Nullable<(effect: Effect, errors: string) => void>;
  103263. /**
  103264. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103265. */
  103266. indexParameters?: any;
  103267. /**
  103268. * Max number of lights that can be used in the shader.
  103269. */
  103270. maxSimultaneousLights?: number;
  103271. /**
  103272. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  103273. */
  103274. transformFeedbackVaryings?: Nullable<string[]>;
  103275. }
  103276. /**
  103277. * Effect containing vertex and fragment shader that can be executed on an object.
  103278. */
  103279. export class Effect implements IDisposable {
  103280. /**
  103281. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103282. */
  103283. static ShadersRepository: string;
  103284. /**
  103285. * Name of the effect.
  103286. */
  103287. name: any;
  103288. /**
  103289. * String container all the define statements that should be set on the shader.
  103290. */
  103291. defines: string;
  103292. /**
  103293. * Callback that will be called when the shader is compiled.
  103294. */
  103295. onCompiled: Nullable<(effect: Effect) => void>;
  103296. /**
  103297. * Callback that will be called if an error occurs during shader compilation.
  103298. */
  103299. onError: Nullable<(effect: Effect, errors: string) => void>;
  103300. /**
  103301. * Callback that will be called when effect is bound.
  103302. */
  103303. onBind: Nullable<(effect: Effect) => void>;
  103304. /**
  103305. * Unique ID of the effect.
  103306. */
  103307. uniqueId: number;
  103308. /**
  103309. * Observable that will be called when the shader is compiled.
  103310. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  103311. */
  103312. onCompileObservable: Observable<Effect>;
  103313. /**
  103314. * Observable that will be called if an error occurs during shader compilation.
  103315. */
  103316. onErrorObservable: Observable<Effect>;
  103317. /** @hidden */
  103318. _onBindObservable: Nullable<Observable<Effect>>;
  103319. /**
  103320. * @hidden
  103321. * Specifies if the effect was previously ready
  103322. */
  103323. _wasPreviouslyReady: boolean;
  103324. /**
  103325. * Observable that will be called when effect is bound.
  103326. */
  103327. get onBindObservable(): Observable<Effect>;
  103328. /** @hidden */
  103329. _bonesComputationForcedToCPU: boolean;
  103330. private static _uniqueIdSeed;
  103331. private _engine;
  103332. private _uniformBuffersNames;
  103333. private _uniformsNames;
  103334. private _samplerList;
  103335. private _samplers;
  103336. private _isReady;
  103337. private _compilationError;
  103338. private _allFallbacksProcessed;
  103339. private _attributesNames;
  103340. private _attributes;
  103341. private _attributeLocationByName;
  103342. private _uniforms;
  103343. /**
  103344. * Key for the effect.
  103345. * @hidden
  103346. */
  103347. _key: string;
  103348. private _indexParameters;
  103349. private _fallbacks;
  103350. private _vertexSourceCode;
  103351. private _fragmentSourceCode;
  103352. private _vertexSourceCodeOverride;
  103353. private _fragmentSourceCodeOverride;
  103354. private _transformFeedbackVaryings;
  103355. /**
  103356. * Compiled shader to webGL program.
  103357. * @hidden
  103358. */
  103359. _pipelineContext: Nullable<IPipelineContext>;
  103360. private _valueCache;
  103361. private static _baseCache;
  103362. /**
  103363. * Instantiates an effect.
  103364. * An effect can be used to create/manage/execute vertex and fragment shaders.
  103365. * @param baseName Name of the effect.
  103366. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  103367. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  103368. * @param samplers List of sampler variables that will be passed to the shader.
  103369. * @param engine Engine to be used to render the effect
  103370. * @param defines Define statements to be added to the shader.
  103371. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  103372. * @param onCompiled Callback that will be called when the shader is compiled.
  103373. * @param onError Callback that will be called if an error occurs during shader compilation.
  103374. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103375. */
  103376. 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);
  103377. private _useFinalCode;
  103378. /**
  103379. * Unique key for this effect
  103380. */
  103381. get key(): string;
  103382. /**
  103383. * If the effect has been compiled and prepared.
  103384. * @returns if the effect is compiled and prepared.
  103385. */
  103386. isReady(): boolean;
  103387. private _isReadyInternal;
  103388. /**
  103389. * The engine the effect was initialized with.
  103390. * @returns the engine.
  103391. */
  103392. getEngine(): Engine;
  103393. /**
  103394. * The pipeline context for this effect
  103395. * @returns the associated pipeline context
  103396. */
  103397. getPipelineContext(): Nullable<IPipelineContext>;
  103398. /**
  103399. * The set of names of attribute variables for the shader.
  103400. * @returns An array of attribute names.
  103401. */
  103402. getAttributesNames(): string[];
  103403. /**
  103404. * Returns the attribute at the given index.
  103405. * @param index The index of the attribute.
  103406. * @returns The location of the attribute.
  103407. */
  103408. getAttributeLocation(index: number): number;
  103409. /**
  103410. * Returns the attribute based on the name of the variable.
  103411. * @param name of the attribute to look up.
  103412. * @returns the attribute location.
  103413. */
  103414. getAttributeLocationByName(name: string): number;
  103415. /**
  103416. * The number of attributes.
  103417. * @returns the numnber of attributes.
  103418. */
  103419. getAttributesCount(): number;
  103420. /**
  103421. * Gets the index of a uniform variable.
  103422. * @param uniformName of the uniform to look up.
  103423. * @returns the index.
  103424. */
  103425. getUniformIndex(uniformName: string): number;
  103426. /**
  103427. * Returns the attribute based on the name of the variable.
  103428. * @param uniformName of the uniform to look up.
  103429. * @returns the location of the uniform.
  103430. */
  103431. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  103432. /**
  103433. * Returns an array of sampler variable names
  103434. * @returns The array of sampler variable neames.
  103435. */
  103436. getSamplers(): string[];
  103437. /**
  103438. * The error from the last compilation.
  103439. * @returns the error string.
  103440. */
  103441. getCompilationError(): string;
  103442. /**
  103443. * Gets a boolean indicating that all fallbacks were used during compilation
  103444. * @returns true if all fallbacks were used
  103445. */
  103446. allFallbacksProcessed(): boolean;
  103447. /**
  103448. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  103449. * @param func The callback to be used.
  103450. */
  103451. executeWhenCompiled(func: (effect: Effect) => void): void;
  103452. private _checkIsReady;
  103453. private _loadShader;
  103454. /**
  103455. * Recompiles the webGL program
  103456. * @param vertexSourceCode The source code for the vertex shader.
  103457. * @param fragmentSourceCode The source code for the fragment shader.
  103458. * @param onCompiled Callback called when completed.
  103459. * @param onError Callback called on error.
  103460. * @hidden
  103461. */
  103462. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  103463. /**
  103464. * Prepares the effect
  103465. * @hidden
  103466. */
  103467. _prepareEffect(): void;
  103468. private _processCompilationErrors;
  103469. /**
  103470. * Checks if the effect is supported. (Must be called after compilation)
  103471. */
  103472. get isSupported(): boolean;
  103473. /**
  103474. * Binds a texture to the engine to be used as output of the shader.
  103475. * @param channel Name of the output variable.
  103476. * @param texture Texture to bind.
  103477. * @hidden
  103478. */
  103479. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  103480. /**
  103481. * Sets a texture on the engine to be used in the shader.
  103482. * @param channel Name of the sampler variable.
  103483. * @param texture Texture to set.
  103484. */
  103485. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  103486. /**
  103487. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  103488. * @param channel Name of the sampler variable.
  103489. * @param texture Texture to set.
  103490. */
  103491. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  103492. /**
  103493. * Sets an array of textures on the engine to be used in the shader.
  103494. * @param channel Name of the variable.
  103495. * @param textures Textures to set.
  103496. */
  103497. setTextureArray(channel: string, textures: BaseTexture[]): void;
  103498. /**
  103499. * 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)
  103500. * @param channel Name of the sampler variable.
  103501. * @param postProcess Post process to get the input texture from.
  103502. */
  103503. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  103504. /**
  103505. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  103506. * 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)
  103507. * @param channel Name of the sampler variable.
  103508. * @param postProcess Post process to get the output texture from.
  103509. */
  103510. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  103511. /** @hidden */
  103512. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  103513. /** @hidden */
  103514. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  103515. /** @hidden */
  103516. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  103517. /** @hidden */
  103518. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  103519. /**
  103520. * Binds a buffer to a uniform.
  103521. * @param buffer Buffer to bind.
  103522. * @param name Name of the uniform variable to bind to.
  103523. */
  103524. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  103525. /**
  103526. * Binds block to a uniform.
  103527. * @param blockName Name of the block to bind.
  103528. * @param index Index to bind.
  103529. */
  103530. bindUniformBlock(blockName: string, index: number): void;
  103531. /**
  103532. * Sets an interger value on a uniform variable.
  103533. * @param uniformName Name of the variable.
  103534. * @param value Value to be set.
  103535. * @returns this effect.
  103536. */
  103537. setInt(uniformName: string, value: number): Effect;
  103538. /**
  103539. * Sets an int array on a uniform variable.
  103540. * @param uniformName Name of the variable.
  103541. * @param array array to be set.
  103542. * @returns this effect.
  103543. */
  103544. setIntArray(uniformName: string, array: Int32Array): Effect;
  103545. /**
  103546. * 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)
  103547. * @param uniformName Name of the variable.
  103548. * @param array array to be set.
  103549. * @returns this effect.
  103550. */
  103551. setIntArray2(uniformName: string, array: Int32Array): Effect;
  103552. /**
  103553. * 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)
  103554. * @param uniformName Name of the variable.
  103555. * @param array array to be set.
  103556. * @returns this effect.
  103557. */
  103558. setIntArray3(uniformName: string, array: Int32Array): Effect;
  103559. /**
  103560. * 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)
  103561. * @param uniformName Name of the variable.
  103562. * @param array array to be set.
  103563. * @returns this effect.
  103564. */
  103565. setIntArray4(uniformName: string, array: Int32Array): Effect;
  103566. /**
  103567. * Sets an float array on a uniform variable.
  103568. * @param uniformName Name of the variable.
  103569. * @param array array to be set.
  103570. * @returns this effect.
  103571. */
  103572. setFloatArray(uniformName: string, array: Float32Array): Effect;
  103573. /**
  103574. * 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)
  103575. * @param uniformName Name of the variable.
  103576. * @param array array to be set.
  103577. * @returns this effect.
  103578. */
  103579. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  103580. /**
  103581. * 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)
  103582. * @param uniformName Name of the variable.
  103583. * @param array array to be set.
  103584. * @returns this effect.
  103585. */
  103586. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  103587. /**
  103588. * 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)
  103589. * @param uniformName Name of the variable.
  103590. * @param array array to be set.
  103591. * @returns this effect.
  103592. */
  103593. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  103594. /**
  103595. * Sets an array on a uniform variable.
  103596. * @param uniformName Name of the variable.
  103597. * @param array array to be set.
  103598. * @returns this effect.
  103599. */
  103600. setArray(uniformName: string, array: number[]): Effect;
  103601. /**
  103602. * 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)
  103603. * @param uniformName Name of the variable.
  103604. * @param array array to be set.
  103605. * @returns this effect.
  103606. */
  103607. setArray2(uniformName: string, array: number[]): Effect;
  103608. /**
  103609. * 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)
  103610. * @param uniformName Name of the variable.
  103611. * @param array array to be set.
  103612. * @returns this effect.
  103613. */
  103614. setArray3(uniformName: string, array: number[]): Effect;
  103615. /**
  103616. * 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)
  103617. * @param uniformName Name of the variable.
  103618. * @param array array to be set.
  103619. * @returns this effect.
  103620. */
  103621. setArray4(uniformName: string, array: number[]): Effect;
  103622. /**
  103623. * Sets matrices on a uniform variable.
  103624. * @param uniformName Name of the variable.
  103625. * @param matrices matrices to be set.
  103626. * @returns this effect.
  103627. */
  103628. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  103629. /**
  103630. * Sets matrix on a uniform variable.
  103631. * @param uniformName Name of the variable.
  103632. * @param matrix matrix to be set.
  103633. * @returns this effect.
  103634. */
  103635. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  103636. /**
  103637. * 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)
  103638. * @param uniformName Name of the variable.
  103639. * @param matrix matrix to be set.
  103640. * @returns this effect.
  103641. */
  103642. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  103643. /**
  103644. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  103645. * @param uniformName Name of the variable.
  103646. * @param matrix matrix to be set.
  103647. * @returns this effect.
  103648. */
  103649. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  103650. /**
  103651. * Sets a float on a uniform variable.
  103652. * @param uniformName Name of the variable.
  103653. * @param value value to be set.
  103654. * @returns this effect.
  103655. */
  103656. setFloat(uniformName: string, value: number): Effect;
  103657. /**
  103658. * Sets a boolean on a uniform variable.
  103659. * @param uniformName Name of the variable.
  103660. * @param bool value to be set.
  103661. * @returns this effect.
  103662. */
  103663. setBool(uniformName: string, bool: boolean): Effect;
  103664. /**
  103665. * Sets a Vector2 on a uniform variable.
  103666. * @param uniformName Name of the variable.
  103667. * @param vector2 vector2 to be set.
  103668. * @returns this effect.
  103669. */
  103670. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  103671. /**
  103672. * Sets a float2 on a uniform variable.
  103673. * @param uniformName Name of the variable.
  103674. * @param x First float in float2.
  103675. * @param y Second float in float2.
  103676. * @returns this effect.
  103677. */
  103678. setFloat2(uniformName: string, x: number, y: number): Effect;
  103679. /**
  103680. * Sets a Vector3 on a uniform variable.
  103681. * @param uniformName Name of the variable.
  103682. * @param vector3 Value to be set.
  103683. * @returns this effect.
  103684. */
  103685. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  103686. /**
  103687. * Sets a float3 on a uniform variable.
  103688. * @param uniformName Name of the variable.
  103689. * @param x First float in float3.
  103690. * @param y Second float in float3.
  103691. * @param z Third float in float3.
  103692. * @returns this effect.
  103693. */
  103694. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  103695. /**
  103696. * Sets a Vector4 on a uniform variable.
  103697. * @param uniformName Name of the variable.
  103698. * @param vector4 Value to be set.
  103699. * @returns this effect.
  103700. */
  103701. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  103702. /**
  103703. * Sets a float4 on a uniform variable.
  103704. * @param uniformName Name of the variable.
  103705. * @param x First float in float4.
  103706. * @param y Second float in float4.
  103707. * @param z Third float in float4.
  103708. * @param w Fourth float in float4.
  103709. * @returns this effect.
  103710. */
  103711. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  103712. /**
  103713. * Sets a Color3 on a uniform variable.
  103714. * @param uniformName Name of the variable.
  103715. * @param color3 Value to be set.
  103716. * @returns this effect.
  103717. */
  103718. setColor3(uniformName: string, color3: IColor3Like): Effect;
  103719. /**
  103720. * Sets a Color4 on a uniform variable.
  103721. * @param uniformName Name of the variable.
  103722. * @param color3 Value to be set.
  103723. * @param alpha Alpha value to be set.
  103724. * @returns this effect.
  103725. */
  103726. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  103727. /**
  103728. * Sets a Color4 on a uniform variable
  103729. * @param uniformName defines the name of the variable
  103730. * @param color4 defines the value to be set
  103731. * @returns this effect.
  103732. */
  103733. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  103734. /** Release all associated resources */
  103735. dispose(): void;
  103736. /**
  103737. * This function will add a new shader to the shader store
  103738. * @param name the name of the shader
  103739. * @param pixelShader optional pixel shader content
  103740. * @param vertexShader optional vertex shader content
  103741. */
  103742. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  103743. /**
  103744. * Store of each shader (The can be looked up using effect.key)
  103745. */
  103746. static ShadersStore: {
  103747. [key: string]: string;
  103748. };
  103749. /**
  103750. * Store of each included file for a shader (The can be looked up using effect.key)
  103751. */
  103752. static IncludesShadersStore: {
  103753. [key: string]: string;
  103754. };
  103755. /**
  103756. * Resets the cache of effects.
  103757. */
  103758. static ResetCache(): void;
  103759. }
  103760. }
  103761. declare module BABYLON {
  103762. /**
  103763. * Interface used to describe the capabilities of the engine relatively to the current browser
  103764. */
  103765. export interface EngineCapabilities {
  103766. /** Maximum textures units per fragment shader */
  103767. maxTexturesImageUnits: number;
  103768. /** Maximum texture units per vertex shader */
  103769. maxVertexTextureImageUnits: number;
  103770. /** Maximum textures units in the entire pipeline */
  103771. maxCombinedTexturesImageUnits: number;
  103772. /** Maximum texture size */
  103773. maxTextureSize: number;
  103774. /** Maximum texture samples */
  103775. maxSamples?: number;
  103776. /** Maximum cube texture size */
  103777. maxCubemapTextureSize: number;
  103778. /** Maximum render texture size */
  103779. maxRenderTextureSize: number;
  103780. /** Maximum number of vertex attributes */
  103781. maxVertexAttribs: number;
  103782. /** Maximum number of varyings */
  103783. maxVaryingVectors: number;
  103784. /** Maximum number of uniforms per vertex shader */
  103785. maxVertexUniformVectors: number;
  103786. /** Maximum number of uniforms per fragment shader */
  103787. maxFragmentUniformVectors: number;
  103788. /** Defines if standard derivates (dx/dy) are supported */
  103789. standardDerivatives: boolean;
  103790. /** Defines if s3tc texture compression is supported */
  103791. s3tc?: WEBGL_compressed_texture_s3tc;
  103792. /** Defines if pvrtc texture compression is supported */
  103793. pvrtc: any;
  103794. /** Defines if etc1 texture compression is supported */
  103795. etc1: any;
  103796. /** Defines if etc2 texture compression is supported */
  103797. etc2: any;
  103798. /** Defines if astc texture compression is supported */
  103799. astc: any;
  103800. /** Defines if float textures are supported */
  103801. textureFloat: boolean;
  103802. /** Defines if vertex array objects are supported */
  103803. vertexArrayObject: boolean;
  103804. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  103805. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  103806. /** Gets the maximum level of anisotropy supported */
  103807. maxAnisotropy: number;
  103808. /** Defines if instancing is supported */
  103809. instancedArrays: boolean;
  103810. /** Defines if 32 bits indices are supported */
  103811. uintIndices: boolean;
  103812. /** Defines if high precision shaders are supported */
  103813. highPrecisionShaderSupported: boolean;
  103814. /** Defines if depth reading in the fragment shader is supported */
  103815. fragmentDepthSupported: boolean;
  103816. /** Defines if float texture linear filtering is supported*/
  103817. textureFloatLinearFiltering: boolean;
  103818. /** Defines if rendering to float textures is supported */
  103819. textureFloatRender: boolean;
  103820. /** Defines if half float textures are supported*/
  103821. textureHalfFloat: boolean;
  103822. /** Defines if half float texture linear filtering is supported*/
  103823. textureHalfFloatLinearFiltering: boolean;
  103824. /** Defines if rendering to half float textures is supported */
  103825. textureHalfFloatRender: boolean;
  103826. /** Defines if textureLOD shader command is supported */
  103827. textureLOD: boolean;
  103828. /** Defines if draw buffers extension is supported */
  103829. drawBuffersExtension: boolean;
  103830. /** Defines if depth textures are supported */
  103831. depthTextureExtension: boolean;
  103832. /** Defines if float color buffer are supported */
  103833. colorBufferFloat: boolean;
  103834. /** Gets disjoint timer query extension (null if not supported) */
  103835. timerQuery?: EXT_disjoint_timer_query;
  103836. /** Defines if timestamp can be used with timer query */
  103837. canUseTimestampForTimerQuery: boolean;
  103838. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  103839. multiview?: any;
  103840. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  103841. oculusMultiview?: any;
  103842. /** Function used to let the system compiles shaders in background */
  103843. parallelShaderCompile?: {
  103844. COMPLETION_STATUS_KHR: number;
  103845. };
  103846. /** Max number of texture samples for MSAA */
  103847. maxMSAASamples: number;
  103848. /** Defines if the blend min max extension is supported */
  103849. blendMinMax: boolean;
  103850. }
  103851. }
  103852. declare module BABYLON {
  103853. /**
  103854. * @hidden
  103855. **/
  103856. export class DepthCullingState {
  103857. private _isDepthTestDirty;
  103858. private _isDepthMaskDirty;
  103859. private _isDepthFuncDirty;
  103860. private _isCullFaceDirty;
  103861. private _isCullDirty;
  103862. private _isZOffsetDirty;
  103863. private _isFrontFaceDirty;
  103864. private _depthTest;
  103865. private _depthMask;
  103866. private _depthFunc;
  103867. private _cull;
  103868. private _cullFace;
  103869. private _zOffset;
  103870. private _frontFace;
  103871. /**
  103872. * Initializes the state.
  103873. */
  103874. constructor();
  103875. get isDirty(): boolean;
  103876. get zOffset(): number;
  103877. set zOffset(value: number);
  103878. get cullFace(): Nullable<number>;
  103879. set cullFace(value: Nullable<number>);
  103880. get cull(): Nullable<boolean>;
  103881. set cull(value: Nullable<boolean>);
  103882. get depthFunc(): Nullable<number>;
  103883. set depthFunc(value: Nullable<number>);
  103884. get depthMask(): boolean;
  103885. set depthMask(value: boolean);
  103886. get depthTest(): boolean;
  103887. set depthTest(value: boolean);
  103888. get frontFace(): Nullable<number>;
  103889. set frontFace(value: Nullable<number>);
  103890. reset(): void;
  103891. apply(gl: WebGLRenderingContext): void;
  103892. }
  103893. }
  103894. declare module BABYLON {
  103895. /**
  103896. * @hidden
  103897. **/
  103898. export class StencilState {
  103899. /** 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 */
  103900. static readonly ALWAYS: number;
  103901. /** Passed to stencilOperation to specify that stencil value must be kept */
  103902. static readonly KEEP: number;
  103903. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103904. static readonly REPLACE: number;
  103905. private _isStencilTestDirty;
  103906. private _isStencilMaskDirty;
  103907. private _isStencilFuncDirty;
  103908. private _isStencilOpDirty;
  103909. private _stencilTest;
  103910. private _stencilMask;
  103911. private _stencilFunc;
  103912. private _stencilFuncRef;
  103913. private _stencilFuncMask;
  103914. private _stencilOpStencilFail;
  103915. private _stencilOpDepthFail;
  103916. private _stencilOpStencilDepthPass;
  103917. get isDirty(): boolean;
  103918. get stencilFunc(): number;
  103919. set stencilFunc(value: number);
  103920. get stencilFuncRef(): number;
  103921. set stencilFuncRef(value: number);
  103922. get stencilFuncMask(): number;
  103923. set stencilFuncMask(value: number);
  103924. get stencilOpStencilFail(): number;
  103925. set stencilOpStencilFail(value: number);
  103926. get stencilOpDepthFail(): number;
  103927. set stencilOpDepthFail(value: number);
  103928. get stencilOpStencilDepthPass(): number;
  103929. set stencilOpStencilDepthPass(value: number);
  103930. get stencilMask(): number;
  103931. set stencilMask(value: number);
  103932. get stencilTest(): boolean;
  103933. set stencilTest(value: boolean);
  103934. constructor();
  103935. reset(): void;
  103936. apply(gl: WebGLRenderingContext): void;
  103937. }
  103938. }
  103939. declare module BABYLON {
  103940. /**
  103941. * @hidden
  103942. **/
  103943. export class AlphaState {
  103944. private _isAlphaBlendDirty;
  103945. private _isBlendFunctionParametersDirty;
  103946. private _isBlendEquationParametersDirty;
  103947. private _isBlendConstantsDirty;
  103948. private _alphaBlend;
  103949. private _blendFunctionParameters;
  103950. private _blendEquationParameters;
  103951. private _blendConstants;
  103952. /**
  103953. * Initializes the state.
  103954. */
  103955. constructor();
  103956. get isDirty(): boolean;
  103957. get alphaBlend(): boolean;
  103958. set alphaBlend(value: boolean);
  103959. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  103960. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  103961. setAlphaEquationParameters(rgb: number, alpha: number): void;
  103962. reset(): void;
  103963. apply(gl: WebGLRenderingContext): void;
  103964. }
  103965. }
  103966. declare module BABYLON {
  103967. /** @hidden */
  103968. export class WebGL2ShaderProcessor implements IShaderProcessor {
  103969. attributeProcessor(attribute: string): string;
  103970. varyingProcessor(varying: string, isFragment: boolean): string;
  103971. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  103972. }
  103973. }
  103974. declare module BABYLON {
  103975. /**
  103976. * Interface for attribute information associated with buffer instanciation
  103977. */
  103978. export interface InstancingAttributeInfo {
  103979. /**
  103980. * Name of the GLSL attribute
  103981. * if attribute index is not specified, this is used to retrieve the index from the effect
  103982. */
  103983. attributeName: string;
  103984. /**
  103985. * Index/offset of the attribute in the vertex shader
  103986. * if not specified, this will be computes from the name.
  103987. */
  103988. index?: number;
  103989. /**
  103990. * size of the attribute, 1, 2, 3 or 4
  103991. */
  103992. attributeSize: number;
  103993. /**
  103994. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  103995. */
  103996. offset: number;
  103997. /**
  103998. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  103999. * default to 1
  104000. */
  104001. divisor?: number;
  104002. /**
  104003. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  104004. * default is FLOAT
  104005. */
  104006. attributeType?: number;
  104007. /**
  104008. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  104009. */
  104010. normalized?: boolean;
  104011. }
  104012. }
  104013. declare module BABYLON {
  104014. interface ThinEngine {
  104015. /**
  104016. * Update a video texture
  104017. * @param texture defines the texture to update
  104018. * @param video defines the video element to use
  104019. * @param invertY defines if data must be stored with Y axis inverted
  104020. */
  104021. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  104022. }
  104023. }
  104024. declare module BABYLON {
  104025. /**
  104026. * Settings for finer control over video usage
  104027. */
  104028. export interface VideoTextureSettings {
  104029. /**
  104030. * Applies `autoplay` to video, if specified
  104031. */
  104032. autoPlay?: boolean;
  104033. /**
  104034. * Applies `loop` to video, if specified
  104035. */
  104036. loop?: boolean;
  104037. /**
  104038. * Automatically updates internal texture from video at every frame in the render loop
  104039. */
  104040. autoUpdateTexture: boolean;
  104041. /**
  104042. * Image src displayed during the video loading or until the user interacts with the video.
  104043. */
  104044. poster?: string;
  104045. }
  104046. /**
  104047. * If you want to display a video in your scene, this is the special texture for that.
  104048. * This special texture works similar to other textures, with the exception of a few parameters.
  104049. * @see https://doc.babylonjs.com/how_to/video_texture
  104050. */
  104051. export class VideoTexture extends Texture {
  104052. /**
  104053. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  104054. */
  104055. readonly autoUpdateTexture: boolean;
  104056. /**
  104057. * The video instance used by the texture internally
  104058. */
  104059. readonly video: HTMLVideoElement;
  104060. private _onUserActionRequestedObservable;
  104061. /**
  104062. * Event triggerd when a dom action is required by the user to play the video.
  104063. * This happens due to recent changes in browser policies preventing video to auto start.
  104064. */
  104065. get onUserActionRequestedObservable(): Observable<Texture>;
  104066. private _generateMipMaps;
  104067. private _engine;
  104068. private _stillImageCaptured;
  104069. private _displayingPosterTexture;
  104070. private _settings;
  104071. private _createInternalTextureOnEvent;
  104072. private _frameId;
  104073. private _currentSrc;
  104074. /**
  104075. * Creates a video texture.
  104076. * If you want to display a video in your scene, this is the special texture for that.
  104077. * This special texture works similar to other textures, with the exception of a few parameters.
  104078. * @see https://doc.babylonjs.com/how_to/video_texture
  104079. * @param name optional name, will detect from video source, if not defined
  104080. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  104081. * @param scene is obviously the current scene.
  104082. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  104083. * @param invertY is false by default but can be used to invert video on Y axis
  104084. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  104085. * @param settings allows finer control over video usage
  104086. */
  104087. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  104088. private _getName;
  104089. private _getVideo;
  104090. private _createInternalTexture;
  104091. private reset;
  104092. /**
  104093. * @hidden Internal method to initiate `update`.
  104094. */
  104095. _rebuild(): void;
  104096. /**
  104097. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  104098. */
  104099. update(): void;
  104100. /**
  104101. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  104102. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  104103. */
  104104. updateTexture(isVisible: boolean): void;
  104105. protected _updateInternalTexture: () => void;
  104106. /**
  104107. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  104108. * @param url New url.
  104109. */
  104110. updateURL(url: string): void;
  104111. /**
  104112. * Clones the texture.
  104113. * @returns the cloned texture
  104114. */
  104115. clone(): VideoTexture;
  104116. /**
  104117. * Dispose the texture and release its associated resources.
  104118. */
  104119. dispose(): void;
  104120. /**
  104121. * Creates a video texture straight from a stream.
  104122. * @param scene Define the scene the texture should be created in
  104123. * @param stream Define the stream the texture should be created from
  104124. * @returns The created video texture as a promise
  104125. */
  104126. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  104127. /**
  104128. * Creates a video texture straight from your WebCam video feed.
  104129. * @param scene Define the scene the texture should be created in
  104130. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104131. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104132. * @returns The created video texture as a promise
  104133. */
  104134. static CreateFromWebCamAsync(scene: Scene, constraints: {
  104135. minWidth: number;
  104136. maxWidth: number;
  104137. minHeight: number;
  104138. maxHeight: number;
  104139. deviceId: string;
  104140. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  104141. /**
  104142. * Creates a video texture straight from your WebCam video feed.
  104143. * @param scene Define the scene the texture should be created in
  104144. * @param onReady Define a callback to triggered once the texture will be ready
  104145. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104146. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104147. */
  104148. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  104149. minWidth: number;
  104150. maxWidth: number;
  104151. minHeight: number;
  104152. maxHeight: number;
  104153. deviceId: string;
  104154. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  104155. }
  104156. }
  104157. declare module BABYLON {
  104158. /**
  104159. * Defines the interface used by objects working like Scene
  104160. * @hidden
  104161. */
  104162. export interface ISceneLike {
  104163. _addPendingData(data: any): void;
  104164. _removePendingData(data: any): void;
  104165. offlineProvider: IOfflineProvider;
  104166. }
  104167. /** Interface defining initialization parameters for Engine class */
  104168. export interface EngineOptions extends WebGLContextAttributes {
  104169. /**
  104170. * Defines if the engine should no exceed a specified device ratio
  104171. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  104172. */
  104173. limitDeviceRatio?: number;
  104174. /**
  104175. * Defines if webvr should be enabled automatically
  104176. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104177. */
  104178. autoEnableWebVR?: boolean;
  104179. /**
  104180. * Defines if webgl2 should be turned off even if supported
  104181. * @see http://doc.babylonjs.com/features/webgl2
  104182. */
  104183. disableWebGL2Support?: boolean;
  104184. /**
  104185. * Defines if webaudio should be initialized as well
  104186. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104187. */
  104188. audioEngine?: boolean;
  104189. /**
  104190. * Defines if animations should run using a deterministic lock step
  104191. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104192. */
  104193. deterministicLockstep?: boolean;
  104194. /** Defines the maximum steps to use with deterministic lock step mode */
  104195. lockstepMaxSteps?: number;
  104196. /** Defines the seconds between each deterministic lock step */
  104197. timeStep?: number;
  104198. /**
  104199. * Defines that engine should ignore context lost events
  104200. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  104201. */
  104202. doNotHandleContextLost?: boolean;
  104203. /**
  104204. * Defines that engine should ignore modifying touch action attribute and style
  104205. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  104206. */
  104207. doNotHandleTouchAction?: boolean;
  104208. /**
  104209. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  104210. */
  104211. useHighPrecisionFloats?: boolean;
  104212. }
  104213. /**
  104214. * The base engine class (root of all engines)
  104215. */
  104216. export class ThinEngine {
  104217. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  104218. static ExceptionList: ({
  104219. key: string;
  104220. capture: string;
  104221. captureConstraint: number;
  104222. targets: string[];
  104223. } | {
  104224. key: string;
  104225. capture: null;
  104226. captureConstraint: null;
  104227. targets: string[];
  104228. })[];
  104229. /** @hidden */
  104230. static _TextureLoaders: IInternalTextureLoader[];
  104231. /**
  104232. * Returns the current npm package of the sdk
  104233. */
  104234. static get NpmPackage(): string;
  104235. /**
  104236. * Returns the current version of the framework
  104237. */
  104238. static get Version(): string;
  104239. /**
  104240. * Returns a string describing the current engine
  104241. */
  104242. get description(): string;
  104243. /**
  104244. * Gets or sets the epsilon value used by collision engine
  104245. */
  104246. static CollisionsEpsilon: number;
  104247. /**
  104248. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104249. */
  104250. static get ShadersRepository(): string;
  104251. static set ShadersRepository(value: string);
  104252. /** @hidden */
  104253. _shaderProcessor: IShaderProcessor;
  104254. /**
  104255. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  104256. */
  104257. forcePOTTextures: boolean;
  104258. /**
  104259. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  104260. */
  104261. isFullscreen: boolean;
  104262. /**
  104263. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  104264. */
  104265. cullBackFaces: boolean;
  104266. /**
  104267. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  104268. */
  104269. renderEvenInBackground: boolean;
  104270. /**
  104271. * Gets or sets a boolean indicating that cache can be kept between frames
  104272. */
  104273. preventCacheWipeBetweenFrames: boolean;
  104274. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  104275. validateShaderPrograms: boolean;
  104276. /**
  104277. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  104278. * This can provide greater z depth for distant objects.
  104279. */
  104280. useReverseDepthBuffer: boolean;
  104281. /**
  104282. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  104283. */
  104284. disableUniformBuffers: boolean;
  104285. /** @hidden */
  104286. _uniformBuffers: UniformBuffer[];
  104287. /**
  104288. * Gets a boolean indicating that the engine supports uniform buffers
  104289. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  104290. */
  104291. get supportsUniformBuffers(): boolean;
  104292. /** @hidden */
  104293. _gl: WebGLRenderingContext;
  104294. /** @hidden */
  104295. _webGLVersion: number;
  104296. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  104297. protected _windowIsBackground: boolean;
  104298. protected _creationOptions: EngineOptions;
  104299. protected _highPrecisionShadersAllowed: boolean;
  104300. /** @hidden */
  104301. get _shouldUseHighPrecisionShader(): boolean;
  104302. /**
  104303. * Gets a boolean indicating that only power of 2 textures are supported
  104304. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  104305. */
  104306. get needPOTTextures(): boolean;
  104307. /** @hidden */
  104308. _badOS: boolean;
  104309. /** @hidden */
  104310. _badDesktopOS: boolean;
  104311. private _hardwareScalingLevel;
  104312. /** @hidden */
  104313. _caps: EngineCapabilities;
  104314. private _isStencilEnable;
  104315. private _glVersion;
  104316. private _glRenderer;
  104317. private _glVendor;
  104318. /** @hidden */
  104319. _videoTextureSupported: boolean;
  104320. protected _renderingQueueLaunched: boolean;
  104321. protected _activeRenderLoops: (() => void)[];
  104322. /**
  104323. * Observable signaled when a context lost event is raised
  104324. */
  104325. onContextLostObservable: Observable<ThinEngine>;
  104326. /**
  104327. * Observable signaled when a context restored event is raised
  104328. */
  104329. onContextRestoredObservable: Observable<ThinEngine>;
  104330. private _onContextLost;
  104331. private _onContextRestored;
  104332. protected _contextWasLost: boolean;
  104333. /** @hidden */
  104334. _doNotHandleContextLost: boolean;
  104335. /**
  104336. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  104337. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  104338. */
  104339. get doNotHandleContextLost(): boolean;
  104340. set doNotHandleContextLost(value: boolean);
  104341. /**
  104342. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  104343. */
  104344. disableVertexArrayObjects: boolean;
  104345. /** @hidden */
  104346. protected _colorWrite: boolean;
  104347. /** @hidden */
  104348. protected _colorWriteChanged: boolean;
  104349. /** @hidden */
  104350. protected _depthCullingState: DepthCullingState;
  104351. /** @hidden */
  104352. protected _stencilState: StencilState;
  104353. /** @hidden */
  104354. _alphaState: AlphaState;
  104355. /** @hidden */
  104356. _alphaMode: number;
  104357. /** @hidden */
  104358. _alphaEquation: number;
  104359. /** @hidden */
  104360. _internalTexturesCache: InternalTexture[];
  104361. /** @hidden */
  104362. protected _activeChannel: number;
  104363. private _currentTextureChannel;
  104364. /** @hidden */
  104365. protected _boundTexturesCache: {
  104366. [key: string]: Nullable<InternalTexture>;
  104367. };
  104368. /** @hidden */
  104369. protected _currentEffect: Nullable<Effect>;
  104370. /** @hidden */
  104371. protected _currentProgram: Nullable<WebGLProgram>;
  104372. private _compiledEffects;
  104373. private _vertexAttribArraysEnabled;
  104374. /** @hidden */
  104375. protected _cachedViewport: Nullable<IViewportLike>;
  104376. private _cachedVertexArrayObject;
  104377. /** @hidden */
  104378. protected _cachedVertexBuffers: any;
  104379. /** @hidden */
  104380. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  104381. /** @hidden */
  104382. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  104383. /** @hidden */
  104384. _currentRenderTarget: Nullable<InternalTexture>;
  104385. private _uintIndicesCurrentlySet;
  104386. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  104387. /** @hidden */
  104388. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  104389. private _currentBufferPointers;
  104390. private _currentInstanceLocations;
  104391. private _currentInstanceBuffers;
  104392. private _textureUnits;
  104393. /** @hidden */
  104394. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104395. /** @hidden */
  104396. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104397. /** @hidden */
  104398. _boundRenderFunction: any;
  104399. private _vaoRecordInProgress;
  104400. private _mustWipeVertexAttributes;
  104401. private _emptyTexture;
  104402. private _emptyCubeTexture;
  104403. private _emptyTexture3D;
  104404. private _emptyTexture2DArray;
  104405. /** @hidden */
  104406. _frameHandler: number;
  104407. private _nextFreeTextureSlots;
  104408. private _maxSimultaneousTextures;
  104409. private _activeRequests;
  104410. protected _texturesSupported: string[];
  104411. /** @hidden */
  104412. _textureFormatInUse: Nullable<string>;
  104413. protected get _supportsHardwareTextureRescaling(): boolean;
  104414. private _framebufferDimensionsObject;
  104415. /**
  104416. * sets the object from which width and height will be taken from when getting render width and height
  104417. * Will fallback to the gl object
  104418. * @param dimensions the framebuffer width and height that will be used.
  104419. */
  104420. set framebufferDimensionsObject(dimensions: Nullable<{
  104421. framebufferWidth: number;
  104422. framebufferHeight: number;
  104423. }>);
  104424. /**
  104425. * Gets the list of texture formats supported
  104426. */
  104427. get texturesSupported(): Array<string>;
  104428. /**
  104429. * Gets the list of texture formats in use
  104430. */
  104431. get textureFormatInUse(): Nullable<string>;
  104432. /**
  104433. * Gets the current viewport
  104434. */
  104435. get currentViewport(): Nullable<IViewportLike>;
  104436. /**
  104437. * Gets the default empty texture
  104438. */
  104439. get emptyTexture(): InternalTexture;
  104440. /**
  104441. * Gets the default empty 3D texture
  104442. */
  104443. get emptyTexture3D(): InternalTexture;
  104444. /**
  104445. * Gets the default empty 2D array texture
  104446. */
  104447. get emptyTexture2DArray(): InternalTexture;
  104448. /**
  104449. * Gets the default empty cube texture
  104450. */
  104451. get emptyCubeTexture(): InternalTexture;
  104452. /**
  104453. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  104454. */
  104455. readonly premultipliedAlpha: boolean;
  104456. /**
  104457. * Observable event triggered before each texture is initialized
  104458. */
  104459. onBeforeTextureInitObservable: Observable<Texture>;
  104460. /**
  104461. * Creates a new engine
  104462. * @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
  104463. * @param antialias defines enable antialiasing (default: false)
  104464. * @param options defines further options to be sent to the getContext() function
  104465. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104466. */
  104467. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104468. private _rebuildInternalTextures;
  104469. private _rebuildEffects;
  104470. /**
  104471. * Gets a boolean indicating if all created effects are ready
  104472. * @returns true if all effects are ready
  104473. */
  104474. areAllEffectsReady(): boolean;
  104475. protected _rebuildBuffers(): void;
  104476. private _initGLContext;
  104477. /**
  104478. * Gets version of the current webGL context
  104479. */
  104480. get webGLVersion(): number;
  104481. /**
  104482. * Gets a string idenfifying the name of the class
  104483. * @returns "Engine" string
  104484. */
  104485. getClassName(): string;
  104486. /**
  104487. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  104488. */
  104489. get isStencilEnable(): boolean;
  104490. /** @hidden */
  104491. _prepareWorkingCanvas(): void;
  104492. /**
  104493. * Reset the texture cache to empty state
  104494. */
  104495. resetTextureCache(): void;
  104496. /**
  104497. * Gets an object containing information about the current webGL context
  104498. * @returns an object containing the vender, the renderer and the version of the current webGL context
  104499. */
  104500. getGlInfo(): {
  104501. vendor: string;
  104502. renderer: string;
  104503. version: string;
  104504. };
  104505. /**
  104506. * Defines the hardware scaling level.
  104507. * By default the hardware scaling level is computed from the window device ratio.
  104508. * 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.
  104509. * @param level defines the level to use
  104510. */
  104511. setHardwareScalingLevel(level: number): void;
  104512. /**
  104513. * Gets the current hardware scaling level.
  104514. * By default the hardware scaling level is computed from the window device ratio.
  104515. * 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.
  104516. * @returns a number indicating the current hardware scaling level
  104517. */
  104518. getHardwareScalingLevel(): number;
  104519. /**
  104520. * Gets the list of loaded textures
  104521. * @returns an array containing all loaded textures
  104522. */
  104523. getLoadedTexturesCache(): InternalTexture[];
  104524. /**
  104525. * Gets the object containing all engine capabilities
  104526. * @returns the EngineCapabilities object
  104527. */
  104528. getCaps(): EngineCapabilities;
  104529. /**
  104530. * stop executing a render loop function and remove it from the execution array
  104531. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  104532. */
  104533. stopRenderLoop(renderFunction?: () => void): void;
  104534. /** @hidden */
  104535. _renderLoop(): void;
  104536. /**
  104537. * Gets the HTML canvas attached with the current webGL context
  104538. * @returns a HTML canvas
  104539. */
  104540. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  104541. /**
  104542. * Gets host window
  104543. * @returns the host window object
  104544. */
  104545. getHostWindow(): Nullable<Window>;
  104546. /**
  104547. * Gets the current render width
  104548. * @param useScreen defines if screen size must be used (or the current render target if any)
  104549. * @returns a number defining the current render width
  104550. */
  104551. getRenderWidth(useScreen?: boolean): number;
  104552. /**
  104553. * Gets the current render height
  104554. * @param useScreen defines if screen size must be used (or the current render target if any)
  104555. * @returns a number defining the current render height
  104556. */
  104557. getRenderHeight(useScreen?: boolean): number;
  104558. /**
  104559. * Can be used to override the current requestAnimationFrame requester.
  104560. * @hidden
  104561. */
  104562. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  104563. /**
  104564. * Register and execute a render loop. The engine can have more than one render function
  104565. * @param renderFunction defines the function to continuously execute
  104566. */
  104567. runRenderLoop(renderFunction: () => void): void;
  104568. /**
  104569. * Clear the current render buffer or the current render target (if any is set up)
  104570. * @param color defines the color to use
  104571. * @param backBuffer defines if the back buffer must be cleared
  104572. * @param depth defines if the depth buffer must be cleared
  104573. * @param stencil defines if the stencil buffer must be cleared
  104574. */
  104575. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104576. private _viewportCached;
  104577. /** @hidden */
  104578. _viewport(x: number, y: number, width: number, height: number): void;
  104579. /**
  104580. * Set the WebGL's viewport
  104581. * @param viewport defines the viewport element to be used
  104582. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  104583. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  104584. */
  104585. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  104586. /**
  104587. * Begin a new frame
  104588. */
  104589. beginFrame(): void;
  104590. /**
  104591. * Enf the current frame
  104592. */
  104593. endFrame(): void;
  104594. /**
  104595. * Resize the view according to the canvas' size
  104596. */
  104597. resize(): void;
  104598. /**
  104599. * Force a specific size of the canvas
  104600. * @param width defines the new canvas' width
  104601. * @param height defines the new canvas' height
  104602. */
  104603. setSize(width: number, height: number): void;
  104604. /**
  104605. * Binds the frame buffer to the specified texture.
  104606. * @param texture The texture to render to or null for the default canvas
  104607. * @param faceIndex The face of the texture to render to in case of cube texture
  104608. * @param requiredWidth The width of the target to render to
  104609. * @param requiredHeight The height of the target to render to
  104610. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  104611. * @param lodLevel defines the lod level to bind to the frame buffer
  104612. * @param layer defines the 2d array index to bind to frame buffer to
  104613. */
  104614. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  104615. /** @hidden */
  104616. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  104617. /**
  104618. * Unbind the current render target texture from the webGL context
  104619. * @param texture defines the render target texture to unbind
  104620. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104621. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104622. */
  104623. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104624. /**
  104625. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  104626. */
  104627. flushFramebuffer(): void;
  104628. /**
  104629. * Unbind the current render target and bind the default framebuffer
  104630. */
  104631. restoreDefaultFramebuffer(): void;
  104632. /** @hidden */
  104633. protected _resetVertexBufferBinding(): void;
  104634. /**
  104635. * Creates a vertex buffer
  104636. * @param data the data for the vertex buffer
  104637. * @returns the new WebGL static buffer
  104638. */
  104639. createVertexBuffer(data: DataArray): DataBuffer;
  104640. private _createVertexBuffer;
  104641. /**
  104642. * Creates a dynamic vertex buffer
  104643. * @param data the data for the dynamic vertex buffer
  104644. * @returns the new WebGL dynamic buffer
  104645. */
  104646. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  104647. protected _resetIndexBufferBinding(): void;
  104648. /**
  104649. * Creates a new index buffer
  104650. * @param indices defines the content of the index buffer
  104651. * @param updatable defines if the index buffer must be updatable
  104652. * @returns a new webGL buffer
  104653. */
  104654. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  104655. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  104656. /**
  104657. * Bind a webGL buffer to the webGL context
  104658. * @param buffer defines the buffer to bind
  104659. */
  104660. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  104661. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  104662. private bindBuffer;
  104663. /**
  104664. * update the bound buffer with the given data
  104665. * @param data defines the data to update
  104666. */
  104667. updateArrayBuffer(data: Float32Array): void;
  104668. private _vertexAttribPointer;
  104669. /** @hidden */
  104670. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  104671. private _bindVertexBuffersAttributes;
  104672. /**
  104673. * Records a vertex array object
  104674. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104675. * @param vertexBuffers defines the list of vertex buffers to store
  104676. * @param indexBuffer defines the index buffer to store
  104677. * @param effect defines the effect to store
  104678. * @returns the new vertex array object
  104679. */
  104680. recordVertexArrayObject(vertexBuffers: {
  104681. [key: string]: VertexBuffer;
  104682. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  104683. /**
  104684. * Bind a specific vertex array object
  104685. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104686. * @param vertexArrayObject defines the vertex array object to bind
  104687. * @param indexBuffer defines the index buffer to bind
  104688. */
  104689. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  104690. /**
  104691. * Bind webGl buffers directly to the webGL context
  104692. * @param vertexBuffer defines the vertex buffer to bind
  104693. * @param indexBuffer defines the index buffer to bind
  104694. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  104695. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  104696. * @param effect defines the effect associated with the vertex buffer
  104697. */
  104698. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  104699. private _unbindVertexArrayObject;
  104700. /**
  104701. * Bind a list of vertex buffers to the webGL context
  104702. * @param vertexBuffers defines the list of vertex buffers to bind
  104703. * @param indexBuffer defines the index buffer to bind
  104704. * @param effect defines the effect associated with the vertex buffers
  104705. */
  104706. bindBuffers(vertexBuffers: {
  104707. [key: string]: Nullable<VertexBuffer>;
  104708. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  104709. /**
  104710. * Unbind all instance attributes
  104711. */
  104712. unbindInstanceAttributes(): void;
  104713. /**
  104714. * Release and free the memory of a vertex array object
  104715. * @param vao defines the vertex array object to delete
  104716. */
  104717. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  104718. /** @hidden */
  104719. _releaseBuffer(buffer: DataBuffer): boolean;
  104720. protected _deleteBuffer(buffer: DataBuffer): void;
  104721. /**
  104722. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  104723. * @param instancesBuffer defines the webGL buffer to update and bind
  104724. * @param data defines the data to store in the buffer
  104725. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  104726. */
  104727. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  104728. /**
  104729. * Bind the content of a webGL buffer used with instantiation
  104730. * @param instancesBuffer defines the webGL buffer to bind
  104731. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  104732. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  104733. */
  104734. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  104735. /**
  104736. * Disable the instance attribute corresponding to the name in parameter
  104737. * @param name defines the name of the attribute to disable
  104738. */
  104739. disableInstanceAttributeByName(name: string): void;
  104740. /**
  104741. * Disable the instance attribute corresponding to the location in parameter
  104742. * @param attributeLocation defines the attribute location of the attribute to disable
  104743. */
  104744. disableInstanceAttribute(attributeLocation: number): void;
  104745. /**
  104746. * Disable the attribute corresponding to the location in parameter
  104747. * @param attributeLocation defines the attribute location of the attribute to disable
  104748. */
  104749. disableAttributeByIndex(attributeLocation: number): void;
  104750. /**
  104751. * Send a draw order
  104752. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104753. * @param indexStart defines the starting index
  104754. * @param indexCount defines the number of index to draw
  104755. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104756. */
  104757. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104758. /**
  104759. * Draw a list of points
  104760. * @param verticesStart defines the index of first vertex to draw
  104761. * @param verticesCount defines the count of vertices to draw
  104762. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104763. */
  104764. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104765. /**
  104766. * Draw a list of unindexed primitives
  104767. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104768. * @param verticesStart defines the index of first vertex to draw
  104769. * @param verticesCount defines the count of vertices to draw
  104770. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104771. */
  104772. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104773. /**
  104774. * Draw a list of indexed primitives
  104775. * @param fillMode defines the primitive to use
  104776. * @param indexStart defines the starting index
  104777. * @param indexCount defines the number of index to draw
  104778. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104779. */
  104780. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104781. /**
  104782. * Draw a list of unindexed primitives
  104783. * @param fillMode defines the primitive to use
  104784. * @param verticesStart defines the index of first vertex to draw
  104785. * @param verticesCount defines the count of vertices to draw
  104786. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104787. */
  104788. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104789. private _drawMode;
  104790. /** @hidden */
  104791. protected _reportDrawCall(): void;
  104792. /** @hidden */
  104793. _releaseEffect(effect: Effect): void;
  104794. /** @hidden */
  104795. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104796. /**
  104797. * Create a new effect (used to store vertex/fragment shaders)
  104798. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  104799. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  104800. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  104801. * @param samplers defines an array of string used to represent textures
  104802. * @param defines defines the string containing the defines to use to compile the shaders
  104803. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104804. * @param onCompiled defines a function to call when the effect creation is successful
  104805. * @param onError defines a function to call when the effect creation has failed
  104806. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  104807. * @returns the new Effect
  104808. */
  104809. 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;
  104810. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  104811. private _compileShader;
  104812. private _compileRawShader;
  104813. /**
  104814. * Directly creates a webGL program
  104815. * @param pipelineContext defines the pipeline context to attach to
  104816. * @param vertexCode defines the vertex shader code to use
  104817. * @param fragmentCode defines the fragment shader code to use
  104818. * @param context defines the webGL context to use (if not set, the current one will be used)
  104819. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104820. * @returns the new webGL program
  104821. */
  104822. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104823. /**
  104824. * Creates a webGL program
  104825. * @param pipelineContext defines the pipeline context to attach to
  104826. * @param vertexCode defines the vertex shader code to use
  104827. * @param fragmentCode defines the fragment shader code to use
  104828. * @param defines defines the string containing the defines to use to compile the shaders
  104829. * @param context defines the webGL context to use (if not set, the current one will be used)
  104830. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104831. * @returns the new webGL program
  104832. */
  104833. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104834. /**
  104835. * Creates a new pipeline context
  104836. * @returns the new pipeline
  104837. */
  104838. createPipelineContext(): IPipelineContext;
  104839. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104840. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  104841. /** @hidden */
  104842. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  104843. /** @hidden */
  104844. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  104845. /** @hidden */
  104846. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  104847. /**
  104848. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  104849. * @param pipelineContext defines the pipeline context to use
  104850. * @param uniformsNames defines the list of uniform names
  104851. * @returns an array of webGL uniform locations
  104852. */
  104853. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104854. /**
  104855. * Gets the lsit of active attributes for a given webGL program
  104856. * @param pipelineContext defines the pipeline context to use
  104857. * @param attributesNames defines the list of attribute names to get
  104858. * @returns an array of indices indicating the offset of each attribute
  104859. */
  104860. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104861. /**
  104862. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  104863. * @param effect defines the effect to activate
  104864. */
  104865. enableEffect(effect: Nullable<Effect>): void;
  104866. /**
  104867. * Set the value of an uniform to a number (int)
  104868. * @param uniform defines the webGL uniform location where to store the value
  104869. * @param value defines the int number to store
  104870. */
  104871. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104872. /**
  104873. * Set the value of an uniform to an array of int32
  104874. * @param uniform defines the webGL uniform location where to store the value
  104875. * @param array defines the array of int32 to store
  104876. */
  104877. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104878. /**
  104879. * Set the value of an uniform to an array of int32 (stored as vec2)
  104880. * @param uniform defines the webGL uniform location where to store the value
  104881. * @param array defines the array of int32 to store
  104882. */
  104883. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104884. /**
  104885. * Set the value of an uniform to an array of int32 (stored as vec3)
  104886. * @param uniform defines the webGL uniform location where to store the value
  104887. * @param array defines the array of int32 to store
  104888. */
  104889. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104890. /**
  104891. * Set the value of an uniform to an array of int32 (stored as vec4)
  104892. * @param uniform defines the webGL uniform location where to store the value
  104893. * @param array defines the array of int32 to store
  104894. */
  104895. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104896. /**
  104897. * Set the value of an uniform to an array of number
  104898. * @param uniform defines the webGL uniform location where to store the value
  104899. * @param array defines the array of number to store
  104900. */
  104901. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104902. /**
  104903. * Set the value of an uniform to an array of number (stored as vec2)
  104904. * @param uniform defines the webGL uniform location where to store the value
  104905. * @param array defines the array of number to store
  104906. */
  104907. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104908. /**
  104909. * Set the value of an uniform to an array of number (stored as vec3)
  104910. * @param uniform defines the webGL uniform location where to store the value
  104911. * @param array defines the array of number to store
  104912. */
  104913. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104914. /**
  104915. * Set the value of an uniform to an array of number (stored as vec4)
  104916. * @param uniform defines the webGL uniform location where to store the value
  104917. * @param array defines the array of number to store
  104918. */
  104919. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104920. /**
  104921. * Set the value of an uniform to an array of float32 (stored as matrices)
  104922. * @param uniform defines the webGL uniform location where to store the value
  104923. * @param matrices defines the array of float32 to store
  104924. */
  104925. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  104926. /**
  104927. * Set the value of an uniform to a matrix (3x3)
  104928. * @param uniform defines the webGL uniform location where to store the value
  104929. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  104930. */
  104931. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104932. /**
  104933. * Set the value of an uniform to a matrix (2x2)
  104934. * @param uniform defines the webGL uniform location where to store the value
  104935. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  104936. */
  104937. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104938. /**
  104939. * Set the value of an uniform to a number (float)
  104940. * @param uniform defines the webGL uniform location where to store the value
  104941. * @param value defines the float number to store
  104942. */
  104943. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104944. /**
  104945. * Set the value of an uniform to a vec2
  104946. * @param uniform defines the webGL uniform location where to store the value
  104947. * @param x defines the 1st component of the value
  104948. * @param y defines the 2nd component of the value
  104949. */
  104950. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  104951. /**
  104952. * Set the value of an uniform to a vec3
  104953. * @param uniform defines the webGL uniform location where to store the value
  104954. * @param x defines the 1st component of the value
  104955. * @param y defines the 2nd component of the value
  104956. * @param z defines the 3rd component of the value
  104957. */
  104958. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  104959. /**
  104960. * Set the value of an uniform to a vec4
  104961. * @param uniform defines the webGL uniform location where to store the value
  104962. * @param x defines the 1st component of the value
  104963. * @param y defines the 2nd component of the value
  104964. * @param z defines the 3rd component of the value
  104965. * @param w defines the 4th component of the value
  104966. */
  104967. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  104968. /**
  104969. * Apply all cached states (depth, culling, stencil and alpha)
  104970. */
  104971. applyStates(): void;
  104972. /**
  104973. * Enable or disable color writing
  104974. * @param enable defines the state to set
  104975. */
  104976. setColorWrite(enable: boolean): void;
  104977. /**
  104978. * Gets a boolean indicating if color writing is enabled
  104979. * @returns the current color writing state
  104980. */
  104981. getColorWrite(): boolean;
  104982. /**
  104983. * Gets the depth culling state manager
  104984. */
  104985. get depthCullingState(): DepthCullingState;
  104986. /**
  104987. * Gets the alpha state manager
  104988. */
  104989. get alphaState(): AlphaState;
  104990. /**
  104991. * Gets the stencil state manager
  104992. */
  104993. get stencilState(): StencilState;
  104994. /**
  104995. * Clears the list of texture accessible through engine.
  104996. * This can help preventing texture load conflict due to name collision.
  104997. */
  104998. clearInternalTexturesCache(): void;
  104999. /**
  105000. * Force the entire cache to be cleared
  105001. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  105002. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  105003. */
  105004. wipeCaches(bruteForce?: boolean): void;
  105005. /** @hidden */
  105006. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  105007. min: number;
  105008. mag: number;
  105009. };
  105010. /** @hidden */
  105011. _createTexture(): WebGLTexture;
  105012. /**
  105013. * Usually called from Texture.ts.
  105014. * Passed information to create a WebGLTexture
  105015. * @param urlArg defines a value which contains one of the following:
  105016. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  105017. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  105018. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  105019. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  105020. * @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)
  105021. * @param scene needed for loading to the correct scene
  105022. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  105023. * @param onLoad optional callback to be called upon successful completion
  105024. * @param onError optional callback to be called upon failure
  105025. * @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
  105026. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  105027. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  105028. * @param forcedExtension defines the extension to use to pick the right loader
  105029. * @param mimeType defines an optional mime type
  105030. * @returns a InternalTexture for assignment back into BABYLON.Texture
  105031. */
  105032. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  105033. /**
  105034. * Loads an image as an HTMLImageElement.
  105035. * @param input url string, ArrayBuffer, or Blob to load
  105036. * @param onLoad callback called when the image successfully loads
  105037. * @param onError callback called when the image fails to load
  105038. * @param offlineProvider offline provider for caching
  105039. * @param mimeType optional mime type
  105040. * @returns the HTMLImageElement of the loaded image
  105041. * @hidden
  105042. */
  105043. 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>;
  105044. /**
  105045. * @hidden
  105046. */
  105047. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  105048. /**
  105049. * Creates a raw texture
  105050. * @param data defines the data to store in the texture
  105051. * @param width defines the width of the texture
  105052. * @param height defines the height of the texture
  105053. * @param format defines the format of the data
  105054. * @param generateMipMaps defines if the engine should generate the mip levels
  105055. * @param invertY defines if data must be stored with Y axis inverted
  105056. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  105057. * @param compression defines the compression used (null by default)
  105058. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105059. * @returns the raw texture inside an InternalTexture
  105060. */
  105061. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  105062. /**
  105063. * Creates a new raw cube texture
  105064. * @param data defines the array of data to use to create each face
  105065. * @param size defines the size of the textures
  105066. * @param format defines the format of the data
  105067. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105068. * @param generateMipMaps defines if the engine should generate the mip levels
  105069. * @param invertY defines if data must be stored with Y axis inverted
  105070. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105071. * @param compression defines the compression used (null by default)
  105072. * @returns the cube texture as an InternalTexture
  105073. */
  105074. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  105075. /**
  105076. * Creates a new raw 3D texture
  105077. * @param data defines the data used to create the texture
  105078. * @param width defines the width of the texture
  105079. * @param height defines the height of the texture
  105080. * @param depth defines the depth of the texture
  105081. * @param format defines the format of the texture
  105082. * @param generateMipMaps defines if the engine must generate mip levels
  105083. * @param invertY defines if data must be stored with Y axis inverted
  105084. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105085. * @param compression defines the compressed used (can be null)
  105086. * @param textureType defines the compressed used (can be null)
  105087. * @returns a new raw 3D texture (stored in an InternalTexture)
  105088. */
  105089. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105090. /**
  105091. * Creates a new raw 2D array texture
  105092. * @param data defines the data used to create the texture
  105093. * @param width defines the width of the texture
  105094. * @param height defines the height of the texture
  105095. * @param depth defines the number of layers of the texture
  105096. * @param format defines the format of the texture
  105097. * @param generateMipMaps defines if the engine must generate mip levels
  105098. * @param invertY defines if data must be stored with Y axis inverted
  105099. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105100. * @param compression defines the compressed used (can be null)
  105101. * @param textureType defines the compressed used (can be null)
  105102. * @returns a new raw 2D array texture (stored in an InternalTexture)
  105103. */
  105104. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105105. private _unpackFlipYCached;
  105106. /**
  105107. * In case you are sharing the context with other applications, it might
  105108. * be interested to not cache the unpack flip y state to ensure a consistent
  105109. * value would be set.
  105110. */
  105111. enableUnpackFlipYCached: boolean;
  105112. /** @hidden */
  105113. _unpackFlipY(value: boolean): void;
  105114. /** @hidden */
  105115. _getUnpackAlignement(): number;
  105116. private _getTextureTarget;
  105117. /**
  105118. * Update the sampling mode of a given texture
  105119. * @param samplingMode defines the required sampling mode
  105120. * @param texture defines the texture to update
  105121. * @param generateMipMaps defines whether to generate mipmaps for the texture
  105122. */
  105123. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  105124. /**
  105125. * Update the sampling mode of a given texture
  105126. * @param texture defines the texture to update
  105127. * @param wrapU defines the texture wrap mode of the u coordinates
  105128. * @param wrapV defines the texture wrap mode of the v coordinates
  105129. * @param wrapR defines the texture wrap mode of the r coordinates
  105130. */
  105131. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  105132. /** @hidden */
  105133. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  105134. width: number;
  105135. height: number;
  105136. layers?: number;
  105137. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  105138. /** @hidden */
  105139. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105140. /** @hidden */
  105141. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  105142. /**
  105143. * Update a portion of an internal texture
  105144. * @param texture defines the texture to update
  105145. * @param imageData defines the data to store into the texture
  105146. * @param xOffset defines the x coordinates of the update rectangle
  105147. * @param yOffset defines the y coordinates of the update rectangle
  105148. * @param width defines the width of the update rectangle
  105149. * @param height defines the height of the update rectangle
  105150. * @param faceIndex defines the face index if texture is a cube (0 by default)
  105151. * @param lod defines the lod level to update (0 by default)
  105152. */
  105153. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  105154. /** @hidden */
  105155. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105156. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  105157. private _prepareWebGLTexture;
  105158. /** @hidden */
  105159. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  105160. private _getDepthStencilBuffer;
  105161. /** @hidden */
  105162. _releaseFramebufferObjects(texture: InternalTexture): void;
  105163. /** @hidden */
  105164. _releaseTexture(texture: InternalTexture): void;
  105165. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  105166. protected _setProgram(program: WebGLProgram): void;
  105167. protected _boundUniforms: {
  105168. [key: number]: WebGLUniformLocation;
  105169. };
  105170. /**
  105171. * Binds an effect to the webGL context
  105172. * @param effect defines the effect to bind
  105173. */
  105174. bindSamplers(effect: Effect): void;
  105175. private _activateCurrentTexture;
  105176. /** @hidden */
  105177. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  105178. /** @hidden */
  105179. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  105180. /**
  105181. * Unbind all textures from the webGL context
  105182. */
  105183. unbindAllTextures(): void;
  105184. /**
  105185. * Sets a texture to the according uniform.
  105186. * @param channel The texture channel
  105187. * @param uniform The uniform to set
  105188. * @param texture The texture to apply
  105189. */
  105190. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  105191. private _bindSamplerUniformToChannel;
  105192. private _getTextureWrapMode;
  105193. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  105194. /**
  105195. * Sets an array of texture to the webGL context
  105196. * @param channel defines the channel where the texture array must be set
  105197. * @param uniform defines the associated uniform location
  105198. * @param textures defines the array of textures to bind
  105199. */
  105200. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  105201. /** @hidden */
  105202. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  105203. private _setTextureParameterFloat;
  105204. private _setTextureParameterInteger;
  105205. /**
  105206. * Unbind all vertex attributes from the webGL context
  105207. */
  105208. unbindAllAttributes(): void;
  105209. /**
  105210. * 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
  105211. */
  105212. releaseEffects(): void;
  105213. /**
  105214. * Dispose and release all associated resources
  105215. */
  105216. dispose(): void;
  105217. /**
  105218. * Attach a new callback raised when context lost event is fired
  105219. * @param callback defines the callback to call
  105220. */
  105221. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105222. /**
  105223. * Attach a new callback raised when context restored event is fired
  105224. * @param callback defines the callback to call
  105225. */
  105226. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105227. /**
  105228. * Get the current error code of the webGL context
  105229. * @returns the error code
  105230. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105231. */
  105232. getError(): number;
  105233. private _canRenderToFloatFramebuffer;
  105234. private _canRenderToHalfFloatFramebuffer;
  105235. private _canRenderToFramebuffer;
  105236. /** @hidden */
  105237. _getWebGLTextureType(type: number): number;
  105238. /** @hidden */
  105239. _getInternalFormat(format: number): number;
  105240. /** @hidden */
  105241. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  105242. /** @hidden */
  105243. _getRGBAMultiSampleBufferFormat(type: number): number;
  105244. /** @hidden */
  105245. _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;
  105246. /**
  105247. * Loads a file from a url
  105248. * @param url url to load
  105249. * @param onSuccess callback called when the file successfully loads
  105250. * @param onProgress callback called while file is loading (if the server supports this mode)
  105251. * @param offlineProvider defines the offline provider for caching
  105252. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105253. * @param onError callback called when the file fails to load
  105254. * @returns a file request object
  105255. * @hidden
  105256. */
  105257. 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;
  105258. /**
  105259. * Reads pixels from the current frame buffer. Please note that this function can be slow
  105260. * @param x defines the x coordinate of the rectangle where pixels must be read
  105261. * @param y defines the y coordinate of the rectangle where pixels must be read
  105262. * @param width defines the width of the rectangle where pixels must be read
  105263. * @param height defines the height of the rectangle where pixels must be read
  105264. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  105265. * @returns a Uint8Array containing RGBA colors
  105266. */
  105267. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  105268. private static _isSupported;
  105269. /**
  105270. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  105271. * @returns true if the engine can be created
  105272. * @ignorenaming
  105273. */
  105274. static isSupported(): boolean;
  105275. /**
  105276. * Find the next highest power of two.
  105277. * @param x Number to start search from.
  105278. * @return Next highest power of two.
  105279. */
  105280. static CeilingPOT(x: number): number;
  105281. /**
  105282. * Find the next lowest power of two.
  105283. * @param x Number to start search from.
  105284. * @return Next lowest power of two.
  105285. */
  105286. static FloorPOT(x: number): number;
  105287. /**
  105288. * Find the nearest power of two.
  105289. * @param x Number to start search from.
  105290. * @return Next nearest power of two.
  105291. */
  105292. static NearestPOT(x: number): number;
  105293. /**
  105294. * Get the closest exponent of two
  105295. * @param value defines the value to approximate
  105296. * @param max defines the maximum value to return
  105297. * @param mode defines how to define the closest value
  105298. * @returns closest exponent of two of the given value
  105299. */
  105300. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  105301. /**
  105302. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  105303. * @param func - the function to be called
  105304. * @param requester - the object that will request the next frame. Falls back to window.
  105305. * @returns frame number
  105306. */
  105307. static QueueNewFrame(func: () => void, requester?: any): number;
  105308. /**
  105309. * Gets host document
  105310. * @returns the host document object
  105311. */
  105312. getHostDocument(): Nullable<Document>;
  105313. }
  105314. }
  105315. declare module BABYLON {
  105316. /**
  105317. * Class representing spherical harmonics coefficients to the 3rd degree
  105318. */
  105319. export class SphericalHarmonics {
  105320. /**
  105321. * Defines whether or not the harmonics have been prescaled for rendering.
  105322. */
  105323. preScaled: boolean;
  105324. /**
  105325. * The l0,0 coefficients of the spherical harmonics
  105326. */
  105327. l00: Vector3;
  105328. /**
  105329. * The l1,-1 coefficients of the spherical harmonics
  105330. */
  105331. l1_1: Vector3;
  105332. /**
  105333. * The l1,0 coefficients of the spherical harmonics
  105334. */
  105335. l10: Vector3;
  105336. /**
  105337. * The l1,1 coefficients of the spherical harmonics
  105338. */
  105339. l11: Vector3;
  105340. /**
  105341. * The l2,-2 coefficients of the spherical harmonics
  105342. */
  105343. l2_2: Vector3;
  105344. /**
  105345. * The l2,-1 coefficients of the spherical harmonics
  105346. */
  105347. l2_1: Vector3;
  105348. /**
  105349. * The l2,0 coefficients of the spherical harmonics
  105350. */
  105351. l20: Vector3;
  105352. /**
  105353. * The l2,1 coefficients of the spherical harmonics
  105354. */
  105355. l21: Vector3;
  105356. /**
  105357. * The l2,2 coefficients of the spherical harmonics
  105358. */
  105359. l22: Vector3;
  105360. /**
  105361. * Adds a light to the spherical harmonics
  105362. * @param direction the direction of the light
  105363. * @param color the color of the light
  105364. * @param deltaSolidAngle the delta solid angle of the light
  105365. */
  105366. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105367. /**
  105368. * Scales the spherical harmonics by the given amount
  105369. * @param scale the amount to scale
  105370. */
  105371. scaleInPlace(scale: number): void;
  105372. /**
  105373. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105374. *
  105375. * ```
  105376. * E_lm = A_l * L_lm
  105377. * ```
  105378. *
  105379. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105380. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105381. * the scaling factors are given in equation 9.
  105382. */
  105383. convertIncidentRadianceToIrradiance(): void;
  105384. /**
  105385. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105386. *
  105387. * ```
  105388. * L = (1/pi) * E * rho
  105389. * ```
  105390. *
  105391. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105392. */
  105393. convertIrradianceToLambertianRadiance(): void;
  105394. /**
  105395. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105396. * required operations at run time.
  105397. *
  105398. * This is simply done by scaling back the SH with Ylm constants parameter.
  105399. * The trigonometric part being applied by the shader at run time.
  105400. */
  105401. preScaleForRendering(): void;
  105402. /**
  105403. * Constructs a spherical harmonics from an array.
  105404. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105405. * @returns the spherical harmonics
  105406. */
  105407. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105408. /**
  105409. * Gets the spherical harmonics from polynomial
  105410. * @param polynomial the spherical polynomial
  105411. * @returns the spherical harmonics
  105412. */
  105413. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105414. }
  105415. /**
  105416. * Class representing spherical polynomial coefficients to the 3rd degree
  105417. */
  105418. export class SphericalPolynomial {
  105419. private _harmonics;
  105420. /**
  105421. * The spherical harmonics used to create the polynomials.
  105422. */
  105423. get preScaledHarmonics(): SphericalHarmonics;
  105424. /**
  105425. * The x coefficients of the spherical polynomial
  105426. */
  105427. x: Vector3;
  105428. /**
  105429. * The y coefficients of the spherical polynomial
  105430. */
  105431. y: Vector3;
  105432. /**
  105433. * The z coefficients of the spherical polynomial
  105434. */
  105435. z: Vector3;
  105436. /**
  105437. * The xx coefficients of the spherical polynomial
  105438. */
  105439. xx: Vector3;
  105440. /**
  105441. * The yy coefficients of the spherical polynomial
  105442. */
  105443. yy: Vector3;
  105444. /**
  105445. * The zz coefficients of the spherical polynomial
  105446. */
  105447. zz: Vector3;
  105448. /**
  105449. * The xy coefficients of the spherical polynomial
  105450. */
  105451. xy: Vector3;
  105452. /**
  105453. * The yz coefficients of the spherical polynomial
  105454. */
  105455. yz: Vector3;
  105456. /**
  105457. * The zx coefficients of the spherical polynomial
  105458. */
  105459. zx: Vector3;
  105460. /**
  105461. * Adds an ambient color to the spherical polynomial
  105462. * @param color the color to add
  105463. */
  105464. addAmbient(color: Color3): void;
  105465. /**
  105466. * Scales the spherical polynomial by the given amount
  105467. * @param scale the amount to scale
  105468. */
  105469. scaleInPlace(scale: number): void;
  105470. /**
  105471. * Gets the spherical polynomial from harmonics
  105472. * @param harmonics the spherical harmonics
  105473. * @returns the spherical polynomial
  105474. */
  105475. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105476. /**
  105477. * Constructs a spherical polynomial from an array.
  105478. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105479. * @returns the spherical polynomial
  105480. */
  105481. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105482. }
  105483. }
  105484. declare module BABYLON {
  105485. /**
  105486. * Defines the source of the internal texture
  105487. */
  105488. export enum InternalTextureSource {
  105489. /**
  105490. * The source of the texture data is unknown
  105491. */
  105492. Unknown = 0,
  105493. /**
  105494. * Texture data comes from an URL
  105495. */
  105496. Url = 1,
  105497. /**
  105498. * Texture data is only used for temporary storage
  105499. */
  105500. Temp = 2,
  105501. /**
  105502. * Texture data comes from raw data (ArrayBuffer)
  105503. */
  105504. Raw = 3,
  105505. /**
  105506. * Texture content is dynamic (video or dynamic texture)
  105507. */
  105508. Dynamic = 4,
  105509. /**
  105510. * Texture content is generated by rendering to it
  105511. */
  105512. RenderTarget = 5,
  105513. /**
  105514. * Texture content is part of a multi render target process
  105515. */
  105516. MultiRenderTarget = 6,
  105517. /**
  105518. * Texture data comes from a cube data file
  105519. */
  105520. Cube = 7,
  105521. /**
  105522. * Texture data comes from a raw cube data
  105523. */
  105524. CubeRaw = 8,
  105525. /**
  105526. * Texture data come from a prefiltered cube data file
  105527. */
  105528. CubePrefiltered = 9,
  105529. /**
  105530. * Texture content is raw 3D data
  105531. */
  105532. Raw3D = 10,
  105533. /**
  105534. * Texture content is raw 2D array data
  105535. */
  105536. Raw2DArray = 11,
  105537. /**
  105538. * Texture content is a depth texture
  105539. */
  105540. Depth = 12,
  105541. /**
  105542. * Texture data comes from a raw cube data encoded with RGBD
  105543. */
  105544. CubeRawRGBD = 13
  105545. }
  105546. /**
  105547. * Class used to store data associated with WebGL texture data for the engine
  105548. * This class should not be used directly
  105549. */
  105550. export class InternalTexture {
  105551. /** @hidden */
  105552. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  105553. /**
  105554. * Defines if the texture is ready
  105555. */
  105556. isReady: boolean;
  105557. /**
  105558. * Defines if the texture is a cube texture
  105559. */
  105560. isCube: boolean;
  105561. /**
  105562. * Defines if the texture contains 3D data
  105563. */
  105564. is3D: boolean;
  105565. /**
  105566. * Defines if the texture contains 2D array data
  105567. */
  105568. is2DArray: boolean;
  105569. /**
  105570. * Defines if the texture contains multiview data
  105571. */
  105572. isMultiview: boolean;
  105573. /**
  105574. * Gets the URL used to load this texture
  105575. */
  105576. url: string;
  105577. /**
  105578. * Gets the sampling mode of the texture
  105579. */
  105580. samplingMode: number;
  105581. /**
  105582. * Gets a boolean indicating if the texture needs mipmaps generation
  105583. */
  105584. generateMipMaps: boolean;
  105585. /**
  105586. * Gets the number of samples used by the texture (WebGL2+ only)
  105587. */
  105588. samples: number;
  105589. /**
  105590. * Gets the type of the texture (int, float...)
  105591. */
  105592. type: number;
  105593. /**
  105594. * Gets the format of the texture (RGB, RGBA...)
  105595. */
  105596. format: number;
  105597. /**
  105598. * Observable called when the texture is loaded
  105599. */
  105600. onLoadedObservable: Observable<InternalTexture>;
  105601. /**
  105602. * Gets the width of the texture
  105603. */
  105604. width: number;
  105605. /**
  105606. * Gets the height of the texture
  105607. */
  105608. height: number;
  105609. /**
  105610. * Gets the depth of the texture
  105611. */
  105612. depth: number;
  105613. /**
  105614. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  105615. */
  105616. baseWidth: number;
  105617. /**
  105618. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  105619. */
  105620. baseHeight: number;
  105621. /**
  105622. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  105623. */
  105624. baseDepth: number;
  105625. /**
  105626. * Gets a boolean indicating if the texture is inverted on Y axis
  105627. */
  105628. invertY: boolean;
  105629. /** @hidden */
  105630. _invertVScale: boolean;
  105631. /** @hidden */
  105632. _associatedChannel: number;
  105633. /** @hidden */
  105634. _source: InternalTextureSource;
  105635. /** @hidden */
  105636. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  105637. /** @hidden */
  105638. _bufferView: Nullable<ArrayBufferView>;
  105639. /** @hidden */
  105640. _bufferViewArray: Nullable<ArrayBufferView[]>;
  105641. /** @hidden */
  105642. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  105643. /** @hidden */
  105644. _size: number;
  105645. /** @hidden */
  105646. _extension: string;
  105647. /** @hidden */
  105648. _files: Nullable<string[]>;
  105649. /** @hidden */
  105650. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105651. /** @hidden */
  105652. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105653. /** @hidden */
  105654. _framebuffer: Nullable<WebGLFramebuffer>;
  105655. /** @hidden */
  105656. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  105657. /** @hidden */
  105658. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  105659. /** @hidden */
  105660. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  105661. /** @hidden */
  105662. _attachments: Nullable<number[]>;
  105663. /** @hidden */
  105664. _cachedCoordinatesMode: Nullable<number>;
  105665. /** @hidden */
  105666. _cachedWrapU: Nullable<number>;
  105667. /** @hidden */
  105668. _cachedWrapV: Nullable<number>;
  105669. /** @hidden */
  105670. _cachedWrapR: Nullable<number>;
  105671. /** @hidden */
  105672. _cachedAnisotropicFilteringLevel: Nullable<number>;
  105673. /** @hidden */
  105674. _isDisabled: boolean;
  105675. /** @hidden */
  105676. _compression: Nullable<string>;
  105677. /** @hidden */
  105678. _generateStencilBuffer: boolean;
  105679. /** @hidden */
  105680. _generateDepthBuffer: boolean;
  105681. /** @hidden */
  105682. _comparisonFunction: number;
  105683. /** @hidden */
  105684. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  105685. /** @hidden */
  105686. _lodGenerationScale: number;
  105687. /** @hidden */
  105688. _lodGenerationOffset: number;
  105689. /** @hidden */
  105690. _depthStencilTexture: Nullable<InternalTexture>;
  105691. /** @hidden */
  105692. _colorTextureArray: Nullable<WebGLTexture>;
  105693. /** @hidden */
  105694. _depthStencilTextureArray: Nullable<WebGLTexture>;
  105695. /** @hidden */
  105696. _lodTextureHigh: Nullable<BaseTexture>;
  105697. /** @hidden */
  105698. _lodTextureMid: Nullable<BaseTexture>;
  105699. /** @hidden */
  105700. _lodTextureLow: Nullable<BaseTexture>;
  105701. /** @hidden */
  105702. _isRGBD: boolean;
  105703. /** @hidden */
  105704. _linearSpecularLOD: boolean;
  105705. /** @hidden */
  105706. _irradianceTexture: Nullable<BaseTexture>;
  105707. /** @hidden */
  105708. _webGLTexture: Nullable<WebGLTexture>;
  105709. /** @hidden */
  105710. _references: number;
  105711. private _engine;
  105712. /**
  105713. * Gets the Engine the texture belongs to.
  105714. * @returns The babylon engine
  105715. */
  105716. getEngine(): ThinEngine;
  105717. /**
  105718. * Gets the data source type of the texture
  105719. */
  105720. get source(): InternalTextureSource;
  105721. /**
  105722. * Creates a new InternalTexture
  105723. * @param engine defines the engine to use
  105724. * @param source defines the type of data that will be used
  105725. * @param delayAllocation if the texture allocation should be delayed (default: false)
  105726. */
  105727. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  105728. /**
  105729. * Increments the number of references (ie. the number of Texture that point to it)
  105730. */
  105731. incrementReferences(): void;
  105732. /**
  105733. * Change the size of the texture (not the size of the content)
  105734. * @param width defines the new width
  105735. * @param height defines the new height
  105736. * @param depth defines the new depth (1 by default)
  105737. */
  105738. updateSize(width: int, height: int, depth?: int): void;
  105739. /** @hidden */
  105740. _rebuild(): void;
  105741. /** @hidden */
  105742. _swapAndDie(target: InternalTexture): void;
  105743. /**
  105744. * Dispose the current allocated resources
  105745. */
  105746. dispose(): void;
  105747. }
  105748. }
  105749. declare module BABYLON {
  105750. /**
  105751. * Class used to work with sound analyzer using fast fourier transform (FFT)
  105752. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105753. */
  105754. export class Analyser {
  105755. /**
  105756. * Gets or sets the smoothing
  105757. * @ignorenaming
  105758. */
  105759. SMOOTHING: number;
  105760. /**
  105761. * Gets or sets the FFT table size
  105762. * @ignorenaming
  105763. */
  105764. FFT_SIZE: number;
  105765. /**
  105766. * Gets or sets the bar graph amplitude
  105767. * @ignorenaming
  105768. */
  105769. BARGRAPHAMPLITUDE: number;
  105770. /**
  105771. * Gets or sets the position of the debug canvas
  105772. * @ignorenaming
  105773. */
  105774. DEBUGCANVASPOS: {
  105775. x: number;
  105776. y: number;
  105777. };
  105778. /**
  105779. * Gets or sets the debug canvas size
  105780. * @ignorenaming
  105781. */
  105782. DEBUGCANVASSIZE: {
  105783. width: number;
  105784. height: number;
  105785. };
  105786. private _byteFreqs;
  105787. private _byteTime;
  105788. private _floatFreqs;
  105789. private _webAudioAnalyser;
  105790. private _debugCanvas;
  105791. private _debugCanvasContext;
  105792. private _scene;
  105793. private _registerFunc;
  105794. private _audioEngine;
  105795. /**
  105796. * Creates a new analyser
  105797. * @param scene defines hosting scene
  105798. */
  105799. constructor(scene: Scene);
  105800. /**
  105801. * Get the number of data values you will have to play with for the visualization
  105802. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  105803. * @returns a number
  105804. */
  105805. getFrequencyBinCount(): number;
  105806. /**
  105807. * Gets the current frequency data as a byte array
  105808. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105809. * @returns a Uint8Array
  105810. */
  105811. getByteFrequencyData(): Uint8Array;
  105812. /**
  105813. * Gets the current waveform as a byte array
  105814. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  105815. * @returns a Uint8Array
  105816. */
  105817. getByteTimeDomainData(): Uint8Array;
  105818. /**
  105819. * Gets the current frequency data as a float array
  105820. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105821. * @returns a Float32Array
  105822. */
  105823. getFloatFrequencyData(): Float32Array;
  105824. /**
  105825. * Renders the debug canvas
  105826. */
  105827. drawDebugCanvas(): void;
  105828. /**
  105829. * Stops rendering the debug canvas and removes it
  105830. */
  105831. stopDebugCanvas(): void;
  105832. /**
  105833. * Connects two audio nodes
  105834. * @param inputAudioNode defines first node to connect
  105835. * @param outputAudioNode defines second node to connect
  105836. */
  105837. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  105838. /**
  105839. * Releases all associated resources
  105840. */
  105841. dispose(): void;
  105842. }
  105843. }
  105844. declare module BABYLON {
  105845. /**
  105846. * This represents an audio engine and it is responsible
  105847. * to play, synchronize and analyse sounds throughout the application.
  105848. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105849. */
  105850. export interface IAudioEngine extends IDisposable {
  105851. /**
  105852. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105853. */
  105854. readonly canUseWebAudio: boolean;
  105855. /**
  105856. * Gets the current AudioContext if available.
  105857. */
  105858. readonly audioContext: Nullable<AudioContext>;
  105859. /**
  105860. * The master gain node defines the global audio volume of your audio engine.
  105861. */
  105862. readonly masterGain: GainNode;
  105863. /**
  105864. * Gets whether or not mp3 are supported by your browser.
  105865. */
  105866. readonly isMP3supported: boolean;
  105867. /**
  105868. * Gets whether or not ogg are supported by your browser.
  105869. */
  105870. readonly isOGGsupported: boolean;
  105871. /**
  105872. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105873. * @ignoreNaming
  105874. */
  105875. WarnedWebAudioUnsupported: boolean;
  105876. /**
  105877. * Defines if the audio engine relies on a custom unlocked button.
  105878. * In this case, the embedded button will not be displayed.
  105879. */
  105880. useCustomUnlockedButton: boolean;
  105881. /**
  105882. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  105883. */
  105884. readonly unlocked: boolean;
  105885. /**
  105886. * Event raised when audio has been unlocked on the browser.
  105887. */
  105888. onAudioUnlockedObservable: Observable<AudioEngine>;
  105889. /**
  105890. * Event raised when audio has been locked on the browser.
  105891. */
  105892. onAudioLockedObservable: Observable<AudioEngine>;
  105893. /**
  105894. * Flags the audio engine in Locked state.
  105895. * This happens due to new browser policies preventing audio to autoplay.
  105896. */
  105897. lock(): void;
  105898. /**
  105899. * Unlocks the audio engine once a user action has been done on the dom.
  105900. * This is helpful to resume play once browser policies have been satisfied.
  105901. */
  105902. unlock(): void;
  105903. }
  105904. /**
  105905. * This represents the default audio engine used in babylon.
  105906. * It is responsible to play, synchronize and analyse sounds throughout the application.
  105907. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105908. */
  105909. export class AudioEngine implements IAudioEngine {
  105910. private _audioContext;
  105911. private _audioContextInitialized;
  105912. private _muteButton;
  105913. private _hostElement;
  105914. /**
  105915. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105916. */
  105917. canUseWebAudio: boolean;
  105918. /**
  105919. * The master gain node defines the global audio volume of your audio engine.
  105920. */
  105921. masterGain: GainNode;
  105922. /**
  105923. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105924. * @ignoreNaming
  105925. */
  105926. WarnedWebAudioUnsupported: boolean;
  105927. /**
  105928. * Gets whether or not mp3 are supported by your browser.
  105929. */
  105930. isMP3supported: boolean;
  105931. /**
  105932. * Gets whether or not ogg are supported by your browser.
  105933. */
  105934. isOGGsupported: boolean;
  105935. /**
  105936. * Gets whether audio has been unlocked on the device.
  105937. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  105938. * a user interaction has happened.
  105939. */
  105940. unlocked: boolean;
  105941. /**
  105942. * Defines if the audio engine relies on a custom unlocked button.
  105943. * In this case, the embedded button will not be displayed.
  105944. */
  105945. useCustomUnlockedButton: boolean;
  105946. /**
  105947. * Event raised when audio has been unlocked on the browser.
  105948. */
  105949. onAudioUnlockedObservable: Observable<AudioEngine>;
  105950. /**
  105951. * Event raised when audio has been locked on the browser.
  105952. */
  105953. onAudioLockedObservable: Observable<AudioEngine>;
  105954. /**
  105955. * Gets the current AudioContext if available.
  105956. */
  105957. get audioContext(): Nullable<AudioContext>;
  105958. private _connectedAnalyser;
  105959. /**
  105960. * Instantiates a new audio engine.
  105961. *
  105962. * There should be only one per page as some browsers restrict the number
  105963. * of audio contexts you can create.
  105964. * @param hostElement defines the host element where to display the mute icon if necessary
  105965. */
  105966. constructor(hostElement?: Nullable<HTMLElement>);
  105967. /**
  105968. * Flags the audio engine in Locked state.
  105969. * This happens due to new browser policies preventing audio to autoplay.
  105970. */
  105971. lock(): void;
  105972. /**
  105973. * Unlocks the audio engine once a user action has been done on the dom.
  105974. * This is helpful to resume play once browser policies have been satisfied.
  105975. */
  105976. unlock(): void;
  105977. private _resumeAudioContext;
  105978. private _initializeAudioContext;
  105979. private _tryToRun;
  105980. private _triggerRunningState;
  105981. private _triggerSuspendedState;
  105982. private _displayMuteButton;
  105983. private _moveButtonToTopLeft;
  105984. private _onResize;
  105985. private _hideMuteButton;
  105986. /**
  105987. * Destroy and release the resources associated with the audio ccontext.
  105988. */
  105989. dispose(): void;
  105990. /**
  105991. * Gets the global volume sets on the master gain.
  105992. * @returns the global volume if set or -1 otherwise
  105993. */
  105994. getGlobalVolume(): number;
  105995. /**
  105996. * Sets the global volume of your experience (sets on the master gain).
  105997. * @param newVolume Defines the new global volume of the application
  105998. */
  105999. setGlobalVolume(newVolume: number): void;
  106000. /**
  106001. * Connect the audio engine to an audio analyser allowing some amazing
  106002. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  106003. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  106004. * @param analyser The analyser to connect to the engine
  106005. */
  106006. connectToAnalyser(analyser: Analyser): void;
  106007. }
  106008. }
  106009. declare module BABYLON {
  106010. /**
  106011. * Interface used to present a loading screen while loading a scene
  106012. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106013. */
  106014. export interface ILoadingScreen {
  106015. /**
  106016. * Function called to display the loading screen
  106017. */
  106018. displayLoadingUI: () => void;
  106019. /**
  106020. * Function called to hide the loading screen
  106021. */
  106022. hideLoadingUI: () => void;
  106023. /**
  106024. * Gets or sets the color to use for the background
  106025. */
  106026. loadingUIBackgroundColor: string;
  106027. /**
  106028. * Gets or sets the text to display while loading
  106029. */
  106030. loadingUIText: string;
  106031. }
  106032. /**
  106033. * Class used for the default loading screen
  106034. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106035. */
  106036. export class DefaultLoadingScreen implements ILoadingScreen {
  106037. private _renderingCanvas;
  106038. private _loadingText;
  106039. private _loadingDivBackgroundColor;
  106040. private _loadingDiv;
  106041. private _loadingTextDiv;
  106042. /** Gets or sets the logo url to use for the default loading screen */
  106043. static DefaultLogoUrl: string;
  106044. /** Gets or sets the spinner url to use for the default loading screen */
  106045. static DefaultSpinnerUrl: string;
  106046. /**
  106047. * Creates a new default loading screen
  106048. * @param _renderingCanvas defines the canvas used to render the scene
  106049. * @param _loadingText defines the default text to display
  106050. * @param _loadingDivBackgroundColor defines the default background color
  106051. */
  106052. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  106053. /**
  106054. * Function called to display the loading screen
  106055. */
  106056. displayLoadingUI(): void;
  106057. /**
  106058. * Function called to hide the loading screen
  106059. */
  106060. hideLoadingUI(): void;
  106061. /**
  106062. * Gets or sets the text to display while loading
  106063. */
  106064. set loadingUIText(text: string);
  106065. get loadingUIText(): string;
  106066. /**
  106067. * Gets or sets the color to use for the background
  106068. */
  106069. get loadingUIBackgroundColor(): string;
  106070. set loadingUIBackgroundColor(color: string);
  106071. private _resizeLoadingUI;
  106072. }
  106073. }
  106074. declare module BABYLON {
  106075. /**
  106076. * Interface for any object that can request an animation frame
  106077. */
  106078. export interface ICustomAnimationFrameRequester {
  106079. /**
  106080. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  106081. */
  106082. renderFunction?: Function;
  106083. /**
  106084. * Called to request the next frame to render to
  106085. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  106086. */
  106087. requestAnimationFrame: Function;
  106088. /**
  106089. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  106090. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  106091. */
  106092. requestID?: number;
  106093. }
  106094. }
  106095. declare module BABYLON {
  106096. /**
  106097. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  106098. */
  106099. export class PerformanceMonitor {
  106100. private _enabled;
  106101. private _rollingFrameTime;
  106102. private _lastFrameTimeMs;
  106103. /**
  106104. * constructor
  106105. * @param frameSampleSize The number of samples required to saturate the sliding window
  106106. */
  106107. constructor(frameSampleSize?: number);
  106108. /**
  106109. * Samples current frame
  106110. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  106111. */
  106112. sampleFrame(timeMs?: number): void;
  106113. /**
  106114. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106115. */
  106116. get averageFrameTime(): number;
  106117. /**
  106118. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106119. */
  106120. get averageFrameTimeVariance(): number;
  106121. /**
  106122. * Returns the frame time of the most recent frame
  106123. */
  106124. get instantaneousFrameTime(): number;
  106125. /**
  106126. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  106127. */
  106128. get averageFPS(): number;
  106129. /**
  106130. * Returns the average framerate in frames per second using the most recent frame time
  106131. */
  106132. get instantaneousFPS(): number;
  106133. /**
  106134. * Returns true if enough samples have been taken to completely fill the sliding window
  106135. */
  106136. get isSaturated(): boolean;
  106137. /**
  106138. * Enables contributions to the sliding window sample set
  106139. */
  106140. enable(): void;
  106141. /**
  106142. * Disables contributions to the sliding window sample set
  106143. * Samples will not be interpolated over the disabled period
  106144. */
  106145. disable(): void;
  106146. /**
  106147. * Returns true if sampling is enabled
  106148. */
  106149. get isEnabled(): boolean;
  106150. /**
  106151. * Resets performance monitor
  106152. */
  106153. reset(): void;
  106154. }
  106155. /**
  106156. * RollingAverage
  106157. *
  106158. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  106159. */
  106160. export class RollingAverage {
  106161. /**
  106162. * Current average
  106163. */
  106164. average: number;
  106165. /**
  106166. * Current variance
  106167. */
  106168. variance: number;
  106169. protected _samples: Array<number>;
  106170. protected _sampleCount: number;
  106171. protected _pos: number;
  106172. protected _m2: number;
  106173. /**
  106174. * constructor
  106175. * @param length The number of samples required to saturate the sliding window
  106176. */
  106177. constructor(length: number);
  106178. /**
  106179. * Adds a sample to the sample set
  106180. * @param v The sample value
  106181. */
  106182. add(v: number): void;
  106183. /**
  106184. * Returns previously added values or null if outside of history or outside the sliding window domain
  106185. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  106186. * @return Value previously recorded with add() or null if outside of range
  106187. */
  106188. history(i: number): number;
  106189. /**
  106190. * Returns true if enough samples have been taken to completely fill the sliding window
  106191. * @return true if sample-set saturated
  106192. */
  106193. isSaturated(): boolean;
  106194. /**
  106195. * Resets the rolling average (equivalent to 0 samples taken so far)
  106196. */
  106197. reset(): void;
  106198. /**
  106199. * Wraps a value around the sample range boundaries
  106200. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  106201. * @return Wrapped position in sample range
  106202. */
  106203. protected _wrapPosition(i: number): number;
  106204. }
  106205. }
  106206. declare module BABYLON {
  106207. /**
  106208. * This class is used to track a performance counter which is number based.
  106209. * The user has access to many properties which give statistics of different nature.
  106210. *
  106211. * The implementer can track two kinds of Performance Counter: time and count.
  106212. * 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.
  106213. * 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.
  106214. */
  106215. export class PerfCounter {
  106216. /**
  106217. * Gets or sets a global boolean to turn on and off all the counters
  106218. */
  106219. static Enabled: boolean;
  106220. /**
  106221. * Returns the smallest value ever
  106222. */
  106223. get min(): number;
  106224. /**
  106225. * Returns the biggest value ever
  106226. */
  106227. get max(): number;
  106228. /**
  106229. * Returns the average value since the performance counter is running
  106230. */
  106231. get average(): number;
  106232. /**
  106233. * Returns the average value of the last second the counter was monitored
  106234. */
  106235. get lastSecAverage(): number;
  106236. /**
  106237. * Returns the current value
  106238. */
  106239. get current(): number;
  106240. /**
  106241. * Gets the accumulated total
  106242. */
  106243. get total(): number;
  106244. /**
  106245. * Gets the total value count
  106246. */
  106247. get count(): number;
  106248. /**
  106249. * Creates a new counter
  106250. */
  106251. constructor();
  106252. /**
  106253. * Call this method to start monitoring a new frame.
  106254. * 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.
  106255. */
  106256. fetchNewFrame(): void;
  106257. /**
  106258. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  106259. * @param newCount the count value to add to the monitored count
  106260. * @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.
  106261. */
  106262. addCount(newCount: number, fetchResult: boolean): void;
  106263. /**
  106264. * Start monitoring this performance counter
  106265. */
  106266. beginMonitoring(): void;
  106267. /**
  106268. * Compute the time lapsed since the previous beginMonitoring() call.
  106269. * @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
  106270. */
  106271. endMonitoring(newFrame?: boolean): void;
  106272. private _fetchResult;
  106273. private _startMonitoringTime;
  106274. private _min;
  106275. private _max;
  106276. private _average;
  106277. private _current;
  106278. private _totalValueCount;
  106279. private _totalAccumulated;
  106280. private _lastSecAverage;
  106281. private _lastSecAccumulated;
  106282. private _lastSecTime;
  106283. private _lastSecValueCount;
  106284. }
  106285. }
  106286. declare module BABYLON {
  106287. interface ThinEngine {
  106288. /**
  106289. * Sets alpha constants used by some alpha blending modes
  106290. * @param r defines the red component
  106291. * @param g defines the green component
  106292. * @param b defines the blue component
  106293. * @param a defines the alpha component
  106294. */
  106295. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  106296. /**
  106297. * Sets the current alpha mode
  106298. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  106299. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  106300. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106301. */
  106302. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106303. /**
  106304. * Gets the current alpha mode
  106305. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106306. * @returns the current alpha mode
  106307. */
  106308. getAlphaMode(): number;
  106309. /**
  106310. * Sets the current alpha equation
  106311. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  106312. */
  106313. setAlphaEquation(equation: number): void;
  106314. /**
  106315. * Gets the current alpha equation.
  106316. * @returns the current alpha equation
  106317. */
  106318. getAlphaEquation(): number;
  106319. }
  106320. }
  106321. declare module BABYLON {
  106322. /**
  106323. * Defines the interface used by display changed events
  106324. */
  106325. export interface IDisplayChangedEventArgs {
  106326. /** Gets the vrDisplay object (if any) */
  106327. vrDisplay: Nullable<any>;
  106328. /** Gets a boolean indicating if webVR is supported */
  106329. vrSupported: boolean;
  106330. }
  106331. /**
  106332. * Defines the interface used by objects containing a viewport (like a camera)
  106333. */
  106334. interface IViewportOwnerLike {
  106335. /**
  106336. * Gets or sets the viewport
  106337. */
  106338. viewport: IViewportLike;
  106339. }
  106340. /**
  106341. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  106342. */
  106343. export class Engine extends ThinEngine {
  106344. /** Defines that alpha blending is disabled */
  106345. static readonly ALPHA_DISABLE: number;
  106346. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  106347. static readonly ALPHA_ADD: number;
  106348. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  106349. static readonly ALPHA_COMBINE: number;
  106350. /** Defines that alpha blending to DEST - SRC * DEST */
  106351. static readonly ALPHA_SUBTRACT: number;
  106352. /** Defines that alpha blending to SRC * DEST */
  106353. static readonly ALPHA_MULTIPLY: number;
  106354. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  106355. static readonly ALPHA_MAXIMIZED: number;
  106356. /** Defines that alpha blending to SRC + DEST */
  106357. static readonly ALPHA_ONEONE: number;
  106358. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  106359. static readonly ALPHA_PREMULTIPLIED: number;
  106360. /**
  106361. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  106362. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  106363. */
  106364. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  106365. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  106366. static readonly ALPHA_INTERPOLATE: number;
  106367. /**
  106368. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  106369. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  106370. */
  106371. static readonly ALPHA_SCREENMODE: number;
  106372. /** Defines that the ressource is not delayed*/
  106373. static readonly DELAYLOADSTATE_NONE: number;
  106374. /** Defines that the ressource was successfully delay loaded */
  106375. static readonly DELAYLOADSTATE_LOADED: number;
  106376. /** Defines that the ressource is currently delay loading */
  106377. static readonly DELAYLOADSTATE_LOADING: number;
  106378. /** Defines that the ressource is delayed and has not started loading */
  106379. static readonly DELAYLOADSTATE_NOTLOADED: number;
  106380. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  106381. static readonly NEVER: number;
  106382. /** 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 */
  106383. static readonly ALWAYS: number;
  106384. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  106385. static readonly LESS: number;
  106386. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  106387. static readonly EQUAL: number;
  106388. /** 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 */
  106389. static readonly LEQUAL: number;
  106390. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  106391. static readonly GREATER: number;
  106392. /** 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 */
  106393. static readonly GEQUAL: number;
  106394. /** 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 */
  106395. static readonly NOTEQUAL: number;
  106396. /** Passed to stencilOperation to specify that stencil value must be kept */
  106397. static readonly KEEP: number;
  106398. /** Passed to stencilOperation to specify that stencil value must be replaced */
  106399. static readonly REPLACE: number;
  106400. /** Passed to stencilOperation to specify that stencil value must be incremented */
  106401. static readonly INCR: number;
  106402. /** Passed to stencilOperation to specify that stencil value must be decremented */
  106403. static readonly DECR: number;
  106404. /** Passed to stencilOperation to specify that stencil value must be inverted */
  106405. static readonly INVERT: number;
  106406. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  106407. static readonly INCR_WRAP: number;
  106408. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  106409. static readonly DECR_WRAP: number;
  106410. /** Texture is not repeating outside of 0..1 UVs */
  106411. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  106412. /** Texture is repeating outside of 0..1 UVs */
  106413. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  106414. /** Texture is repeating and mirrored */
  106415. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  106416. /** ALPHA */
  106417. static readonly TEXTUREFORMAT_ALPHA: number;
  106418. /** LUMINANCE */
  106419. static readonly TEXTUREFORMAT_LUMINANCE: number;
  106420. /** LUMINANCE_ALPHA */
  106421. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  106422. /** RGB */
  106423. static readonly TEXTUREFORMAT_RGB: number;
  106424. /** RGBA */
  106425. static readonly TEXTUREFORMAT_RGBA: number;
  106426. /** RED */
  106427. static readonly TEXTUREFORMAT_RED: number;
  106428. /** RED (2nd reference) */
  106429. static readonly TEXTUREFORMAT_R: number;
  106430. /** RG */
  106431. static readonly TEXTUREFORMAT_RG: number;
  106432. /** RED_INTEGER */
  106433. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  106434. /** RED_INTEGER (2nd reference) */
  106435. static readonly TEXTUREFORMAT_R_INTEGER: number;
  106436. /** RG_INTEGER */
  106437. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  106438. /** RGB_INTEGER */
  106439. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  106440. /** RGBA_INTEGER */
  106441. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  106442. /** UNSIGNED_BYTE */
  106443. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  106444. /** UNSIGNED_BYTE (2nd reference) */
  106445. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  106446. /** FLOAT */
  106447. static readonly TEXTURETYPE_FLOAT: number;
  106448. /** HALF_FLOAT */
  106449. static readonly TEXTURETYPE_HALF_FLOAT: number;
  106450. /** BYTE */
  106451. static readonly TEXTURETYPE_BYTE: number;
  106452. /** SHORT */
  106453. static readonly TEXTURETYPE_SHORT: number;
  106454. /** UNSIGNED_SHORT */
  106455. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  106456. /** INT */
  106457. static readonly TEXTURETYPE_INT: number;
  106458. /** UNSIGNED_INT */
  106459. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  106460. /** UNSIGNED_SHORT_4_4_4_4 */
  106461. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  106462. /** UNSIGNED_SHORT_5_5_5_1 */
  106463. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  106464. /** UNSIGNED_SHORT_5_6_5 */
  106465. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  106466. /** UNSIGNED_INT_2_10_10_10_REV */
  106467. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  106468. /** UNSIGNED_INT_24_8 */
  106469. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  106470. /** UNSIGNED_INT_10F_11F_11F_REV */
  106471. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  106472. /** UNSIGNED_INT_5_9_9_9_REV */
  106473. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  106474. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  106475. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  106476. /** nearest is mag = nearest and min = nearest and mip = linear */
  106477. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  106478. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106479. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  106480. /** Trilinear is mag = linear and min = linear and mip = linear */
  106481. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  106482. /** nearest is mag = nearest and min = nearest and mip = linear */
  106483. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  106484. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106485. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  106486. /** Trilinear is mag = linear and min = linear and mip = linear */
  106487. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  106488. /** mag = nearest and min = nearest and mip = nearest */
  106489. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  106490. /** mag = nearest and min = linear and mip = nearest */
  106491. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  106492. /** mag = nearest and min = linear and mip = linear */
  106493. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  106494. /** mag = nearest and min = linear and mip = none */
  106495. static readonly TEXTURE_NEAREST_LINEAR: number;
  106496. /** mag = nearest and min = nearest and mip = none */
  106497. static readonly TEXTURE_NEAREST_NEAREST: number;
  106498. /** mag = linear and min = nearest and mip = nearest */
  106499. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  106500. /** mag = linear and min = nearest and mip = linear */
  106501. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  106502. /** mag = linear and min = linear and mip = none */
  106503. static readonly TEXTURE_LINEAR_LINEAR: number;
  106504. /** mag = linear and min = nearest and mip = none */
  106505. static readonly TEXTURE_LINEAR_NEAREST: number;
  106506. /** Explicit coordinates mode */
  106507. static readonly TEXTURE_EXPLICIT_MODE: number;
  106508. /** Spherical coordinates mode */
  106509. static readonly TEXTURE_SPHERICAL_MODE: number;
  106510. /** Planar coordinates mode */
  106511. static readonly TEXTURE_PLANAR_MODE: number;
  106512. /** Cubic coordinates mode */
  106513. static readonly TEXTURE_CUBIC_MODE: number;
  106514. /** Projection coordinates mode */
  106515. static readonly TEXTURE_PROJECTION_MODE: number;
  106516. /** Skybox coordinates mode */
  106517. static readonly TEXTURE_SKYBOX_MODE: number;
  106518. /** Inverse Cubic coordinates mode */
  106519. static readonly TEXTURE_INVCUBIC_MODE: number;
  106520. /** Equirectangular coordinates mode */
  106521. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  106522. /** Equirectangular Fixed coordinates mode */
  106523. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  106524. /** Equirectangular Fixed Mirrored coordinates mode */
  106525. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  106526. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  106527. static readonly SCALEMODE_FLOOR: number;
  106528. /** Defines that texture rescaling will look for the nearest power of 2 size */
  106529. static readonly SCALEMODE_NEAREST: number;
  106530. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  106531. static readonly SCALEMODE_CEILING: number;
  106532. /**
  106533. * Returns the current npm package of the sdk
  106534. */
  106535. static get NpmPackage(): string;
  106536. /**
  106537. * Returns the current version of the framework
  106538. */
  106539. static get Version(): string;
  106540. /** Gets the list of created engines */
  106541. static get Instances(): Engine[];
  106542. /**
  106543. * Gets the latest created engine
  106544. */
  106545. static get LastCreatedEngine(): Nullable<Engine>;
  106546. /**
  106547. * Gets the latest created scene
  106548. */
  106549. static get LastCreatedScene(): Nullable<Scene>;
  106550. /**
  106551. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  106552. * @param flag defines which part of the materials must be marked as dirty
  106553. * @param predicate defines a predicate used to filter which materials should be affected
  106554. */
  106555. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  106556. /**
  106557. * Method called to create the default loading screen.
  106558. * This can be overriden in your own app.
  106559. * @param canvas The rendering canvas element
  106560. * @returns The loading screen
  106561. */
  106562. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  106563. /**
  106564. * Method called to create the default rescale post process on each engine.
  106565. */
  106566. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  106567. /**
  106568. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  106569. **/
  106570. enableOfflineSupport: boolean;
  106571. /**
  106572. * 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)
  106573. **/
  106574. disableManifestCheck: boolean;
  106575. /**
  106576. * Gets the list of created scenes
  106577. */
  106578. scenes: Scene[];
  106579. /**
  106580. * Event raised when a new scene is created
  106581. */
  106582. onNewSceneAddedObservable: Observable<Scene>;
  106583. /**
  106584. * Gets the list of created postprocesses
  106585. */
  106586. postProcesses: PostProcess[];
  106587. /**
  106588. * Gets a boolean indicating if the pointer is currently locked
  106589. */
  106590. isPointerLock: boolean;
  106591. /**
  106592. * Observable event triggered each time the rendering canvas is resized
  106593. */
  106594. onResizeObservable: Observable<Engine>;
  106595. /**
  106596. * Observable event triggered each time the canvas loses focus
  106597. */
  106598. onCanvasBlurObservable: Observable<Engine>;
  106599. /**
  106600. * Observable event triggered each time the canvas gains focus
  106601. */
  106602. onCanvasFocusObservable: Observable<Engine>;
  106603. /**
  106604. * Observable event triggered each time the canvas receives pointerout event
  106605. */
  106606. onCanvasPointerOutObservable: Observable<PointerEvent>;
  106607. /**
  106608. * Observable raised when the engine begins a new frame
  106609. */
  106610. onBeginFrameObservable: Observable<Engine>;
  106611. /**
  106612. * If set, will be used to request the next animation frame for the render loop
  106613. */
  106614. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  106615. /**
  106616. * Observable raised when the engine ends the current frame
  106617. */
  106618. onEndFrameObservable: Observable<Engine>;
  106619. /**
  106620. * Observable raised when the engine is about to compile a shader
  106621. */
  106622. onBeforeShaderCompilationObservable: Observable<Engine>;
  106623. /**
  106624. * Observable raised when the engine has jsut compiled a shader
  106625. */
  106626. onAfterShaderCompilationObservable: Observable<Engine>;
  106627. /**
  106628. * Gets the audio engine
  106629. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106630. * @ignorenaming
  106631. */
  106632. static audioEngine: IAudioEngine;
  106633. /**
  106634. * Default AudioEngine factory responsible of creating the Audio Engine.
  106635. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  106636. */
  106637. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  106638. /**
  106639. * Default offline support factory responsible of creating a tool used to store data locally.
  106640. * By default, this will create a Database object if the workload has been embedded.
  106641. */
  106642. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  106643. private _loadingScreen;
  106644. private _pointerLockRequested;
  106645. private _dummyFramebuffer;
  106646. private _rescalePostProcess;
  106647. private _deterministicLockstep;
  106648. private _lockstepMaxSteps;
  106649. private _timeStep;
  106650. protected get _supportsHardwareTextureRescaling(): boolean;
  106651. private _fps;
  106652. private _deltaTime;
  106653. /** @hidden */
  106654. _drawCalls: PerfCounter;
  106655. /** 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 */
  106656. canvasTabIndex: number;
  106657. /**
  106658. * Turn this value on if you want to pause FPS computation when in background
  106659. */
  106660. disablePerformanceMonitorInBackground: boolean;
  106661. private _performanceMonitor;
  106662. /**
  106663. * Gets the performance monitor attached to this engine
  106664. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106665. */
  106666. get performanceMonitor(): PerformanceMonitor;
  106667. private _onFocus;
  106668. private _onBlur;
  106669. private _onCanvasPointerOut;
  106670. private _onCanvasBlur;
  106671. private _onCanvasFocus;
  106672. private _onFullscreenChange;
  106673. private _onPointerLockChange;
  106674. /**
  106675. * Gets the HTML element used to attach event listeners
  106676. * @returns a HTML element
  106677. */
  106678. getInputElement(): Nullable<HTMLElement>;
  106679. /**
  106680. * Creates a new engine
  106681. * @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
  106682. * @param antialias defines enable antialiasing (default: false)
  106683. * @param options defines further options to be sent to the getContext() function
  106684. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  106685. */
  106686. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  106687. /**
  106688. * Gets current aspect ratio
  106689. * @param viewportOwner defines the camera to use to get the aspect ratio
  106690. * @param useScreen defines if screen size must be used (or the current render target if any)
  106691. * @returns a number defining the aspect ratio
  106692. */
  106693. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  106694. /**
  106695. * Gets current screen aspect ratio
  106696. * @returns a number defining the aspect ratio
  106697. */
  106698. getScreenAspectRatio(): number;
  106699. /**
  106700. * Gets the client rect of the HTML canvas attached with the current webGL context
  106701. * @returns a client rectanglee
  106702. */
  106703. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  106704. /**
  106705. * Gets the client rect of the HTML element used for events
  106706. * @returns a client rectanglee
  106707. */
  106708. getInputElementClientRect(): Nullable<ClientRect>;
  106709. /**
  106710. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  106711. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106712. * @returns true if engine is in deterministic lock step mode
  106713. */
  106714. isDeterministicLockStep(): boolean;
  106715. /**
  106716. * Gets the max steps when engine is running in deterministic lock step
  106717. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106718. * @returns the max steps
  106719. */
  106720. getLockstepMaxSteps(): number;
  106721. /**
  106722. * Returns the time in ms between steps when using deterministic lock step.
  106723. * @returns time step in (ms)
  106724. */
  106725. getTimeStep(): number;
  106726. /**
  106727. * Force the mipmap generation for the given render target texture
  106728. * @param texture defines the render target texture to use
  106729. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  106730. */
  106731. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  106732. /** States */
  106733. /**
  106734. * Set various states to the webGL context
  106735. * @param culling defines backface culling state
  106736. * @param zOffset defines the value to apply to zOffset (0 by default)
  106737. * @param force defines if states must be applied even if cache is up to date
  106738. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  106739. */
  106740. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106741. /**
  106742. * Set the z offset to apply to current rendering
  106743. * @param value defines the offset to apply
  106744. */
  106745. setZOffset(value: number): void;
  106746. /**
  106747. * Gets the current value of the zOffset
  106748. * @returns the current zOffset state
  106749. */
  106750. getZOffset(): number;
  106751. /**
  106752. * Enable or disable depth buffering
  106753. * @param enable defines the state to set
  106754. */
  106755. setDepthBuffer(enable: boolean): void;
  106756. /**
  106757. * Gets a boolean indicating if depth writing is enabled
  106758. * @returns the current depth writing state
  106759. */
  106760. getDepthWrite(): boolean;
  106761. /**
  106762. * Enable or disable depth writing
  106763. * @param enable defines the state to set
  106764. */
  106765. setDepthWrite(enable: boolean): void;
  106766. /**
  106767. * Gets a boolean indicating if stencil buffer is enabled
  106768. * @returns the current stencil buffer state
  106769. */
  106770. getStencilBuffer(): boolean;
  106771. /**
  106772. * Enable or disable the stencil buffer
  106773. * @param enable defines if the stencil buffer must be enabled or disabled
  106774. */
  106775. setStencilBuffer(enable: boolean): void;
  106776. /**
  106777. * Gets the current stencil mask
  106778. * @returns a number defining the new stencil mask to use
  106779. */
  106780. getStencilMask(): number;
  106781. /**
  106782. * Sets the current stencil mask
  106783. * @param mask defines the new stencil mask to use
  106784. */
  106785. setStencilMask(mask: number): void;
  106786. /**
  106787. * Gets the current stencil function
  106788. * @returns a number defining the stencil function to use
  106789. */
  106790. getStencilFunction(): number;
  106791. /**
  106792. * Gets the current stencil reference value
  106793. * @returns a number defining the stencil reference value to use
  106794. */
  106795. getStencilFunctionReference(): number;
  106796. /**
  106797. * Gets the current stencil mask
  106798. * @returns a number defining the stencil mask to use
  106799. */
  106800. getStencilFunctionMask(): number;
  106801. /**
  106802. * Sets the current stencil function
  106803. * @param stencilFunc defines the new stencil function to use
  106804. */
  106805. setStencilFunction(stencilFunc: number): void;
  106806. /**
  106807. * Sets the current stencil reference
  106808. * @param reference defines the new stencil reference to use
  106809. */
  106810. setStencilFunctionReference(reference: number): void;
  106811. /**
  106812. * Sets the current stencil mask
  106813. * @param mask defines the new stencil mask to use
  106814. */
  106815. setStencilFunctionMask(mask: number): void;
  106816. /**
  106817. * Gets the current stencil operation when stencil fails
  106818. * @returns a number defining stencil operation to use when stencil fails
  106819. */
  106820. getStencilOperationFail(): number;
  106821. /**
  106822. * Gets the current stencil operation when depth fails
  106823. * @returns a number defining stencil operation to use when depth fails
  106824. */
  106825. getStencilOperationDepthFail(): number;
  106826. /**
  106827. * Gets the current stencil operation when stencil passes
  106828. * @returns a number defining stencil operation to use when stencil passes
  106829. */
  106830. getStencilOperationPass(): number;
  106831. /**
  106832. * Sets the stencil operation to use when stencil fails
  106833. * @param operation defines the stencil operation to use when stencil fails
  106834. */
  106835. setStencilOperationFail(operation: number): void;
  106836. /**
  106837. * Sets the stencil operation to use when depth fails
  106838. * @param operation defines the stencil operation to use when depth fails
  106839. */
  106840. setStencilOperationDepthFail(operation: number): void;
  106841. /**
  106842. * Sets the stencil operation to use when stencil passes
  106843. * @param operation defines the stencil operation to use when stencil passes
  106844. */
  106845. setStencilOperationPass(operation: number): void;
  106846. /**
  106847. * Sets a boolean indicating if the dithering state is enabled or disabled
  106848. * @param value defines the dithering state
  106849. */
  106850. setDitheringState(value: boolean): void;
  106851. /**
  106852. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  106853. * @param value defines the rasterizer state
  106854. */
  106855. setRasterizerState(value: boolean): void;
  106856. /**
  106857. * Gets the current depth function
  106858. * @returns a number defining the depth function
  106859. */
  106860. getDepthFunction(): Nullable<number>;
  106861. /**
  106862. * Sets the current depth function
  106863. * @param depthFunc defines the function to use
  106864. */
  106865. setDepthFunction(depthFunc: number): void;
  106866. /**
  106867. * Sets the current depth function to GREATER
  106868. */
  106869. setDepthFunctionToGreater(): void;
  106870. /**
  106871. * Sets the current depth function to GEQUAL
  106872. */
  106873. setDepthFunctionToGreaterOrEqual(): void;
  106874. /**
  106875. * Sets the current depth function to LESS
  106876. */
  106877. setDepthFunctionToLess(): void;
  106878. /**
  106879. * Sets the current depth function to LEQUAL
  106880. */
  106881. setDepthFunctionToLessOrEqual(): void;
  106882. private _cachedStencilBuffer;
  106883. private _cachedStencilFunction;
  106884. private _cachedStencilMask;
  106885. private _cachedStencilOperationPass;
  106886. private _cachedStencilOperationFail;
  106887. private _cachedStencilOperationDepthFail;
  106888. private _cachedStencilReference;
  106889. /**
  106890. * Caches the the state of the stencil buffer
  106891. */
  106892. cacheStencilState(): void;
  106893. /**
  106894. * Restores the state of the stencil buffer
  106895. */
  106896. restoreStencilState(): void;
  106897. /**
  106898. * Directly set the WebGL Viewport
  106899. * @param x defines the x coordinate of the viewport (in screen space)
  106900. * @param y defines the y coordinate of the viewport (in screen space)
  106901. * @param width defines the width of the viewport (in screen space)
  106902. * @param height defines the height of the viewport (in screen space)
  106903. * @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
  106904. */
  106905. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  106906. /**
  106907. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  106908. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106909. * @param y defines the y-coordinate of the corner of the clear rectangle
  106910. * @param width defines the width of the clear rectangle
  106911. * @param height defines the height of the clear rectangle
  106912. * @param clearColor defines the clear color
  106913. */
  106914. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  106915. /**
  106916. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  106917. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106918. * @param y defines the y-coordinate of the corner of the clear rectangle
  106919. * @param width defines the width of the clear rectangle
  106920. * @param height defines the height of the clear rectangle
  106921. */
  106922. enableScissor(x: number, y: number, width: number, height: number): void;
  106923. /**
  106924. * Disable previously set scissor test rectangle
  106925. */
  106926. disableScissor(): void;
  106927. protected _reportDrawCall(): void;
  106928. /**
  106929. * Initializes a webVR display and starts listening to display change events
  106930. * The onVRDisplayChangedObservable will be notified upon these changes
  106931. * @returns The onVRDisplayChangedObservable
  106932. */
  106933. initWebVR(): Observable<IDisplayChangedEventArgs>;
  106934. /** @hidden */
  106935. _prepareVRComponent(): void;
  106936. /** @hidden */
  106937. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  106938. /** @hidden */
  106939. _submitVRFrame(): void;
  106940. /**
  106941. * Call this function to leave webVR mode
  106942. * Will do nothing if webVR is not supported or if there is no webVR device
  106943. * @see http://doc.babylonjs.com/how_to/webvr_camera
  106944. */
  106945. disableVR(): void;
  106946. /**
  106947. * Gets a boolean indicating that the system is in VR mode and is presenting
  106948. * @returns true if VR mode is engaged
  106949. */
  106950. isVRPresenting(): boolean;
  106951. /** @hidden */
  106952. _requestVRFrame(): void;
  106953. /** @hidden */
  106954. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  106955. /**
  106956. * Gets the source code of the vertex shader associated with a specific webGL program
  106957. * @param program defines the program to use
  106958. * @returns a string containing the source code of the vertex shader associated with the program
  106959. */
  106960. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  106961. /**
  106962. * Gets the source code of the fragment shader associated with a specific webGL program
  106963. * @param program defines the program to use
  106964. * @returns a string containing the source code of the fragment shader associated with the program
  106965. */
  106966. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  106967. /**
  106968. * Sets a depth stencil texture from a render target to the according uniform.
  106969. * @param channel The texture channel
  106970. * @param uniform The uniform to set
  106971. * @param texture The render target texture containing the depth stencil texture to apply
  106972. */
  106973. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  106974. /**
  106975. * Sets a texture to the webGL context from a postprocess
  106976. * @param channel defines the channel to use
  106977. * @param postProcess defines the source postprocess
  106978. */
  106979. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  106980. /**
  106981. * Binds the output of the passed in post process to the texture channel specified
  106982. * @param channel The channel the texture should be bound to
  106983. * @param postProcess The post process which's output should be bound
  106984. */
  106985. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  106986. /** @hidden */
  106987. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  106988. protected _rebuildBuffers(): void;
  106989. /** @hidden */
  106990. _renderFrame(): void;
  106991. _renderLoop(): void;
  106992. /** @hidden */
  106993. _renderViews(): boolean;
  106994. /**
  106995. * Toggle full screen mode
  106996. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106997. */
  106998. switchFullscreen(requestPointerLock: boolean): void;
  106999. /**
  107000. * Enters full screen mode
  107001. * @param requestPointerLock defines if a pointer lock should be requested from the user
  107002. */
  107003. enterFullscreen(requestPointerLock: boolean): void;
  107004. /**
  107005. * Exits full screen mode
  107006. */
  107007. exitFullscreen(): void;
  107008. /**
  107009. * Enters Pointerlock mode
  107010. */
  107011. enterPointerlock(): void;
  107012. /**
  107013. * Exits Pointerlock mode
  107014. */
  107015. exitPointerlock(): void;
  107016. /**
  107017. * Begin a new frame
  107018. */
  107019. beginFrame(): void;
  107020. /**
  107021. * Enf the current frame
  107022. */
  107023. endFrame(): void;
  107024. resize(): void;
  107025. /**
  107026. * Force a specific size of the canvas
  107027. * @param width defines the new canvas' width
  107028. * @param height defines the new canvas' height
  107029. */
  107030. setSize(width: number, height: number): void;
  107031. /**
  107032. * Updates a dynamic vertex buffer.
  107033. * @param vertexBuffer the vertex buffer to update
  107034. * @param data the data used to update the vertex buffer
  107035. * @param byteOffset the byte offset of the data
  107036. * @param byteLength the byte length of the data
  107037. */
  107038. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  107039. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  107040. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107041. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107042. _releaseTexture(texture: InternalTexture): void;
  107043. /**
  107044. * @hidden
  107045. * Rescales a texture
  107046. * @param source input texutre
  107047. * @param destination destination texture
  107048. * @param scene scene to use to render the resize
  107049. * @param internalFormat format to use when resizing
  107050. * @param onComplete callback to be called when resize has completed
  107051. */
  107052. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  107053. /**
  107054. * Gets the current framerate
  107055. * @returns a number representing the framerate
  107056. */
  107057. getFps(): number;
  107058. /**
  107059. * Gets the time spent between current and previous frame
  107060. * @returns a number representing the delta time in ms
  107061. */
  107062. getDeltaTime(): number;
  107063. private _measureFps;
  107064. /** @hidden */
  107065. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  107066. /**
  107067. * Update a dynamic index buffer
  107068. * @param indexBuffer defines the target index buffer
  107069. * @param indices defines the data to update
  107070. * @param offset defines the offset in the target index buffer where update should start
  107071. */
  107072. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  107073. /**
  107074. * Updates the sample count of a render target texture
  107075. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107076. * @param texture defines the texture to update
  107077. * @param samples defines the sample count to set
  107078. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107079. */
  107080. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  107081. /**
  107082. * Updates a depth texture Comparison Mode and Function.
  107083. * If the comparison Function is equal to 0, the mode will be set to none.
  107084. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  107085. * @param texture The texture to set the comparison function for
  107086. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  107087. */
  107088. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  107089. /**
  107090. * Creates a webGL buffer to use with instanciation
  107091. * @param capacity defines the size of the buffer
  107092. * @returns the webGL buffer
  107093. */
  107094. createInstancesBuffer(capacity: number): DataBuffer;
  107095. /**
  107096. * Delete a webGL buffer used with instanciation
  107097. * @param buffer defines the webGL buffer to delete
  107098. */
  107099. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  107100. private _clientWaitAsync;
  107101. /** @hidden */
  107102. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  107103. /** @hidden */
  107104. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  107105. dispose(): void;
  107106. private _disableTouchAction;
  107107. /**
  107108. * Display the loading screen
  107109. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107110. */
  107111. displayLoadingUI(): void;
  107112. /**
  107113. * Hide the loading screen
  107114. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107115. */
  107116. hideLoadingUI(): void;
  107117. /**
  107118. * Gets the current loading screen object
  107119. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107120. */
  107121. get loadingScreen(): ILoadingScreen;
  107122. /**
  107123. * Sets the current loading screen object
  107124. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107125. */
  107126. set loadingScreen(loadingScreen: ILoadingScreen);
  107127. /**
  107128. * Sets the current loading screen text
  107129. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107130. */
  107131. set loadingUIText(text: string);
  107132. /**
  107133. * Sets the current loading screen background color
  107134. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107135. */
  107136. set loadingUIBackgroundColor(color: string);
  107137. /** Pointerlock and fullscreen */
  107138. /**
  107139. * Ask the browser to promote the current element to pointerlock mode
  107140. * @param element defines the DOM element to promote
  107141. */
  107142. static _RequestPointerlock(element: HTMLElement): void;
  107143. /**
  107144. * Asks the browser to exit pointerlock mode
  107145. */
  107146. static _ExitPointerlock(): void;
  107147. /**
  107148. * Ask the browser to promote the current element to fullscreen rendering mode
  107149. * @param element defines the DOM element to promote
  107150. */
  107151. static _RequestFullscreen(element: HTMLElement): void;
  107152. /**
  107153. * Asks the browser to exit fullscreen mode
  107154. */
  107155. static _ExitFullscreen(): void;
  107156. }
  107157. }
  107158. declare module BABYLON {
  107159. /**
  107160. * The engine store class is responsible to hold all the instances of Engine and Scene created
  107161. * during the life time of the application.
  107162. */
  107163. export class EngineStore {
  107164. /** Gets the list of created engines */
  107165. static Instances: Engine[];
  107166. /** @hidden */
  107167. static _LastCreatedScene: Nullable<Scene>;
  107168. /**
  107169. * Gets the latest created engine
  107170. */
  107171. static get LastCreatedEngine(): Nullable<Engine>;
  107172. /**
  107173. * Gets the latest created scene
  107174. */
  107175. static get LastCreatedScene(): Nullable<Scene>;
  107176. /**
  107177. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107178. * @ignorenaming
  107179. */
  107180. static UseFallbackTexture: boolean;
  107181. /**
  107182. * Texture content used if a texture cannot loaded
  107183. * @ignorenaming
  107184. */
  107185. static FallbackTexture: string;
  107186. }
  107187. }
  107188. declare module BABYLON {
  107189. /**
  107190. * Helper class that provides a small promise polyfill
  107191. */
  107192. export class PromisePolyfill {
  107193. /**
  107194. * Static function used to check if the polyfill is required
  107195. * If this is the case then the function will inject the polyfill to window.Promise
  107196. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  107197. */
  107198. static Apply(force?: boolean): void;
  107199. }
  107200. }
  107201. declare module BABYLON {
  107202. /**
  107203. * Interface for screenshot methods with describe argument called `size` as object with options
  107204. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  107205. */
  107206. export interface IScreenshotSize {
  107207. /**
  107208. * number in pixels for canvas height
  107209. */
  107210. height?: number;
  107211. /**
  107212. * multiplier allowing render at a higher or lower resolution
  107213. * If value is defined then height and width will be ignored and taken from camera
  107214. */
  107215. precision?: number;
  107216. /**
  107217. * number in pixels for canvas width
  107218. */
  107219. width?: number;
  107220. }
  107221. }
  107222. declare module BABYLON {
  107223. interface IColor4Like {
  107224. r: float;
  107225. g: float;
  107226. b: float;
  107227. a: float;
  107228. }
  107229. /**
  107230. * Class containing a set of static utilities functions
  107231. */
  107232. export class Tools {
  107233. /**
  107234. * Gets or sets the base URL to use to load assets
  107235. */
  107236. static get BaseUrl(): string;
  107237. static set BaseUrl(value: string);
  107238. /**
  107239. * Enable/Disable Custom HTTP Request Headers globally.
  107240. * default = false
  107241. * @see CustomRequestHeaders
  107242. */
  107243. static UseCustomRequestHeaders: boolean;
  107244. /**
  107245. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  107246. * i.e. when loading files, where the server/service expects an Authorization header
  107247. */
  107248. static CustomRequestHeaders: {
  107249. [key: string]: string;
  107250. };
  107251. /**
  107252. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  107253. */
  107254. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  107255. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  107256. /**
  107257. * Default behaviour for cors in the application.
  107258. * It can be a string if the expected behavior is identical in the entire app.
  107259. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  107260. */
  107261. static get CorsBehavior(): string | ((url: string | string[]) => string);
  107262. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  107263. /**
  107264. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107265. * @ignorenaming
  107266. */
  107267. static get UseFallbackTexture(): boolean;
  107268. static set UseFallbackTexture(value: boolean);
  107269. /**
  107270. * Use this object to register external classes like custom textures or material
  107271. * to allow the laoders to instantiate them
  107272. */
  107273. static get RegisteredExternalClasses(): {
  107274. [key: string]: Object;
  107275. };
  107276. static set RegisteredExternalClasses(classes: {
  107277. [key: string]: Object;
  107278. });
  107279. /**
  107280. * Texture content used if a texture cannot loaded
  107281. * @ignorenaming
  107282. */
  107283. static get fallbackTexture(): string;
  107284. static set fallbackTexture(value: string);
  107285. /**
  107286. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  107287. * @param u defines the coordinate on X axis
  107288. * @param v defines the coordinate on Y axis
  107289. * @param width defines the width of the source data
  107290. * @param height defines the height of the source data
  107291. * @param pixels defines the source byte array
  107292. * @param color defines the output color
  107293. */
  107294. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  107295. /**
  107296. * Interpolates between a and b via alpha
  107297. * @param a The lower value (returned when alpha = 0)
  107298. * @param b The upper value (returned when alpha = 1)
  107299. * @param alpha The interpolation-factor
  107300. * @return The mixed value
  107301. */
  107302. static Mix(a: number, b: number, alpha: number): number;
  107303. /**
  107304. * Tries to instantiate a new object from a given class name
  107305. * @param className defines the class name to instantiate
  107306. * @returns the new object or null if the system was not able to do the instantiation
  107307. */
  107308. static Instantiate(className: string): any;
  107309. /**
  107310. * Provides a slice function that will work even on IE
  107311. * @param data defines the array to slice
  107312. * @param start defines the start of the data (optional)
  107313. * @param end defines the end of the data (optional)
  107314. * @returns the new sliced array
  107315. */
  107316. static Slice<T>(data: T, start?: number, end?: number): T;
  107317. /**
  107318. * Polyfill for setImmediate
  107319. * @param action defines the action to execute after the current execution block
  107320. */
  107321. static SetImmediate(action: () => void): void;
  107322. /**
  107323. * Function indicating if a number is an exponent of 2
  107324. * @param value defines the value to test
  107325. * @returns true if the value is an exponent of 2
  107326. */
  107327. static IsExponentOfTwo(value: number): boolean;
  107328. private static _tmpFloatArray;
  107329. /**
  107330. * Returns the nearest 32-bit single precision float representation of a Number
  107331. * @param value A Number. If the parameter is of a different type, it will get converted
  107332. * to a number or to NaN if it cannot be converted
  107333. * @returns number
  107334. */
  107335. static FloatRound(value: number): number;
  107336. /**
  107337. * Extracts the filename from a path
  107338. * @param path defines the path to use
  107339. * @returns the filename
  107340. */
  107341. static GetFilename(path: string): string;
  107342. /**
  107343. * Extracts the "folder" part of a path (everything before the filename).
  107344. * @param uri The URI to extract the info from
  107345. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  107346. * @returns The "folder" part of the path
  107347. */
  107348. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  107349. /**
  107350. * Extracts text content from a DOM element hierarchy
  107351. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  107352. */
  107353. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  107354. /**
  107355. * Convert an angle in radians to degrees
  107356. * @param angle defines the angle to convert
  107357. * @returns the angle in degrees
  107358. */
  107359. static ToDegrees(angle: number): number;
  107360. /**
  107361. * Convert an angle in degrees to radians
  107362. * @param angle defines the angle to convert
  107363. * @returns the angle in radians
  107364. */
  107365. static ToRadians(angle: number): number;
  107366. /**
  107367. * Returns an array if obj is not an array
  107368. * @param obj defines the object to evaluate as an array
  107369. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  107370. * @returns either obj directly if obj is an array or a new array containing obj
  107371. */
  107372. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  107373. /**
  107374. * Gets the pointer prefix to use
  107375. * @returns "pointer" if touch is enabled. Else returns "mouse"
  107376. */
  107377. static GetPointerPrefix(): string;
  107378. /**
  107379. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  107380. * @param url define the url we are trying
  107381. * @param element define the dom element where to configure the cors policy
  107382. */
  107383. static SetCorsBehavior(url: string | string[], element: {
  107384. crossOrigin: string | null;
  107385. }): void;
  107386. /**
  107387. * Removes unwanted characters from an url
  107388. * @param url defines the url to clean
  107389. * @returns the cleaned url
  107390. */
  107391. static CleanUrl(url: string): string;
  107392. /**
  107393. * Gets or sets a function used to pre-process url before using them to load assets
  107394. */
  107395. static get PreprocessUrl(): (url: string) => string;
  107396. static set PreprocessUrl(processor: (url: string) => string);
  107397. /**
  107398. * Loads an image as an HTMLImageElement.
  107399. * @param input url string, ArrayBuffer, or Blob to load
  107400. * @param onLoad callback called when the image successfully loads
  107401. * @param onError callback called when the image fails to load
  107402. * @param offlineProvider offline provider for caching
  107403. * @param mimeType optional mime type
  107404. * @returns the HTMLImageElement of the loaded image
  107405. */
  107406. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  107407. /**
  107408. * Loads a file from a url
  107409. * @param url url string, ArrayBuffer, or Blob to load
  107410. * @param onSuccess callback called when the file successfully loads
  107411. * @param onProgress callback called while file is loading (if the server supports this mode)
  107412. * @param offlineProvider defines the offline provider for caching
  107413. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107414. * @param onError callback called when the file fails to load
  107415. * @returns a file request object
  107416. */
  107417. 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;
  107418. /**
  107419. * Loads a file from a url
  107420. * @param url the file url to load
  107421. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107422. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  107423. */
  107424. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  107425. /**
  107426. * Load a script (identified by an url). When the url returns, the
  107427. * content of this file is added into a new script element, attached to the DOM (body element)
  107428. * @param scriptUrl defines the url of the script to laod
  107429. * @param onSuccess defines the callback called when the script is loaded
  107430. * @param onError defines the callback to call if an error occurs
  107431. * @param scriptId defines the id of the script element
  107432. */
  107433. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  107434. /**
  107435. * Load an asynchronous script (identified by an url). When the url returns, the
  107436. * content of this file is added into a new script element, attached to the DOM (body element)
  107437. * @param scriptUrl defines the url of the script to laod
  107438. * @param scriptId defines the id of the script element
  107439. * @returns a promise request object
  107440. */
  107441. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  107442. /**
  107443. * Loads a file from a blob
  107444. * @param fileToLoad defines the blob to use
  107445. * @param callback defines the callback to call when data is loaded
  107446. * @param progressCallback defines the callback to call during loading process
  107447. * @returns a file request object
  107448. */
  107449. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  107450. /**
  107451. * Reads a file from a File object
  107452. * @param file defines the file to load
  107453. * @param onSuccess defines the callback to call when data is loaded
  107454. * @param onProgress defines the callback to call during loading process
  107455. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  107456. * @param onError defines the callback to call when an error occurs
  107457. * @returns a file request object
  107458. */
  107459. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107460. /**
  107461. * Creates a data url from a given string content
  107462. * @param content defines the content to convert
  107463. * @returns the new data url link
  107464. */
  107465. static FileAsURL(content: string): string;
  107466. /**
  107467. * Format the given number to a specific decimal format
  107468. * @param value defines the number to format
  107469. * @param decimals defines the number of decimals to use
  107470. * @returns the formatted string
  107471. */
  107472. static Format(value: number, decimals?: number): string;
  107473. /**
  107474. * Tries to copy an object by duplicating every property
  107475. * @param source defines the source object
  107476. * @param destination defines the target object
  107477. * @param doNotCopyList defines a list of properties to avoid
  107478. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  107479. */
  107480. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  107481. /**
  107482. * Gets a boolean indicating if the given object has no own property
  107483. * @param obj defines the object to test
  107484. * @returns true if object has no own property
  107485. */
  107486. static IsEmpty(obj: any): boolean;
  107487. /**
  107488. * Function used to register events at window level
  107489. * @param windowElement defines the Window object to use
  107490. * @param events defines the events to register
  107491. */
  107492. static RegisterTopRootEvents(windowElement: Window, events: {
  107493. name: string;
  107494. handler: Nullable<(e: FocusEvent) => any>;
  107495. }[]): void;
  107496. /**
  107497. * Function used to unregister events from window level
  107498. * @param windowElement defines the Window object to use
  107499. * @param events defines the events to unregister
  107500. */
  107501. static UnregisterTopRootEvents(windowElement: Window, events: {
  107502. name: string;
  107503. handler: Nullable<(e: FocusEvent) => any>;
  107504. }[]): void;
  107505. /**
  107506. * @ignore
  107507. */
  107508. static _ScreenshotCanvas: HTMLCanvasElement;
  107509. /**
  107510. * Dumps the current bound framebuffer
  107511. * @param width defines the rendering width
  107512. * @param height defines the rendering height
  107513. * @param engine defines the hosting engine
  107514. * @param successCallback defines the callback triggered once the data are available
  107515. * @param mimeType defines the mime type of the result
  107516. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  107517. */
  107518. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107519. /**
  107520. * Converts the canvas data to blob.
  107521. * This acts as a polyfill for browsers not supporting the to blob function.
  107522. * @param canvas Defines the canvas to extract the data from
  107523. * @param successCallback Defines the callback triggered once the data are available
  107524. * @param mimeType Defines the mime type of the result
  107525. */
  107526. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  107527. /**
  107528. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  107529. * @param successCallback defines the callback triggered once the data are available
  107530. * @param mimeType defines the mime type of the result
  107531. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  107532. */
  107533. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107534. /**
  107535. * Downloads a blob in the browser
  107536. * @param blob defines the blob to download
  107537. * @param fileName defines the name of the downloaded file
  107538. */
  107539. static Download(blob: Blob, fileName: string): void;
  107540. /**
  107541. * Captures a screenshot of the current rendering
  107542. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107543. * @param engine defines the rendering engine
  107544. * @param camera defines the source camera
  107545. * @param size This parameter can be set to a single number or to an object with the
  107546. * following (optional) properties: precision, width, height. If a single number is passed,
  107547. * it will be used for both width and height. If an object is passed, the screenshot size
  107548. * will be derived from the parameters. The precision property is a multiplier allowing
  107549. * rendering at a higher or lower resolution
  107550. * @param successCallback defines the callback receives a single parameter which contains the
  107551. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107552. * src parameter of an <img> to display it
  107553. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107554. * Check your browser for supported MIME types
  107555. */
  107556. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  107557. /**
  107558. * Captures a screenshot of the current rendering
  107559. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107560. * @param engine defines the rendering engine
  107561. * @param camera defines the source camera
  107562. * @param size This parameter can be set to a single number or to an object with the
  107563. * following (optional) properties: precision, width, height. If a single number is passed,
  107564. * it will be used for both width and height. If an object is passed, the screenshot size
  107565. * will be derived from the parameters. The precision property is a multiplier allowing
  107566. * rendering at a higher or lower resolution
  107567. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107568. * Check your browser for supported MIME types
  107569. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107570. * to the src parameter of an <img> to display it
  107571. */
  107572. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  107573. /**
  107574. * Generates an image screenshot from the specified camera.
  107575. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107576. * @param engine The engine to use for rendering
  107577. * @param camera The camera to use for rendering
  107578. * @param size This parameter can be set to a single number or to an object with the
  107579. * following (optional) properties: precision, width, height. If a single number is passed,
  107580. * it will be used for both width and height. If an object is passed, the screenshot size
  107581. * will be derived from the parameters. The precision property is a multiplier allowing
  107582. * rendering at a higher or lower resolution
  107583. * @param successCallback The callback receives a single parameter which contains the
  107584. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107585. * src parameter of an <img> to display it
  107586. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107587. * Check your browser for supported MIME types
  107588. * @param samples Texture samples (default: 1)
  107589. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107590. * @param fileName A name for for the downloaded file.
  107591. */
  107592. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  107593. /**
  107594. * Generates an image screenshot from the specified camera.
  107595. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107596. * @param engine The engine to use for rendering
  107597. * @param camera The camera to use for rendering
  107598. * @param size This parameter can be set to a single number or to an object with the
  107599. * following (optional) properties: precision, width, height. If a single number is passed,
  107600. * it will be used for both width and height. If an object is passed, the screenshot size
  107601. * will be derived from the parameters. The precision property is a multiplier allowing
  107602. * rendering at a higher or lower resolution
  107603. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107604. * Check your browser for supported MIME types
  107605. * @param samples Texture samples (default: 1)
  107606. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107607. * @param fileName A name for for the downloaded file.
  107608. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107609. * to the src parameter of an <img> to display it
  107610. */
  107611. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  107612. /**
  107613. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  107614. * Be aware Math.random() could cause collisions, but:
  107615. * "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"
  107616. * @returns a pseudo random id
  107617. */
  107618. static RandomId(): string;
  107619. /**
  107620. * Test if the given uri is a base64 string
  107621. * @param uri The uri to test
  107622. * @return True if the uri is a base64 string or false otherwise
  107623. */
  107624. static IsBase64(uri: string): boolean;
  107625. /**
  107626. * Decode the given base64 uri.
  107627. * @param uri The uri to decode
  107628. * @return The decoded base64 data.
  107629. */
  107630. static DecodeBase64(uri: string): ArrayBuffer;
  107631. /**
  107632. * Gets the absolute url.
  107633. * @param url the input url
  107634. * @return the absolute url
  107635. */
  107636. static GetAbsoluteUrl(url: string): string;
  107637. /**
  107638. * No log
  107639. */
  107640. static readonly NoneLogLevel: number;
  107641. /**
  107642. * Only message logs
  107643. */
  107644. static readonly MessageLogLevel: number;
  107645. /**
  107646. * Only warning logs
  107647. */
  107648. static readonly WarningLogLevel: number;
  107649. /**
  107650. * Only error logs
  107651. */
  107652. static readonly ErrorLogLevel: number;
  107653. /**
  107654. * All logs
  107655. */
  107656. static readonly AllLogLevel: number;
  107657. /**
  107658. * Gets a value indicating the number of loading errors
  107659. * @ignorenaming
  107660. */
  107661. static get errorsCount(): number;
  107662. /**
  107663. * Callback called when a new log is added
  107664. */
  107665. static OnNewCacheEntry: (entry: string) => void;
  107666. /**
  107667. * Log a message to the console
  107668. * @param message defines the message to log
  107669. */
  107670. static Log(message: string): void;
  107671. /**
  107672. * Write a warning message to the console
  107673. * @param message defines the message to log
  107674. */
  107675. static Warn(message: string): void;
  107676. /**
  107677. * Write an error message to the console
  107678. * @param message defines the message to log
  107679. */
  107680. static Error(message: string): void;
  107681. /**
  107682. * Gets current log cache (list of logs)
  107683. */
  107684. static get LogCache(): string;
  107685. /**
  107686. * Clears the log cache
  107687. */
  107688. static ClearLogCache(): void;
  107689. /**
  107690. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  107691. */
  107692. static set LogLevels(level: number);
  107693. /**
  107694. * Checks if the window object exists
  107695. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  107696. */
  107697. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  107698. /**
  107699. * No performance log
  107700. */
  107701. static readonly PerformanceNoneLogLevel: number;
  107702. /**
  107703. * Use user marks to log performance
  107704. */
  107705. static readonly PerformanceUserMarkLogLevel: number;
  107706. /**
  107707. * Log performance to the console
  107708. */
  107709. static readonly PerformanceConsoleLogLevel: number;
  107710. private static _performance;
  107711. /**
  107712. * Sets the current performance log level
  107713. */
  107714. static set PerformanceLogLevel(level: number);
  107715. private static _StartPerformanceCounterDisabled;
  107716. private static _EndPerformanceCounterDisabled;
  107717. private static _StartUserMark;
  107718. private static _EndUserMark;
  107719. private static _StartPerformanceConsole;
  107720. private static _EndPerformanceConsole;
  107721. /**
  107722. * Starts a performance counter
  107723. */
  107724. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107725. /**
  107726. * Ends a specific performance coutner
  107727. */
  107728. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107729. /**
  107730. * Gets either window.performance.now() if supported or Date.now() else
  107731. */
  107732. static get Now(): number;
  107733. /**
  107734. * This method will return the name of the class used to create the instance of the given object.
  107735. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  107736. * @param object the object to get the class name from
  107737. * @param isType defines if the object is actually a type
  107738. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  107739. */
  107740. static GetClassName(object: any, isType?: boolean): string;
  107741. /**
  107742. * Gets the first element of an array satisfying a given predicate
  107743. * @param array defines the array to browse
  107744. * @param predicate defines the predicate to use
  107745. * @returns null if not found or the element
  107746. */
  107747. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  107748. /**
  107749. * This method will return the name of the full name of the class, including its owning module (if any).
  107750. * 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).
  107751. * @param object the object to get the class name from
  107752. * @param isType defines if the object is actually a type
  107753. * @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.
  107754. * @ignorenaming
  107755. */
  107756. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  107757. /**
  107758. * Returns a promise that resolves after the given amount of time.
  107759. * @param delay Number of milliseconds to delay
  107760. * @returns Promise that resolves after the given amount of time
  107761. */
  107762. static DelayAsync(delay: number): Promise<void>;
  107763. /**
  107764. * Utility function to detect if the current user agent is Safari
  107765. * @returns whether or not the current user agent is safari
  107766. */
  107767. static IsSafari(): boolean;
  107768. }
  107769. /**
  107770. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  107771. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  107772. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  107773. * @param name The name of the class, case should be preserved
  107774. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  107775. */
  107776. export function className(name: string, module?: string): (target: Object) => void;
  107777. /**
  107778. * An implementation of a loop for asynchronous functions.
  107779. */
  107780. export class AsyncLoop {
  107781. /**
  107782. * Defines the number of iterations for the loop
  107783. */
  107784. iterations: number;
  107785. /**
  107786. * Defines the current index of the loop.
  107787. */
  107788. index: number;
  107789. private _done;
  107790. private _fn;
  107791. private _successCallback;
  107792. /**
  107793. * Constructor.
  107794. * @param iterations the number of iterations.
  107795. * @param func the function to run each iteration
  107796. * @param successCallback the callback that will be called upon succesful execution
  107797. * @param offset starting offset.
  107798. */
  107799. constructor(
  107800. /**
  107801. * Defines the number of iterations for the loop
  107802. */
  107803. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  107804. /**
  107805. * Execute the next iteration. Must be called after the last iteration was finished.
  107806. */
  107807. executeNext(): void;
  107808. /**
  107809. * Break the loop and run the success callback.
  107810. */
  107811. breakLoop(): void;
  107812. /**
  107813. * Create and run an async loop.
  107814. * @param iterations the number of iterations.
  107815. * @param fn the function to run each iteration
  107816. * @param successCallback the callback that will be called upon succesful execution
  107817. * @param offset starting offset.
  107818. * @returns the created async loop object
  107819. */
  107820. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  107821. /**
  107822. * A for-loop that will run a given number of iterations synchronous and the rest async.
  107823. * @param iterations total number of iterations
  107824. * @param syncedIterations number of synchronous iterations in each async iteration.
  107825. * @param fn the function to call each iteration.
  107826. * @param callback a success call back that will be called when iterating stops.
  107827. * @param breakFunction a break condition (optional)
  107828. * @param timeout timeout settings for the setTimeout function. default - 0.
  107829. * @returns the created async loop object
  107830. */
  107831. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  107832. }
  107833. }
  107834. declare module BABYLON {
  107835. /**
  107836. * This class implement a typical dictionary using a string as key and the generic type T as value.
  107837. * The underlying implementation relies on an associative array to ensure the best performances.
  107838. * The value can be anything including 'null' but except 'undefined'
  107839. */
  107840. export class StringDictionary<T> {
  107841. /**
  107842. * This will clear this dictionary and copy the content from the 'source' one.
  107843. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  107844. * @param source the dictionary to take the content from and copy to this dictionary
  107845. */
  107846. copyFrom(source: StringDictionary<T>): void;
  107847. /**
  107848. * Get a value based from its key
  107849. * @param key the given key to get the matching value from
  107850. * @return the value if found, otherwise undefined is returned
  107851. */
  107852. get(key: string): T | undefined;
  107853. /**
  107854. * Get a value from its key or add it if it doesn't exist.
  107855. * This method will ensure you that a given key/data will be present in the dictionary.
  107856. * @param key the given key to get the matching value from
  107857. * @param factory the factory that will create the value if the key is not present in the dictionary.
  107858. * The factory will only be invoked if there's no data for the given key.
  107859. * @return the value corresponding to the key.
  107860. */
  107861. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  107862. /**
  107863. * Get a value from its key if present in the dictionary otherwise add it
  107864. * @param key the key to get the value from
  107865. * @param val if there's no such key/value pair in the dictionary add it with this value
  107866. * @return the value corresponding to the key
  107867. */
  107868. getOrAdd(key: string, val: T): T;
  107869. /**
  107870. * Check if there's a given key in the dictionary
  107871. * @param key the key to check for
  107872. * @return true if the key is present, false otherwise
  107873. */
  107874. contains(key: string): boolean;
  107875. /**
  107876. * Add a new key and its corresponding value
  107877. * @param key the key to add
  107878. * @param value the value corresponding to the key
  107879. * @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
  107880. */
  107881. add(key: string, value: T): boolean;
  107882. /**
  107883. * Update a specific value associated to a key
  107884. * @param key defines the key to use
  107885. * @param value defines the value to store
  107886. * @returns true if the value was updated (or false if the key was not found)
  107887. */
  107888. set(key: string, value: T): boolean;
  107889. /**
  107890. * Get the element of the given key and remove it from the dictionary
  107891. * @param key defines the key to search
  107892. * @returns the value associated with the key or null if not found
  107893. */
  107894. getAndRemove(key: string): Nullable<T>;
  107895. /**
  107896. * Remove a key/value from the dictionary.
  107897. * @param key the key to remove
  107898. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  107899. */
  107900. remove(key: string): boolean;
  107901. /**
  107902. * Clear the whole content of the dictionary
  107903. */
  107904. clear(): void;
  107905. /**
  107906. * Gets the current count
  107907. */
  107908. get count(): number;
  107909. /**
  107910. * Execute a callback on each key/val of the dictionary.
  107911. * Note that you can remove any element in this dictionary in the callback implementation
  107912. * @param callback the callback to execute on a given key/value pair
  107913. */
  107914. forEach(callback: (key: string, val: T) => void): void;
  107915. /**
  107916. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  107917. * If the callback returns null or undefined the method will iterate to the next key/value pair
  107918. * Note that you can remove any element in this dictionary in the callback implementation
  107919. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  107920. * @returns the first item
  107921. */
  107922. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  107923. private _count;
  107924. private _data;
  107925. }
  107926. }
  107927. declare module BABYLON {
  107928. /** @hidden */
  107929. export interface ICollisionCoordinator {
  107930. createCollider(): Collider;
  107931. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107932. init(scene: Scene): void;
  107933. }
  107934. /** @hidden */
  107935. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  107936. private _scene;
  107937. private _scaledPosition;
  107938. private _scaledVelocity;
  107939. private _finalPosition;
  107940. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107941. createCollider(): Collider;
  107942. init(scene: Scene): void;
  107943. private _collideWithWorld;
  107944. }
  107945. }
  107946. declare module BABYLON {
  107947. /**
  107948. * Class used to manage all inputs for the scene.
  107949. */
  107950. export class InputManager {
  107951. /** The distance in pixel that you have to move to prevent some events */
  107952. static DragMovementThreshold: number;
  107953. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  107954. static LongPressDelay: number;
  107955. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  107956. static DoubleClickDelay: number;
  107957. /** If you need to check double click without raising a single click at first click, enable this flag */
  107958. static ExclusiveDoubleClickMode: boolean;
  107959. private _wheelEventName;
  107960. private _onPointerMove;
  107961. private _onPointerDown;
  107962. private _onPointerUp;
  107963. private _initClickEvent;
  107964. private _initActionManager;
  107965. private _delayedSimpleClick;
  107966. private _delayedSimpleClickTimeout;
  107967. private _previousDelayedSimpleClickTimeout;
  107968. private _meshPickProceed;
  107969. private _previousButtonPressed;
  107970. private _currentPickResult;
  107971. private _previousPickResult;
  107972. private _totalPointersPressed;
  107973. private _doubleClickOccured;
  107974. private _pointerOverMesh;
  107975. private _pickedDownMesh;
  107976. private _pickedUpMesh;
  107977. private _pointerX;
  107978. private _pointerY;
  107979. private _unTranslatedPointerX;
  107980. private _unTranslatedPointerY;
  107981. private _startingPointerPosition;
  107982. private _previousStartingPointerPosition;
  107983. private _startingPointerTime;
  107984. private _previousStartingPointerTime;
  107985. private _pointerCaptures;
  107986. private _onKeyDown;
  107987. private _onKeyUp;
  107988. private _onCanvasFocusObserver;
  107989. private _onCanvasBlurObserver;
  107990. private _scene;
  107991. /**
  107992. * Creates a new InputManager
  107993. * @param scene defines the hosting scene
  107994. */
  107995. constructor(scene: Scene);
  107996. /**
  107997. * Gets the mesh that is currently under the pointer
  107998. */
  107999. get meshUnderPointer(): Nullable<AbstractMesh>;
  108000. /**
  108001. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  108002. */
  108003. get unTranslatedPointer(): Vector2;
  108004. /**
  108005. * Gets or sets the current on-screen X position of the pointer
  108006. */
  108007. get pointerX(): number;
  108008. set pointerX(value: number);
  108009. /**
  108010. * Gets or sets the current on-screen Y position of the pointer
  108011. */
  108012. get pointerY(): number;
  108013. set pointerY(value: number);
  108014. private _updatePointerPosition;
  108015. private _processPointerMove;
  108016. private _setRayOnPointerInfo;
  108017. private _checkPrePointerObservable;
  108018. /**
  108019. * Use this method to simulate a pointer move on a mesh
  108020. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108021. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108022. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108023. */
  108024. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108025. /**
  108026. * Use this method to simulate a pointer down on a mesh
  108027. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108028. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108029. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108030. */
  108031. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108032. private _processPointerDown;
  108033. /** @hidden */
  108034. _isPointerSwiping(): boolean;
  108035. /**
  108036. * Use this method to simulate a pointer up on a mesh
  108037. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108038. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108039. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108040. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  108041. */
  108042. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  108043. private _processPointerUp;
  108044. /**
  108045. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  108046. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  108047. * @returns true if the pointer was captured
  108048. */
  108049. isPointerCaptured(pointerId?: number): boolean;
  108050. /**
  108051. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108052. * @param attachUp defines if you want to attach events to pointerup
  108053. * @param attachDown defines if you want to attach events to pointerdown
  108054. * @param attachMove defines if you want to attach events to pointermove
  108055. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  108056. */
  108057. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  108058. /**
  108059. * Detaches all event handlers
  108060. */
  108061. detachControl(): void;
  108062. /**
  108063. * Force the value of meshUnderPointer
  108064. * @param mesh defines the mesh to use
  108065. */
  108066. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  108067. /**
  108068. * Gets the mesh under the pointer
  108069. * @returns a Mesh or null if no mesh is under the pointer
  108070. */
  108071. getPointerOverMesh(): Nullable<AbstractMesh>;
  108072. }
  108073. }
  108074. declare module BABYLON {
  108075. /**
  108076. * Helper class used to generate session unique ID
  108077. */
  108078. export class UniqueIdGenerator {
  108079. private static _UniqueIdCounter;
  108080. /**
  108081. * Gets an unique (relatively to the current scene) Id
  108082. */
  108083. static get UniqueId(): number;
  108084. }
  108085. }
  108086. declare module BABYLON {
  108087. /**
  108088. * This class defines the direct association between an animation and a target
  108089. */
  108090. export class TargetedAnimation {
  108091. /**
  108092. * Animation to perform
  108093. */
  108094. animation: Animation;
  108095. /**
  108096. * Target to animate
  108097. */
  108098. target: any;
  108099. /**
  108100. * Serialize the object
  108101. * @returns the JSON object representing the current entity
  108102. */
  108103. serialize(): any;
  108104. }
  108105. /**
  108106. * Use this class to create coordinated animations on multiple targets
  108107. */
  108108. export class AnimationGroup implements IDisposable {
  108109. /** The name of the animation group */
  108110. name: string;
  108111. private _scene;
  108112. private _targetedAnimations;
  108113. private _animatables;
  108114. private _from;
  108115. private _to;
  108116. private _isStarted;
  108117. private _isPaused;
  108118. private _speedRatio;
  108119. private _loopAnimation;
  108120. /**
  108121. * Gets or sets the unique id of the node
  108122. */
  108123. uniqueId: number;
  108124. /**
  108125. * This observable will notify when one animation have ended
  108126. */
  108127. onAnimationEndObservable: Observable<TargetedAnimation>;
  108128. /**
  108129. * Observer raised when one animation loops
  108130. */
  108131. onAnimationLoopObservable: Observable<TargetedAnimation>;
  108132. /**
  108133. * Observer raised when all animations have looped
  108134. */
  108135. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  108136. /**
  108137. * This observable will notify when all animations have ended.
  108138. */
  108139. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  108140. /**
  108141. * This observable will notify when all animations have paused.
  108142. */
  108143. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  108144. /**
  108145. * This observable will notify when all animations are playing.
  108146. */
  108147. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  108148. /**
  108149. * Gets the first frame
  108150. */
  108151. get from(): number;
  108152. /**
  108153. * Gets the last frame
  108154. */
  108155. get to(): number;
  108156. /**
  108157. * Define if the animations are started
  108158. */
  108159. get isStarted(): boolean;
  108160. /**
  108161. * Gets a value indicating that the current group is playing
  108162. */
  108163. get isPlaying(): boolean;
  108164. /**
  108165. * Gets or sets the speed ratio to use for all animations
  108166. */
  108167. get speedRatio(): number;
  108168. /**
  108169. * Gets or sets the speed ratio to use for all animations
  108170. */
  108171. set speedRatio(value: number);
  108172. /**
  108173. * Gets or sets if all animations should loop or not
  108174. */
  108175. get loopAnimation(): boolean;
  108176. set loopAnimation(value: boolean);
  108177. /**
  108178. * Gets the targeted animations for this animation group
  108179. */
  108180. get targetedAnimations(): Array<TargetedAnimation>;
  108181. /**
  108182. * returning the list of animatables controlled by this animation group.
  108183. */
  108184. get animatables(): Array<Animatable>;
  108185. /**
  108186. * Instantiates a new Animation Group.
  108187. * This helps managing several animations at once.
  108188. * @see http://doc.babylonjs.com/how_to/group
  108189. * @param name Defines the name of the group
  108190. * @param scene Defines the scene the group belongs to
  108191. */
  108192. constructor(
  108193. /** The name of the animation group */
  108194. name: string, scene?: Nullable<Scene>);
  108195. /**
  108196. * Add an animation (with its target) in the group
  108197. * @param animation defines the animation we want to add
  108198. * @param target defines the target of the animation
  108199. * @returns the TargetedAnimation object
  108200. */
  108201. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  108202. /**
  108203. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  108204. * It can add constant keys at begin or end
  108205. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  108206. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  108207. * @returns the animation group
  108208. */
  108209. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  108210. private _animationLoopCount;
  108211. private _animationLoopFlags;
  108212. private _processLoop;
  108213. /**
  108214. * Start all animations on given targets
  108215. * @param loop defines if animations must loop
  108216. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  108217. * @param from defines the from key (optional)
  108218. * @param to defines the to key (optional)
  108219. * @returns the current animation group
  108220. */
  108221. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  108222. /**
  108223. * Pause all animations
  108224. * @returns the animation group
  108225. */
  108226. pause(): AnimationGroup;
  108227. /**
  108228. * Play all animations to initial state
  108229. * This function will start() the animations if they were not started or will restart() them if they were paused
  108230. * @param loop defines if animations must loop
  108231. * @returns the animation group
  108232. */
  108233. play(loop?: boolean): AnimationGroup;
  108234. /**
  108235. * Reset all animations to initial state
  108236. * @returns the animation group
  108237. */
  108238. reset(): AnimationGroup;
  108239. /**
  108240. * Restart animations from key 0
  108241. * @returns the animation group
  108242. */
  108243. restart(): AnimationGroup;
  108244. /**
  108245. * Stop all animations
  108246. * @returns the animation group
  108247. */
  108248. stop(): AnimationGroup;
  108249. /**
  108250. * Set animation weight for all animatables
  108251. * @param weight defines the weight to use
  108252. * @return the animationGroup
  108253. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108254. */
  108255. setWeightForAllAnimatables(weight: number): AnimationGroup;
  108256. /**
  108257. * Synchronize and normalize all animatables with a source animatable
  108258. * @param root defines the root animatable to synchronize with
  108259. * @return the animationGroup
  108260. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108261. */
  108262. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  108263. /**
  108264. * Goes to a specific frame in this animation group
  108265. * @param frame the frame number to go to
  108266. * @return the animationGroup
  108267. */
  108268. goToFrame(frame: number): AnimationGroup;
  108269. /**
  108270. * Dispose all associated resources
  108271. */
  108272. dispose(): void;
  108273. private _checkAnimationGroupEnded;
  108274. /**
  108275. * Clone the current animation group and returns a copy
  108276. * @param newName defines the name of the new group
  108277. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  108278. * @returns the new aniamtion group
  108279. */
  108280. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  108281. /**
  108282. * Serializes the animationGroup to an object
  108283. * @returns Serialized object
  108284. */
  108285. serialize(): any;
  108286. /**
  108287. * Returns a new AnimationGroup object parsed from the source provided.
  108288. * @param parsedAnimationGroup defines the source
  108289. * @param scene defines the scene that will receive the animationGroup
  108290. * @returns a new AnimationGroup
  108291. */
  108292. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  108293. /**
  108294. * Returns the string "AnimationGroup"
  108295. * @returns "AnimationGroup"
  108296. */
  108297. getClassName(): string;
  108298. /**
  108299. * Creates a detailled string about the object
  108300. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  108301. * @returns a string representing the object
  108302. */
  108303. toString(fullDetails?: boolean): string;
  108304. }
  108305. }
  108306. declare module BABYLON {
  108307. /**
  108308. * Define an interface for all classes that will hold resources
  108309. */
  108310. export interface IDisposable {
  108311. /**
  108312. * Releases all held resources
  108313. */
  108314. dispose(): void;
  108315. }
  108316. /** Interface defining initialization parameters for Scene class */
  108317. export interface SceneOptions {
  108318. /**
  108319. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  108320. * It will improve performance when the number of geometries becomes important.
  108321. */
  108322. useGeometryUniqueIdsMap?: boolean;
  108323. /**
  108324. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  108325. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108326. */
  108327. useMaterialMeshMap?: boolean;
  108328. /**
  108329. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  108330. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108331. */
  108332. useClonedMeshMap?: boolean;
  108333. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  108334. virtual?: boolean;
  108335. }
  108336. /**
  108337. * Represents a scene to be rendered by the engine.
  108338. * @see http://doc.babylonjs.com/features/scene
  108339. */
  108340. export class Scene extends AbstractScene implements IAnimatable {
  108341. /** The fog is deactivated */
  108342. static readonly FOGMODE_NONE: number;
  108343. /** The fog density is following an exponential function */
  108344. static readonly FOGMODE_EXP: number;
  108345. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  108346. static readonly FOGMODE_EXP2: number;
  108347. /** The fog density is following a linear function. */
  108348. static readonly FOGMODE_LINEAR: number;
  108349. /**
  108350. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  108351. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108352. */
  108353. static MinDeltaTime: number;
  108354. /**
  108355. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  108356. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108357. */
  108358. static MaxDeltaTime: number;
  108359. /**
  108360. * Factory used to create the default material.
  108361. * @param name The name of the material to create
  108362. * @param scene The scene to create the material for
  108363. * @returns The default material
  108364. */
  108365. static DefaultMaterialFactory(scene: Scene): Material;
  108366. /**
  108367. * Factory used to create the a collision coordinator.
  108368. * @returns The collision coordinator
  108369. */
  108370. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  108371. /** @hidden */
  108372. _inputManager: InputManager;
  108373. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  108374. cameraToUseForPointers: Nullable<Camera>;
  108375. /** @hidden */
  108376. readonly _isScene: boolean;
  108377. /** @hidden */
  108378. _blockEntityCollection: boolean;
  108379. /**
  108380. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  108381. */
  108382. autoClear: boolean;
  108383. /**
  108384. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  108385. */
  108386. autoClearDepthAndStencil: boolean;
  108387. /**
  108388. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  108389. */
  108390. clearColor: Color4;
  108391. /**
  108392. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  108393. */
  108394. ambientColor: Color3;
  108395. /**
  108396. * This is use to store the default BRDF lookup for PBR materials in your scene.
  108397. * It should only be one of the following (if not the default embedded one):
  108398. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108399. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  108400. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108401. * The material properties need to be setup according to the type of texture in use.
  108402. */
  108403. environmentBRDFTexture: BaseTexture;
  108404. /** @hidden */
  108405. protected _environmentTexture: Nullable<BaseTexture>;
  108406. /**
  108407. * Texture used in all pbr material as the reflection texture.
  108408. * As in the majority of the scene they are the same (exception for multi room and so on),
  108409. * this is easier to reference from here than from all the materials.
  108410. */
  108411. get environmentTexture(): Nullable<BaseTexture>;
  108412. /**
  108413. * Texture used in all pbr material as the reflection texture.
  108414. * As in the majority of the scene they are the same (exception for multi room and so on),
  108415. * this is easier to set here than in all the materials.
  108416. */
  108417. set environmentTexture(value: Nullable<BaseTexture>);
  108418. /** @hidden */
  108419. protected _environmentIntensity: number;
  108420. /**
  108421. * Intensity of the environment in all pbr material.
  108422. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108423. * As in the majority of the scene they are the same (exception for multi room and so on),
  108424. * this is easier to reference from here than from all the materials.
  108425. */
  108426. get environmentIntensity(): number;
  108427. /**
  108428. * Intensity of the environment in all pbr material.
  108429. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108430. * As in the majority of the scene they are the same (exception for multi room and so on),
  108431. * this is easier to set here than in all the materials.
  108432. */
  108433. set environmentIntensity(value: number);
  108434. /** @hidden */
  108435. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108436. /**
  108437. * Default image processing configuration used either in the rendering
  108438. * Forward main pass or through the imageProcessingPostProcess if present.
  108439. * As in the majority of the scene they are the same (exception for multi camera),
  108440. * this is easier to reference from here than from all the materials and post process.
  108441. *
  108442. * No setter as we it is a shared configuration, you can set the values instead.
  108443. */
  108444. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108445. private _forceWireframe;
  108446. /**
  108447. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  108448. */
  108449. set forceWireframe(value: boolean);
  108450. get forceWireframe(): boolean;
  108451. private _skipFrustumClipping;
  108452. /**
  108453. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  108454. */
  108455. set skipFrustumClipping(value: boolean);
  108456. get skipFrustumClipping(): boolean;
  108457. private _forcePointsCloud;
  108458. /**
  108459. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  108460. */
  108461. set forcePointsCloud(value: boolean);
  108462. get forcePointsCloud(): boolean;
  108463. /**
  108464. * Gets or sets the active clipplane 1
  108465. */
  108466. clipPlane: Nullable<Plane>;
  108467. /**
  108468. * Gets or sets the active clipplane 2
  108469. */
  108470. clipPlane2: Nullable<Plane>;
  108471. /**
  108472. * Gets or sets the active clipplane 3
  108473. */
  108474. clipPlane3: Nullable<Plane>;
  108475. /**
  108476. * Gets or sets the active clipplane 4
  108477. */
  108478. clipPlane4: Nullable<Plane>;
  108479. /**
  108480. * Gets or sets the active clipplane 5
  108481. */
  108482. clipPlane5: Nullable<Plane>;
  108483. /**
  108484. * Gets or sets the active clipplane 6
  108485. */
  108486. clipPlane6: Nullable<Plane>;
  108487. /**
  108488. * Gets or sets a boolean indicating if animations are enabled
  108489. */
  108490. animationsEnabled: boolean;
  108491. private _animationPropertiesOverride;
  108492. /**
  108493. * Gets or sets the animation properties override
  108494. */
  108495. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  108496. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  108497. /**
  108498. * Gets or sets a boolean indicating if a constant deltatime has to be used
  108499. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  108500. */
  108501. useConstantAnimationDeltaTime: boolean;
  108502. /**
  108503. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  108504. * Please note that it requires to run a ray cast through the scene on every frame
  108505. */
  108506. constantlyUpdateMeshUnderPointer: boolean;
  108507. /**
  108508. * Defines the HTML cursor to use when hovering over interactive elements
  108509. */
  108510. hoverCursor: string;
  108511. /**
  108512. * Defines the HTML default cursor to use (empty by default)
  108513. */
  108514. defaultCursor: string;
  108515. /**
  108516. * Defines whether cursors are handled by the scene.
  108517. */
  108518. doNotHandleCursors: boolean;
  108519. /**
  108520. * This is used to call preventDefault() on pointer down
  108521. * in order to block unwanted artifacts like system double clicks
  108522. */
  108523. preventDefaultOnPointerDown: boolean;
  108524. /**
  108525. * This is used to call preventDefault() on pointer up
  108526. * in order to block unwanted artifacts like system double clicks
  108527. */
  108528. preventDefaultOnPointerUp: boolean;
  108529. /**
  108530. * Gets or sets user defined metadata
  108531. */
  108532. metadata: any;
  108533. /**
  108534. * For internal use only. Please do not use.
  108535. */
  108536. reservedDataStore: any;
  108537. /**
  108538. * Gets the name of the plugin used to load this scene (null by default)
  108539. */
  108540. loadingPluginName: string;
  108541. /**
  108542. * Use this array to add regular expressions used to disable offline support for specific urls
  108543. */
  108544. disableOfflineSupportExceptionRules: RegExp[];
  108545. /**
  108546. * An event triggered when the scene is disposed.
  108547. */
  108548. onDisposeObservable: Observable<Scene>;
  108549. private _onDisposeObserver;
  108550. /** Sets a function to be executed when this scene is disposed. */
  108551. set onDispose(callback: () => void);
  108552. /**
  108553. * An event triggered before rendering the scene (right after animations and physics)
  108554. */
  108555. onBeforeRenderObservable: Observable<Scene>;
  108556. private _onBeforeRenderObserver;
  108557. /** Sets a function to be executed before rendering this scene */
  108558. set beforeRender(callback: Nullable<() => void>);
  108559. /**
  108560. * An event triggered after rendering the scene
  108561. */
  108562. onAfterRenderObservable: Observable<Scene>;
  108563. /**
  108564. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  108565. */
  108566. onAfterRenderCameraObservable: Observable<Camera>;
  108567. private _onAfterRenderObserver;
  108568. /** Sets a function to be executed after rendering this scene */
  108569. set afterRender(callback: Nullable<() => void>);
  108570. /**
  108571. * An event triggered before animating the scene
  108572. */
  108573. onBeforeAnimationsObservable: Observable<Scene>;
  108574. /**
  108575. * An event triggered after animations processing
  108576. */
  108577. onAfterAnimationsObservable: Observable<Scene>;
  108578. /**
  108579. * An event triggered before draw calls are ready to be sent
  108580. */
  108581. onBeforeDrawPhaseObservable: Observable<Scene>;
  108582. /**
  108583. * An event triggered after draw calls have been sent
  108584. */
  108585. onAfterDrawPhaseObservable: Observable<Scene>;
  108586. /**
  108587. * An event triggered when the scene is ready
  108588. */
  108589. onReadyObservable: Observable<Scene>;
  108590. /**
  108591. * An event triggered before rendering a camera
  108592. */
  108593. onBeforeCameraRenderObservable: Observable<Camera>;
  108594. private _onBeforeCameraRenderObserver;
  108595. /** Sets a function to be executed before rendering a camera*/
  108596. set beforeCameraRender(callback: () => void);
  108597. /**
  108598. * An event triggered after rendering a camera
  108599. */
  108600. onAfterCameraRenderObservable: Observable<Camera>;
  108601. private _onAfterCameraRenderObserver;
  108602. /** Sets a function to be executed after rendering a camera*/
  108603. set afterCameraRender(callback: () => void);
  108604. /**
  108605. * An event triggered when active meshes evaluation is about to start
  108606. */
  108607. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  108608. /**
  108609. * An event triggered when active meshes evaluation is done
  108610. */
  108611. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  108612. /**
  108613. * An event triggered when particles rendering is about to start
  108614. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108615. */
  108616. onBeforeParticlesRenderingObservable: Observable<Scene>;
  108617. /**
  108618. * An event triggered when particles rendering is done
  108619. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108620. */
  108621. onAfterParticlesRenderingObservable: Observable<Scene>;
  108622. /**
  108623. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  108624. */
  108625. onDataLoadedObservable: Observable<Scene>;
  108626. /**
  108627. * An event triggered when a camera is created
  108628. */
  108629. onNewCameraAddedObservable: Observable<Camera>;
  108630. /**
  108631. * An event triggered when a camera is removed
  108632. */
  108633. onCameraRemovedObservable: Observable<Camera>;
  108634. /**
  108635. * An event triggered when a light is created
  108636. */
  108637. onNewLightAddedObservable: Observable<Light>;
  108638. /**
  108639. * An event triggered when a light is removed
  108640. */
  108641. onLightRemovedObservable: Observable<Light>;
  108642. /**
  108643. * An event triggered when a geometry is created
  108644. */
  108645. onNewGeometryAddedObservable: Observable<Geometry>;
  108646. /**
  108647. * An event triggered when a geometry is removed
  108648. */
  108649. onGeometryRemovedObservable: Observable<Geometry>;
  108650. /**
  108651. * An event triggered when a transform node is created
  108652. */
  108653. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  108654. /**
  108655. * An event triggered when a transform node is removed
  108656. */
  108657. onTransformNodeRemovedObservable: Observable<TransformNode>;
  108658. /**
  108659. * An event triggered when a mesh is created
  108660. */
  108661. onNewMeshAddedObservable: Observable<AbstractMesh>;
  108662. /**
  108663. * An event triggered when a mesh is removed
  108664. */
  108665. onMeshRemovedObservable: Observable<AbstractMesh>;
  108666. /**
  108667. * An event triggered when a skeleton is created
  108668. */
  108669. onNewSkeletonAddedObservable: Observable<Skeleton>;
  108670. /**
  108671. * An event triggered when a skeleton is removed
  108672. */
  108673. onSkeletonRemovedObservable: Observable<Skeleton>;
  108674. /**
  108675. * An event triggered when a material is created
  108676. */
  108677. onNewMaterialAddedObservable: Observable<Material>;
  108678. /**
  108679. * An event triggered when a material is removed
  108680. */
  108681. onMaterialRemovedObservable: Observable<Material>;
  108682. /**
  108683. * An event triggered when a texture is created
  108684. */
  108685. onNewTextureAddedObservable: Observable<BaseTexture>;
  108686. /**
  108687. * An event triggered when a texture is removed
  108688. */
  108689. onTextureRemovedObservable: Observable<BaseTexture>;
  108690. /**
  108691. * An event triggered when render targets are about to be rendered
  108692. * Can happen multiple times per frame.
  108693. */
  108694. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  108695. /**
  108696. * An event triggered when render targets were rendered.
  108697. * Can happen multiple times per frame.
  108698. */
  108699. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  108700. /**
  108701. * An event triggered before calculating deterministic simulation step
  108702. */
  108703. onBeforeStepObservable: Observable<Scene>;
  108704. /**
  108705. * An event triggered after calculating deterministic simulation step
  108706. */
  108707. onAfterStepObservable: Observable<Scene>;
  108708. /**
  108709. * An event triggered when the activeCamera property is updated
  108710. */
  108711. onActiveCameraChanged: Observable<Scene>;
  108712. /**
  108713. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  108714. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108715. * 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)
  108716. */
  108717. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108718. /**
  108719. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  108720. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108721. * 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)
  108722. */
  108723. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108724. /**
  108725. * This Observable will when a mesh has been imported into the scene.
  108726. */
  108727. onMeshImportedObservable: Observable<AbstractMesh>;
  108728. /**
  108729. * This Observable will when an animation file has been imported into the scene.
  108730. */
  108731. onAnimationFileImportedObservable: Observable<Scene>;
  108732. /**
  108733. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  108734. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  108735. */
  108736. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  108737. /** @hidden */
  108738. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  108739. /**
  108740. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  108741. */
  108742. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  108743. /**
  108744. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  108745. */
  108746. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  108747. /**
  108748. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  108749. */
  108750. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  108751. /** Callback called when a pointer move is detected */
  108752. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108753. /** Callback called when a pointer down is detected */
  108754. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108755. /** Callback called when a pointer up is detected */
  108756. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  108757. /** Callback called when a pointer pick is detected */
  108758. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  108759. /**
  108760. * 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).
  108761. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  108762. */
  108763. onPrePointerObservable: Observable<PointerInfoPre>;
  108764. /**
  108765. * Observable event triggered each time an input event is received from the rendering canvas
  108766. */
  108767. onPointerObservable: Observable<PointerInfo>;
  108768. /**
  108769. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  108770. */
  108771. get unTranslatedPointer(): Vector2;
  108772. /**
  108773. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  108774. */
  108775. static get DragMovementThreshold(): number;
  108776. static set DragMovementThreshold(value: number);
  108777. /**
  108778. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  108779. */
  108780. static get LongPressDelay(): number;
  108781. static set LongPressDelay(value: number);
  108782. /**
  108783. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  108784. */
  108785. static get DoubleClickDelay(): number;
  108786. static set DoubleClickDelay(value: number);
  108787. /** If you need to check double click without raising a single click at first click, enable this flag */
  108788. static get ExclusiveDoubleClickMode(): boolean;
  108789. static set ExclusiveDoubleClickMode(value: boolean);
  108790. /** @hidden */
  108791. _mirroredCameraPosition: Nullable<Vector3>;
  108792. /**
  108793. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  108794. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  108795. */
  108796. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  108797. /**
  108798. * Observable event triggered each time an keyboard event is received from the hosting window
  108799. */
  108800. onKeyboardObservable: Observable<KeyboardInfo>;
  108801. private _useRightHandedSystem;
  108802. /**
  108803. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  108804. */
  108805. set useRightHandedSystem(value: boolean);
  108806. get useRightHandedSystem(): boolean;
  108807. private _timeAccumulator;
  108808. private _currentStepId;
  108809. private _currentInternalStep;
  108810. /**
  108811. * Sets the step Id used by deterministic lock step
  108812. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108813. * @param newStepId defines the step Id
  108814. */
  108815. setStepId(newStepId: number): void;
  108816. /**
  108817. * Gets the step Id used by deterministic lock step
  108818. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108819. * @returns the step Id
  108820. */
  108821. getStepId(): number;
  108822. /**
  108823. * Gets the internal step used by deterministic lock step
  108824. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108825. * @returns the internal step
  108826. */
  108827. getInternalStep(): number;
  108828. private _fogEnabled;
  108829. /**
  108830. * Gets or sets a boolean indicating if fog is enabled on this scene
  108831. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108832. * (Default is true)
  108833. */
  108834. set fogEnabled(value: boolean);
  108835. get fogEnabled(): boolean;
  108836. private _fogMode;
  108837. /**
  108838. * Gets or sets the fog mode to use
  108839. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108840. * | mode | value |
  108841. * | --- | --- |
  108842. * | FOGMODE_NONE | 0 |
  108843. * | FOGMODE_EXP | 1 |
  108844. * | FOGMODE_EXP2 | 2 |
  108845. * | FOGMODE_LINEAR | 3 |
  108846. */
  108847. set fogMode(value: number);
  108848. get fogMode(): number;
  108849. /**
  108850. * Gets or sets the fog color to use
  108851. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108852. * (Default is Color3(0.2, 0.2, 0.3))
  108853. */
  108854. fogColor: Color3;
  108855. /**
  108856. * Gets or sets the fog density to use
  108857. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108858. * (Default is 0.1)
  108859. */
  108860. fogDensity: number;
  108861. /**
  108862. * Gets or sets the fog start distance to use
  108863. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108864. * (Default is 0)
  108865. */
  108866. fogStart: number;
  108867. /**
  108868. * Gets or sets the fog end distance to use
  108869. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108870. * (Default is 1000)
  108871. */
  108872. fogEnd: number;
  108873. private _shadowsEnabled;
  108874. /**
  108875. * Gets or sets a boolean indicating if shadows are enabled on this scene
  108876. */
  108877. set shadowsEnabled(value: boolean);
  108878. get shadowsEnabled(): boolean;
  108879. private _lightsEnabled;
  108880. /**
  108881. * Gets or sets a boolean indicating if lights are enabled on this scene
  108882. */
  108883. set lightsEnabled(value: boolean);
  108884. get lightsEnabled(): boolean;
  108885. /** All of the active cameras added to this scene. */
  108886. activeCameras: Camera[];
  108887. /** @hidden */
  108888. _activeCamera: Nullable<Camera>;
  108889. /** Gets or sets the current active camera */
  108890. get activeCamera(): Nullable<Camera>;
  108891. set activeCamera(value: Nullable<Camera>);
  108892. private _defaultMaterial;
  108893. /** The default material used on meshes when no material is affected */
  108894. get defaultMaterial(): Material;
  108895. /** The default material used on meshes when no material is affected */
  108896. set defaultMaterial(value: Material);
  108897. private _texturesEnabled;
  108898. /**
  108899. * Gets or sets a boolean indicating if textures are enabled on this scene
  108900. */
  108901. set texturesEnabled(value: boolean);
  108902. get texturesEnabled(): boolean;
  108903. /**
  108904. * Gets or sets a boolean indicating if particles are enabled on this scene
  108905. */
  108906. particlesEnabled: boolean;
  108907. /**
  108908. * Gets or sets a boolean indicating if sprites are enabled on this scene
  108909. */
  108910. spritesEnabled: boolean;
  108911. private _skeletonsEnabled;
  108912. /**
  108913. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  108914. */
  108915. set skeletonsEnabled(value: boolean);
  108916. get skeletonsEnabled(): boolean;
  108917. /**
  108918. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  108919. */
  108920. lensFlaresEnabled: boolean;
  108921. /**
  108922. * Gets or sets a boolean indicating if collisions are enabled on this scene
  108923. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108924. */
  108925. collisionsEnabled: boolean;
  108926. private _collisionCoordinator;
  108927. /** @hidden */
  108928. get collisionCoordinator(): ICollisionCoordinator;
  108929. /**
  108930. * Defines the gravity applied to this scene (used only for collisions)
  108931. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108932. */
  108933. gravity: Vector3;
  108934. /**
  108935. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  108936. */
  108937. postProcessesEnabled: boolean;
  108938. /**
  108939. * The list of postprocesses added to the scene
  108940. */
  108941. postProcesses: PostProcess[];
  108942. /**
  108943. * Gets the current postprocess manager
  108944. */
  108945. postProcessManager: PostProcessManager;
  108946. /**
  108947. * Gets or sets a boolean indicating if render targets are enabled on this scene
  108948. */
  108949. renderTargetsEnabled: boolean;
  108950. /**
  108951. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  108952. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  108953. */
  108954. dumpNextRenderTargets: boolean;
  108955. /**
  108956. * The list of user defined render targets added to the scene
  108957. */
  108958. customRenderTargets: RenderTargetTexture[];
  108959. /**
  108960. * Defines if texture loading must be delayed
  108961. * If true, textures will only be loaded when they need to be rendered
  108962. */
  108963. useDelayedTextureLoading: boolean;
  108964. /**
  108965. * Gets the list of meshes imported to the scene through SceneLoader
  108966. */
  108967. importedMeshesFiles: String[];
  108968. /**
  108969. * Gets or sets a boolean indicating if probes are enabled on this scene
  108970. */
  108971. probesEnabled: boolean;
  108972. /**
  108973. * Gets or sets the current offline provider to use to store scene data
  108974. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  108975. */
  108976. offlineProvider: IOfflineProvider;
  108977. /**
  108978. * Gets or sets the action manager associated with the scene
  108979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108980. */
  108981. actionManager: AbstractActionManager;
  108982. private _meshesForIntersections;
  108983. /**
  108984. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  108985. */
  108986. proceduralTexturesEnabled: boolean;
  108987. private _engine;
  108988. private _totalVertices;
  108989. /** @hidden */
  108990. _activeIndices: PerfCounter;
  108991. /** @hidden */
  108992. _activeParticles: PerfCounter;
  108993. /** @hidden */
  108994. _activeBones: PerfCounter;
  108995. private _animationRatio;
  108996. /** @hidden */
  108997. _animationTimeLast: number;
  108998. /** @hidden */
  108999. _animationTime: number;
  109000. /**
  109001. * Gets or sets a general scale for animation speed
  109002. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  109003. */
  109004. animationTimeScale: number;
  109005. /** @hidden */
  109006. _cachedMaterial: Nullable<Material>;
  109007. /** @hidden */
  109008. _cachedEffect: Nullable<Effect>;
  109009. /** @hidden */
  109010. _cachedVisibility: Nullable<number>;
  109011. private _renderId;
  109012. private _frameId;
  109013. private _executeWhenReadyTimeoutId;
  109014. private _intermediateRendering;
  109015. private _viewUpdateFlag;
  109016. private _projectionUpdateFlag;
  109017. /** @hidden */
  109018. _toBeDisposed: Nullable<IDisposable>[];
  109019. private _activeRequests;
  109020. /** @hidden */
  109021. _pendingData: any[];
  109022. private _isDisposed;
  109023. /**
  109024. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  109025. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  109026. */
  109027. dispatchAllSubMeshesOfActiveMeshes: boolean;
  109028. private _activeMeshes;
  109029. private _processedMaterials;
  109030. private _renderTargets;
  109031. /** @hidden */
  109032. _activeParticleSystems: SmartArray<IParticleSystem>;
  109033. private _activeSkeletons;
  109034. private _softwareSkinnedMeshes;
  109035. private _renderingManager;
  109036. /** @hidden */
  109037. _activeAnimatables: Animatable[];
  109038. private _transformMatrix;
  109039. private _sceneUbo;
  109040. /** @hidden */
  109041. _viewMatrix: Matrix;
  109042. private _projectionMatrix;
  109043. /** @hidden */
  109044. _forcedViewPosition: Nullable<Vector3>;
  109045. /** @hidden */
  109046. _frustumPlanes: Plane[];
  109047. /**
  109048. * Gets the list of frustum planes (built from the active camera)
  109049. */
  109050. get frustumPlanes(): Plane[];
  109051. /**
  109052. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  109053. * This is useful if there are more lights that the maximum simulteanous authorized
  109054. */
  109055. requireLightSorting: boolean;
  109056. /** @hidden */
  109057. readonly useMaterialMeshMap: boolean;
  109058. /** @hidden */
  109059. readonly useClonedMeshMap: boolean;
  109060. private _externalData;
  109061. private _uid;
  109062. /**
  109063. * @hidden
  109064. * Backing store of defined scene components.
  109065. */
  109066. _components: ISceneComponent[];
  109067. /**
  109068. * @hidden
  109069. * Backing store of defined scene components.
  109070. */
  109071. _serializableComponents: ISceneSerializableComponent[];
  109072. /**
  109073. * List of components to register on the next registration step.
  109074. */
  109075. private _transientComponents;
  109076. /**
  109077. * Registers the transient components if needed.
  109078. */
  109079. private _registerTransientComponents;
  109080. /**
  109081. * @hidden
  109082. * Add a component to the scene.
  109083. * Note that the ccomponent could be registered on th next frame if this is called after
  109084. * the register component stage.
  109085. * @param component Defines the component to add to the scene
  109086. */
  109087. _addComponent(component: ISceneComponent): void;
  109088. /**
  109089. * @hidden
  109090. * Gets a component from the scene.
  109091. * @param name defines the name of the component to retrieve
  109092. * @returns the component or null if not present
  109093. */
  109094. _getComponent(name: string): Nullable<ISceneComponent>;
  109095. /**
  109096. * @hidden
  109097. * Defines the actions happening before camera updates.
  109098. */
  109099. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  109100. /**
  109101. * @hidden
  109102. * Defines the actions happening before clear the canvas.
  109103. */
  109104. _beforeClearStage: Stage<SimpleStageAction>;
  109105. /**
  109106. * @hidden
  109107. * Defines the actions when collecting render targets for the frame.
  109108. */
  109109. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109110. /**
  109111. * @hidden
  109112. * Defines the actions happening for one camera in the frame.
  109113. */
  109114. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109115. /**
  109116. * @hidden
  109117. * Defines the actions happening during the per mesh ready checks.
  109118. */
  109119. _isReadyForMeshStage: Stage<MeshStageAction>;
  109120. /**
  109121. * @hidden
  109122. * Defines the actions happening before evaluate active mesh checks.
  109123. */
  109124. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  109125. /**
  109126. * @hidden
  109127. * Defines the actions happening during the evaluate sub mesh checks.
  109128. */
  109129. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  109130. /**
  109131. * @hidden
  109132. * Defines the actions happening during the active mesh stage.
  109133. */
  109134. _activeMeshStage: Stage<ActiveMeshStageAction>;
  109135. /**
  109136. * @hidden
  109137. * Defines the actions happening during the per camera render target step.
  109138. */
  109139. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  109140. /**
  109141. * @hidden
  109142. * Defines the actions happening just before the active camera is drawing.
  109143. */
  109144. _beforeCameraDrawStage: Stage<CameraStageAction>;
  109145. /**
  109146. * @hidden
  109147. * Defines the actions happening just before a render target is drawing.
  109148. */
  109149. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109150. /**
  109151. * @hidden
  109152. * Defines the actions happening just before a rendering group is drawing.
  109153. */
  109154. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109155. /**
  109156. * @hidden
  109157. * Defines the actions happening just before a mesh is drawing.
  109158. */
  109159. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109160. /**
  109161. * @hidden
  109162. * Defines the actions happening just after a mesh has been drawn.
  109163. */
  109164. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109165. /**
  109166. * @hidden
  109167. * Defines the actions happening just after a rendering group has been drawn.
  109168. */
  109169. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109170. /**
  109171. * @hidden
  109172. * Defines the actions happening just after the active camera has been drawn.
  109173. */
  109174. _afterCameraDrawStage: Stage<CameraStageAction>;
  109175. /**
  109176. * @hidden
  109177. * Defines the actions happening just after a render target has been drawn.
  109178. */
  109179. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109180. /**
  109181. * @hidden
  109182. * Defines the actions happening just after rendering all cameras and computing intersections.
  109183. */
  109184. _afterRenderStage: Stage<SimpleStageAction>;
  109185. /**
  109186. * @hidden
  109187. * Defines the actions happening when a pointer move event happens.
  109188. */
  109189. _pointerMoveStage: Stage<PointerMoveStageAction>;
  109190. /**
  109191. * @hidden
  109192. * Defines the actions happening when a pointer down event happens.
  109193. */
  109194. _pointerDownStage: Stage<PointerUpDownStageAction>;
  109195. /**
  109196. * @hidden
  109197. * Defines the actions happening when a pointer up event happens.
  109198. */
  109199. _pointerUpStage: Stage<PointerUpDownStageAction>;
  109200. /**
  109201. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  109202. */
  109203. private geometriesByUniqueId;
  109204. /**
  109205. * Creates a new Scene
  109206. * @param engine defines the engine to use to render this scene
  109207. * @param options defines the scene options
  109208. */
  109209. constructor(engine: Engine, options?: SceneOptions);
  109210. /**
  109211. * Gets a string idenfifying the name of the class
  109212. * @returns "Scene" string
  109213. */
  109214. getClassName(): string;
  109215. private _defaultMeshCandidates;
  109216. /**
  109217. * @hidden
  109218. */
  109219. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109220. private _defaultSubMeshCandidates;
  109221. /**
  109222. * @hidden
  109223. */
  109224. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109225. /**
  109226. * Sets the default candidate providers for the scene.
  109227. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  109228. * and getCollidingSubMeshCandidates to their default function
  109229. */
  109230. setDefaultCandidateProviders(): void;
  109231. /**
  109232. * Gets the mesh that is currently under the pointer
  109233. */
  109234. get meshUnderPointer(): Nullable<AbstractMesh>;
  109235. /**
  109236. * Gets or sets the current on-screen X position of the pointer
  109237. */
  109238. get pointerX(): number;
  109239. set pointerX(value: number);
  109240. /**
  109241. * Gets or sets the current on-screen Y position of the pointer
  109242. */
  109243. get pointerY(): number;
  109244. set pointerY(value: number);
  109245. /**
  109246. * Gets the cached material (ie. the latest rendered one)
  109247. * @returns the cached material
  109248. */
  109249. getCachedMaterial(): Nullable<Material>;
  109250. /**
  109251. * Gets the cached effect (ie. the latest rendered one)
  109252. * @returns the cached effect
  109253. */
  109254. getCachedEffect(): Nullable<Effect>;
  109255. /**
  109256. * Gets the cached visibility state (ie. the latest rendered one)
  109257. * @returns the cached visibility state
  109258. */
  109259. getCachedVisibility(): Nullable<number>;
  109260. /**
  109261. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  109262. * @param material defines the current material
  109263. * @param effect defines the current effect
  109264. * @param visibility defines the current visibility state
  109265. * @returns true if one parameter is not cached
  109266. */
  109267. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  109268. /**
  109269. * Gets the engine associated with the scene
  109270. * @returns an Engine
  109271. */
  109272. getEngine(): Engine;
  109273. /**
  109274. * Gets the total number of vertices rendered per frame
  109275. * @returns the total number of vertices rendered per frame
  109276. */
  109277. getTotalVertices(): number;
  109278. /**
  109279. * Gets the performance counter for total vertices
  109280. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109281. */
  109282. get totalVerticesPerfCounter(): PerfCounter;
  109283. /**
  109284. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  109285. * @returns the total number of active indices rendered per frame
  109286. */
  109287. getActiveIndices(): number;
  109288. /**
  109289. * Gets the performance counter for active indices
  109290. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109291. */
  109292. get totalActiveIndicesPerfCounter(): PerfCounter;
  109293. /**
  109294. * Gets the total number of active particles rendered per frame
  109295. * @returns the total number of active particles rendered per frame
  109296. */
  109297. getActiveParticles(): number;
  109298. /**
  109299. * Gets the performance counter for active particles
  109300. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109301. */
  109302. get activeParticlesPerfCounter(): PerfCounter;
  109303. /**
  109304. * Gets the total number of active bones rendered per frame
  109305. * @returns the total number of active bones rendered per frame
  109306. */
  109307. getActiveBones(): number;
  109308. /**
  109309. * Gets the performance counter for active bones
  109310. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109311. */
  109312. get activeBonesPerfCounter(): PerfCounter;
  109313. /**
  109314. * Gets the array of active meshes
  109315. * @returns an array of AbstractMesh
  109316. */
  109317. getActiveMeshes(): SmartArray<AbstractMesh>;
  109318. /**
  109319. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  109320. * @returns a number
  109321. */
  109322. getAnimationRatio(): number;
  109323. /**
  109324. * Gets an unique Id for the current render phase
  109325. * @returns a number
  109326. */
  109327. getRenderId(): number;
  109328. /**
  109329. * Gets an unique Id for the current frame
  109330. * @returns a number
  109331. */
  109332. getFrameId(): number;
  109333. /** Call this function if you want to manually increment the render Id*/
  109334. incrementRenderId(): void;
  109335. private _createUbo;
  109336. /**
  109337. * Use this method to simulate a pointer move on a mesh
  109338. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109339. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109340. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109341. * @returns the current scene
  109342. */
  109343. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109344. /**
  109345. * Use this method to simulate a pointer down on a mesh
  109346. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109347. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109348. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109349. * @returns the current scene
  109350. */
  109351. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109352. /**
  109353. * Use this method to simulate a pointer up on a mesh
  109354. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109355. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109356. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109357. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109358. * @returns the current scene
  109359. */
  109360. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  109361. /**
  109362. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109363. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109364. * @returns true if the pointer was captured
  109365. */
  109366. isPointerCaptured(pointerId?: number): boolean;
  109367. /**
  109368. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109369. * @param attachUp defines if you want to attach events to pointerup
  109370. * @param attachDown defines if you want to attach events to pointerdown
  109371. * @param attachMove defines if you want to attach events to pointermove
  109372. */
  109373. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  109374. /** Detaches all event handlers*/
  109375. detachControl(): void;
  109376. /**
  109377. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  109378. * Delay loaded resources are not taking in account
  109379. * @return true if all required resources are ready
  109380. */
  109381. isReady(): boolean;
  109382. /** Resets all cached information relative to material (including effect and visibility) */
  109383. resetCachedMaterial(): void;
  109384. /**
  109385. * Registers a function to be called before every frame render
  109386. * @param func defines the function to register
  109387. */
  109388. registerBeforeRender(func: () => void): void;
  109389. /**
  109390. * Unregisters a function called before every frame render
  109391. * @param func defines the function to unregister
  109392. */
  109393. unregisterBeforeRender(func: () => void): void;
  109394. /**
  109395. * Registers a function to be called after every frame render
  109396. * @param func defines the function to register
  109397. */
  109398. registerAfterRender(func: () => void): void;
  109399. /**
  109400. * Unregisters a function called after every frame render
  109401. * @param func defines the function to unregister
  109402. */
  109403. unregisterAfterRender(func: () => void): void;
  109404. private _executeOnceBeforeRender;
  109405. /**
  109406. * The provided function will run before render once and will be disposed afterwards.
  109407. * A timeout delay can be provided so that the function will be executed in N ms.
  109408. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  109409. * @param func The function to be executed.
  109410. * @param timeout optional delay in ms
  109411. */
  109412. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  109413. /** @hidden */
  109414. _addPendingData(data: any): void;
  109415. /** @hidden */
  109416. _removePendingData(data: any): void;
  109417. /**
  109418. * Returns the number of items waiting to be loaded
  109419. * @returns the number of items waiting to be loaded
  109420. */
  109421. getWaitingItemsCount(): number;
  109422. /**
  109423. * Returns a boolean indicating if the scene is still loading data
  109424. */
  109425. get isLoading(): boolean;
  109426. /**
  109427. * Registers a function to be executed when the scene is ready
  109428. * @param {Function} func - the function to be executed
  109429. */
  109430. executeWhenReady(func: () => void): void;
  109431. /**
  109432. * Returns a promise that resolves when the scene is ready
  109433. * @returns A promise that resolves when the scene is ready
  109434. */
  109435. whenReadyAsync(): Promise<void>;
  109436. /** @hidden */
  109437. _checkIsReady(): void;
  109438. /**
  109439. * Gets all animatable attached to the scene
  109440. */
  109441. get animatables(): Animatable[];
  109442. /**
  109443. * Resets the last animation time frame.
  109444. * Useful to override when animations start running when loading a scene for the first time.
  109445. */
  109446. resetLastAnimationTimeFrame(): void;
  109447. /**
  109448. * Gets the current view matrix
  109449. * @returns a Matrix
  109450. */
  109451. getViewMatrix(): Matrix;
  109452. /**
  109453. * Gets the current projection matrix
  109454. * @returns a Matrix
  109455. */
  109456. getProjectionMatrix(): Matrix;
  109457. /**
  109458. * Gets the current transform matrix
  109459. * @returns a Matrix made of View * Projection
  109460. */
  109461. getTransformMatrix(): Matrix;
  109462. /**
  109463. * Sets the current transform matrix
  109464. * @param viewL defines the View matrix to use
  109465. * @param projectionL defines the Projection matrix to use
  109466. * @param viewR defines the right View matrix to use (if provided)
  109467. * @param projectionR defines the right Projection matrix to use (if provided)
  109468. */
  109469. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  109470. /**
  109471. * Gets the uniform buffer used to store scene data
  109472. * @returns a UniformBuffer
  109473. */
  109474. getSceneUniformBuffer(): UniformBuffer;
  109475. /**
  109476. * Gets an unique (relatively to the current scene) Id
  109477. * @returns an unique number for the scene
  109478. */
  109479. getUniqueId(): number;
  109480. /**
  109481. * Add a mesh to the list of scene's meshes
  109482. * @param newMesh defines the mesh to add
  109483. * @param recursive if all child meshes should also be added to the scene
  109484. */
  109485. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  109486. /**
  109487. * Remove a mesh for the list of scene's meshes
  109488. * @param toRemove defines the mesh to remove
  109489. * @param recursive if all child meshes should also be removed from the scene
  109490. * @returns the index where the mesh was in the mesh list
  109491. */
  109492. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  109493. /**
  109494. * Add a transform node to the list of scene's transform nodes
  109495. * @param newTransformNode defines the transform node to add
  109496. */
  109497. addTransformNode(newTransformNode: TransformNode): void;
  109498. /**
  109499. * Remove a transform node for the list of scene's transform nodes
  109500. * @param toRemove defines the transform node to remove
  109501. * @returns the index where the transform node was in the transform node list
  109502. */
  109503. removeTransformNode(toRemove: TransformNode): number;
  109504. /**
  109505. * Remove a skeleton for the list of scene's skeletons
  109506. * @param toRemove defines the skeleton to remove
  109507. * @returns the index where the skeleton was in the skeleton list
  109508. */
  109509. removeSkeleton(toRemove: Skeleton): number;
  109510. /**
  109511. * Remove a morph target for the list of scene's morph targets
  109512. * @param toRemove defines the morph target to remove
  109513. * @returns the index where the morph target was in the morph target list
  109514. */
  109515. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  109516. /**
  109517. * Remove a light for the list of scene's lights
  109518. * @param toRemove defines the light to remove
  109519. * @returns the index where the light was in the light list
  109520. */
  109521. removeLight(toRemove: Light): number;
  109522. /**
  109523. * Remove a camera for the list of scene's cameras
  109524. * @param toRemove defines the camera to remove
  109525. * @returns the index where the camera was in the camera list
  109526. */
  109527. removeCamera(toRemove: Camera): number;
  109528. /**
  109529. * Remove a particle system for the list of scene's particle systems
  109530. * @param toRemove defines the particle system to remove
  109531. * @returns the index where the particle system was in the particle system list
  109532. */
  109533. removeParticleSystem(toRemove: IParticleSystem): number;
  109534. /**
  109535. * Remove a animation for the list of scene's animations
  109536. * @param toRemove defines the animation to remove
  109537. * @returns the index where the animation was in the animation list
  109538. */
  109539. removeAnimation(toRemove: Animation): number;
  109540. /**
  109541. * Will stop the animation of the given target
  109542. * @param target - the target
  109543. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  109544. * @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)
  109545. */
  109546. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  109547. /**
  109548. * Removes the given animation group from this scene.
  109549. * @param toRemove The animation group to remove
  109550. * @returns The index of the removed animation group
  109551. */
  109552. removeAnimationGroup(toRemove: AnimationGroup): number;
  109553. /**
  109554. * Removes the given multi-material from this scene.
  109555. * @param toRemove The multi-material to remove
  109556. * @returns The index of the removed multi-material
  109557. */
  109558. removeMultiMaterial(toRemove: MultiMaterial): number;
  109559. /**
  109560. * Removes the given material from this scene.
  109561. * @param toRemove The material to remove
  109562. * @returns The index of the removed material
  109563. */
  109564. removeMaterial(toRemove: Material): number;
  109565. /**
  109566. * Removes the given action manager from this scene.
  109567. * @param toRemove The action manager to remove
  109568. * @returns The index of the removed action manager
  109569. */
  109570. removeActionManager(toRemove: AbstractActionManager): number;
  109571. /**
  109572. * Removes the given texture from this scene.
  109573. * @param toRemove The texture to remove
  109574. * @returns The index of the removed texture
  109575. */
  109576. removeTexture(toRemove: BaseTexture): number;
  109577. /**
  109578. * Adds the given light to this scene
  109579. * @param newLight The light to add
  109580. */
  109581. addLight(newLight: Light): void;
  109582. /**
  109583. * Sorts the list list based on light priorities
  109584. */
  109585. sortLightsByPriority(): void;
  109586. /**
  109587. * Adds the given camera to this scene
  109588. * @param newCamera The camera to add
  109589. */
  109590. addCamera(newCamera: Camera): void;
  109591. /**
  109592. * Adds the given skeleton to this scene
  109593. * @param newSkeleton The skeleton to add
  109594. */
  109595. addSkeleton(newSkeleton: Skeleton): void;
  109596. /**
  109597. * Adds the given particle system to this scene
  109598. * @param newParticleSystem The particle system to add
  109599. */
  109600. addParticleSystem(newParticleSystem: IParticleSystem): void;
  109601. /**
  109602. * Adds the given animation to this scene
  109603. * @param newAnimation The animation to add
  109604. */
  109605. addAnimation(newAnimation: Animation): void;
  109606. /**
  109607. * Adds the given animation group to this scene.
  109608. * @param newAnimationGroup The animation group to add
  109609. */
  109610. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  109611. /**
  109612. * Adds the given multi-material to this scene
  109613. * @param newMultiMaterial The multi-material to add
  109614. */
  109615. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  109616. /**
  109617. * Adds the given material to this scene
  109618. * @param newMaterial The material to add
  109619. */
  109620. addMaterial(newMaterial: Material): void;
  109621. /**
  109622. * Adds the given morph target to this scene
  109623. * @param newMorphTargetManager The morph target to add
  109624. */
  109625. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  109626. /**
  109627. * Adds the given geometry to this scene
  109628. * @param newGeometry The geometry to add
  109629. */
  109630. addGeometry(newGeometry: Geometry): void;
  109631. /**
  109632. * Adds the given action manager to this scene
  109633. * @param newActionManager The action manager to add
  109634. */
  109635. addActionManager(newActionManager: AbstractActionManager): void;
  109636. /**
  109637. * Adds the given texture to this scene.
  109638. * @param newTexture The texture to add
  109639. */
  109640. addTexture(newTexture: BaseTexture): void;
  109641. /**
  109642. * Switch active camera
  109643. * @param newCamera defines the new active camera
  109644. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  109645. */
  109646. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  109647. /**
  109648. * sets the active camera of the scene using its ID
  109649. * @param id defines the camera's ID
  109650. * @return the new active camera or null if none found.
  109651. */
  109652. setActiveCameraByID(id: string): Nullable<Camera>;
  109653. /**
  109654. * sets the active camera of the scene using its name
  109655. * @param name defines the camera's name
  109656. * @returns the new active camera or null if none found.
  109657. */
  109658. setActiveCameraByName(name: string): Nullable<Camera>;
  109659. /**
  109660. * get an animation group using its name
  109661. * @param name defines the material's name
  109662. * @return the animation group or null if none found.
  109663. */
  109664. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  109665. /**
  109666. * Get a material using its unique id
  109667. * @param uniqueId defines the material's unique id
  109668. * @return the material or null if none found.
  109669. */
  109670. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  109671. /**
  109672. * get a material using its id
  109673. * @param id defines the material's ID
  109674. * @return the material or null if none found.
  109675. */
  109676. getMaterialByID(id: string): Nullable<Material>;
  109677. /**
  109678. * Gets a the last added material using a given id
  109679. * @param id defines the material's ID
  109680. * @return the last material with the given id or null if none found.
  109681. */
  109682. getLastMaterialByID(id: string): Nullable<Material>;
  109683. /**
  109684. * Gets a material using its name
  109685. * @param name defines the material's name
  109686. * @return the material or null if none found.
  109687. */
  109688. getMaterialByName(name: string): Nullable<Material>;
  109689. /**
  109690. * Get a texture using its unique id
  109691. * @param uniqueId defines the texture's unique id
  109692. * @return the texture or null if none found.
  109693. */
  109694. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  109695. /**
  109696. * Gets a camera using its id
  109697. * @param id defines the id to look for
  109698. * @returns the camera or null if not found
  109699. */
  109700. getCameraByID(id: string): Nullable<Camera>;
  109701. /**
  109702. * Gets a camera using its unique id
  109703. * @param uniqueId defines the unique id to look for
  109704. * @returns the camera or null if not found
  109705. */
  109706. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  109707. /**
  109708. * Gets a camera using its name
  109709. * @param name defines the camera's name
  109710. * @return the camera or null if none found.
  109711. */
  109712. getCameraByName(name: string): Nullable<Camera>;
  109713. /**
  109714. * Gets a bone using its id
  109715. * @param id defines the bone's id
  109716. * @return the bone or null if not found
  109717. */
  109718. getBoneByID(id: string): Nullable<Bone>;
  109719. /**
  109720. * Gets a bone using its id
  109721. * @param name defines the bone's name
  109722. * @return the bone or null if not found
  109723. */
  109724. getBoneByName(name: string): Nullable<Bone>;
  109725. /**
  109726. * Gets a light node using its name
  109727. * @param name defines the the light's name
  109728. * @return the light or null if none found.
  109729. */
  109730. getLightByName(name: string): Nullable<Light>;
  109731. /**
  109732. * Gets a light node using its id
  109733. * @param id defines the light's id
  109734. * @return the light or null if none found.
  109735. */
  109736. getLightByID(id: string): Nullable<Light>;
  109737. /**
  109738. * Gets a light node using its scene-generated unique ID
  109739. * @param uniqueId defines the light's unique id
  109740. * @return the light or null if none found.
  109741. */
  109742. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  109743. /**
  109744. * Gets a particle system by id
  109745. * @param id defines the particle system id
  109746. * @return the corresponding system or null if none found
  109747. */
  109748. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  109749. /**
  109750. * Gets a geometry using its ID
  109751. * @param id defines the geometry's id
  109752. * @return the geometry or null if none found.
  109753. */
  109754. getGeometryByID(id: string): Nullable<Geometry>;
  109755. private _getGeometryByUniqueID;
  109756. /**
  109757. * Add a new geometry to this scene
  109758. * @param geometry defines the geometry to be added to the scene.
  109759. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  109760. * @return a boolean defining if the geometry was added or not
  109761. */
  109762. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  109763. /**
  109764. * Removes an existing geometry
  109765. * @param geometry defines the geometry to be removed from the scene
  109766. * @return a boolean defining if the geometry was removed or not
  109767. */
  109768. removeGeometry(geometry: Geometry): boolean;
  109769. /**
  109770. * Gets the list of geometries attached to the scene
  109771. * @returns an array of Geometry
  109772. */
  109773. getGeometries(): Geometry[];
  109774. /**
  109775. * Gets the first added mesh found of a given ID
  109776. * @param id defines the id to search for
  109777. * @return the mesh found or null if not found at all
  109778. */
  109779. getMeshByID(id: string): Nullable<AbstractMesh>;
  109780. /**
  109781. * Gets a list of meshes using their id
  109782. * @param id defines the id to search for
  109783. * @returns a list of meshes
  109784. */
  109785. getMeshesByID(id: string): Array<AbstractMesh>;
  109786. /**
  109787. * Gets the first added transform node found of a given ID
  109788. * @param id defines the id to search for
  109789. * @return the found transform node or null if not found at all.
  109790. */
  109791. getTransformNodeByID(id: string): Nullable<TransformNode>;
  109792. /**
  109793. * Gets a transform node with its auto-generated unique id
  109794. * @param uniqueId efines the unique id to search for
  109795. * @return the found transform node or null if not found at all.
  109796. */
  109797. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  109798. /**
  109799. * Gets a list of transform nodes using their id
  109800. * @param id defines the id to search for
  109801. * @returns a list of transform nodes
  109802. */
  109803. getTransformNodesByID(id: string): Array<TransformNode>;
  109804. /**
  109805. * Gets a mesh with its auto-generated unique id
  109806. * @param uniqueId defines the unique id to search for
  109807. * @return the found mesh or null if not found at all.
  109808. */
  109809. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  109810. /**
  109811. * Gets a the last added mesh using a given id
  109812. * @param id defines the id to search for
  109813. * @return the found mesh or null if not found at all.
  109814. */
  109815. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  109816. /**
  109817. * Gets a the last added node (Mesh, Camera, Light) using a given id
  109818. * @param id defines the id to search for
  109819. * @return the found node or null if not found at all
  109820. */
  109821. getLastEntryByID(id: string): Nullable<Node>;
  109822. /**
  109823. * Gets a node (Mesh, Camera, Light) using a given id
  109824. * @param id defines the id to search for
  109825. * @return the found node or null if not found at all
  109826. */
  109827. getNodeByID(id: string): Nullable<Node>;
  109828. /**
  109829. * Gets a node (Mesh, Camera, Light) using a given name
  109830. * @param name defines the name to search for
  109831. * @return the found node or null if not found at all.
  109832. */
  109833. getNodeByName(name: string): Nullable<Node>;
  109834. /**
  109835. * Gets a mesh using a given name
  109836. * @param name defines the name to search for
  109837. * @return the found mesh or null if not found at all.
  109838. */
  109839. getMeshByName(name: string): Nullable<AbstractMesh>;
  109840. /**
  109841. * Gets a transform node using a given name
  109842. * @param name defines the name to search for
  109843. * @return the found transform node or null if not found at all.
  109844. */
  109845. getTransformNodeByName(name: string): Nullable<TransformNode>;
  109846. /**
  109847. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  109848. * @param id defines the id to search for
  109849. * @return the found skeleton or null if not found at all.
  109850. */
  109851. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  109852. /**
  109853. * Gets a skeleton using a given auto generated unique id
  109854. * @param uniqueId defines the unique id to search for
  109855. * @return the found skeleton or null if not found at all.
  109856. */
  109857. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  109858. /**
  109859. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  109860. * @param id defines the id to search for
  109861. * @return the found skeleton or null if not found at all.
  109862. */
  109863. getSkeletonById(id: string): Nullable<Skeleton>;
  109864. /**
  109865. * Gets a skeleton using a given name
  109866. * @param name defines the name to search for
  109867. * @return the found skeleton or null if not found at all.
  109868. */
  109869. getSkeletonByName(name: string): Nullable<Skeleton>;
  109870. /**
  109871. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  109872. * @param id defines the id to search for
  109873. * @return the found morph target manager or null if not found at all.
  109874. */
  109875. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  109876. /**
  109877. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  109878. * @param id defines the id to search for
  109879. * @return the found morph target or null if not found at all.
  109880. */
  109881. getMorphTargetById(id: string): Nullable<MorphTarget>;
  109882. /**
  109883. * Gets a boolean indicating if the given mesh is active
  109884. * @param mesh defines the mesh to look for
  109885. * @returns true if the mesh is in the active list
  109886. */
  109887. isActiveMesh(mesh: AbstractMesh): boolean;
  109888. /**
  109889. * Return a unique id as a string which can serve as an identifier for the scene
  109890. */
  109891. get uid(): string;
  109892. /**
  109893. * Add an externaly attached data from its key.
  109894. * This method call will fail and return false, if such key already exists.
  109895. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  109896. * @param key the unique key that identifies the data
  109897. * @param data the data object to associate to the key for this Engine instance
  109898. * @return true if no such key were already present and the data was added successfully, false otherwise
  109899. */
  109900. addExternalData<T>(key: string, data: T): boolean;
  109901. /**
  109902. * Get an externaly attached data from its key
  109903. * @param key the unique key that identifies the data
  109904. * @return the associated data, if present (can be null), or undefined if not present
  109905. */
  109906. getExternalData<T>(key: string): Nullable<T>;
  109907. /**
  109908. * Get an externaly attached data from its key, create it using a factory if it's not already present
  109909. * @param key the unique key that identifies the data
  109910. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  109911. * @return the associated data, can be null if the factory returned null.
  109912. */
  109913. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  109914. /**
  109915. * Remove an externaly attached data from the Engine instance
  109916. * @param key the unique key that identifies the data
  109917. * @return true if the data was successfully removed, false if it doesn't exist
  109918. */
  109919. removeExternalData(key: string): boolean;
  109920. private _evaluateSubMesh;
  109921. /**
  109922. * Clear the processed materials smart array preventing retention point in material dispose.
  109923. */
  109924. freeProcessedMaterials(): void;
  109925. private _preventFreeActiveMeshesAndRenderingGroups;
  109926. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  109927. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  109928. * when disposing several meshes in a row or a hierarchy of meshes.
  109929. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  109930. */
  109931. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  109932. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  109933. /**
  109934. * Clear the active meshes smart array preventing retention point in mesh dispose.
  109935. */
  109936. freeActiveMeshes(): void;
  109937. /**
  109938. * Clear the info related to rendering groups preventing retention points during dispose.
  109939. */
  109940. freeRenderingGroups(): void;
  109941. /** @hidden */
  109942. _isInIntermediateRendering(): boolean;
  109943. /**
  109944. * Lambda returning the list of potentially active meshes.
  109945. */
  109946. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  109947. /**
  109948. * Lambda returning the list of potentially active sub meshes.
  109949. */
  109950. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  109951. /**
  109952. * Lambda returning the list of potentially intersecting sub meshes.
  109953. */
  109954. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  109955. /**
  109956. * Lambda returning the list of potentially colliding sub meshes.
  109957. */
  109958. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  109959. private _activeMeshesFrozen;
  109960. private _skipEvaluateActiveMeshesCompletely;
  109961. /**
  109962. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  109963. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  109964. * @returns the current scene
  109965. */
  109966. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  109967. /**
  109968. * Use this function to restart evaluating active meshes on every frame
  109969. * @returns the current scene
  109970. */
  109971. unfreezeActiveMeshes(): Scene;
  109972. private _evaluateActiveMeshes;
  109973. private _activeMesh;
  109974. /**
  109975. * Update the transform matrix to update from the current active camera
  109976. * @param force defines a boolean used to force the update even if cache is up to date
  109977. */
  109978. updateTransformMatrix(force?: boolean): void;
  109979. private _bindFrameBuffer;
  109980. /** @hidden */
  109981. _allowPostProcessClearColor: boolean;
  109982. /** @hidden */
  109983. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  109984. private _processSubCameras;
  109985. private _checkIntersections;
  109986. /** @hidden */
  109987. _advancePhysicsEngineStep(step: number): void;
  109988. /**
  109989. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  109990. */
  109991. getDeterministicFrameTime: () => number;
  109992. /** @hidden */
  109993. _animate(): void;
  109994. /** Execute all animations (for a frame) */
  109995. animate(): void;
  109996. /**
  109997. * Render the scene
  109998. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  109999. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  110000. */
  110001. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  110002. /**
  110003. * Freeze all materials
  110004. * A frozen material will not be updatable but should be faster to render
  110005. */
  110006. freezeMaterials(): void;
  110007. /**
  110008. * Unfreeze all materials
  110009. * A frozen material will not be updatable but should be faster to render
  110010. */
  110011. unfreezeMaterials(): void;
  110012. /**
  110013. * Releases all held ressources
  110014. */
  110015. dispose(): void;
  110016. /**
  110017. * Gets if the scene is already disposed
  110018. */
  110019. get isDisposed(): boolean;
  110020. /**
  110021. * Call this function to reduce memory footprint of the scene.
  110022. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  110023. */
  110024. clearCachedVertexData(): void;
  110025. /**
  110026. * This function will remove the local cached buffer data from texture.
  110027. * It will save memory but will prevent the texture from being rebuilt
  110028. */
  110029. cleanCachedTextureBuffer(): void;
  110030. /**
  110031. * Get the world extend vectors with an optional filter
  110032. *
  110033. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  110034. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  110035. */
  110036. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  110037. min: Vector3;
  110038. max: Vector3;
  110039. };
  110040. /**
  110041. * Creates a ray that can be used to pick in the scene
  110042. * @param x defines the x coordinate of the origin (on-screen)
  110043. * @param y defines the y coordinate of the origin (on-screen)
  110044. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110045. * @param camera defines the camera to use for the picking
  110046. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110047. * @returns a Ray
  110048. */
  110049. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  110050. /**
  110051. * Creates a ray that can be used to pick in the scene
  110052. * @param x defines the x coordinate of the origin (on-screen)
  110053. * @param y defines the y coordinate of the origin (on-screen)
  110054. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110055. * @param result defines the ray where to store the picking ray
  110056. * @param camera defines the camera to use for the picking
  110057. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110058. * @returns the current scene
  110059. */
  110060. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  110061. /**
  110062. * Creates a ray that can be used to pick in the scene
  110063. * @param x defines the x coordinate of the origin (on-screen)
  110064. * @param y defines the y coordinate of the origin (on-screen)
  110065. * @param camera defines the camera to use for the picking
  110066. * @returns a Ray
  110067. */
  110068. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  110069. /**
  110070. * Creates a ray that can be used to pick in the scene
  110071. * @param x defines the x coordinate of the origin (on-screen)
  110072. * @param y defines the y coordinate of the origin (on-screen)
  110073. * @param result defines the ray where to store the picking ray
  110074. * @param camera defines the camera to use for the picking
  110075. * @returns the current scene
  110076. */
  110077. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  110078. /** Launch a ray to try to pick a mesh in the scene
  110079. * @param x position on screen
  110080. * @param y position on screen
  110081. * @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
  110082. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  110083. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110084. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110085. * @returns a PickingInfo
  110086. */
  110087. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110088. /** Use the given ray to pick a mesh in the scene
  110089. * @param ray The ray to use to pick meshes
  110090. * @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
  110091. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  110092. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110093. * @returns a PickingInfo
  110094. */
  110095. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110096. /**
  110097. * Launch a ray to try to pick a mesh in the scene
  110098. * @param x X position on screen
  110099. * @param y Y position on screen
  110100. * @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
  110101. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110102. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110103. * @returns an array of PickingInfo
  110104. */
  110105. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110106. /**
  110107. * Launch a ray to try to pick a mesh in the scene
  110108. * @param ray Ray to use
  110109. * @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
  110110. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110111. * @returns an array of PickingInfo
  110112. */
  110113. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110114. /**
  110115. * Force the value of meshUnderPointer
  110116. * @param mesh defines the mesh to use
  110117. */
  110118. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  110119. /**
  110120. * Gets the mesh under the pointer
  110121. * @returns a Mesh or null if no mesh is under the pointer
  110122. */
  110123. getPointerOverMesh(): Nullable<AbstractMesh>;
  110124. /** @hidden */
  110125. _rebuildGeometries(): void;
  110126. /** @hidden */
  110127. _rebuildTextures(): void;
  110128. private _getByTags;
  110129. /**
  110130. * Get a list of meshes by tags
  110131. * @param tagsQuery defines the tags query to use
  110132. * @param forEach defines a predicate used to filter results
  110133. * @returns an array of Mesh
  110134. */
  110135. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  110136. /**
  110137. * Get a list of cameras by tags
  110138. * @param tagsQuery defines the tags query to use
  110139. * @param forEach defines a predicate used to filter results
  110140. * @returns an array of Camera
  110141. */
  110142. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  110143. /**
  110144. * Get a list of lights by tags
  110145. * @param tagsQuery defines the tags query to use
  110146. * @param forEach defines a predicate used to filter results
  110147. * @returns an array of Light
  110148. */
  110149. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  110150. /**
  110151. * Get a list of materials by tags
  110152. * @param tagsQuery defines the tags query to use
  110153. * @param forEach defines a predicate used to filter results
  110154. * @returns an array of Material
  110155. */
  110156. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  110157. /**
  110158. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110159. * This allowed control for front to back rendering or reversly depending of the special needs.
  110160. *
  110161. * @param renderingGroupId The rendering group id corresponding to its index
  110162. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110163. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110164. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110165. */
  110166. 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;
  110167. /**
  110168. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110169. *
  110170. * @param renderingGroupId The rendering group id corresponding to its index
  110171. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110172. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110173. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110174. */
  110175. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110176. /**
  110177. * Gets the current auto clear configuration for one rendering group of the rendering
  110178. * manager.
  110179. * @param index the rendering group index to get the information for
  110180. * @returns The auto clear setup for the requested rendering group
  110181. */
  110182. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110183. private _blockMaterialDirtyMechanism;
  110184. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  110185. get blockMaterialDirtyMechanism(): boolean;
  110186. set blockMaterialDirtyMechanism(value: boolean);
  110187. /**
  110188. * Will flag all materials as dirty to trigger new shader compilation
  110189. * @param flag defines the flag used to specify which material part must be marked as dirty
  110190. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  110191. */
  110192. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  110193. /** @hidden */
  110194. _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;
  110195. /** @hidden */
  110196. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110197. /** @hidden */
  110198. _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;
  110199. /** @hidden */
  110200. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  110201. /** @hidden */
  110202. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110203. /** @hidden */
  110204. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110205. }
  110206. }
  110207. declare module BABYLON {
  110208. /**
  110209. * Set of assets to keep when moving a scene into an asset container.
  110210. */
  110211. export class KeepAssets extends AbstractScene {
  110212. }
  110213. /**
  110214. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  110215. */
  110216. export class InstantiatedEntries {
  110217. /**
  110218. * List of new root nodes (eg. nodes with no parent)
  110219. */
  110220. rootNodes: TransformNode[];
  110221. /**
  110222. * List of new skeletons
  110223. */
  110224. skeletons: Skeleton[];
  110225. /**
  110226. * List of new animation groups
  110227. */
  110228. animationGroups: AnimationGroup[];
  110229. }
  110230. /**
  110231. * Container with a set of assets that can be added or removed from a scene.
  110232. */
  110233. export class AssetContainer extends AbstractScene {
  110234. private _wasAddedToScene;
  110235. /**
  110236. * The scene the AssetContainer belongs to.
  110237. */
  110238. scene: Scene;
  110239. /**
  110240. * Instantiates an AssetContainer.
  110241. * @param scene The scene the AssetContainer belongs to.
  110242. */
  110243. constructor(scene: Scene);
  110244. /**
  110245. * Instantiate or clone all meshes and add the new ones to the scene.
  110246. * Skeletons and animation groups will all be cloned
  110247. * @param nameFunction defines an optional function used to get new names for clones
  110248. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  110249. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  110250. */
  110251. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  110252. /**
  110253. * Adds all the assets from the container to the scene.
  110254. */
  110255. addAllToScene(): void;
  110256. /**
  110257. * Removes all the assets in the container from the scene
  110258. */
  110259. removeAllFromScene(): void;
  110260. /**
  110261. * Disposes all the assets in the container
  110262. */
  110263. dispose(): void;
  110264. private _moveAssets;
  110265. /**
  110266. * Removes all the assets contained in the scene and adds them to the container.
  110267. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  110268. */
  110269. moveAllFromScene(keepAssets?: KeepAssets): void;
  110270. /**
  110271. * 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.
  110272. * @returns the root mesh
  110273. */
  110274. createRootMesh(): Mesh;
  110275. /**
  110276. * Merge animations from this asset container into a scene
  110277. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110278. * @param animatables set of animatables to retarget to a node from the scene
  110279. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  110280. */
  110281. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  110282. }
  110283. }
  110284. declare module BABYLON {
  110285. /**
  110286. * Defines how the parser contract is defined.
  110287. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  110288. */
  110289. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  110290. /**
  110291. * Defines how the individual parser contract is defined.
  110292. * These parser can parse an individual asset
  110293. */
  110294. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  110295. /**
  110296. * Base class of the scene acting as a container for the different elements composing a scene.
  110297. * This class is dynamically extended by the different components of the scene increasing
  110298. * flexibility and reducing coupling
  110299. */
  110300. export abstract class AbstractScene {
  110301. /**
  110302. * Stores the list of available parsers in the application.
  110303. */
  110304. private static _BabylonFileParsers;
  110305. /**
  110306. * Stores the list of available individual parsers in the application.
  110307. */
  110308. private static _IndividualBabylonFileParsers;
  110309. /**
  110310. * Adds a parser in the list of available ones
  110311. * @param name Defines the name of the parser
  110312. * @param parser Defines the parser to add
  110313. */
  110314. static AddParser(name: string, parser: BabylonFileParser): void;
  110315. /**
  110316. * Gets a general parser from the list of avaialble ones
  110317. * @param name Defines the name of the parser
  110318. * @returns the requested parser or null
  110319. */
  110320. static GetParser(name: string): Nullable<BabylonFileParser>;
  110321. /**
  110322. * Adds n individual parser in the list of available ones
  110323. * @param name Defines the name of the parser
  110324. * @param parser Defines the parser to add
  110325. */
  110326. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  110327. /**
  110328. * Gets an individual parser from the list of avaialble ones
  110329. * @param name Defines the name of the parser
  110330. * @returns the requested parser or null
  110331. */
  110332. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  110333. /**
  110334. * Parser json data and populate both a scene and its associated container object
  110335. * @param jsonData Defines the data to parse
  110336. * @param scene Defines the scene to parse the data for
  110337. * @param container Defines the container attached to the parsing sequence
  110338. * @param rootUrl Defines the root url of the data
  110339. */
  110340. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  110341. /**
  110342. * Gets the list of root nodes (ie. nodes with no parent)
  110343. */
  110344. rootNodes: Node[];
  110345. /** All of the cameras added to this scene
  110346. * @see http://doc.babylonjs.com/babylon101/cameras
  110347. */
  110348. cameras: Camera[];
  110349. /**
  110350. * All of the lights added to this scene
  110351. * @see http://doc.babylonjs.com/babylon101/lights
  110352. */
  110353. lights: Light[];
  110354. /**
  110355. * All of the (abstract) meshes added to this scene
  110356. */
  110357. meshes: AbstractMesh[];
  110358. /**
  110359. * The list of skeletons added to the scene
  110360. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110361. */
  110362. skeletons: Skeleton[];
  110363. /**
  110364. * All of the particle systems added to this scene
  110365. * @see http://doc.babylonjs.com/babylon101/particles
  110366. */
  110367. particleSystems: IParticleSystem[];
  110368. /**
  110369. * Gets a list of Animations associated with the scene
  110370. */
  110371. animations: Animation[];
  110372. /**
  110373. * All of the animation groups added to this scene
  110374. * @see http://doc.babylonjs.com/how_to/group
  110375. */
  110376. animationGroups: AnimationGroup[];
  110377. /**
  110378. * All of the multi-materials added to this scene
  110379. * @see http://doc.babylonjs.com/how_to/multi_materials
  110380. */
  110381. multiMaterials: MultiMaterial[];
  110382. /**
  110383. * All of the materials added to this scene
  110384. * In the context of a Scene, it is not supposed to be modified manually.
  110385. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  110386. * Note also that the order of the Material within the array is not significant and might change.
  110387. * @see http://doc.babylonjs.com/babylon101/materials
  110388. */
  110389. materials: Material[];
  110390. /**
  110391. * The list of morph target managers added to the scene
  110392. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110393. */
  110394. morphTargetManagers: MorphTargetManager[];
  110395. /**
  110396. * The list of geometries used in the scene.
  110397. */
  110398. geometries: Geometry[];
  110399. /**
  110400. * All of the tranform nodes added to this scene
  110401. * In the context of a Scene, it is not supposed to be modified manually.
  110402. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  110403. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  110404. * @see http://doc.babylonjs.com/how_to/transformnode
  110405. */
  110406. transformNodes: TransformNode[];
  110407. /**
  110408. * ActionManagers available on the scene.
  110409. */
  110410. actionManagers: AbstractActionManager[];
  110411. /**
  110412. * Textures to keep.
  110413. */
  110414. textures: BaseTexture[];
  110415. /**
  110416. * Environment texture for the scene
  110417. */
  110418. environmentTexture: Nullable<BaseTexture>;
  110419. /**
  110420. * @returns all meshes, lights, cameras, transformNodes and bones
  110421. */
  110422. getNodes(): Array<Node>;
  110423. }
  110424. }
  110425. declare module BABYLON {
  110426. /**
  110427. * Interface used to define options for Sound class
  110428. */
  110429. export interface ISoundOptions {
  110430. /**
  110431. * Does the sound autoplay once loaded.
  110432. */
  110433. autoplay?: boolean;
  110434. /**
  110435. * Does the sound loop after it finishes playing once.
  110436. */
  110437. loop?: boolean;
  110438. /**
  110439. * Sound's volume
  110440. */
  110441. volume?: number;
  110442. /**
  110443. * Is it a spatial sound?
  110444. */
  110445. spatialSound?: boolean;
  110446. /**
  110447. * Maximum distance to hear that sound
  110448. */
  110449. maxDistance?: number;
  110450. /**
  110451. * Uses user defined attenuation function
  110452. */
  110453. useCustomAttenuation?: boolean;
  110454. /**
  110455. * Define the roll off factor of spatial sounds.
  110456. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110457. */
  110458. rolloffFactor?: number;
  110459. /**
  110460. * Define the reference distance the sound should be heard perfectly.
  110461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110462. */
  110463. refDistance?: number;
  110464. /**
  110465. * Define the distance attenuation model the sound will follow.
  110466. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110467. */
  110468. distanceModel?: string;
  110469. /**
  110470. * Defines the playback speed (1 by default)
  110471. */
  110472. playbackRate?: number;
  110473. /**
  110474. * Defines if the sound is from a streaming source
  110475. */
  110476. streaming?: boolean;
  110477. /**
  110478. * Defines an optional length (in seconds) inside the sound file
  110479. */
  110480. length?: number;
  110481. /**
  110482. * Defines an optional offset (in seconds) inside the sound file
  110483. */
  110484. offset?: number;
  110485. /**
  110486. * If true, URLs will not be required to state the audio file codec to use.
  110487. */
  110488. skipCodecCheck?: boolean;
  110489. }
  110490. /**
  110491. * Defines a sound that can be played in the application.
  110492. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  110493. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110494. */
  110495. export class Sound {
  110496. /**
  110497. * The name of the sound in the scene.
  110498. */
  110499. name: string;
  110500. /**
  110501. * Does the sound autoplay once loaded.
  110502. */
  110503. autoplay: boolean;
  110504. /**
  110505. * Does the sound loop after it finishes playing once.
  110506. */
  110507. loop: boolean;
  110508. /**
  110509. * Does the sound use a custom attenuation curve to simulate the falloff
  110510. * happening when the source gets further away from the camera.
  110511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110512. */
  110513. useCustomAttenuation: boolean;
  110514. /**
  110515. * The sound track id this sound belongs to.
  110516. */
  110517. soundTrackId: number;
  110518. /**
  110519. * Is this sound currently played.
  110520. */
  110521. isPlaying: boolean;
  110522. /**
  110523. * Is this sound currently paused.
  110524. */
  110525. isPaused: boolean;
  110526. /**
  110527. * Does this sound enables spatial sound.
  110528. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110529. */
  110530. spatialSound: boolean;
  110531. /**
  110532. * Define the reference distance the sound should be heard perfectly.
  110533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110534. */
  110535. refDistance: number;
  110536. /**
  110537. * Define the roll off factor of spatial sounds.
  110538. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110539. */
  110540. rolloffFactor: number;
  110541. /**
  110542. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  110543. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110544. */
  110545. maxDistance: number;
  110546. /**
  110547. * Define the distance attenuation model the sound will follow.
  110548. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110549. */
  110550. distanceModel: string;
  110551. /**
  110552. * @hidden
  110553. * Back Compat
  110554. **/
  110555. onended: () => any;
  110556. /**
  110557. * Observable event when the current playing sound finishes.
  110558. */
  110559. onEndedObservable: Observable<Sound>;
  110560. private _panningModel;
  110561. private _playbackRate;
  110562. private _streaming;
  110563. private _startTime;
  110564. private _startOffset;
  110565. private _position;
  110566. /** @hidden */
  110567. _positionInEmitterSpace: boolean;
  110568. private _localDirection;
  110569. private _volume;
  110570. private _isReadyToPlay;
  110571. private _isDirectional;
  110572. private _readyToPlayCallback;
  110573. private _audioBuffer;
  110574. private _soundSource;
  110575. private _streamingSource;
  110576. private _soundPanner;
  110577. private _soundGain;
  110578. private _inputAudioNode;
  110579. private _outputAudioNode;
  110580. private _coneInnerAngle;
  110581. private _coneOuterAngle;
  110582. private _coneOuterGain;
  110583. private _scene;
  110584. private _connectedTransformNode;
  110585. private _customAttenuationFunction;
  110586. private _registerFunc;
  110587. private _isOutputConnected;
  110588. private _htmlAudioElement;
  110589. private _urlType;
  110590. private _length?;
  110591. private _offset?;
  110592. /** @hidden */
  110593. static _SceneComponentInitialization: (scene: Scene) => void;
  110594. /**
  110595. * Create a sound and attach it to a scene
  110596. * @param name Name of your sound
  110597. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  110598. * @param scene defines the scene the sound belongs to
  110599. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  110600. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  110601. */
  110602. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  110603. /**
  110604. * Release the sound and its associated resources
  110605. */
  110606. dispose(): void;
  110607. /**
  110608. * Gets if the sounds is ready to be played or not.
  110609. * @returns true if ready, otherwise false
  110610. */
  110611. isReady(): boolean;
  110612. private _soundLoaded;
  110613. /**
  110614. * Sets the data of the sound from an audiobuffer
  110615. * @param audioBuffer The audioBuffer containing the data
  110616. */
  110617. setAudioBuffer(audioBuffer: AudioBuffer): void;
  110618. /**
  110619. * Updates the current sounds options such as maxdistance, loop...
  110620. * @param options A JSON object containing values named as the object properties
  110621. */
  110622. updateOptions(options: ISoundOptions): void;
  110623. private _createSpatialParameters;
  110624. private _updateSpatialParameters;
  110625. /**
  110626. * Switch the panning model to HRTF:
  110627. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110629. */
  110630. switchPanningModelToHRTF(): void;
  110631. /**
  110632. * Switch the panning model to Equal Power:
  110633. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110634. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110635. */
  110636. switchPanningModelToEqualPower(): void;
  110637. private _switchPanningModel;
  110638. /**
  110639. * Connect this sound to a sound track audio node like gain...
  110640. * @param soundTrackAudioNode the sound track audio node to connect to
  110641. */
  110642. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  110643. /**
  110644. * Transform this sound into a directional source
  110645. * @param coneInnerAngle Size of the inner cone in degree
  110646. * @param coneOuterAngle Size of the outer cone in degree
  110647. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  110648. */
  110649. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  110650. /**
  110651. * Gets or sets the inner angle for the directional cone.
  110652. */
  110653. get directionalConeInnerAngle(): number;
  110654. /**
  110655. * Gets or sets the inner angle for the directional cone.
  110656. */
  110657. set directionalConeInnerAngle(value: number);
  110658. /**
  110659. * Gets or sets the outer angle for the directional cone.
  110660. */
  110661. get directionalConeOuterAngle(): number;
  110662. /**
  110663. * Gets or sets the outer angle for the directional cone.
  110664. */
  110665. set directionalConeOuterAngle(value: number);
  110666. /**
  110667. * Sets the position of the emitter if spatial sound is enabled
  110668. * @param newPosition Defines the new posisiton
  110669. */
  110670. setPosition(newPosition: Vector3): void;
  110671. /**
  110672. * Sets the local direction of the emitter if spatial sound is enabled
  110673. * @param newLocalDirection Defines the new local direction
  110674. */
  110675. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  110676. private _updateDirection;
  110677. /** @hidden */
  110678. updateDistanceFromListener(): void;
  110679. /**
  110680. * Sets a new custom attenuation function for the sound.
  110681. * @param callback Defines the function used for the attenuation
  110682. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110683. */
  110684. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  110685. /**
  110686. * Play the sound
  110687. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  110688. * @param offset (optional) Start the sound at a specific time in seconds
  110689. * @param length (optional) Sound duration (in seconds)
  110690. */
  110691. play(time?: number, offset?: number, length?: number): void;
  110692. private _onended;
  110693. /**
  110694. * Stop the sound
  110695. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  110696. */
  110697. stop(time?: number): void;
  110698. /**
  110699. * Put the sound in pause
  110700. */
  110701. pause(): void;
  110702. /**
  110703. * Sets a dedicated volume for this sounds
  110704. * @param newVolume Define the new volume of the sound
  110705. * @param time Define time for gradual change to new volume
  110706. */
  110707. setVolume(newVolume: number, time?: number): void;
  110708. /**
  110709. * Set the sound play back rate
  110710. * @param newPlaybackRate Define the playback rate the sound should be played at
  110711. */
  110712. setPlaybackRate(newPlaybackRate: number): void;
  110713. /**
  110714. * Gets the volume of the sound.
  110715. * @returns the volume of the sound
  110716. */
  110717. getVolume(): number;
  110718. /**
  110719. * Attach the sound to a dedicated mesh
  110720. * @param transformNode The transform node to connect the sound with
  110721. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110722. */
  110723. attachToMesh(transformNode: TransformNode): void;
  110724. /**
  110725. * Detach the sound from the previously attached mesh
  110726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110727. */
  110728. detachFromMesh(): void;
  110729. private _onRegisterAfterWorldMatrixUpdate;
  110730. /**
  110731. * Clone the current sound in the scene.
  110732. * @returns the new sound clone
  110733. */
  110734. clone(): Nullable<Sound>;
  110735. /**
  110736. * Gets the current underlying audio buffer containing the data
  110737. * @returns the audio buffer
  110738. */
  110739. getAudioBuffer(): Nullable<AudioBuffer>;
  110740. /**
  110741. * Serializes the Sound in a JSON representation
  110742. * @returns the JSON representation of the sound
  110743. */
  110744. serialize(): any;
  110745. /**
  110746. * Parse a JSON representation of a sound to innstantiate in a given scene
  110747. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  110748. * @param scene Define the scene the new parsed sound should be created in
  110749. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  110750. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  110751. * @returns the newly parsed sound
  110752. */
  110753. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  110754. }
  110755. }
  110756. declare module BABYLON {
  110757. /**
  110758. * This defines an action helpful to play a defined sound on a triggered action.
  110759. */
  110760. export class PlaySoundAction extends Action {
  110761. private _sound;
  110762. /**
  110763. * Instantiate the action
  110764. * @param triggerOptions defines the trigger options
  110765. * @param sound defines the sound to play
  110766. * @param condition defines the trigger related conditions
  110767. */
  110768. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110769. /** @hidden */
  110770. _prepare(): void;
  110771. /**
  110772. * Execute the action and play the sound.
  110773. */
  110774. execute(): void;
  110775. /**
  110776. * Serializes the actions and its related information.
  110777. * @param parent defines the object to serialize in
  110778. * @returns the serialized object
  110779. */
  110780. serialize(parent: any): any;
  110781. }
  110782. /**
  110783. * This defines an action helpful to stop a defined sound on a triggered action.
  110784. */
  110785. export class StopSoundAction extends Action {
  110786. private _sound;
  110787. /**
  110788. * Instantiate the action
  110789. * @param triggerOptions defines the trigger options
  110790. * @param sound defines the sound to stop
  110791. * @param condition defines the trigger related conditions
  110792. */
  110793. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110794. /** @hidden */
  110795. _prepare(): void;
  110796. /**
  110797. * Execute the action and stop the sound.
  110798. */
  110799. execute(): void;
  110800. /**
  110801. * Serializes the actions and its related information.
  110802. * @param parent defines the object to serialize in
  110803. * @returns the serialized object
  110804. */
  110805. serialize(parent: any): any;
  110806. }
  110807. }
  110808. declare module BABYLON {
  110809. /**
  110810. * This defines an action responsible to change the value of a property
  110811. * by interpolating between its current value and the newly set one once triggered.
  110812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110813. */
  110814. export class InterpolateValueAction extends Action {
  110815. /**
  110816. * Defines the path of the property where the value should be interpolated
  110817. */
  110818. propertyPath: string;
  110819. /**
  110820. * Defines the target value at the end of the interpolation.
  110821. */
  110822. value: any;
  110823. /**
  110824. * Defines the time it will take for the property to interpolate to the value.
  110825. */
  110826. duration: number;
  110827. /**
  110828. * Defines if the other scene animations should be stopped when the action has been triggered
  110829. */
  110830. stopOtherAnimations?: boolean;
  110831. /**
  110832. * Defines a callback raised once the interpolation animation has been done.
  110833. */
  110834. onInterpolationDone?: () => void;
  110835. /**
  110836. * Observable triggered once the interpolation animation has been done.
  110837. */
  110838. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  110839. private _target;
  110840. private _effectiveTarget;
  110841. private _property;
  110842. /**
  110843. * Instantiate the action
  110844. * @param triggerOptions defines the trigger options
  110845. * @param target defines the object containing the value to interpolate
  110846. * @param propertyPath defines the path to the property in the target object
  110847. * @param value defines the target value at the end of the interpolation
  110848. * @param duration deines the time it will take for the property to interpolate to the value.
  110849. * @param condition defines the trigger related conditions
  110850. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  110851. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  110852. */
  110853. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  110854. /** @hidden */
  110855. _prepare(): void;
  110856. /**
  110857. * Execute the action starts the value interpolation.
  110858. */
  110859. execute(): void;
  110860. /**
  110861. * Serializes the actions and its related information.
  110862. * @param parent defines the object to serialize in
  110863. * @returns the serialized object
  110864. */
  110865. serialize(parent: any): any;
  110866. }
  110867. }
  110868. declare module BABYLON {
  110869. /**
  110870. * Options allowed during the creation of a sound track.
  110871. */
  110872. export interface ISoundTrackOptions {
  110873. /**
  110874. * The volume the sound track should take during creation
  110875. */
  110876. volume?: number;
  110877. /**
  110878. * Define if the sound track is the main sound track of the scene
  110879. */
  110880. mainTrack?: boolean;
  110881. }
  110882. /**
  110883. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  110884. * It will be also used in a future release to apply effects on a specific track.
  110885. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110886. */
  110887. export class SoundTrack {
  110888. /**
  110889. * The unique identifier of the sound track in the scene.
  110890. */
  110891. id: number;
  110892. /**
  110893. * The list of sounds included in the sound track.
  110894. */
  110895. soundCollection: Array<Sound>;
  110896. private _outputAudioNode;
  110897. private _scene;
  110898. private _connectedAnalyser;
  110899. private _options;
  110900. private _isInitialized;
  110901. /**
  110902. * Creates a new sound track.
  110903. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110904. * @param scene Define the scene the sound track belongs to
  110905. * @param options
  110906. */
  110907. constructor(scene: Scene, options?: ISoundTrackOptions);
  110908. private _initializeSoundTrackAudioGraph;
  110909. /**
  110910. * Release the sound track and its associated resources
  110911. */
  110912. dispose(): void;
  110913. /**
  110914. * Adds a sound to this sound track
  110915. * @param sound define the cound to add
  110916. * @ignoreNaming
  110917. */
  110918. AddSound(sound: Sound): void;
  110919. /**
  110920. * Removes a sound to this sound track
  110921. * @param sound define the cound to remove
  110922. * @ignoreNaming
  110923. */
  110924. RemoveSound(sound: Sound): void;
  110925. /**
  110926. * Set a global volume for the full sound track.
  110927. * @param newVolume Define the new volume of the sound track
  110928. */
  110929. setVolume(newVolume: number): void;
  110930. /**
  110931. * Switch the panning model to HRTF:
  110932. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110933. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110934. */
  110935. switchPanningModelToHRTF(): void;
  110936. /**
  110937. * Switch the panning model to Equal Power:
  110938. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110939. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110940. */
  110941. switchPanningModelToEqualPower(): void;
  110942. /**
  110943. * Connect the sound track to an audio analyser allowing some amazing
  110944. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  110945. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  110946. * @param analyser The analyser to connect to the engine
  110947. */
  110948. connectToAnalyser(analyser: Analyser): void;
  110949. }
  110950. }
  110951. declare module BABYLON {
  110952. interface AbstractScene {
  110953. /**
  110954. * The list of sounds used in the scene.
  110955. */
  110956. sounds: Nullable<Array<Sound>>;
  110957. }
  110958. interface Scene {
  110959. /**
  110960. * @hidden
  110961. * Backing field
  110962. */
  110963. _mainSoundTrack: SoundTrack;
  110964. /**
  110965. * The main sound track played by the scene.
  110966. * It cotains your primary collection of sounds.
  110967. */
  110968. mainSoundTrack: SoundTrack;
  110969. /**
  110970. * The list of sound tracks added to the scene
  110971. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110972. */
  110973. soundTracks: Nullable<Array<SoundTrack>>;
  110974. /**
  110975. * Gets a sound using a given name
  110976. * @param name defines the name to search for
  110977. * @return the found sound or null if not found at all.
  110978. */
  110979. getSoundByName(name: string): Nullable<Sound>;
  110980. /**
  110981. * Gets or sets if audio support is enabled
  110982. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110983. */
  110984. audioEnabled: boolean;
  110985. /**
  110986. * Gets or sets if audio will be output to headphones
  110987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110988. */
  110989. headphone: boolean;
  110990. /**
  110991. * Gets or sets custom audio listener position provider
  110992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110993. */
  110994. audioListenerPositionProvider: Nullable<() => Vector3>;
  110995. /**
  110996. * Gets or sets a refresh rate when using 3D audio positioning
  110997. */
  110998. audioPositioningRefreshRate: number;
  110999. }
  111000. /**
  111001. * Defines the sound scene component responsible to manage any sounds
  111002. * in a given scene.
  111003. */
  111004. export class AudioSceneComponent implements ISceneSerializableComponent {
  111005. /**
  111006. * The component name helpfull to identify the component in the list of scene components.
  111007. */
  111008. readonly name: string;
  111009. /**
  111010. * The scene the component belongs to.
  111011. */
  111012. scene: Scene;
  111013. private _audioEnabled;
  111014. /**
  111015. * Gets whether audio is enabled or not.
  111016. * Please use related enable/disable method to switch state.
  111017. */
  111018. get audioEnabled(): boolean;
  111019. private _headphone;
  111020. /**
  111021. * Gets whether audio is outputing to headphone or not.
  111022. * Please use the according Switch methods to change output.
  111023. */
  111024. get headphone(): boolean;
  111025. /**
  111026. * Gets or sets a refresh rate when using 3D audio positioning
  111027. */
  111028. audioPositioningRefreshRate: number;
  111029. private _audioListenerPositionProvider;
  111030. /**
  111031. * Gets the current audio listener position provider
  111032. */
  111033. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  111034. /**
  111035. * Sets a custom listener position for all sounds in the scene
  111036. * By default, this is the position of the first active camera
  111037. */
  111038. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  111039. /**
  111040. * Creates a new instance of the component for the given scene
  111041. * @param scene Defines the scene to register the component in
  111042. */
  111043. constructor(scene: Scene);
  111044. /**
  111045. * Registers the component in a given scene
  111046. */
  111047. register(): void;
  111048. /**
  111049. * Rebuilds the elements related to this component in case of
  111050. * context lost for instance.
  111051. */
  111052. rebuild(): void;
  111053. /**
  111054. * Serializes the component data to the specified json object
  111055. * @param serializationObject The object to serialize to
  111056. */
  111057. serialize(serializationObject: any): void;
  111058. /**
  111059. * Adds all the elements from the container to the scene
  111060. * @param container the container holding the elements
  111061. */
  111062. addFromContainer(container: AbstractScene): void;
  111063. /**
  111064. * Removes all the elements in the container from the scene
  111065. * @param container contains the elements to remove
  111066. * @param dispose if the removed element should be disposed (default: false)
  111067. */
  111068. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111069. /**
  111070. * Disposes the component and the associated ressources.
  111071. */
  111072. dispose(): void;
  111073. /**
  111074. * Disables audio in the associated scene.
  111075. */
  111076. disableAudio(): void;
  111077. /**
  111078. * Enables audio in the associated scene.
  111079. */
  111080. enableAudio(): void;
  111081. /**
  111082. * Switch audio to headphone output.
  111083. */
  111084. switchAudioModeForHeadphones(): void;
  111085. /**
  111086. * Switch audio to normal speakers.
  111087. */
  111088. switchAudioModeForNormalSpeakers(): void;
  111089. private _cachedCameraDirection;
  111090. private _cachedCameraPosition;
  111091. private _lastCheck;
  111092. private _afterRender;
  111093. }
  111094. }
  111095. declare module BABYLON {
  111096. /**
  111097. * Wraps one or more Sound objects and selects one with random weight for playback.
  111098. */
  111099. export class WeightedSound {
  111100. /** When true a Sound will be selected and played when the current playing Sound completes. */
  111101. loop: boolean;
  111102. private _coneInnerAngle;
  111103. private _coneOuterAngle;
  111104. private _volume;
  111105. /** A Sound is currently playing. */
  111106. isPlaying: boolean;
  111107. /** A Sound is currently paused. */
  111108. isPaused: boolean;
  111109. private _sounds;
  111110. private _weights;
  111111. private _currentIndex?;
  111112. /**
  111113. * Creates a new WeightedSound from the list of sounds given.
  111114. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  111115. * @param sounds Array of Sounds that will be selected from.
  111116. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  111117. */
  111118. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  111119. /**
  111120. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  111121. */
  111122. get directionalConeInnerAngle(): number;
  111123. /**
  111124. * The size of cone in degress for a directional sound in which there will be no attenuation.
  111125. */
  111126. set directionalConeInnerAngle(value: number);
  111127. /**
  111128. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111129. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111130. */
  111131. get directionalConeOuterAngle(): number;
  111132. /**
  111133. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111134. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111135. */
  111136. set directionalConeOuterAngle(value: number);
  111137. /**
  111138. * Playback volume.
  111139. */
  111140. get volume(): number;
  111141. /**
  111142. * Playback volume.
  111143. */
  111144. set volume(value: number);
  111145. private _onended;
  111146. /**
  111147. * Suspend playback
  111148. */
  111149. pause(): void;
  111150. /**
  111151. * Stop playback
  111152. */
  111153. stop(): void;
  111154. /**
  111155. * Start playback.
  111156. * @param startOffset Position the clip head at a specific time in seconds.
  111157. */
  111158. play(startOffset?: number): void;
  111159. }
  111160. }
  111161. declare module BABYLON {
  111162. /**
  111163. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  111164. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111165. */
  111166. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  111167. /**
  111168. * Gets the name of the behavior.
  111169. */
  111170. get name(): string;
  111171. /**
  111172. * The easing function used by animations
  111173. */
  111174. static EasingFunction: BackEase;
  111175. /**
  111176. * The easing mode used by animations
  111177. */
  111178. static EasingMode: number;
  111179. /**
  111180. * The duration of the animation, in milliseconds
  111181. */
  111182. transitionDuration: number;
  111183. /**
  111184. * Length of the distance animated by the transition when lower radius is reached
  111185. */
  111186. lowerRadiusTransitionRange: number;
  111187. /**
  111188. * Length of the distance animated by the transition when upper radius is reached
  111189. */
  111190. upperRadiusTransitionRange: number;
  111191. private _autoTransitionRange;
  111192. /**
  111193. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111194. */
  111195. get autoTransitionRange(): boolean;
  111196. /**
  111197. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111198. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  111199. */
  111200. set autoTransitionRange(value: boolean);
  111201. private _attachedCamera;
  111202. private _onAfterCheckInputsObserver;
  111203. private _onMeshTargetChangedObserver;
  111204. /**
  111205. * Initializes the behavior.
  111206. */
  111207. init(): void;
  111208. /**
  111209. * Attaches the behavior to its arc rotate camera.
  111210. * @param camera Defines the camera to attach the behavior to
  111211. */
  111212. attach(camera: ArcRotateCamera): void;
  111213. /**
  111214. * Detaches the behavior from its current arc rotate camera.
  111215. */
  111216. detach(): void;
  111217. private _radiusIsAnimating;
  111218. private _radiusBounceTransition;
  111219. private _animatables;
  111220. private _cachedWheelPrecision;
  111221. /**
  111222. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  111223. * @param radiusLimit The limit to check against.
  111224. * @return Bool to indicate if at limit.
  111225. */
  111226. private _isRadiusAtLimit;
  111227. /**
  111228. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  111229. * @param radiusDelta The delta by which to animate to. Can be negative.
  111230. */
  111231. private _applyBoundRadiusAnimation;
  111232. /**
  111233. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  111234. */
  111235. protected _clearAnimationLocks(): void;
  111236. /**
  111237. * Stops and removes all animations that have been applied to the camera
  111238. */
  111239. stopAllAnimations(): void;
  111240. }
  111241. }
  111242. declare module BABYLON {
  111243. /**
  111244. * 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.
  111245. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111246. */
  111247. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  111248. /**
  111249. * Gets the name of the behavior.
  111250. */
  111251. get name(): string;
  111252. private _mode;
  111253. private _radiusScale;
  111254. private _positionScale;
  111255. private _defaultElevation;
  111256. private _elevationReturnTime;
  111257. private _elevationReturnWaitTime;
  111258. private _zoomStopsAnimation;
  111259. private _framingTime;
  111260. /**
  111261. * The easing function used by animations
  111262. */
  111263. static EasingFunction: ExponentialEase;
  111264. /**
  111265. * The easing mode used by animations
  111266. */
  111267. static EasingMode: number;
  111268. /**
  111269. * Sets the current mode used by the behavior
  111270. */
  111271. set mode(mode: number);
  111272. /**
  111273. * Gets current mode used by the behavior.
  111274. */
  111275. get mode(): number;
  111276. /**
  111277. * Sets the scale applied to the radius (1 by default)
  111278. */
  111279. set radiusScale(radius: number);
  111280. /**
  111281. * Gets the scale applied to the radius
  111282. */
  111283. get radiusScale(): number;
  111284. /**
  111285. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111286. */
  111287. set positionScale(scale: number);
  111288. /**
  111289. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111290. */
  111291. get positionScale(): number;
  111292. /**
  111293. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111294. * behaviour is triggered, in radians.
  111295. */
  111296. set defaultElevation(elevation: number);
  111297. /**
  111298. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111299. * behaviour is triggered, in radians.
  111300. */
  111301. get defaultElevation(): number;
  111302. /**
  111303. * Sets the time (in milliseconds) taken to return to the default beta position.
  111304. * Negative value indicates camera should not return to default.
  111305. */
  111306. set elevationReturnTime(speed: number);
  111307. /**
  111308. * Gets the time (in milliseconds) taken to return to the default beta position.
  111309. * Negative value indicates camera should not return to default.
  111310. */
  111311. get elevationReturnTime(): number;
  111312. /**
  111313. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111314. */
  111315. set elevationReturnWaitTime(time: number);
  111316. /**
  111317. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111318. */
  111319. get elevationReturnWaitTime(): number;
  111320. /**
  111321. * Sets the flag that indicates if user zooming should stop animation.
  111322. */
  111323. set zoomStopsAnimation(flag: boolean);
  111324. /**
  111325. * Gets the flag that indicates if user zooming should stop animation.
  111326. */
  111327. get zoomStopsAnimation(): boolean;
  111328. /**
  111329. * Sets the transition time when framing the mesh, in milliseconds
  111330. */
  111331. set framingTime(time: number);
  111332. /**
  111333. * Gets the transition time when framing the mesh, in milliseconds
  111334. */
  111335. get framingTime(): number;
  111336. /**
  111337. * Define if the behavior should automatically change the configured
  111338. * camera limits and sensibilities.
  111339. */
  111340. autoCorrectCameraLimitsAndSensibility: boolean;
  111341. private _onPrePointerObservableObserver;
  111342. private _onAfterCheckInputsObserver;
  111343. private _onMeshTargetChangedObserver;
  111344. private _attachedCamera;
  111345. private _isPointerDown;
  111346. private _lastInteractionTime;
  111347. /**
  111348. * Initializes the behavior.
  111349. */
  111350. init(): void;
  111351. /**
  111352. * Attaches the behavior to its arc rotate camera.
  111353. * @param camera Defines the camera to attach the behavior to
  111354. */
  111355. attach(camera: ArcRotateCamera): void;
  111356. /**
  111357. * Detaches the behavior from its current arc rotate camera.
  111358. */
  111359. detach(): void;
  111360. private _animatables;
  111361. private _betaIsAnimating;
  111362. private _betaTransition;
  111363. private _radiusTransition;
  111364. private _vectorTransition;
  111365. /**
  111366. * Targets the given mesh and updates zoom level accordingly.
  111367. * @param mesh The mesh to target.
  111368. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111369. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111370. */
  111371. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111372. /**
  111373. * Targets the given mesh with its children and updates zoom level accordingly.
  111374. * @param mesh The mesh to target.
  111375. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111376. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111377. */
  111378. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111379. /**
  111380. * Targets the given meshes with their children and updates zoom level accordingly.
  111381. * @param meshes The mesh to target.
  111382. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111383. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111384. */
  111385. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111386. /**
  111387. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  111388. * @param minimumWorld Determines the smaller position of the bounding box extend
  111389. * @param maximumWorld Determines the bigger position of the bounding box extend
  111390. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111391. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111392. */
  111393. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111394. /**
  111395. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  111396. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  111397. * frustum width.
  111398. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  111399. * to fully enclose the mesh in the viewing frustum.
  111400. */
  111401. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  111402. /**
  111403. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  111404. * is automatically returned to its default position (expected to be above ground plane).
  111405. */
  111406. private _maintainCameraAboveGround;
  111407. /**
  111408. * Returns the frustum slope based on the canvas ratio and camera FOV
  111409. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  111410. */
  111411. private _getFrustumSlope;
  111412. /**
  111413. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  111414. */
  111415. private _clearAnimationLocks;
  111416. /**
  111417. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111418. */
  111419. private _applyUserInteraction;
  111420. /**
  111421. * Stops and removes all animations that have been applied to the camera
  111422. */
  111423. stopAllAnimations(): void;
  111424. /**
  111425. * Gets a value indicating if the user is moving the camera
  111426. */
  111427. get isUserIsMoving(): boolean;
  111428. /**
  111429. * The camera can move all the way towards the mesh.
  111430. */
  111431. static IgnoreBoundsSizeMode: number;
  111432. /**
  111433. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  111434. */
  111435. static FitFrustumSidesMode: number;
  111436. }
  111437. }
  111438. declare module BABYLON {
  111439. /**
  111440. * Base class for Camera Pointer Inputs.
  111441. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  111442. * for example usage.
  111443. */
  111444. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  111445. /**
  111446. * Defines the camera the input is attached to.
  111447. */
  111448. abstract camera: Camera;
  111449. /**
  111450. * Whether keyboard modifier keys are pressed at time of last mouse event.
  111451. */
  111452. protected _altKey: boolean;
  111453. protected _ctrlKey: boolean;
  111454. protected _metaKey: boolean;
  111455. protected _shiftKey: boolean;
  111456. /**
  111457. * Which mouse buttons were pressed at time of last mouse event.
  111458. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  111459. */
  111460. protected _buttonsPressed: number;
  111461. /**
  111462. * Defines the buttons associated with the input to handle camera move.
  111463. */
  111464. buttons: number[];
  111465. /**
  111466. * Attach the input controls to a specific dom element to get the input from.
  111467. * @param element Defines the element the controls should be listened from
  111468. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111469. */
  111470. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111471. /**
  111472. * Detach the current controls from the specified dom element.
  111473. * @param element Defines the element to stop listening the inputs from
  111474. */
  111475. detachControl(element: Nullable<HTMLElement>): void;
  111476. /**
  111477. * Gets the class name of the current input.
  111478. * @returns the class name
  111479. */
  111480. getClassName(): string;
  111481. /**
  111482. * Get the friendly name associated with the input class.
  111483. * @returns the input friendly name
  111484. */
  111485. getSimpleName(): string;
  111486. /**
  111487. * Called on pointer POINTERDOUBLETAP event.
  111488. * Override this method to provide functionality on POINTERDOUBLETAP event.
  111489. */
  111490. protected onDoubleTap(type: string): void;
  111491. /**
  111492. * Called on pointer POINTERMOVE event if only a single touch is active.
  111493. * Override this method to provide functionality.
  111494. */
  111495. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111496. /**
  111497. * Called on pointer POINTERMOVE event if multiple touches are active.
  111498. * Override this method to provide functionality.
  111499. */
  111500. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111501. /**
  111502. * Called on JS contextmenu event.
  111503. * Override this method to provide functionality.
  111504. */
  111505. protected onContextMenu(evt: PointerEvent): void;
  111506. /**
  111507. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111508. * press.
  111509. * Override this method to provide functionality.
  111510. */
  111511. protected onButtonDown(evt: PointerEvent): void;
  111512. /**
  111513. * Called each time a new POINTERUP event occurs. Ie, for each button
  111514. * release.
  111515. * Override this method to provide functionality.
  111516. */
  111517. protected onButtonUp(evt: PointerEvent): void;
  111518. /**
  111519. * Called when window becomes inactive.
  111520. * Override this method to provide functionality.
  111521. */
  111522. protected onLostFocus(): void;
  111523. private _pointerInput;
  111524. private _observer;
  111525. private _onLostFocus;
  111526. private pointA;
  111527. private pointB;
  111528. }
  111529. }
  111530. declare module BABYLON {
  111531. /**
  111532. * Manage the pointers inputs to control an arc rotate camera.
  111533. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111534. */
  111535. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  111536. /**
  111537. * Defines the camera the input is attached to.
  111538. */
  111539. camera: ArcRotateCamera;
  111540. /**
  111541. * Gets the class name of the current input.
  111542. * @returns the class name
  111543. */
  111544. getClassName(): string;
  111545. /**
  111546. * Defines the buttons associated with the input to handle camera move.
  111547. */
  111548. buttons: number[];
  111549. /**
  111550. * Defines the pointer angular sensibility along the X axis or how fast is
  111551. * the camera rotating.
  111552. */
  111553. angularSensibilityX: number;
  111554. /**
  111555. * Defines the pointer angular sensibility along the Y axis or how fast is
  111556. * the camera rotating.
  111557. */
  111558. angularSensibilityY: number;
  111559. /**
  111560. * Defines the pointer pinch precision or how fast is the camera zooming.
  111561. */
  111562. pinchPrecision: number;
  111563. /**
  111564. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111565. * from 0.
  111566. * It defines the percentage of current camera.radius to use as delta when
  111567. * pinch zoom is used.
  111568. */
  111569. pinchDeltaPercentage: number;
  111570. /**
  111571. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111572. * that any object in the plane at the camera's target point will scale
  111573. * perfectly with finger motion.
  111574. * Overrides pinchDeltaPercentage and pinchPrecision.
  111575. */
  111576. useNaturalPinchZoom: boolean;
  111577. /**
  111578. * Defines the pointer panning sensibility or how fast is the camera moving.
  111579. */
  111580. panningSensibility: number;
  111581. /**
  111582. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  111583. */
  111584. multiTouchPanning: boolean;
  111585. /**
  111586. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  111587. * zoom (pinch) through multitouch.
  111588. */
  111589. multiTouchPanAndZoom: boolean;
  111590. /**
  111591. * Revers pinch action direction.
  111592. */
  111593. pinchInwards: boolean;
  111594. private _isPanClick;
  111595. private _twoFingerActivityCount;
  111596. private _isPinching;
  111597. /**
  111598. * Called on pointer POINTERMOVE event if only a single touch is active.
  111599. */
  111600. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111601. /**
  111602. * Called on pointer POINTERDOUBLETAP event.
  111603. */
  111604. protected onDoubleTap(type: string): void;
  111605. /**
  111606. * Called on pointer POINTERMOVE event if multiple touches are active.
  111607. */
  111608. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111609. /**
  111610. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111611. * press.
  111612. */
  111613. protected onButtonDown(evt: PointerEvent): void;
  111614. /**
  111615. * Called each time a new POINTERUP event occurs. Ie, for each button
  111616. * release.
  111617. */
  111618. protected onButtonUp(evt: PointerEvent): void;
  111619. /**
  111620. * Called when window becomes inactive.
  111621. */
  111622. protected onLostFocus(): void;
  111623. }
  111624. }
  111625. declare module BABYLON {
  111626. /**
  111627. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  111628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111629. */
  111630. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  111631. /**
  111632. * Defines the camera the input is attached to.
  111633. */
  111634. camera: ArcRotateCamera;
  111635. /**
  111636. * Defines the list of key codes associated with the up action (increase alpha)
  111637. */
  111638. keysUp: number[];
  111639. /**
  111640. * Defines the list of key codes associated with the down action (decrease alpha)
  111641. */
  111642. keysDown: number[];
  111643. /**
  111644. * Defines the list of key codes associated with the left action (increase beta)
  111645. */
  111646. keysLeft: number[];
  111647. /**
  111648. * Defines the list of key codes associated with the right action (decrease beta)
  111649. */
  111650. keysRight: number[];
  111651. /**
  111652. * Defines the list of key codes associated with the reset action.
  111653. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  111654. */
  111655. keysReset: number[];
  111656. /**
  111657. * Defines the panning sensibility of the inputs.
  111658. * (How fast is the camera panning)
  111659. */
  111660. panningSensibility: number;
  111661. /**
  111662. * Defines the zooming sensibility of the inputs.
  111663. * (How fast is the camera zooming)
  111664. */
  111665. zoomingSensibility: number;
  111666. /**
  111667. * Defines whether maintaining the alt key down switch the movement mode from
  111668. * orientation to zoom.
  111669. */
  111670. useAltToZoom: boolean;
  111671. /**
  111672. * Rotation speed of the camera
  111673. */
  111674. angularSpeed: number;
  111675. private _keys;
  111676. private _ctrlPressed;
  111677. private _altPressed;
  111678. private _onCanvasBlurObserver;
  111679. private _onKeyboardObserver;
  111680. private _engine;
  111681. private _scene;
  111682. /**
  111683. * Attach the input controls to a specific dom element to get the input from.
  111684. * @param element Defines the element the controls should be listened from
  111685. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111686. */
  111687. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111688. /**
  111689. * Detach the current controls from the specified dom element.
  111690. * @param element Defines the element to stop listening the inputs from
  111691. */
  111692. detachControl(element: Nullable<HTMLElement>): void;
  111693. /**
  111694. * Update the current camera state depending on the inputs that have been used this frame.
  111695. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111696. */
  111697. checkInputs(): void;
  111698. /**
  111699. * Gets the class name of the current intput.
  111700. * @returns the class name
  111701. */
  111702. getClassName(): string;
  111703. /**
  111704. * Get the friendly name associated with the input class.
  111705. * @returns the input friendly name
  111706. */
  111707. getSimpleName(): string;
  111708. }
  111709. }
  111710. declare module BABYLON {
  111711. /**
  111712. * Manage the mouse wheel inputs to control an arc rotate camera.
  111713. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111714. */
  111715. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  111716. /**
  111717. * Defines the camera the input is attached to.
  111718. */
  111719. camera: ArcRotateCamera;
  111720. /**
  111721. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111722. */
  111723. wheelPrecision: number;
  111724. /**
  111725. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111726. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111727. */
  111728. wheelDeltaPercentage: number;
  111729. private _wheel;
  111730. private _observer;
  111731. private computeDeltaFromMouseWheelLegacyEvent;
  111732. /**
  111733. * Attach the input controls to a specific dom element to get the input from.
  111734. * @param element Defines the element the controls should be listened from
  111735. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111736. */
  111737. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111738. /**
  111739. * Detach the current controls from the specified dom element.
  111740. * @param element Defines the element to stop listening the inputs from
  111741. */
  111742. detachControl(element: Nullable<HTMLElement>): void;
  111743. /**
  111744. * Gets the class name of the current intput.
  111745. * @returns the class name
  111746. */
  111747. getClassName(): string;
  111748. /**
  111749. * Get the friendly name associated with the input class.
  111750. * @returns the input friendly name
  111751. */
  111752. getSimpleName(): string;
  111753. }
  111754. }
  111755. declare module BABYLON {
  111756. /**
  111757. * Default Inputs manager for the ArcRotateCamera.
  111758. * It groups all the default supported inputs for ease of use.
  111759. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111760. */
  111761. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  111762. /**
  111763. * Instantiates a new ArcRotateCameraInputsManager.
  111764. * @param camera Defines the camera the inputs belong to
  111765. */
  111766. constructor(camera: ArcRotateCamera);
  111767. /**
  111768. * Add mouse wheel input support to the input manager.
  111769. * @returns the current input manager
  111770. */
  111771. addMouseWheel(): ArcRotateCameraInputsManager;
  111772. /**
  111773. * Add pointers input support to the input manager.
  111774. * @returns the current input manager
  111775. */
  111776. addPointers(): ArcRotateCameraInputsManager;
  111777. /**
  111778. * Add keyboard input support to the input manager.
  111779. * @returns the current input manager
  111780. */
  111781. addKeyboard(): ArcRotateCameraInputsManager;
  111782. }
  111783. }
  111784. declare module BABYLON {
  111785. /**
  111786. * This represents an orbital type of camera.
  111787. *
  111788. * 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.
  111789. * 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.
  111790. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  111791. */
  111792. export class ArcRotateCamera extends TargetCamera {
  111793. /**
  111794. * Defines the rotation angle of the camera along the longitudinal axis.
  111795. */
  111796. alpha: number;
  111797. /**
  111798. * Defines the rotation angle of the camera along the latitudinal axis.
  111799. */
  111800. beta: number;
  111801. /**
  111802. * Defines the radius of the camera from it s target point.
  111803. */
  111804. radius: number;
  111805. protected _target: Vector3;
  111806. protected _targetHost: Nullable<AbstractMesh>;
  111807. /**
  111808. * Defines the target point of the camera.
  111809. * The camera looks towards it form the radius distance.
  111810. */
  111811. get target(): Vector3;
  111812. set target(value: Vector3);
  111813. /**
  111814. * Define the current local position of the camera in the scene
  111815. */
  111816. get position(): Vector3;
  111817. set position(newPosition: Vector3);
  111818. protected _upVector: Vector3;
  111819. protected _upToYMatrix: Matrix;
  111820. protected _YToUpMatrix: Matrix;
  111821. /**
  111822. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  111823. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  111824. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  111825. */
  111826. set upVector(vec: Vector3);
  111827. get upVector(): Vector3;
  111828. /**
  111829. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  111830. */
  111831. setMatUp(): void;
  111832. /**
  111833. * Current inertia value on the longitudinal axis.
  111834. * The bigger this number the longer it will take for the camera to stop.
  111835. */
  111836. inertialAlphaOffset: number;
  111837. /**
  111838. * Current inertia value on the latitudinal axis.
  111839. * The bigger this number the longer it will take for the camera to stop.
  111840. */
  111841. inertialBetaOffset: number;
  111842. /**
  111843. * Current inertia value on the radius axis.
  111844. * The bigger this number the longer it will take for the camera to stop.
  111845. */
  111846. inertialRadiusOffset: number;
  111847. /**
  111848. * Minimum allowed angle on the longitudinal axis.
  111849. * This can help limiting how the Camera is able to move in the scene.
  111850. */
  111851. lowerAlphaLimit: Nullable<number>;
  111852. /**
  111853. * Maximum allowed angle on the longitudinal axis.
  111854. * This can help limiting how the Camera is able to move in the scene.
  111855. */
  111856. upperAlphaLimit: Nullable<number>;
  111857. /**
  111858. * Minimum allowed angle on the latitudinal axis.
  111859. * This can help limiting how the Camera is able to move in the scene.
  111860. */
  111861. lowerBetaLimit: number;
  111862. /**
  111863. * Maximum allowed angle on the latitudinal axis.
  111864. * This can help limiting how the Camera is able to move in the scene.
  111865. */
  111866. upperBetaLimit: number;
  111867. /**
  111868. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  111869. * This can help limiting how the Camera is able to move in the scene.
  111870. */
  111871. lowerRadiusLimit: Nullable<number>;
  111872. /**
  111873. * Maximum allowed distance of the camera to the target (The camera can not get further).
  111874. * This can help limiting how the Camera is able to move in the scene.
  111875. */
  111876. upperRadiusLimit: Nullable<number>;
  111877. /**
  111878. * Defines the current inertia value used during panning of the camera along the X axis.
  111879. */
  111880. inertialPanningX: number;
  111881. /**
  111882. * Defines the current inertia value used during panning of the camera along the Y axis.
  111883. */
  111884. inertialPanningY: number;
  111885. /**
  111886. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  111887. * Basically if your fingers moves away from more than this distance you will be considered
  111888. * in pinch mode.
  111889. */
  111890. pinchToPanMaxDistance: number;
  111891. /**
  111892. * Defines the maximum distance the camera can pan.
  111893. * This could help keeping the cammera always in your scene.
  111894. */
  111895. panningDistanceLimit: Nullable<number>;
  111896. /**
  111897. * Defines the target of the camera before paning.
  111898. */
  111899. panningOriginTarget: Vector3;
  111900. /**
  111901. * Defines the value of the inertia used during panning.
  111902. * 0 would mean stop inertia and one would mean no decelleration at all.
  111903. */
  111904. panningInertia: number;
  111905. /**
  111906. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  111907. */
  111908. get angularSensibilityX(): number;
  111909. set angularSensibilityX(value: number);
  111910. /**
  111911. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  111912. */
  111913. get angularSensibilityY(): number;
  111914. set angularSensibilityY(value: number);
  111915. /**
  111916. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  111917. */
  111918. get pinchPrecision(): number;
  111919. set pinchPrecision(value: number);
  111920. /**
  111921. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  111922. * It will be used instead of pinchDeltaPrecision if different from 0.
  111923. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111924. */
  111925. get pinchDeltaPercentage(): number;
  111926. set pinchDeltaPercentage(value: number);
  111927. /**
  111928. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  111929. * and pinch delta percentage.
  111930. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111931. * that any object in the plane at the camera's target point will scale
  111932. * perfectly with finger motion.
  111933. */
  111934. get useNaturalPinchZoom(): boolean;
  111935. set useNaturalPinchZoom(value: boolean);
  111936. /**
  111937. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  111938. */
  111939. get panningSensibility(): number;
  111940. set panningSensibility(value: number);
  111941. /**
  111942. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  111943. */
  111944. get keysUp(): number[];
  111945. set keysUp(value: number[]);
  111946. /**
  111947. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  111948. */
  111949. get keysDown(): number[];
  111950. set keysDown(value: number[]);
  111951. /**
  111952. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  111953. */
  111954. get keysLeft(): number[];
  111955. set keysLeft(value: number[]);
  111956. /**
  111957. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  111958. */
  111959. get keysRight(): number[];
  111960. set keysRight(value: number[]);
  111961. /**
  111962. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111963. */
  111964. get wheelPrecision(): number;
  111965. set wheelPrecision(value: number);
  111966. /**
  111967. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  111968. * It will be used instead of pinchDeltaPrecision if different from 0.
  111969. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111970. */
  111971. get wheelDeltaPercentage(): number;
  111972. set wheelDeltaPercentage(value: number);
  111973. /**
  111974. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  111975. */
  111976. zoomOnFactor: number;
  111977. /**
  111978. * Defines a screen offset for the camera position.
  111979. */
  111980. targetScreenOffset: Vector2;
  111981. /**
  111982. * Allows the camera to be completely reversed.
  111983. * If false the camera can not arrive upside down.
  111984. */
  111985. allowUpsideDown: boolean;
  111986. /**
  111987. * Define if double tap/click is used to restore the previously saved state of the camera.
  111988. */
  111989. useInputToRestoreState: boolean;
  111990. /** @hidden */
  111991. _viewMatrix: Matrix;
  111992. /** @hidden */
  111993. _useCtrlForPanning: boolean;
  111994. /** @hidden */
  111995. _panningMouseButton: number;
  111996. /**
  111997. * Defines the input associated to the camera.
  111998. */
  111999. inputs: ArcRotateCameraInputsManager;
  112000. /** @hidden */
  112001. _reset: () => void;
  112002. /**
  112003. * Defines the allowed panning axis.
  112004. */
  112005. panningAxis: Vector3;
  112006. protected _localDirection: Vector3;
  112007. protected _transformedDirection: Vector3;
  112008. private _bouncingBehavior;
  112009. /**
  112010. * Gets the bouncing behavior of the camera if it has been enabled.
  112011. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112012. */
  112013. get bouncingBehavior(): Nullable<BouncingBehavior>;
  112014. /**
  112015. * Defines if the bouncing behavior of the camera is enabled on the camera.
  112016. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112017. */
  112018. get useBouncingBehavior(): boolean;
  112019. set useBouncingBehavior(value: boolean);
  112020. private _framingBehavior;
  112021. /**
  112022. * Gets the framing behavior of the camera if it has been enabled.
  112023. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112024. */
  112025. get framingBehavior(): Nullable<FramingBehavior>;
  112026. /**
  112027. * Defines if the framing behavior of the camera is enabled on the camera.
  112028. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112029. */
  112030. get useFramingBehavior(): boolean;
  112031. set useFramingBehavior(value: boolean);
  112032. private _autoRotationBehavior;
  112033. /**
  112034. * Gets the auto rotation behavior of the camera if it has been enabled.
  112035. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112036. */
  112037. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  112038. /**
  112039. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  112040. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112041. */
  112042. get useAutoRotationBehavior(): boolean;
  112043. set useAutoRotationBehavior(value: boolean);
  112044. /**
  112045. * Observable triggered when the mesh target has been changed on the camera.
  112046. */
  112047. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  112048. /**
  112049. * Event raised when the camera is colliding with a mesh.
  112050. */
  112051. onCollide: (collidedMesh: AbstractMesh) => void;
  112052. /**
  112053. * Defines whether the camera should check collision with the objects oh the scene.
  112054. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  112055. */
  112056. checkCollisions: boolean;
  112057. /**
  112058. * Defines the collision radius of the camera.
  112059. * This simulates a sphere around the camera.
  112060. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112061. */
  112062. collisionRadius: Vector3;
  112063. protected _collider: Collider;
  112064. protected _previousPosition: Vector3;
  112065. protected _collisionVelocity: Vector3;
  112066. protected _newPosition: Vector3;
  112067. protected _previousAlpha: number;
  112068. protected _previousBeta: number;
  112069. protected _previousRadius: number;
  112070. protected _collisionTriggered: boolean;
  112071. protected _targetBoundingCenter: Nullable<Vector3>;
  112072. private _computationVector;
  112073. /**
  112074. * Instantiates a new ArcRotateCamera in a given scene
  112075. * @param name Defines the name of the camera
  112076. * @param alpha Defines the camera rotation along the logitudinal axis
  112077. * @param beta Defines the camera rotation along the latitudinal axis
  112078. * @param radius Defines the camera distance from its target
  112079. * @param target Defines the camera target
  112080. * @param scene Defines the scene the camera belongs to
  112081. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  112082. */
  112083. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112084. /** @hidden */
  112085. _initCache(): void;
  112086. /** @hidden */
  112087. _updateCache(ignoreParentClass?: boolean): void;
  112088. protected _getTargetPosition(): Vector3;
  112089. private _storedAlpha;
  112090. private _storedBeta;
  112091. private _storedRadius;
  112092. private _storedTarget;
  112093. private _storedTargetScreenOffset;
  112094. /**
  112095. * Stores the current state of the camera (alpha, beta, radius and target)
  112096. * @returns the camera itself
  112097. */
  112098. storeState(): Camera;
  112099. /**
  112100. * @hidden
  112101. * Restored camera state. You must call storeState() first
  112102. */
  112103. _restoreStateValues(): boolean;
  112104. /** @hidden */
  112105. _isSynchronizedViewMatrix(): boolean;
  112106. /**
  112107. * Attached controls to the current camera.
  112108. * @param element Defines the element the controls should be listened from
  112109. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112110. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  112111. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  112112. */
  112113. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  112114. /**
  112115. * Detach the current controls from the camera.
  112116. * The camera will stop reacting to inputs.
  112117. * @param element Defines the element to stop listening the inputs from
  112118. */
  112119. detachControl(element: HTMLElement): void;
  112120. /** @hidden */
  112121. _checkInputs(): void;
  112122. protected _checkLimits(): void;
  112123. /**
  112124. * Rebuilds angles (alpha, beta) and radius from the give position and target
  112125. */
  112126. rebuildAnglesAndRadius(): void;
  112127. /**
  112128. * Use a position to define the current camera related information like alpha, beta and radius
  112129. * @param position Defines the position to set the camera at
  112130. */
  112131. setPosition(position: Vector3): void;
  112132. /**
  112133. * Defines the target the camera should look at.
  112134. * This will automatically adapt alpha beta and radius to fit within the new target.
  112135. * @param target Defines the new target as a Vector or a mesh
  112136. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  112137. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  112138. */
  112139. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  112140. /** @hidden */
  112141. _getViewMatrix(): Matrix;
  112142. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  112143. /**
  112144. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  112145. * @param meshes Defines the mesh to zoom on
  112146. * @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)
  112147. */
  112148. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  112149. /**
  112150. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  112151. * The target will be changed but the radius
  112152. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  112153. * @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)
  112154. */
  112155. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  112156. min: Vector3;
  112157. max: Vector3;
  112158. distance: number;
  112159. }, doNotUpdateMaxZ?: boolean): void;
  112160. /**
  112161. * @override
  112162. * Override Camera.createRigCamera
  112163. */
  112164. createRigCamera(name: string, cameraIndex: number): Camera;
  112165. /**
  112166. * @hidden
  112167. * @override
  112168. * Override Camera._updateRigCameras
  112169. */
  112170. _updateRigCameras(): void;
  112171. /**
  112172. * Destroy the camera and release the current resources hold by it.
  112173. */
  112174. dispose(): void;
  112175. /**
  112176. * Gets the current object class name.
  112177. * @return the class name
  112178. */
  112179. getClassName(): string;
  112180. }
  112181. }
  112182. declare module BABYLON {
  112183. /**
  112184. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  112185. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112186. */
  112187. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  112188. /**
  112189. * Gets the name of the behavior.
  112190. */
  112191. get name(): string;
  112192. private _zoomStopsAnimation;
  112193. private _idleRotationSpeed;
  112194. private _idleRotationWaitTime;
  112195. private _idleRotationSpinupTime;
  112196. /**
  112197. * Sets the flag that indicates if user zooming should stop animation.
  112198. */
  112199. set zoomStopsAnimation(flag: boolean);
  112200. /**
  112201. * Gets the flag that indicates if user zooming should stop animation.
  112202. */
  112203. get zoomStopsAnimation(): boolean;
  112204. /**
  112205. * Sets the default speed at which the camera rotates around the model.
  112206. */
  112207. set idleRotationSpeed(speed: number);
  112208. /**
  112209. * Gets the default speed at which the camera rotates around the model.
  112210. */
  112211. get idleRotationSpeed(): number;
  112212. /**
  112213. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  112214. */
  112215. set idleRotationWaitTime(time: number);
  112216. /**
  112217. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  112218. */
  112219. get idleRotationWaitTime(): number;
  112220. /**
  112221. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112222. */
  112223. set idleRotationSpinupTime(time: number);
  112224. /**
  112225. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112226. */
  112227. get idleRotationSpinupTime(): number;
  112228. /**
  112229. * Gets a value indicating if the camera is currently rotating because of this behavior
  112230. */
  112231. get rotationInProgress(): boolean;
  112232. private _onPrePointerObservableObserver;
  112233. private _onAfterCheckInputsObserver;
  112234. private _attachedCamera;
  112235. private _isPointerDown;
  112236. private _lastFrameTime;
  112237. private _lastInteractionTime;
  112238. private _cameraRotationSpeed;
  112239. /**
  112240. * Initializes the behavior.
  112241. */
  112242. init(): void;
  112243. /**
  112244. * Attaches the behavior to its arc rotate camera.
  112245. * @param camera Defines the camera to attach the behavior to
  112246. */
  112247. attach(camera: ArcRotateCamera): void;
  112248. /**
  112249. * Detaches the behavior from its current arc rotate camera.
  112250. */
  112251. detach(): void;
  112252. /**
  112253. * Returns true if user is scrolling.
  112254. * @return true if user is scrolling.
  112255. */
  112256. private _userIsZooming;
  112257. private _lastFrameRadius;
  112258. private _shouldAnimationStopForInteraction;
  112259. /**
  112260. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112261. */
  112262. private _applyUserInteraction;
  112263. private _userIsMoving;
  112264. }
  112265. }
  112266. declare module BABYLON {
  112267. /**
  112268. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  112269. */
  112270. export class AttachToBoxBehavior implements Behavior<Mesh> {
  112271. private ui;
  112272. /**
  112273. * The name of the behavior
  112274. */
  112275. name: string;
  112276. /**
  112277. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  112278. */
  112279. distanceAwayFromFace: number;
  112280. /**
  112281. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  112282. */
  112283. distanceAwayFromBottomOfFace: number;
  112284. private _faceVectors;
  112285. private _target;
  112286. private _scene;
  112287. private _onRenderObserver;
  112288. private _tmpMatrix;
  112289. private _tmpVector;
  112290. /**
  112291. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  112292. * @param ui The transform node that should be attched to the mesh
  112293. */
  112294. constructor(ui: TransformNode);
  112295. /**
  112296. * Initializes the behavior
  112297. */
  112298. init(): void;
  112299. private _closestFace;
  112300. private _zeroVector;
  112301. private _lookAtTmpMatrix;
  112302. private _lookAtToRef;
  112303. /**
  112304. * Attaches the AttachToBoxBehavior to the passed in mesh
  112305. * @param target The mesh that the specified node will be attached to
  112306. */
  112307. attach(target: Mesh): void;
  112308. /**
  112309. * Detaches the behavior from the mesh
  112310. */
  112311. detach(): void;
  112312. }
  112313. }
  112314. declare module BABYLON {
  112315. /**
  112316. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  112317. */
  112318. export class FadeInOutBehavior implements Behavior<Mesh> {
  112319. /**
  112320. * Time in milliseconds to delay before fading in (Default: 0)
  112321. */
  112322. delay: number;
  112323. /**
  112324. * Time in milliseconds for the mesh to fade in (Default: 300)
  112325. */
  112326. fadeInTime: number;
  112327. private _millisecondsPerFrame;
  112328. private _hovered;
  112329. private _hoverValue;
  112330. private _ownerNode;
  112331. /**
  112332. * Instatiates the FadeInOutBehavior
  112333. */
  112334. constructor();
  112335. /**
  112336. * The name of the behavior
  112337. */
  112338. get name(): string;
  112339. /**
  112340. * Initializes the behavior
  112341. */
  112342. init(): void;
  112343. /**
  112344. * Attaches the fade behavior on the passed in mesh
  112345. * @param ownerNode The mesh that will be faded in/out once attached
  112346. */
  112347. attach(ownerNode: Mesh): void;
  112348. /**
  112349. * Detaches the behavior from the mesh
  112350. */
  112351. detach(): void;
  112352. /**
  112353. * Triggers the mesh to begin fading in or out
  112354. * @param value if the object should fade in or out (true to fade in)
  112355. */
  112356. fadeIn(value: boolean): void;
  112357. private _update;
  112358. private _setAllVisibility;
  112359. }
  112360. }
  112361. declare module BABYLON {
  112362. /**
  112363. * Class containing a set of static utilities functions for managing Pivots
  112364. * @hidden
  112365. */
  112366. export class PivotTools {
  112367. private static _PivotCached;
  112368. private static _OldPivotPoint;
  112369. private static _PivotTranslation;
  112370. private static _PivotTmpVector;
  112371. /** @hidden */
  112372. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  112373. /** @hidden */
  112374. static _RestorePivotPoint(mesh: AbstractMesh): void;
  112375. }
  112376. }
  112377. declare module BABYLON {
  112378. /**
  112379. * Class containing static functions to help procedurally build meshes
  112380. */
  112381. export class PlaneBuilder {
  112382. /**
  112383. * Creates a plane mesh
  112384. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  112385. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  112386. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  112387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112388. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112390. * @param name defines the name of the mesh
  112391. * @param options defines the options used to create the mesh
  112392. * @param scene defines the hosting scene
  112393. * @returns the plane mesh
  112394. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  112395. */
  112396. static CreatePlane(name: string, options: {
  112397. size?: number;
  112398. width?: number;
  112399. height?: number;
  112400. sideOrientation?: number;
  112401. frontUVs?: Vector4;
  112402. backUVs?: Vector4;
  112403. updatable?: boolean;
  112404. sourcePlane?: Plane;
  112405. }, scene?: Nullable<Scene>): Mesh;
  112406. }
  112407. }
  112408. declare module BABYLON {
  112409. /**
  112410. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  112411. */
  112412. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  112413. private static _AnyMouseID;
  112414. /**
  112415. * Abstract mesh the behavior is set on
  112416. */
  112417. attachedNode: AbstractMesh;
  112418. private _dragPlane;
  112419. private _scene;
  112420. private _pointerObserver;
  112421. private _beforeRenderObserver;
  112422. private static _planeScene;
  112423. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  112424. /**
  112425. * 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)
  112426. */
  112427. maxDragAngle: number;
  112428. /**
  112429. * @hidden
  112430. */
  112431. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  112432. /**
  112433. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112434. */
  112435. currentDraggingPointerID: number;
  112436. /**
  112437. * The last position where the pointer hit the drag plane in world space
  112438. */
  112439. lastDragPosition: Vector3;
  112440. /**
  112441. * If the behavior is currently in a dragging state
  112442. */
  112443. dragging: boolean;
  112444. /**
  112445. * 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)
  112446. */
  112447. dragDeltaRatio: number;
  112448. /**
  112449. * If the drag plane orientation should be updated during the dragging (Default: true)
  112450. */
  112451. updateDragPlane: boolean;
  112452. private _debugMode;
  112453. private _moving;
  112454. /**
  112455. * Fires each time the attached mesh is dragged with the pointer
  112456. * * delta between last drag position and current drag position in world space
  112457. * * dragDistance along the drag axis
  112458. * * dragPlaneNormal normal of the current drag plane used during the drag
  112459. * * dragPlanePoint in world space where the drag intersects the drag plane
  112460. */
  112461. onDragObservable: Observable<{
  112462. delta: Vector3;
  112463. dragPlanePoint: Vector3;
  112464. dragPlaneNormal: Vector3;
  112465. dragDistance: number;
  112466. pointerId: number;
  112467. }>;
  112468. /**
  112469. * Fires each time a drag begins (eg. mouse down on mesh)
  112470. */
  112471. onDragStartObservable: Observable<{
  112472. dragPlanePoint: Vector3;
  112473. pointerId: number;
  112474. }>;
  112475. /**
  112476. * Fires each time a drag ends (eg. mouse release after drag)
  112477. */
  112478. onDragEndObservable: Observable<{
  112479. dragPlanePoint: Vector3;
  112480. pointerId: number;
  112481. }>;
  112482. /**
  112483. * If the attached mesh should be moved when dragged
  112484. */
  112485. moveAttached: boolean;
  112486. /**
  112487. * If the drag behavior will react to drag events (Default: true)
  112488. */
  112489. enabled: boolean;
  112490. /**
  112491. * If pointer events should start and release the drag (Default: true)
  112492. */
  112493. startAndReleaseDragOnPointerEvents: boolean;
  112494. /**
  112495. * If camera controls should be detached during the drag
  112496. */
  112497. detachCameraControls: boolean;
  112498. /**
  112499. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  112500. */
  112501. useObjectOrientationForDragging: boolean;
  112502. private _options;
  112503. /**
  112504. * Gets the options used by the behavior
  112505. */
  112506. get options(): {
  112507. dragAxis?: Vector3;
  112508. dragPlaneNormal?: Vector3;
  112509. };
  112510. /**
  112511. * Sets the options used by the behavior
  112512. */
  112513. set options(options: {
  112514. dragAxis?: Vector3;
  112515. dragPlaneNormal?: Vector3;
  112516. });
  112517. /**
  112518. * Creates a pointer drag behavior that can be attached to a mesh
  112519. * @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)
  112520. */
  112521. constructor(options?: {
  112522. dragAxis?: Vector3;
  112523. dragPlaneNormal?: Vector3;
  112524. });
  112525. /**
  112526. * Predicate to determine if it is valid to move the object to a new position when it is moved
  112527. */
  112528. validateDrag: (targetPosition: Vector3) => boolean;
  112529. /**
  112530. * The name of the behavior
  112531. */
  112532. get name(): string;
  112533. /**
  112534. * Initializes the behavior
  112535. */
  112536. init(): void;
  112537. private _tmpVector;
  112538. private _alternatePickedPoint;
  112539. private _worldDragAxis;
  112540. private _targetPosition;
  112541. private _attachedElement;
  112542. /**
  112543. * Attaches the drag behavior the passed in mesh
  112544. * @param ownerNode The mesh that will be dragged around once attached
  112545. * @param predicate Predicate to use for pick filtering
  112546. */
  112547. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  112548. /**
  112549. * Force relase the drag action by code.
  112550. */
  112551. releaseDrag(): void;
  112552. private _startDragRay;
  112553. private _lastPointerRay;
  112554. /**
  112555. * Simulates the start of a pointer drag event on the behavior
  112556. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  112557. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  112558. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  112559. */
  112560. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  112561. private _startDrag;
  112562. private _dragDelta;
  112563. private _moveDrag;
  112564. private _pickWithRayOnDragPlane;
  112565. private _pointA;
  112566. private _pointB;
  112567. private _pointC;
  112568. private _lineA;
  112569. private _lineB;
  112570. private _localAxis;
  112571. private _lookAt;
  112572. private _updateDragPlanePosition;
  112573. /**
  112574. * Detaches the behavior from the mesh
  112575. */
  112576. detach(): void;
  112577. }
  112578. }
  112579. declare module BABYLON {
  112580. /**
  112581. * A behavior that when attached to a mesh will allow the mesh to be scaled
  112582. */
  112583. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  112584. private _dragBehaviorA;
  112585. private _dragBehaviorB;
  112586. private _startDistance;
  112587. private _initialScale;
  112588. private _targetScale;
  112589. private _ownerNode;
  112590. private _sceneRenderObserver;
  112591. /**
  112592. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  112593. */
  112594. constructor();
  112595. /**
  112596. * The name of the behavior
  112597. */
  112598. get name(): string;
  112599. /**
  112600. * Initializes the behavior
  112601. */
  112602. init(): void;
  112603. private _getCurrentDistance;
  112604. /**
  112605. * Attaches the scale behavior the passed in mesh
  112606. * @param ownerNode The mesh that will be scaled around once attached
  112607. */
  112608. attach(ownerNode: Mesh): void;
  112609. /**
  112610. * Detaches the behavior from the mesh
  112611. */
  112612. detach(): void;
  112613. }
  112614. }
  112615. declare module BABYLON {
  112616. /**
  112617. * 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
  112618. */
  112619. export class SixDofDragBehavior implements Behavior<Mesh> {
  112620. private static _virtualScene;
  112621. private _ownerNode;
  112622. private _sceneRenderObserver;
  112623. private _scene;
  112624. private _targetPosition;
  112625. private _virtualOriginMesh;
  112626. private _virtualDragMesh;
  112627. private _pointerObserver;
  112628. private _moving;
  112629. private _startingOrientation;
  112630. /**
  112631. * 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)
  112632. */
  112633. private zDragFactor;
  112634. /**
  112635. * If the object should rotate to face the drag origin
  112636. */
  112637. rotateDraggedObject: boolean;
  112638. /**
  112639. * If the behavior is currently in a dragging state
  112640. */
  112641. dragging: boolean;
  112642. /**
  112643. * 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)
  112644. */
  112645. dragDeltaRatio: number;
  112646. /**
  112647. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112648. */
  112649. currentDraggingPointerID: number;
  112650. /**
  112651. * If camera controls should be detached during the drag
  112652. */
  112653. detachCameraControls: boolean;
  112654. /**
  112655. * Fires each time a drag starts
  112656. */
  112657. onDragStartObservable: Observable<{}>;
  112658. /**
  112659. * Fires each time a drag ends (eg. mouse release after drag)
  112660. */
  112661. onDragEndObservable: Observable<{}>;
  112662. /**
  112663. * 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
  112664. */
  112665. constructor();
  112666. /**
  112667. * The name of the behavior
  112668. */
  112669. get name(): string;
  112670. /**
  112671. * Initializes the behavior
  112672. */
  112673. init(): void;
  112674. /**
  112675. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  112676. */
  112677. private get _pointerCamera();
  112678. /**
  112679. * Attaches the scale behavior the passed in mesh
  112680. * @param ownerNode The mesh that will be scaled around once attached
  112681. */
  112682. attach(ownerNode: Mesh): void;
  112683. /**
  112684. * Detaches the behavior from the mesh
  112685. */
  112686. detach(): void;
  112687. }
  112688. }
  112689. declare module BABYLON {
  112690. /**
  112691. * Class used to apply inverse kinematics to bones
  112692. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  112693. */
  112694. export class BoneIKController {
  112695. private static _tmpVecs;
  112696. private static _tmpQuat;
  112697. private static _tmpMats;
  112698. /**
  112699. * Gets or sets the target mesh
  112700. */
  112701. targetMesh: AbstractMesh;
  112702. /** Gets or sets the mesh used as pole */
  112703. poleTargetMesh: AbstractMesh;
  112704. /**
  112705. * Gets or sets the bone used as pole
  112706. */
  112707. poleTargetBone: Nullable<Bone>;
  112708. /**
  112709. * Gets or sets the target position
  112710. */
  112711. targetPosition: Vector3;
  112712. /**
  112713. * Gets or sets the pole target position
  112714. */
  112715. poleTargetPosition: Vector3;
  112716. /**
  112717. * Gets or sets the pole target local offset
  112718. */
  112719. poleTargetLocalOffset: Vector3;
  112720. /**
  112721. * Gets or sets the pole angle
  112722. */
  112723. poleAngle: number;
  112724. /**
  112725. * Gets or sets the mesh associated with the controller
  112726. */
  112727. mesh: AbstractMesh;
  112728. /**
  112729. * 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)
  112730. */
  112731. slerpAmount: number;
  112732. private _bone1Quat;
  112733. private _bone1Mat;
  112734. private _bone2Ang;
  112735. private _bone1;
  112736. private _bone2;
  112737. private _bone1Length;
  112738. private _bone2Length;
  112739. private _maxAngle;
  112740. private _maxReach;
  112741. private _rightHandedSystem;
  112742. private _bendAxis;
  112743. private _slerping;
  112744. private _adjustRoll;
  112745. /**
  112746. * Gets or sets maximum allowed angle
  112747. */
  112748. get maxAngle(): number;
  112749. set maxAngle(value: number);
  112750. /**
  112751. * Creates a new BoneIKController
  112752. * @param mesh defines the mesh to control
  112753. * @param bone defines the bone to control
  112754. * @param options defines options to set up the controller
  112755. */
  112756. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  112757. targetMesh?: AbstractMesh;
  112758. poleTargetMesh?: AbstractMesh;
  112759. poleTargetBone?: Bone;
  112760. poleTargetLocalOffset?: Vector3;
  112761. poleAngle?: number;
  112762. bendAxis?: Vector3;
  112763. maxAngle?: number;
  112764. slerpAmount?: number;
  112765. });
  112766. private _setMaxAngle;
  112767. /**
  112768. * Force the controller to update the bones
  112769. */
  112770. update(): void;
  112771. }
  112772. }
  112773. declare module BABYLON {
  112774. /**
  112775. * Class used to make a bone look toward a point in space
  112776. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  112777. */
  112778. export class BoneLookController {
  112779. private static _tmpVecs;
  112780. private static _tmpQuat;
  112781. private static _tmpMats;
  112782. /**
  112783. * The target Vector3 that the bone will look at
  112784. */
  112785. target: Vector3;
  112786. /**
  112787. * The mesh that the bone is attached to
  112788. */
  112789. mesh: AbstractMesh;
  112790. /**
  112791. * The bone that will be looking to the target
  112792. */
  112793. bone: Bone;
  112794. /**
  112795. * The up axis of the coordinate system that is used when the bone is rotated
  112796. */
  112797. upAxis: Vector3;
  112798. /**
  112799. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  112800. */
  112801. upAxisSpace: Space;
  112802. /**
  112803. * Used to make an adjustment to the yaw of the bone
  112804. */
  112805. adjustYaw: number;
  112806. /**
  112807. * Used to make an adjustment to the pitch of the bone
  112808. */
  112809. adjustPitch: number;
  112810. /**
  112811. * Used to make an adjustment to the roll of the bone
  112812. */
  112813. adjustRoll: number;
  112814. /**
  112815. * 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)
  112816. */
  112817. slerpAmount: number;
  112818. private _minYaw;
  112819. private _maxYaw;
  112820. private _minPitch;
  112821. private _maxPitch;
  112822. private _minYawSin;
  112823. private _minYawCos;
  112824. private _maxYawSin;
  112825. private _maxYawCos;
  112826. private _midYawConstraint;
  112827. private _minPitchTan;
  112828. private _maxPitchTan;
  112829. private _boneQuat;
  112830. private _slerping;
  112831. private _transformYawPitch;
  112832. private _transformYawPitchInv;
  112833. private _firstFrameSkipped;
  112834. private _yawRange;
  112835. private _fowardAxis;
  112836. /**
  112837. * Gets or sets the minimum yaw angle that the bone can look to
  112838. */
  112839. get minYaw(): number;
  112840. set minYaw(value: number);
  112841. /**
  112842. * Gets or sets the maximum yaw angle that the bone can look to
  112843. */
  112844. get maxYaw(): number;
  112845. set maxYaw(value: number);
  112846. /**
  112847. * Gets or sets the minimum pitch angle that the bone can look to
  112848. */
  112849. get minPitch(): number;
  112850. set minPitch(value: number);
  112851. /**
  112852. * Gets or sets the maximum pitch angle that the bone can look to
  112853. */
  112854. get maxPitch(): number;
  112855. set maxPitch(value: number);
  112856. /**
  112857. * Create a BoneLookController
  112858. * @param mesh the mesh that the bone belongs to
  112859. * @param bone the bone that will be looking to the target
  112860. * @param target the target Vector3 to look at
  112861. * @param options optional settings:
  112862. * * maxYaw: the maximum angle the bone will yaw to
  112863. * * minYaw: the minimum angle the bone will yaw to
  112864. * * maxPitch: the maximum angle the bone will pitch to
  112865. * * minPitch: the minimum angle the bone will yaw to
  112866. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  112867. * * upAxis: the up axis of the coordinate system
  112868. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  112869. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  112870. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  112871. * * adjustYaw: used to make an adjustment to the yaw of the bone
  112872. * * adjustPitch: used to make an adjustment to the pitch of the bone
  112873. * * adjustRoll: used to make an adjustment to the roll of the bone
  112874. **/
  112875. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  112876. maxYaw?: number;
  112877. minYaw?: number;
  112878. maxPitch?: number;
  112879. minPitch?: number;
  112880. slerpAmount?: number;
  112881. upAxis?: Vector3;
  112882. upAxisSpace?: Space;
  112883. yawAxis?: Vector3;
  112884. pitchAxis?: Vector3;
  112885. adjustYaw?: number;
  112886. adjustPitch?: number;
  112887. adjustRoll?: number;
  112888. });
  112889. /**
  112890. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  112891. */
  112892. update(): void;
  112893. private _getAngleDiff;
  112894. private _getAngleBetween;
  112895. private _isAngleBetween;
  112896. }
  112897. }
  112898. declare module BABYLON {
  112899. /**
  112900. * Manage the gamepad inputs to control an arc rotate camera.
  112901. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112902. */
  112903. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  112904. /**
  112905. * Defines the camera the input is attached to.
  112906. */
  112907. camera: ArcRotateCamera;
  112908. /**
  112909. * Defines the gamepad the input is gathering event from.
  112910. */
  112911. gamepad: Nullable<Gamepad>;
  112912. /**
  112913. * Defines the gamepad rotation sensiblity.
  112914. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112915. */
  112916. gamepadRotationSensibility: number;
  112917. /**
  112918. * Defines the gamepad move sensiblity.
  112919. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112920. */
  112921. gamepadMoveSensibility: number;
  112922. private _yAxisScale;
  112923. /**
  112924. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  112925. */
  112926. get invertYAxis(): boolean;
  112927. set invertYAxis(value: boolean);
  112928. private _onGamepadConnectedObserver;
  112929. private _onGamepadDisconnectedObserver;
  112930. /**
  112931. * Attach the input controls to a specific dom element to get the input from.
  112932. * @param element Defines the element the controls should be listened from
  112933. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112934. */
  112935. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112936. /**
  112937. * Detach the current controls from the specified dom element.
  112938. * @param element Defines the element to stop listening the inputs from
  112939. */
  112940. detachControl(element: Nullable<HTMLElement>): void;
  112941. /**
  112942. * Update the current camera state depending on the inputs that have been used this frame.
  112943. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112944. */
  112945. checkInputs(): void;
  112946. /**
  112947. * Gets the class name of the current intput.
  112948. * @returns the class name
  112949. */
  112950. getClassName(): string;
  112951. /**
  112952. * Get the friendly name associated with the input class.
  112953. * @returns the input friendly name
  112954. */
  112955. getSimpleName(): string;
  112956. }
  112957. }
  112958. declare module BABYLON {
  112959. interface ArcRotateCameraInputsManager {
  112960. /**
  112961. * Add orientation input support to the input manager.
  112962. * @returns the current input manager
  112963. */
  112964. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  112965. }
  112966. /**
  112967. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  112968. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112969. */
  112970. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  112971. /**
  112972. * Defines the camera the input is attached to.
  112973. */
  112974. camera: ArcRotateCamera;
  112975. /**
  112976. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  112977. */
  112978. alphaCorrection: number;
  112979. /**
  112980. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  112981. */
  112982. gammaCorrection: number;
  112983. private _alpha;
  112984. private _gamma;
  112985. private _dirty;
  112986. private _deviceOrientationHandler;
  112987. /**
  112988. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  112989. */
  112990. constructor();
  112991. /**
  112992. * Attach the input controls to a specific dom element to get the input from.
  112993. * @param element Defines the element the controls should be listened from
  112994. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112995. */
  112996. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112997. /** @hidden */
  112998. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  112999. /**
  113000. * Update the current camera state depending on the inputs that have been used this frame.
  113001. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113002. */
  113003. checkInputs(): void;
  113004. /**
  113005. * Detach the current controls from the specified dom element.
  113006. * @param element Defines the element to stop listening the inputs from
  113007. */
  113008. detachControl(element: Nullable<HTMLElement>): void;
  113009. /**
  113010. * Gets the class name of the current intput.
  113011. * @returns the class name
  113012. */
  113013. getClassName(): string;
  113014. /**
  113015. * Get the friendly name associated with the input class.
  113016. * @returns the input friendly name
  113017. */
  113018. getSimpleName(): string;
  113019. }
  113020. }
  113021. declare module BABYLON {
  113022. /**
  113023. * Listen to mouse events to control the camera.
  113024. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113025. */
  113026. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  113027. /**
  113028. * Defines the camera the input is attached to.
  113029. */
  113030. camera: FlyCamera;
  113031. /**
  113032. * Defines if touch is enabled. (Default is true.)
  113033. */
  113034. touchEnabled: boolean;
  113035. /**
  113036. * Defines the buttons associated with the input to handle camera rotation.
  113037. */
  113038. buttons: number[];
  113039. /**
  113040. * Assign buttons for Yaw control.
  113041. */
  113042. buttonsYaw: number[];
  113043. /**
  113044. * Assign buttons for Pitch control.
  113045. */
  113046. buttonsPitch: number[];
  113047. /**
  113048. * Assign buttons for Roll control.
  113049. */
  113050. buttonsRoll: number[];
  113051. /**
  113052. * Detect if any button is being pressed while mouse is moved.
  113053. * -1 = Mouse locked.
  113054. * 0 = Left button.
  113055. * 1 = Middle Button.
  113056. * 2 = Right Button.
  113057. */
  113058. activeButton: number;
  113059. /**
  113060. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  113061. * Higher values reduce its sensitivity.
  113062. */
  113063. angularSensibility: number;
  113064. private _mousemoveCallback;
  113065. private _observer;
  113066. private _rollObserver;
  113067. private previousPosition;
  113068. private noPreventDefault;
  113069. private element;
  113070. /**
  113071. * Listen to mouse events to control the camera.
  113072. * @param touchEnabled Define if touch is enabled. (Default is true.)
  113073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113074. */
  113075. constructor(touchEnabled?: boolean);
  113076. /**
  113077. * Attach the mouse control to the HTML DOM element.
  113078. * @param element Defines the element that listens to the input events.
  113079. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  113080. */
  113081. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113082. /**
  113083. * Detach the current controls from the specified dom element.
  113084. * @param element Defines the element to stop listening the inputs from
  113085. */
  113086. detachControl(element: Nullable<HTMLElement>): void;
  113087. /**
  113088. * Gets the class name of the current input.
  113089. * @returns the class name.
  113090. */
  113091. getClassName(): string;
  113092. /**
  113093. * Get the friendly name associated with the input class.
  113094. * @returns the input's friendly name.
  113095. */
  113096. getSimpleName(): string;
  113097. private _pointerInput;
  113098. private _onMouseMove;
  113099. /**
  113100. * Rotate camera by mouse offset.
  113101. */
  113102. private rotateCamera;
  113103. }
  113104. }
  113105. declare module BABYLON {
  113106. /**
  113107. * Default Inputs manager for the FlyCamera.
  113108. * It groups all the default supported inputs for ease of use.
  113109. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113110. */
  113111. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  113112. /**
  113113. * Instantiates a new FlyCameraInputsManager.
  113114. * @param camera Defines the camera the inputs belong to.
  113115. */
  113116. constructor(camera: FlyCamera);
  113117. /**
  113118. * Add keyboard input support to the input manager.
  113119. * @returns the new FlyCameraKeyboardMoveInput().
  113120. */
  113121. addKeyboard(): FlyCameraInputsManager;
  113122. /**
  113123. * Add mouse input support to the input manager.
  113124. * @param touchEnabled Enable touch screen support.
  113125. * @returns the new FlyCameraMouseInput().
  113126. */
  113127. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  113128. }
  113129. }
  113130. declare module BABYLON {
  113131. /**
  113132. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113133. * such as in a 3D Space Shooter or a Flight Simulator.
  113134. */
  113135. export class FlyCamera extends TargetCamera {
  113136. /**
  113137. * Define the collision ellipsoid of the camera.
  113138. * This is helpful for simulating a camera body, like a player's body.
  113139. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113140. */
  113141. ellipsoid: Vector3;
  113142. /**
  113143. * Define an offset for the position of the ellipsoid around the camera.
  113144. * This can be helpful if the camera is attached away from the player's body center,
  113145. * such as at its head.
  113146. */
  113147. ellipsoidOffset: Vector3;
  113148. /**
  113149. * Enable or disable collisions of the camera with the rest of the scene objects.
  113150. */
  113151. checkCollisions: boolean;
  113152. /**
  113153. * Enable or disable gravity on the camera.
  113154. */
  113155. applyGravity: boolean;
  113156. /**
  113157. * Define the current direction the camera is moving to.
  113158. */
  113159. cameraDirection: Vector3;
  113160. /**
  113161. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  113162. * This overrides and empties cameraRotation.
  113163. */
  113164. rotationQuaternion: Quaternion;
  113165. /**
  113166. * Track Roll to maintain the wanted Rolling when looking around.
  113167. */
  113168. _trackRoll: number;
  113169. /**
  113170. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  113171. */
  113172. rollCorrect: number;
  113173. /**
  113174. * Mimic a banked turn, Rolling the camera when Yawing.
  113175. * It's recommended to use rollCorrect = 10 for faster banking correction.
  113176. */
  113177. bankedTurn: boolean;
  113178. /**
  113179. * Limit in radians for how much Roll banking will add. (Default: 90°)
  113180. */
  113181. bankedTurnLimit: number;
  113182. /**
  113183. * Value of 0 disables the banked Roll.
  113184. * Value of 1 is equal to the Yaw angle in radians.
  113185. */
  113186. bankedTurnMultiplier: number;
  113187. /**
  113188. * The inputs manager loads all the input sources, such as keyboard and mouse.
  113189. */
  113190. inputs: FlyCameraInputsManager;
  113191. /**
  113192. * Gets the input sensibility for mouse input.
  113193. * Higher values reduce sensitivity.
  113194. */
  113195. get angularSensibility(): number;
  113196. /**
  113197. * Sets the input sensibility for a mouse input.
  113198. * Higher values reduce sensitivity.
  113199. */
  113200. set angularSensibility(value: number);
  113201. /**
  113202. * Get the keys for camera movement forward.
  113203. */
  113204. get keysForward(): number[];
  113205. /**
  113206. * Set the keys for camera movement forward.
  113207. */
  113208. set keysForward(value: number[]);
  113209. /**
  113210. * Get the keys for camera movement backward.
  113211. */
  113212. get keysBackward(): number[];
  113213. set keysBackward(value: number[]);
  113214. /**
  113215. * Get the keys for camera movement up.
  113216. */
  113217. get keysUp(): number[];
  113218. /**
  113219. * Set the keys for camera movement up.
  113220. */
  113221. set keysUp(value: number[]);
  113222. /**
  113223. * Get the keys for camera movement down.
  113224. */
  113225. get keysDown(): number[];
  113226. /**
  113227. * Set the keys for camera movement down.
  113228. */
  113229. set keysDown(value: number[]);
  113230. /**
  113231. * Get the keys for camera movement left.
  113232. */
  113233. get keysLeft(): number[];
  113234. /**
  113235. * Set the keys for camera movement left.
  113236. */
  113237. set keysLeft(value: number[]);
  113238. /**
  113239. * Set the keys for camera movement right.
  113240. */
  113241. get keysRight(): number[];
  113242. /**
  113243. * Set the keys for camera movement right.
  113244. */
  113245. set keysRight(value: number[]);
  113246. /**
  113247. * Event raised when the camera collides with a mesh in the scene.
  113248. */
  113249. onCollide: (collidedMesh: AbstractMesh) => void;
  113250. private _collider;
  113251. private _needMoveForGravity;
  113252. private _oldPosition;
  113253. private _diffPosition;
  113254. private _newPosition;
  113255. /** @hidden */
  113256. _localDirection: Vector3;
  113257. /** @hidden */
  113258. _transformedDirection: Vector3;
  113259. /**
  113260. * Instantiates a FlyCamera.
  113261. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113262. * such as in a 3D Space Shooter or a Flight Simulator.
  113263. * @param name Define the name of the camera in the scene.
  113264. * @param position Define the starting position of the camera in the scene.
  113265. * @param scene Define the scene the camera belongs to.
  113266. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  113267. */
  113268. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113269. /**
  113270. * Attach a control to the HTML DOM element.
  113271. * @param element Defines the element that listens to the input events.
  113272. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  113273. */
  113274. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113275. /**
  113276. * Detach a control from the HTML DOM element.
  113277. * The camera will stop reacting to that input.
  113278. * @param element Defines the element that listens to the input events.
  113279. */
  113280. detachControl(element: HTMLElement): void;
  113281. private _collisionMask;
  113282. /**
  113283. * Get the mask that the camera ignores in collision events.
  113284. */
  113285. get collisionMask(): number;
  113286. /**
  113287. * Set the mask that the camera ignores in collision events.
  113288. */
  113289. set collisionMask(mask: number);
  113290. /** @hidden */
  113291. _collideWithWorld(displacement: Vector3): void;
  113292. /** @hidden */
  113293. private _onCollisionPositionChange;
  113294. /** @hidden */
  113295. _checkInputs(): void;
  113296. /** @hidden */
  113297. _decideIfNeedsToMove(): boolean;
  113298. /** @hidden */
  113299. _updatePosition(): void;
  113300. /**
  113301. * Restore the Roll to its target value at the rate specified.
  113302. * @param rate - Higher means slower restoring.
  113303. * @hidden
  113304. */
  113305. restoreRoll(rate: number): void;
  113306. /**
  113307. * Destroy the camera and release the current resources held by it.
  113308. */
  113309. dispose(): void;
  113310. /**
  113311. * Get the current object class name.
  113312. * @returns the class name.
  113313. */
  113314. getClassName(): string;
  113315. }
  113316. }
  113317. declare module BABYLON {
  113318. /**
  113319. * Listen to keyboard events to control the camera.
  113320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113321. */
  113322. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  113323. /**
  113324. * Defines the camera the input is attached to.
  113325. */
  113326. camera: FlyCamera;
  113327. /**
  113328. * The list of keyboard keys used to control the forward move of the camera.
  113329. */
  113330. keysForward: number[];
  113331. /**
  113332. * The list of keyboard keys used to control the backward move of the camera.
  113333. */
  113334. keysBackward: number[];
  113335. /**
  113336. * The list of keyboard keys used to control the forward move of the camera.
  113337. */
  113338. keysUp: number[];
  113339. /**
  113340. * The list of keyboard keys used to control the backward move of the camera.
  113341. */
  113342. keysDown: number[];
  113343. /**
  113344. * The list of keyboard keys used to control the right strafe move of the camera.
  113345. */
  113346. keysRight: number[];
  113347. /**
  113348. * The list of keyboard keys used to control the left strafe move of the camera.
  113349. */
  113350. keysLeft: number[];
  113351. private _keys;
  113352. private _onCanvasBlurObserver;
  113353. private _onKeyboardObserver;
  113354. private _engine;
  113355. private _scene;
  113356. /**
  113357. * Attach the input controls to a specific dom element to get the input from.
  113358. * @param element Defines the element the controls should be listened from
  113359. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113360. */
  113361. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113362. /**
  113363. * Detach the current controls from the specified dom element.
  113364. * @param element Defines the element to stop listening the inputs from
  113365. */
  113366. detachControl(element: Nullable<HTMLElement>): void;
  113367. /**
  113368. * Gets the class name of the current intput.
  113369. * @returns the class name
  113370. */
  113371. getClassName(): string;
  113372. /** @hidden */
  113373. _onLostFocus(e: FocusEvent): void;
  113374. /**
  113375. * Get the friendly name associated with the input class.
  113376. * @returns the input friendly name
  113377. */
  113378. getSimpleName(): string;
  113379. /**
  113380. * Update the current camera state depending on the inputs that have been used this frame.
  113381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113382. */
  113383. checkInputs(): void;
  113384. }
  113385. }
  113386. declare module BABYLON {
  113387. /**
  113388. * Manage the mouse wheel inputs to control a follow camera.
  113389. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113390. */
  113391. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  113392. /**
  113393. * Defines the camera the input is attached to.
  113394. */
  113395. camera: FollowCamera;
  113396. /**
  113397. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  113398. */
  113399. axisControlRadius: boolean;
  113400. /**
  113401. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  113402. */
  113403. axisControlHeight: boolean;
  113404. /**
  113405. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  113406. */
  113407. axisControlRotation: boolean;
  113408. /**
  113409. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  113410. * relation to mouseWheel events.
  113411. */
  113412. wheelPrecision: number;
  113413. /**
  113414. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113415. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113416. */
  113417. wheelDeltaPercentage: number;
  113418. private _wheel;
  113419. private _observer;
  113420. /**
  113421. * Attach the input controls to a specific dom element to get the input from.
  113422. * @param element Defines the element the controls should be listened from
  113423. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113424. */
  113425. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113426. /**
  113427. * Detach the current controls from the specified dom element.
  113428. * @param element Defines the element to stop listening the inputs from
  113429. */
  113430. detachControl(element: Nullable<HTMLElement>): void;
  113431. /**
  113432. * Gets the class name of the current intput.
  113433. * @returns the class name
  113434. */
  113435. getClassName(): string;
  113436. /**
  113437. * Get the friendly name associated with the input class.
  113438. * @returns the input friendly name
  113439. */
  113440. getSimpleName(): string;
  113441. }
  113442. }
  113443. declare module BABYLON {
  113444. /**
  113445. * Manage the pointers inputs to control an follow camera.
  113446. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113447. */
  113448. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  113449. /**
  113450. * Defines the camera the input is attached to.
  113451. */
  113452. camera: FollowCamera;
  113453. /**
  113454. * Gets the class name of the current input.
  113455. * @returns the class name
  113456. */
  113457. getClassName(): string;
  113458. /**
  113459. * Defines the pointer angular sensibility along the X axis or how fast is
  113460. * the camera rotating.
  113461. * A negative number will reverse the axis direction.
  113462. */
  113463. angularSensibilityX: number;
  113464. /**
  113465. * Defines the pointer angular sensibility along the Y axis or how fast is
  113466. * the camera rotating.
  113467. * A negative number will reverse the axis direction.
  113468. */
  113469. angularSensibilityY: number;
  113470. /**
  113471. * Defines the pointer pinch precision or how fast is the camera zooming.
  113472. * A negative number will reverse the axis direction.
  113473. */
  113474. pinchPrecision: number;
  113475. /**
  113476. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  113477. * from 0.
  113478. * It defines the percentage of current camera.radius to use as delta when
  113479. * pinch zoom is used.
  113480. */
  113481. pinchDeltaPercentage: number;
  113482. /**
  113483. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  113484. */
  113485. axisXControlRadius: boolean;
  113486. /**
  113487. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  113488. */
  113489. axisXControlHeight: boolean;
  113490. /**
  113491. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  113492. */
  113493. axisXControlRotation: boolean;
  113494. /**
  113495. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  113496. */
  113497. axisYControlRadius: boolean;
  113498. /**
  113499. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  113500. */
  113501. axisYControlHeight: boolean;
  113502. /**
  113503. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  113504. */
  113505. axisYControlRotation: boolean;
  113506. /**
  113507. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  113508. */
  113509. axisPinchControlRadius: boolean;
  113510. /**
  113511. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  113512. */
  113513. axisPinchControlHeight: boolean;
  113514. /**
  113515. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  113516. */
  113517. axisPinchControlRotation: boolean;
  113518. /**
  113519. * Log error messages if basic misconfiguration has occurred.
  113520. */
  113521. warningEnable: boolean;
  113522. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113523. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113524. private _warningCounter;
  113525. private _warning;
  113526. }
  113527. }
  113528. declare module BABYLON {
  113529. /**
  113530. * Default Inputs manager for the FollowCamera.
  113531. * It groups all the default supported inputs for ease of use.
  113532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113533. */
  113534. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  113535. /**
  113536. * Instantiates a new FollowCameraInputsManager.
  113537. * @param camera Defines the camera the inputs belong to
  113538. */
  113539. constructor(camera: FollowCamera);
  113540. /**
  113541. * Add keyboard input support to the input manager.
  113542. * @returns the current input manager
  113543. */
  113544. addKeyboard(): FollowCameraInputsManager;
  113545. /**
  113546. * Add mouse wheel input support to the input manager.
  113547. * @returns the current input manager
  113548. */
  113549. addMouseWheel(): FollowCameraInputsManager;
  113550. /**
  113551. * Add pointers input support to the input manager.
  113552. * @returns the current input manager
  113553. */
  113554. addPointers(): FollowCameraInputsManager;
  113555. /**
  113556. * Add orientation input support to the input manager.
  113557. * @returns the current input manager
  113558. */
  113559. addVRDeviceOrientation(): FollowCameraInputsManager;
  113560. }
  113561. }
  113562. declare module BABYLON {
  113563. /**
  113564. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  113565. * an arc rotate version arcFollowCamera are available.
  113566. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113567. */
  113568. export class FollowCamera extends TargetCamera {
  113569. /**
  113570. * Distance the follow camera should follow an object at
  113571. */
  113572. radius: number;
  113573. /**
  113574. * Minimum allowed distance of the camera to the axis of rotation
  113575. * (The camera can not get closer).
  113576. * This can help limiting how the Camera is able to move in the scene.
  113577. */
  113578. lowerRadiusLimit: Nullable<number>;
  113579. /**
  113580. * Maximum allowed distance of the camera to the axis of rotation
  113581. * (The camera can not get further).
  113582. * This can help limiting how the Camera is able to move in the scene.
  113583. */
  113584. upperRadiusLimit: Nullable<number>;
  113585. /**
  113586. * Define a rotation offset between the camera and the object it follows
  113587. */
  113588. rotationOffset: number;
  113589. /**
  113590. * Minimum allowed angle to camera position relative to target object.
  113591. * This can help limiting how the Camera is able to move in the scene.
  113592. */
  113593. lowerRotationOffsetLimit: Nullable<number>;
  113594. /**
  113595. * Maximum allowed angle to camera position relative to target object.
  113596. * This can help limiting how the Camera is able to move in the scene.
  113597. */
  113598. upperRotationOffsetLimit: Nullable<number>;
  113599. /**
  113600. * Define a height offset between the camera and the object it follows.
  113601. * It can help following an object from the top (like a car chaing a plane)
  113602. */
  113603. heightOffset: number;
  113604. /**
  113605. * Minimum allowed height of camera position relative to target object.
  113606. * This can help limiting how the Camera is able to move in the scene.
  113607. */
  113608. lowerHeightOffsetLimit: Nullable<number>;
  113609. /**
  113610. * Maximum allowed height of camera position relative to target object.
  113611. * This can help limiting how the Camera is able to move in the scene.
  113612. */
  113613. upperHeightOffsetLimit: Nullable<number>;
  113614. /**
  113615. * Define how fast the camera can accelerate to follow it s target.
  113616. */
  113617. cameraAcceleration: number;
  113618. /**
  113619. * Define the speed limit of the camera following an object.
  113620. */
  113621. maxCameraSpeed: number;
  113622. /**
  113623. * Define the target of the camera.
  113624. */
  113625. lockedTarget: Nullable<AbstractMesh>;
  113626. /**
  113627. * Defines the input associated with the camera.
  113628. */
  113629. inputs: FollowCameraInputsManager;
  113630. /**
  113631. * Instantiates the follow camera.
  113632. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113633. * @param name Define the name of the camera in the scene
  113634. * @param position Define the position of the camera
  113635. * @param scene Define the scene the camera belong to
  113636. * @param lockedTarget Define the target of the camera
  113637. */
  113638. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  113639. private _follow;
  113640. /**
  113641. * Attached controls to the current camera.
  113642. * @param element Defines the element the controls should be listened from
  113643. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113644. */
  113645. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113646. /**
  113647. * Detach the current controls from the camera.
  113648. * The camera will stop reacting to inputs.
  113649. * @param element Defines the element to stop listening the inputs from
  113650. */
  113651. detachControl(element: HTMLElement): void;
  113652. /** @hidden */
  113653. _checkInputs(): void;
  113654. private _checkLimits;
  113655. /**
  113656. * Gets the camera class name.
  113657. * @returns the class name
  113658. */
  113659. getClassName(): string;
  113660. }
  113661. /**
  113662. * Arc Rotate version of the follow camera.
  113663. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  113664. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113665. */
  113666. export class ArcFollowCamera extends TargetCamera {
  113667. /** The longitudinal angle of the camera */
  113668. alpha: number;
  113669. /** The latitudinal angle of the camera */
  113670. beta: number;
  113671. /** The radius of the camera from its target */
  113672. radius: number;
  113673. /** Define the camera target (the messh it should follow) */
  113674. target: Nullable<AbstractMesh>;
  113675. private _cartesianCoordinates;
  113676. /**
  113677. * Instantiates a new ArcFollowCamera
  113678. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113679. * @param name Define the name of the camera
  113680. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  113681. * @param beta Define the rotation angle of the camera around the elevation axis
  113682. * @param radius Define the radius of the camera from its target point
  113683. * @param target Define the target of the camera
  113684. * @param scene Define the scene the camera belongs to
  113685. */
  113686. constructor(name: string,
  113687. /** The longitudinal angle of the camera */
  113688. alpha: number,
  113689. /** The latitudinal angle of the camera */
  113690. beta: number,
  113691. /** The radius of the camera from its target */
  113692. radius: number,
  113693. /** Define the camera target (the messh it should follow) */
  113694. target: Nullable<AbstractMesh>, scene: Scene);
  113695. private _follow;
  113696. /** @hidden */
  113697. _checkInputs(): void;
  113698. /**
  113699. * Returns the class name of the object.
  113700. * It is mostly used internally for serialization purposes.
  113701. */
  113702. getClassName(): string;
  113703. }
  113704. }
  113705. declare module BABYLON {
  113706. /**
  113707. * Manage the keyboard inputs to control the movement of a follow camera.
  113708. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113709. */
  113710. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  113711. /**
  113712. * Defines the camera the input is attached to.
  113713. */
  113714. camera: FollowCamera;
  113715. /**
  113716. * Defines the list of key codes associated with the up action (increase heightOffset)
  113717. */
  113718. keysHeightOffsetIncr: number[];
  113719. /**
  113720. * Defines the list of key codes associated with the down action (decrease heightOffset)
  113721. */
  113722. keysHeightOffsetDecr: number[];
  113723. /**
  113724. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  113725. */
  113726. keysHeightOffsetModifierAlt: boolean;
  113727. /**
  113728. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  113729. */
  113730. keysHeightOffsetModifierCtrl: boolean;
  113731. /**
  113732. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  113733. */
  113734. keysHeightOffsetModifierShift: boolean;
  113735. /**
  113736. * Defines the list of key codes associated with the left action (increase rotationOffset)
  113737. */
  113738. keysRotationOffsetIncr: number[];
  113739. /**
  113740. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  113741. */
  113742. keysRotationOffsetDecr: number[];
  113743. /**
  113744. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  113745. */
  113746. keysRotationOffsetModifierAlt: boolean;
  113747. /**
  113748. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  113749. */
  113750. keysRotationOffsetModifierCtrl: boolean;
  113751. /**
  113752. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  113753. */
  113754. keysRotationOffsetModifierShift: boolean;
  113755. /**
  113756. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  113757. */
  113758. keysRadiusIncr: number[];
  113759. /**
  113760. * Defines the list of key codes associated with the zoom-out action (increase radius)
  113761. */
  113762. keysRadiusDecr: number[];
  113763. /**
  113764. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  113765. */
  113766. keysRadiusModifierAlt: boolean;
  113767. /**
  113768. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  113769. */
  113770. keysRadiusModifierCtrl: boolean;
  113771. /**
  113772. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  113773. */
  113774. keysRadiusModifierShift: boolean;
  113775. /**
  113776. * Defines the rate of change of heightOffset.
  113777. */
  113778. heightSensibility: number;
  113779. /**
  113780. * Defines the rate of change of rotationOffset.
  113781. */
  113782. rotationSensibility: number;
  113783. /**
  113784. * Defines the rate of change of radius.
  113785. */
  113786. radiusSensibility: number;
  113787. private _keys;
  113788. private _ctrlPressed;
  113789. private _altPressed;
  113790. private _shiftPressed;
  113791. private _onCanvasBlurObserver;
  113792. private _onKeyboardObserver;
  113793. private _engine;
  113794. private _scene;
  113795. /**
  113796. * Attach the input controls to a specific dom element to get the input from.
  113797. * @param element Defines the element the controls should be listened from
  113798. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113799. */
  113800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113801. /**
  113802. * Detach the current controls from the specified dom element.
  113803. * @param element Defines the element to stop listening the inputs from
  113804. */
  113805. detachControl(element: Nullable<HTMLElement>): void;
  113806. /**
  113807. * Update the current camera state depending on the inputs that have been used this frame.
  113808. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113809. */
  113810. checkInputs(): void;
  113811. /**
  113812. * Gets the class name of the current input.
  113813. * @returns the class name
  113814. */
  113815. getClassName(): string;
  113816. /**
  113817. * Get the friendly name associated with the input class.
  113818. * @returns the input friendly name
  113819. */
  113820. getSimpleName(): string;
  113821. /**
  113822. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113823. * allow modification of the heightOffset value.
  113824. */
  113825. private _modifierHeightOffset;
  113826. /**
  113827. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113828. * allow modification of the rotationOffset value.
  113829. */
  113830. private _modifierRotationOffset;
  113831. /**
  113832. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113833. * allow modification of the radius value.
  113834. */
  113835. private _modifierRadius;
  113836. }
  113837. }
  113838. declare module BABYLON {
  113839. interface FreeCameraInputsManager {
  113840. /**
  113841. * @hidden
  113842. */
  113843. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  113844. /**
  113845. * Add orientation input support to the input manager.
  113846. * @returns the current input manager
  113847. */
  113848. addDeviceOrientation(): FreeCameraInputsManager;
  113849. }
  113850. /**
  113851. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  113852. * Screen rotation is taken into account.
  113853. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113854. */
  113855. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  113856. private _camera;
  113857. private _screenOrientationAngle;
  113858. private _constantTranform;
  113859. private _screenQuaternion;
  113860. private _alpha;
  113861. private _beta;
  113862. private _gamma;
  113863. /**
  113864. * Can be used to detect if a device orientation sensor is available on a device
  113865. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  113866. * @returns a promise that will resolve on orientation change
  113867. */
  113868. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  113869. /**
  113870. * @hidden
  113871. */
  113872. _onDeviceOrientationChangedObservable: Observable<void>;
  113873. /**
  113874. * Instantiates a new input
  113875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113876. */
  113877. constructor();
  113878. /**
  113879. * Define the camera controlled by the input.
  113880. */
  113881. get camera(): FreeCamera;
  113882. set camera(camera: FreeCamera);
  113883. /**
  113884. * Attach the input controls to a specific dom element to get the input from.
  113885. * @param element Defines the element the controls should be listened from
  113886. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113887. */
  113888. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113889. private _orientationChanged;
  113890. private _deviceOrientation;
  113891. /**
  113892. * Detach the current controls from the specified dom element.
  113893. * @param element Defines the element to stop listening the inputs from
  113894. */
  113895. detachControl(element: Nullable<HTMLElement>): void;
  113896. /**
  113897. * Update the current camera state depending on the inputs that have been used this frame.
  113898. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113899. */
  113900. checkInputs(): void;
  113901. /**
  113902. * Gets the class name of the current intput.
  113903. * @returns the class name
  113904. */
  113905. getClassName(): string;
  113906. /**
  113907. * Get the friendly name associated with the input class.
  113908. * @returns the input friendly name
  113909. */
  113910. getSimpleName(): string;
  113911. }
  113912. }
  113913. declare module BABYLON {
  113914. /**
  113915. * Manage the gamepad inputs to control a free camera.
  113916. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113917. */
  113918. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  113919. /**
  113920. * Define the camera the input is attached to.
  113921. */
  113922. camera: FreeCamera;
  113923. /**
  113924. * Define the Gamepad controlling the input
  113925. */
  113926. gamepad: Nullable<Gamepad>;
  113927. /**
  113928. * Defines the gamepad rotation sensiblity.
  113929. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113930. */
  113931. gamepadAngularSensibility: number;
  113932. /**
  113933. * Defines the gamepad move sensiblity.
  113934. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113935. */
  113936. gamepadMoveSensibility: number;
  113937. private _yAxisScale;
  113938. /**
  113939. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113940. */
  113941. get invertYAxis(): boolean;
  113942. set invertYAxis(value: boolean);
  113943. private _onGamepadConnectedObserver;
  113944. private _onGamepadDisconnectedObserver;
  113945. private _cameraTransform;
  113946. private _deltaTransform;
  113947. private _vector3;
  113948. private _vector2;
  113949. /**
  113950. * Attach the input controls to a specific dom element to get the input from.
  113951. * @param element Defines the element the controls should be listened from
  113952. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113953. */
  113954. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113955. /**
  113956. * Detach the current controls from the specified dom element.
  113957. * @param element Defines the element to stop listening the inputs from
  113958. */
  113959. detachControl(element: Nullable<HTMLElement>): void;
  113960. /**
  113961. * Update the current camera state depending on the inputs that have been used this frame.
  113962. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113963. */
  113964. checkInputs(): void;
  113965. /**
  113966. * Gets the class name of the current intput.
  113967. * @returns the class name
  113968. */
  113969. getClassName(): string;
  113970. /**
  113971. * Get the friendly name associated with the input class.
  113972. * @returns the input friendly name
  113973. */
  113974. getSimpleName(): string;
  113975. }
  113976. }
  113977. declare module BABYLON {
  113978. /**
  113979. * Defines the potential axis of a Joystick
  113980. */
  113981. export enum JoystickAxis {
  113982. /** X axis */
  113983. X = 0,
  113984. /** Y axis */
  113985. Y = 1,
  113986. /** Z axis */
  113987. Z = 2
  113988. }
  113989. /**
  113990. * Class used to define virtual joystick (used in touch mode)
  113991. */
  113992. export class VirtualJoystick {
  113993. /**
  113994. * Gets or sets a boolean indicating that left and right values must be inverted
  113995. */
  113996. reverseLeftRight: boolean;
  113997. /**
  113998. * Gets or sets a boolean indicating that up and down values must be inverted
  113999. */
  114000. reverseUpDown: boolean;
  114001. /**
  114002. * Gets the offset value for the position (ie. the change of the position value)
  114003. */
  114004. deltaPosition: Vector3;
  114005. /**
  114006. * Gets a boolean indicating if the virtual joystick was pressed
  114007. */
  114008. pressed: boolean;
  114009. /**
  114010. * Canvas the virtual joystick will render onto, default z-index of this is 5
  114011. */
  114012. static Canvas: Nullable<HTMLCanvasElement>;
  114013. private static _globalJoystickIndex;
  114014. private static vjCanvasContext;
  114015. private static vjCanvasWidth;
  114016. private static vjCanvasHeight;
  114017. private static halfWidth;
  114018. private _action;
  114019. private _axisTargetedByLeftAndRight;
  114020. private _axisTargetedByUpAndDown;
  114021. private _joystickSensibility;
  114022. private _inversedSensibility;
  114023. private _joystickPointerID;
  114024. private _joystickColor;
  114025. private _joystickPointerPos;
  114026. private _joystickPreviousPointerPos;
  114027. private _joystickPointerStartPos;
  114028. private _deltaJoystickVector;
  114029. private _leftJoystick;
  114030. private _touches;
  114031. private _onPointerDownHandlerRef;
  114032. private _onPointerMoveHandlerRef;
  114033. private _onPointerUpHandlerRef;
  114034. private _onResize;
  114035. /**
  114036. * Creates a new virtual joystick
  114037. * @param leftJoystick defines that the joystick is for left hand (false by default)
  114038. */
  114039. constructor(leftJoystick?: boolean);
  114040. /**
  114041. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  114042. * @param newJoystickSensibility defines the new sensibility
  114043. */
  114044. setJoystickSensibility(newJoystickSensibility: number): void;
  114045. private _onPointerDown;
  114046. private _onPointerMove;
  114047. private _onPointerUp;
  114048. /**
  114049. * Change the color of the virtual joystick
  114050. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  114051. */
  114052. setJoystickColor(newColor: string): void;
  114053. /**
  114054. * Defines a callback to call when the joystick is touched
  114055. * @param action defines the callback
  114056. */
  114057. setActionOnTouch(action: () => any): void;
  114058. /**
  114059. * Defines which axis you'd like to control for left & right
  114060. * @param axis defines the axis to use
  114061. */
  114062. setAxisForLeftRight(axis: JoystickAxis): void;
  114063. /**
  114064. * Defines which axis you'd like to control for up & down
  114065. * @param axis defines the axis to use
  114066. */
  114067. setAxisForUpDown(axis: JoystickAxis): void;
  114068. private _drawVirtualJoystick;
  114069. /**
  114070. * Release internal HTML canvas
  114071. */
  114072. releaseCanvas(): void;
  114073. }
  114074. }
  114075. declare module BABYLON {
  114076. interface FreeCameraInputsManager {
  114077. /**
  114078. * Add virtual joystick input support to the input manager.
  114079. * @returns the current input manager
  114080. */
  114081. addVirtualJoystick(): FreeCameraInputsManager;
  114082. }
  114083. /**
  114084. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  114085. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114086. */
  114087. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  114088. /**
  114089. * Defines the camera the input is attached to.
  114090. */
  114091. camera: FreeCamera;
  114092. private _leftjoystick;
  114093. private _rightjoystick;
  114094. /**
  114095. * Gets the left stick of the virtual joystick.
  114096. * @returns The virtual Joystick
  114097. */
  114098. getLeftJoystick(): VirtualJoystick;
  114099. /**
  114100. * Gets the right stick of the virtual joystick.
  114101. * @returns The virtual Joystick
  114102. */
  114103. getRightJoystick(): VirtualJoystick;
  114104. /**
  114105. * Update the current camera state depending on the inputs that have been used this frame.
  114106. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114107. */
  114108. checkInputs(): void;
  114109. /**
  114110. * Attach the input controls to a specific dom element to get the input from.
  114111. * @param element Defines the element the controls should be listened from
  114112. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114113. */
  114114. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114115. /**
  114116. * Detach the current controls from the specified dom element.
  114117. * @param element Defines the element to stop listening the inputs from
  114118. */
  114119. detachControl(element: Nullable<HTMLElement>): void;
  114120. /**
  114121. * Gets the class name of the current intput.
  114122. * @returns the class name
  114123. */
  114124. getClassName(): string;
  114125. /**
  114126. * Get the friendly name associated with the input class.
  114127. * @returns the input friendly name
  114128. */
  114129. getSimpleName(): string;
  114130. }
  114131. }
  114132. declare module BABYLON {
  114133. /**
  114134. * This represents a FPS type of camera controlled by touch.
  114135. * This is like a universal camera minus the Gamepad controls.
  114136. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114137. */
  114138. export class TouchCamera extends FreeCamera {
  114139. /**
  114140. * Defines the touch sensibility for rotation.
  114141. * The higher the faster.
  114142. */
  114143. get touchAngularSensibility(): number;
  114144. set touchAngularSensibility(value: number);
  114145. /**
  114146. * Defines the touch sensibility for move.
  114147. * The higher the faster.
  114148. */
  114149. get touchMoveSensibility(): number;
  114150. set touchMoveSensibility(value: number);
  114151. /**
  114152. * Instantiates a new touch camera.
  114153. * This represents a FPS type of camera controlled by touch.
  114154. * This is like a universal camera minus the Gamepad controls.
  114155. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114156. * @param name Define the name of the camera in the scene
  114157. * @param position Define the start position of the camera in the scene
  114158. * @param scene Define the scene the camera belongs to
  114159. */
  114160. constructor(name: string, position: Vector3, scene: Scene);
  114161. /**
  114162. * Gets the current object class name.
  114163. * @return the class name
  114164. */
  114165. getClassName(): string;
  114166. /** @hidden */
  114167. _setupInputs(): void;
  114168. }
  114169. }
  114170. declare module BABYLON {
  114171. /**
  114172. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  114173. * being tilted forward or back and left or right.
  114174. */
  114175. export class DeviceOrientationCamera extends FreeCamera {
  114176. private _initialQuaternion;
  114177. private _quaternionCache;
  114178. private _tmpDragQuaternion;
  114179. private _disablePointerInputWhenUsingDeviceOrientation;
  114180. /**
  114181. * Creates a new device orientation camera
  114182. * @param name The name of the camera
  114183. * @param position The start position camera
  114184. * @param scene The scene the camera belongs to
  114185. */
  114186. constructor(name: string, position: Vector3, scene: Scene);
  114187. /**
  114188. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  114189. */
  114190. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  114191. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  114192. private _dragFactor;
  114193. /**
  114194. * Enabled turning on the y axis when the orientation sensor is active
  114195. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  114196. */
  114197. enableHorizontalDragging(dragFactor?: number): void;
  114198. /**
  114199. * Gets the current instance class name ("DeviceOrientationCamera").
  114200. * This helps avoiding instanceof at run time.
  114201. * @returns the class name
  114202. */
  114203. getClassName(): string;
  114204. /**
  114205. * @hidden
  114206. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  114207. */
  114208. _checkInputs(): void;
  114209. /**
  114210. * Reset the camera to its default orientation on the specified axis only.
  114211. * @param axis The axis to reset
  114212. */
  114213. resetToCurrentRotation(axis?: Axis): void;
  114214. }
  114215. }
  114216. declare module BABYLON {
  114217. /**
  114218. * Defines supported buttons for XBox360 compatible gamepads
  114219. */
  114220. export enum Xbox360Button {
  114221. /** A */
  114222. A = 0,
  114223. /** B */
  114224. B = 1,
  114225. /** X */
  114226. X = 2,
  114227. /** Y */
  114228. Y = 3,
  114229. /** Left button */
  114230. LB = 4,
  114231. /** Right button */
  114232. RB = 5,
  114233. /** Back */
  114234. Back = 8,
  114235. /** Start */
  114236. Start = 9,
  114237. /** Left stick */
  114238. LeftStick = 10,
  114239. /** Right stick */
  114240. RightStick = 11
  114241. }
  114242. /** Defines values for XBox360 DPad */
  114243. export enum Xbox360Dpad {
  114244. /** Up */
  114245. Up = 12,
  114246. /** Down */
  114247. Down = 13,
  114248. /** Left */
  114249. Left = 14,
  114250. /** Right */
  114251. Right = 15
  114252. }
  114253. /**
  114254. * Defines a XBox360 gamepad
  114255. */
  114256. export class Xbox360Pad extends Gamepad {
  114257. private _leftTrigger;
  114258. private _rightTrigger;
  114259. private _onlefttriggerchanged;
  114260. private _onrighttriggerchanged;
  114261. private _onbuttondown;
  114262. private _onbuttonup;
  114263. private _ondpaddown;
  114264. private _ondpadup;
  114265. /** Observable raised when a button is pressed */
  114266. onButtonDownObservable: Observable<Xbox360Button>;
  114267. /** Observable raised when a button is released */
  114268. onButtonUpObservable: Observable<Xbox360Button>;
  114269. /** Observable raised when a pad is pressed */
  114270. onPadDownObservable: Observable<Xbox360Dpad>;
  114271. /** Observable raised when a pad is released */
  114272. onPadUpObservable: Observable<Xbox360Dpad>;
  114273. private _buttonA;
  114274. private _buttonB;
  114275. private _buttonX;
  114276. private _buttonY;
  114277. private _buttonBack;
  114278. private _buttonStart;
  114279. private _buttonLB;
  114280. private _buttonRB;
  114281. private _buttonLeftStick;
  114282. private _buttonRightStick;
  114283. private _dPadUp;
  114284. private _dPadDown;
  114285. private _dPadLeft;
  114286. private _dPadRight;
  114287. private _isXboxOnePad;
  114288. /**
  114289. * Creates a new XBox360 gamepad object
  114290. * @param id defines the id of this gamepad
  114291. * @param index defines its index
  114292. * @param gamepad defines the internal HTML gamepad object
  114293. * @param xboxOne defines if it is a XBox One gamepad
  114294. */
  114295. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  114296. /**
  114297. * Defines the callback to call when left trigger is pressed
  114298. * @param callback defines the callback to use
  114299. */
  114300. onlefttriggerchanged(callback: (value: number) => void): void;
  114301. /**
  114302. * Defines the callback to call when right trigger is pressed
  114303. * @param callback defines the callback to use
  114304. */
  114305. onrighttriggerchanged(callback: (value: number) => void): void;
  114306. /**
  114307. * Gets the left trigger value
  114308. */
  114309. get leftTrigger(): number;
  114310. /**
  114311. * Sets the left trigger value
  114312. */
  114313. set leftTrigger(newValue: number);
  114314. /**
  114315. * Gets the right trigger value
  114316. */
  114317. get rightTrigger(): number;
  114318. /**
  114319. * Sets the right trigger value
  114320. */
  114321. set rightTrigger(newValue: number);
  114322. /**
  114323. * Defines the callback to call when a button is pressed
  114324. * @param callback defines the callback to use
  114325. */
  114326. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  114327. /**
  114328. * Defines the callback to call when a button is released
  114329. * @param callback defines the callback to use
  114330. */
  114331. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  114332. /**
  114333. * Defines the callback to call when a pad is pressed
  114334. * @param callback defines the callback to use
  114335. */
  114336. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  114337. /**
  114338. * Defines the callback to call when a pad is released
  114339. * @param callback defines the callback to use
  114340. */
  114341. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  114342. private _setButtonValue;
  114343. private _setDPadValue;
  114344. /**
  114345. * Gets the value of the `A` button
  114346. */
  114347. get buttonA(): number;
  114348. /**
  114349. * Sets the value of the `A` button
  114350. */
  114351. set buttonA(value: number);
  114352. /**
  114353. * Gets the value of the `B` button
  114354. */
  114355. get buttonB(): number;
  114356. /**
  114357. * Sets the value of the `B` button
  114358. */
  114359. set buttonB(value: number);
  114360. /**
  114361. * Gets the value of the `X` button
  114362. */
  114363. get buttonX(): number;
  114364. /**
  114365. * Sets the value of the `X` button
  114366. */
  114367. set buttonX(value: number);
  114368. /**
  114369. * Gets the value of the `Y` button
  114370. */
  114371. get buttonY(): number;
  114372. /**
  114373. * Sets the value of the `Y` button
  114374. */
  114375. set buttonY(value: number);
  114376. /**
  114377. * Gets the value of the `Start` button
  114378. */
  114379. get buttonStart(): number;
  114380. /**
  114381. * Sets the value of the `Start` button
  114382. */
  114383. set buttonStart(value: number);
  114384. /**
  114385. * Gets the value of the `Back` button
  114386. */
  114387. get buttonBack(): number;
  114388. /**
  114389. * Sets the value of the `Back` button
  114390. */
  114391. set buttonBack(value: number);
  114392. /**
  114393. * Gets the value of the `Left` button
  114394. */
  114395. get buttonLB(): number;
  114396. /**
  114397. * Sets the value of the `Left` button
  114398. */
  114399. set buttonLB(value: number);
  114400. /**
  114401. * Gets the value of the `Right` button
  114402. */
  114403. get buttonRB(): number;
  114404. /**
  114405. * Sets the value of the `Right` button
  114406. */
  114407. set buttonRB(value: number);
  114408. /**
  114409. * Gets the value of the Left joystick
  114410. */
  114411. get buttonLeftStick(): number;
  114412. /**
  114413. * Sets the value of the Left joystick
  114414. */
  114415. set buttonLeftStick(value: number);
  114416. /**
  114417. * Gets the value of the Right joystick
  114418. */
  114419. get buttonRightStick(): number;
  114420. /**
  114421. * Sets the value of the Right joystick
  114422. */
  114423. set buttonRightStick(value: number);
  114424. /**
  114425. * Gets the value of D-pad up
  114426. */
  114427. get dPadUp(): number;
  114428. /**
  114429. * Sets the value of D-pad up
  114430. */
  114431. set dPadUp(value: number);
  114432. /**
  114433. * Gets the value of D-pad down
  114434. */
  114435. get dPadDown(): number;
  114436. /**
  114437. * Sets the value of D-pad down
  114438. */
  114439. set dPadDown(value: number);
  114440. /**
  114441. * Gets the value of D-pad left
  114442. */
  114443. get dPadLeft(): number;
  114444. /**
  114445. * Sets the value of D-pad left
  114446. */
  114447. set dPadLeft(value: number);
  114448. /**
  114449. * Gets the value of D-pad right
  114450. */
  114451. get dPadRight(): number;
  114452. /**
  114453. * Sets the value of D-pad right
  114454. */
  114455. set dPadRight(value: number);
  114456. /**
  114457. * Force the gamepad to synchronize with device values
  114458. */
  114459. update(): void;
  114460. /**
  114461. * Disposes the gamepad
  114462. */
  114463. dispose(): void;
  114464. }
  114465. }
  114466. declare module BABYLON {
  114467. /**
  114468. * Defines supported buttons for DualShock compatible gamepads
  114469. */
  114470. export enum DualShockButton {
  114471. /** Cross */
  114472. Cross = 0,
  114473. /** Circle */
  114474. Circle = 1,
  114475. /** Square */
  114476. Square = 2,
  114477. /** Triangle */
  114478. Triangle = 3,
  114479. /** L1 */
  114480. L1 = 4,
  114481. /** R1 */
  114482. R1 = 5,
  114483. /** Share */
  114484. Share = 8,
  114485. /** Options */
  114486. Options = 9,
  114487. /** Left stick */
  114488. LeftStick = 10,
  114489. /** Right stick */
  114490. RightStick = 11
  114491. }
  114492. /** Defines values for DualShock DPad */
  114493. export enum DualShockDpad {
  114494. /** Up */
  114495. Up = 12,
  114496. /** Down */
  114497. Down = 13,
  114498. /** Left */
  114499. Left = 14,
  114500. /** Right */
  114501. Right = 15
  114502. }
  114503. /**
  114504. * Defines a DualShock gamepad
  114505. */
  114506. export class DualShockPad extends Gamepad {
  114507. private _leftTrigger;
  114508. private _rightTrigger;
  114509. private _onlefttriggerchanged;
  114510. private _onrighttriggerchanged;
  114511. private _onbuttondown;
  114512. private _onbuttonup;
  114513. private _ondpaddown;
  114514. private _ondpadup;
  114515. /** Observable raised when a button is pressed */
  114516. onButtonDownObservable: Observable<DualShockButton>;
  114517. /** Observable raised when a button is released */
  114518. onButtonUpObservable: Observable<DualShockButton>;
  114519. /** Observable raised when a pad is pressed */
  114520. onPadDownObservable: Observable<DualShockDpad>;
  114521. /** Observable raised when a pad is released */
  114522. onPadUpObservable: Observable<DualShockDpad>;
  114523. private _buttonCross;
  114524. private _buttonCircle;
  114525. private _buttonSquare;
  114526. private _buttonTriangle;
  114527. private _buttonShare;
  114528. private _buttonOptions;
  114529. private _buttonL1;
  114530. private _buttonR1;
  114531. private _buttonLeftStick;
  114532. private _buttonRightStick;
  114533. private _dPadUp;
  114534. private _dPadDown;
  114535. private _dPadLeft;
  114536. private _dPadRight;
  114537. /**
  114538. * Creates a new DualShock gamepad object
  114539. * @param id defines the id of this gamepad
  114540. * @param index defines its index
  114541. * @param gamepad defines the internal HTML gamepad object
  114542. */
  114543. constructor(id: string, index: number, gamepad: any);
  114544. /**
  114545. * Defines the callback to call when left trigger is pressed
  114546. * @param callback defines the callback to use
  114547. */
  114548. onlefttriggerchanged(callback: (value: number) => void): void;
  114549. /**
  114550. * Defines the callback to call when right trigger is pressed
  114551. * @param callback defines the callback to use
  114552. */
  114553. onrighttriggerchanged(callback: (value: number) => void): void;
  114554. /**
  114555. * Gets the left trigger value
  114556. */
  114557. get leftTrigger(): number;
  114558. /**
  114559. * Sets the left trigger value
  114560. */
  114561. set leftTrigger(newValue: number);
  114562. /**
  114563. * Gets the right trigger value
  114564. */
  114565. get rightTrigger(): number;
  114566. /**
  114567. * Sets the right trigger value
  114568. */
  114569. set rightTrigger(newValue: number);
  114570. /**
  114571. * Defines the callback to call when a button is pressed
  114572. * @param callback defines the callback to use
  114573. */
  114574. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  114575. /**
  114576. * Defines the callback to call when a button is released
  114577. * @param callback defines the callback to use
  114578. */
  114579. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  114580. /**
  114581. * Defines the callback to call when a pad is pressed
  114582. * @param callback defines the callback to use
  114583. */
  114584. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  114585. /**
  114586. * Defines the callback to call when a pad is released
  114587. * @param callback defines the callback to use
  114588. */
  114589. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  114590. private _setButtonValue;
  114591. private _setDPadValue;
  114592. /**
  114593. * Gets the value of the `Cross` button
  114594. */
  114595. get buttonCross(): number;
  114596. /**
  114597. * Sets the value of the `Cross` button
  114598. */
  114599. set buttonCross(value: number);
  114600. /**
  114601. * Gets the value of the `Circle` button
  114602. */
  114603. get buttonCircle(): number;
  114604. /**
  114605. * Sets the value of the `Circle` button
  114606. */
  114607. set buttonCircle(value: number);
  114608. /**
  114609. * Gets the value of the `Square` button
  114610. */
  114611. get buttonSquare(): number;
  114612. /**
  114613. * Sets the value of the `Square` button
  114614. */
  114615. set buttonSquare(value: number);
  114616. /**
  114617. * Gets the value of the `Triangle` button
  114618. */
  114619. get buttonTriangle(): number;
  114620. /**
  114621. * Sets the value of the `Triangle` button
  114622. */
  114623. set buttonTriangle(value: number);
  114624. /**
  114625. * Gets the value of the `Options` button
  114626. */
  114627. get buttonOptions(): number;
  114628. /**
  114629. * Sets the value of the `Options` button
  114630. */
  114631. set buttonOptions(value: number);
  114632. /**
  114633. * Gets the value of the `Share` button
  114634. */
  114635. get buttonShare(): number;
  114636. /**
  114637. * Sets the value of the `Share` button
  114638. */
  114639. set buttonShare(value: number);
  114640. /**
  114641. * Gets the value of the `L1` button
  114642. */
  114643. get buttonL1(): number;
  114644. /**
  114645. * Sets the value of the `L1` button
  114646. */
  114647. set buttonL1(value: number);
  114648. /**
  114649. * Gets the value of the `R1` button
  114650. */
  114651. get buttonR1(): number;
  114652. /**
  114653. * Sets the value of the `R1` button
  114654. */
  114655. set buttonR1(value: number);
  114656. /**
  114657. * Gets the value of the Left joystick
  114658. */
  114659. get buttonLeftStick(): number;
  114660. /**
  114661. * Sets the value of the Left joystick
  114662. */
  114663. set buttonLeftStick(value: number);
  114664. /**
  114665. * Gets the value of the Right joystick
  114666. */
  114667. get buttonRightStick(): number;
  114668. /**
  114669. * Sets the value of the Right joystick
  114670. */
  114671. set buttonRightStick(value: number);
  114672. /**
  114673. * Gets the value of D-pad up
  114674. */
  114675. get dPadUp(): number;
  114676. /**
  114677. * Sets the value of D-pad up
  114678. */
  114679. set dPadUp(value: number);
  114680. /**
  114681. * Gets the value of D-pad down
  114682. */
  114683. get dPadDown(): number;
  114684. /**
  114685. * Sets the value of D-pad down
  114686. */
  114687. set dPadDown(value: number);
  114688. /**
  114689. * Gets the value of D-pad left
  114690. */
  114691. get dPadLeft(): number;
  114692. /**
  114693. * Sets the value of D-pad left
  114694. */
  114695. set dPadLeft(value: number);
  114696. /**
  114697. * Gets the value of D-pad right
  114698. */
  114699. get dPadRight(): number;
  114700. /**
  114701. * Sets the value of D-pad right
  114702. */
  114703. set dPadRight(value: number);
  114704. /**
  114705. * Force the gamepad to synchronize with device values
  114706. */
  114707. update(): void;
  114708. /**
  114709. * Disposes the gamepad
  114710. */
  114711. dispose(): void;
  114712. }
  114713. }
  114714. declare module BABYLON {
  114715. /**
  114716. * Manager for handling gamepads
  114717. */
  114718. export class GamepadManager {
  114719. private _scene?;
  114720. private _babylonGamepads;
  114721. private _oneGamepadConnected;
  114722. /** @hidden */
  114723. _isMonitoring: boolean;
  114724. private _gamepadEventSupported;
  114725. private _gamepadSupport?;
  114726. /**
  114727. * observable to be triggered when the gamepad controller has been connected
  114728. */
  114729. onGamepadConnectedObservable: Observable<Gamepad>;
  114730. /**
  114731. * observable to be triggered when the gamepad controller has been disconnected
  114732. */
  114733. onGamepadDisconnectedObservable: Observable<Gamepad>;
  114734. private _onGamepadConnectedEvent;
  114735. private _onGamepadDisconnectedEvent;
  114736. /**
  114737. * Initializes the gamepad manager
  114738. * @param _scene BabylonJS scene
  114739. */
  114740. constructor(_scene?: Scene | undefined);
  114741. /**
  114742. * The gamepads in the game pad manager
  114743. */
  114744. get gamepads(): Gamepad[];
  114745. /**
  114746. * Get the gamepad controllers based on type
  114747. * @param type The type of gamepad controller
  114748. * @returns Nullable gamepad
  114749. */
  114750. getGamepadByType(type?: number): Nullable<Gamepad>;
  114751. /**
  114752. * Disposes the gamepad manager
  114753. */
  114754. dispose(): void;
  114755. private _addNewGamepad;
  114756. private _startMonitoringGamepads;
  114757. private _stopMonitoringGamepads;
  114758. /** @hidden */
  114759. _checkGamepadsStatus(): void;
  114760. private _updateGamepadObjects;
  114761. }
  114762. }
  114763. declare module BABYLON {
  114764. interface Scene {
  114765. /** @hidden */
  114766. _gamepadManager: Nullable<GamepadManager>;
  114767. /**
  114768. * Gets the gamepad manager associated with the scene
  114769. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  114770. */
  114771. gamepadManager: GamepadManager;
  114772. }
  114773. /**
  114774. * Interface representing a free camera inputs manager
  114775. */
  114776. interface FreeCameraInputsManager {
  114777. /**
  114778. * Adds gamepad input support to the FreeCameraInputsManager.
  114779. * @returns the FreeCameraInputsManager
  114780. */
  114781. addGamepad(): FreeCameraInputsManager;
  114782. }
  114783. /**
  114784. * Interface representing an arc rotate camera inputs manager
  114785. */
  114786. interface ArcRotateCameraInputsManager {
  114787. /**
  114788. * Adds gamepad input support to the ArcRotateCamera InputManager.
  114789. * @returns the camera inputs manager
  114790. */
  114791. addGamepad(): ArcRotateCameraInputsManager;
  114792. }
  114793. /**
  114794. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  114795. */
  114796. export class GamepadSystemSceneComponent implements ISceneComponent {
  114797. /**
  114798. * The component name helpfull to identify the component in the list of scene components.
  114799. */
  114800. readonly name: string;
  114801. /**
  114802. * The scene the component belongs to.
  114803. */
  114804. scene: Scene;
  114805. /**
  114806. * Creates a new instance of the component for the given scene
  114807. * @param scene Defines the scene to register the component in
  114808. */
  114809. constructor(scene: Scene);
  114810. /**
  114811. * Registers the component in a given scene
  114812. */
  114813. register(): void;
  114814. /**
  114815. * Rebuilds the elements related to this component in case of
  114816. * context lost for instance.
  114817. */
  114818. rebuild(): void;
  114819. /**
  114820. * Disposes the component and the associated ressources
  114821. */
  114822. dispose(): void;
  114823. private _beforeCameraUpdate;
  114824. }
  114825. }
  114826. declare module BABYLON {
  114827. /**
  114828. * 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,
  114829. * which still works and will still be found in many Playgrounds.
  114830. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114831. */
  114832. export class UniversalCamera extends TouchCamera {
  114833. /**
  114834. * Defines the gamepad rotation sensiblity.
  114835. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114836. */
  114837. get gamepadAngularSensibility(): number;
  114838. set gamepadAngularSensibility(value: number);
  114839. /**
  114840. * Defines the gamepad move sensiblity.
  114841. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114842. */
  114843. get gamepadMoveSensibility(): number;
  114844. set gamepadMoveSensibility(value: number);
  114845. /**
  114846. * 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,
  114847. * which still works and will still be found in many Playgrounds.
  114848. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114849. * @param name Define the name of the camera in the scene
  114850. * @param position Define the start position of the camera in the scene
  114851. * @param scene Define the scene the camera belongs to
  114852. */
  114853. constructor(name: string, position: Vector3, scene: Scene);
  114854. /**
  114855. * Gets the current object class name.
  114856. * @return the class name
  114857. */
  114858. getClassName(): string;
  114859. }
  114860. }
  114861. declare module BABYLON {
  114862. /**
  114863. * This represents a FPS type of camera. This is only here for back compat purpose.
  114864. * Please use the UniversalCamera instead as both are identical.
  114865. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114866. */
  114867. export class GamepadCamera extends UniversalCamera {
  114868. /**
  114869. * Instantiates a new Gamepad Camera
  114870. * This represents a FPS type of camera. This is only here for back compat purpose.
  114871. * Please use the UniversalCamera instead as both are identical.
  114872. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114873. * @param name Define the name of the camera in the scene
  114874. * @param position Define the start position of the camera in the scene
  114875. * @param scene Define the scene the camera belongs to
  114876. */
  114877. constructor(name: string, position: Vector3, scene: Scene);
  114878. /**
  114879. * Gets the current object class name.
  114880. * @return the class name
  114881. */
  114882. getClassName(): string;
  114883. }
  114884. }
  114885. declare module BABYLON {
  114886. /** @hidden */
  114887. export var passPixelShader: {
  114888. name: string;
  114889. shader: string;
  114890. };
  114891. }
  114892. declare module BABYLON {
  114893. /** @hidden */
  114894. export var passCubePixelShader: {
  114895. name: string;
  114896. shader: string;
  114897. };
  114898. }
  114899. declare module BABYLON {
  114900. /**
  114901. * PassPostProcess which produces an output the same as it's input
  114902. */
  114903. export class PassPostProcess extends PostProcess {
  114904. /**
  114905. * Creates the PassPostProcess
  114906. * @param name The name of the effect.
  114907. * @param options The required width/height ratio to downsize to before computing the render pass.
  114908. * @param camera The camera to apply the render pass to.
  114909. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114910. * @param engine The engine which the post process will be applied. (default: current engine)
  114911. * @param reusable If the post process can be reused on the same frame. (default: false)
  114912. * @param textureType The type of texture to be used when performing the post processing.
  114913. * @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)
  114914. */
  114915. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114916. }
  114917. /**
  114918. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  114919. */
  114920. export class PassCubePostProcess extends PostProcess {
  114921. private _face;
  114922. /**
  114923. * Gets or sets the cube face to display.
  114924. * * 0 is +X
  114925. * * 1 is -X
  114926. * * 2 is +Y
  114927. * * 3 is -Y
  114928. * * 4 is +Z
  114929. * * 5 is -Z
  114930. */
  114931. get face(): number;
  114932. set face(value: number);
  114933. /**
  114934. * Creates the PassCubePostProcess
  114935. * @param name The name of the effect.
  114936. * @param options The required width/height ratio to downsize to before computing the render pass.
  114937. * @param camera The camera to apply the render pass to.
  114938. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114939. * @param engine The engine which the post process will be applied. (default: current engine)
  114940. * @param reusable If the post process can be reused on the same frame. (default: false)
  114941. * @param textureType The type of texture to be used when performing the post processing.
  114942. * @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)
  114943. */
  114944. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114945. }
  114946. }
  114947. declare module BABYLON {
  114948. /** @hidden */
  114949. export var anaglyphPixelShader: {
  114950. name: string;
  114951. shader: string;
  114952. };
  114953. }
  114954. declare module BABYLON {
  114955. /**
  114956. * Postprocess used to generate anaglyphic rendering
  114957. */
  114958. export class AnaglyphPostProcess extends PostProcess {
  114959. private _passedProcess;
  114960. /**
  114961. * Creates a new AnaglyphPostProcess
  114962. * @param name defines postprocess name
  114963. * @param options defines creation options or target ratio scale
  114964. * @param rigCameras defines cameras using this postprocess
  114965. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  114966. * @param engine defines hosting engine
  114967. * @param reusable defines if the postprocess will be reused multiple times per frame
  114968. */
  114969. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  114970. }
  114971. }
  114972. declare module BABYLON {
  114973. /**
  114974. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  114975. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114976. */
  114977. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  114978. /**
  114979. * Creates a new AnaglyphArcRotateCamera
  114980. * @param name defines camera name
  114981. * @param alpha defines alpha angle (in radians)
  114982. * @param beta defines beta angle (in radians)
  114983. * @param radius defines radius
  114984. * @param target defines camera target
  114985. * @param interaxialDistance defines distance between each color axis
  114986. * @param scene defines the hosting scene
  114987. */
  114988. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  114989. /**
  114990. * Gets camera class name
  114991. * @returns AnaglyphArcRotateCamera
  114992. */
  114993. getClassName(): string;
  114994. }
  114995. }
  114996. declare module BABYLON {
  114997. /**
  114998. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  114999. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115000. */
  115001. export class AnaglyphFreeCamera extends FreeCamera {
  115002. /**
  115003. * Creates a new AnaglyphFreeCamera
  115004. * @param name defines camera name
  115005. * @param position defines initial position
  115006. * @param interaxialDistance defines distance between each color axis
  115007. * @param scene defines the hosting scene
  115008. */
  115009. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115010. /**
  115011. * Gets camera class name
  115012. * @returns AnaglyphFreeCamera
  115013. */
  115014. getClassName(): string;
  115015. }
  115016. }
  115017. declare module BABYLON {
  115018. /**
  115019. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  115020. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115021. */
  115022. export class AnaglyphGamepadCamera extends GamepadCamera {
  115023. /**
  115024. * Creates a new AnaglyphGamepadCamera
  115025. * @param name defines camera name
  115026. * @param position defines initial position
  115027. * @param interaxialDistance defines distance between each color axis
  115028. * @param scene defines the hosting scene
  115029. */
  115030. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115031. /**
  115032. * Gets camera class name
  115033. * @returns AnaglyphGamepadCamera
  115034. */
  115035. getClassName(): string;
  115036. }
  115037. }
  115038. declare module BABYLON {
  115039. /**
  115040. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  115041. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115042. */
  115043. export class AnaglyphUniversalCamera extends UniversalCamera {
  115044. /**
  115045. * Creates a new AnaglyphUniversalCamera
  115046. * @param name defines camera name
  115047. * @param position defines initial position
  115048. * @param interaxialDistance defines distance between each color axis
  115049. * @param scene defines the hosting scene
  115050. */
  115051. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115052. /**
  115053. * Gets camera class name
  115054. * @returns AnaglyphUniversalCamera
  115055. */
  115056. getClassName(): string;
  115057. }
  115058. }
  115059. declare module BABYLON {
  115060. /** @hidden */
  115061. export var stereoscopicInterlacePixelShader: {
  115062. name: string;
  115063. shader: string;
  115064. };
  115065. }
  115066. declare module BABYLON {
  115067. /**
  115068. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  115069. */
  115070. export class StereoscopicInterlacePostProcessI extends PostProcess {
  115071. private _stepSize;
  115072. private _passedProcess;
  115073. /**
  115074. * Initializes a StereoscopicInterlacePostProcessI
  115075. * @param name The name of the effect.
  115076. * @param rigCameras The rig cameras to be appled to the post process
  115077. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  115078. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  115079. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115080. * @param engine The engine which the post process will be applied. (default: current engine)
  115081. * @param reusable If the post process can be reused on the same frame. (default: false)
  115082. */
  115083. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115084. }
  115085. /**
  115086. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  115087. */
  115088. export class StereoscopicInterlacePostProcess extends PostProcess {
  115089. private _stepSize;
  115090. private _passedProcess;
  115091. /**
  115092. * Initializes a StereoscopicInterlacePostProcess
  115093. * @param name The name of the effect.
  115094. * @param rigCameras The rig cameras to be appled to the post process
  115095. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  115096. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115097. * @param engine The engine which the post process will be applied. (default: current engine)
  115098. * @param reusable If the post process can be reused on the same frame. (default: false)
  115099. */
  115100. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115101. }
  115102. }
  115103. declare module BABYLON {
  115104. /**
  115105. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  115106. * @see http://doc.babylonjs.com/features/cameras
  115107. */
  115108. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  115109. /**
  115110. * Creates a new StereoscopicArcRotateCamera
  115111. * @param name defines camera name
  115112. * @param alpha defines alpha angle (in radians)
  115113. * @param beta defines beta angle (in radians)
  115114. * @param radius defines radius
  115115. * @param target defines camera target
  115116. * @param interaxialDistance defines distance between each color axis
  115117. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115118. * @param scene defines the hosting scene
  115119. */
  115120. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115121. /**
  115122. * Gets camera class name
  115123. * @returns StereoscopicArcRotateCamera
  115124. */
  115125. getClassName(): string;
  115126. }
  115127. }
  115128. declare module BABYLON {
  115129. /**
  115130. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  115131. * @see http://doc.babylonjs.com/features/cameras
  115132. */
  115133. export class StereoscopicFreeCamera extends FreeCamera {
  115134. /**
  115135. * Creates a new StereoscopicFreeCamera
  115136. * @param name defines camera name
  115137. * @param position defines initial position
  115138. * @param interaxialDistance defines distance between each color axis
  115139. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115140. * @param scene defines the hosting scene
  115141. */
  115142. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115143. /**
  115144. * Gets camera class name
  115145. * @returns StereoscopicFreeCamera
  115146. */
  115147. getClassName(): string;
  115148. }
  115149. }
  115150. declare module BABYLON {
  115151. /**
  115152. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  115153. * @see http://doc.babylonjs.com/features/cameras
  115154. */
  115155. export class StereoscopicGamepadCamera extends GamepadCamera {
  115156. /**
  115157. * Creates a new StereoscopicGamepadCamera
  115158. * @param name defines camera name
  115159. * @param position defines initial position
  115160. * @param interaxialDistance defines distance between each color axis
  115161. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115162. * @param scene defines the hosting scene
  115163. */
  115164. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115165. /**
  115166. * Gets camera class name
  115167. * @returns StereoscopicGamepadCamera
  115168. */
  115169. getClassName(): string;
  115170. }
  115171. }
  115172. declare module BABYLON {
  115173. /**
  115174. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  115175. * @see http://doc.babylonjs.com/features/cameras
  115176. */
  115177. export class StereoscopicUniversalCamera extends UniversalCamera {
  115178. /**
  115179. * Creates a new StereoscopicUniversalCamera
  115180. * @param name defines camera name
  115181. * @param position defines initial position
  115182. * @param interaxialDistance defines distance between each color axis
  115183. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115184. * @param scene defines the hosting scene
  115185. */
  115186. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115187. /**
  115188. * Gets camera class name
  115189. * @returns StereoscopicUniversalCamera
  115190. */
  115191. getClassName(): string;
  115192. }
  115193. }
  115194. declare module BABYLON {
  115195. /**
  115196. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  115197. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115198. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115199. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115200. */
  115201. export class VirtualJoysticksCamera extends FreeCamera {
  115202. /**
  115203. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  115204. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115205. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115206. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115207. * @param name Define the name of the camera in the scene
  115208. * @param position Define the start position of the camera in the scene
  115209. * @param scene Define the scene the camera belongs to
  115210. */
  115211. constructor(name: string, position: Vector3, scene: Scene);
  115212. /**
  115213. * Gets the current object class name.
  115214. * @return the class name
  115215. */
  115216. getClassName(): string;
  115217. }
  115218. }
  115219. declare module BABYLON {
  115220. /**
  115221. * This represents all the required metrics to create a VR camera.
  115222. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  115223. */
  115224. export class VRCameraMetrics {
  115225. /**
  115226. * Define the horizontal resolution off the screen.
  115227. */
  115228. hResolution: number;
  115229. /**
  115230. * Define the vertical resolution off the screen.
  115231. */
  115232. vResolution: number;
  115233. /**
  115234. * Define the horizontal screen size.
  115235. */
  115236. hScreenSize: number;
  115237. /**
  115238. * Define the vertical screen size.
  115239. */
  115240. vScreenSize: number;
  115241. /**
  115242. * Define the vertical screen center position.
  115243. */
  115244. vScreenCenter: number;
  115245. /**
  115246. * Define the distance of the eyes to the screen.
  115247. */
  115248. eyeToScreenDistance: number;
  115249. /**
  115250. * Define the distance between both lenses
  115251. */
  115252. lensSeparationDistance: number;
  115253. /**
  115254. * Define the distance between both viewer's eyes.
  115255. */
  115256. interpupillaryDistance: number;
  115257. /**
  115258. * Define the distortion factor of the VR postprocess.
  115259. * Please, touch with care.
  115260. */
  115261. distortionK: number[];
  115262. /**
  115263. * Define the chromatic aberration correction factors for the VR post process.
  115264. */
  115265. chromaAbCorrection: number[];
  115266. /**
  115267. * Define the scale factor of the post process.
  115268. * The smaller the better but the slower.
  115269. */
  115270. postProcessScaleFactor: number;
  115271. /**
  115272. * Define an offset for the lens center.
  115273. */
  115274. lensCenterOffset: number;
  115275. /**
  115276. * Define if the current vr camera should compensate the distortion of the lense or not.
  115277. */
  115278. compensateDistortion: boolean;
  115279. /**
  115280. * Defines if multiview should be enabled when rendering (Default: false)
  115281. */
  115282. multiviewEnabled: boolean;
  115283. /**
  115284. * Gets the rendering aspect ratio based on the provided resolutions.
  115285. */
  115286. get aspectRatio(): number;
  115287. /**
  115288. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  115289. */
  115290. get aspectRatioFov(): number;
  115291. /**
  115292. * @hidden
  115293. */
  115294. get leftHMatrix(): Matrix;
  115295. /**
  115296. * @hidden
  115297. */
  115298. get rightHMatrix(): Matrix;
  115299. /**
  115300. * @hidden
  115301. */
  115302. get leftPreViewMatrix(): Matrix;
  115303. /**
  115304. * @hidden
  115305. */
  115306. get rightPreViewMatrix(): Matrix;
  115307. /**
  115308. * Get the default VRMetrics based on the most generic setup.
  115309. * @returns the default vr metrics
  115310. */
  115311. static GetDefault(): VRCameraMetrics;
  115312. }
  115313. }
  115314. declare module BABYLON {
  115315. /** @hidden */
  115316. export var vrDistortionCorrectionPixelShader: {
  115317. name: string;
  115318. shader: string;
  115319. };
  115320. }
  115321. declare module BABYLON {
  115322. /**
  115323. * VRDistortionCorrectionPostProcess used for mobile VR
  115324. */
  115325. export class VRDistortionCorrectionPostProcess extends PostProcess {
  115326. private _isRightEye;
  115327. private _distortionFactors;
  115328. private _postProcessScaleFactor;
  115329. private _lensCenterOffset;
  115330. private _scaleIn;
  115331. private _scaleFactor;
  115332. private _lensCenter;
  115333. /**
  115334. * Initializes the VRDistortionCorrectionPostProcess
  115335. * @param name The name of the effect.
  115336. * @param camera The camera to apply the render pass to.
  115337. * @param isRightEye If this is for the right eye distortion
  115338. * @param vrMetrics All the required metrics for the VR camera
  115339. */
  115340. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  115341. }
  115342. }
  115343. declare module BABYLON {
  115344. /**
  115345. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  115346. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115347. */
  115348. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  115349. /**
  115350. * Creates a new VRDeviceOrientationArcRotateCamera
  115351. * @param name defines camera name
  115352. * @param alpha defines the camera rotation along the logitudinal axis
  115353. * @param beta defines the camera rotation along the latitudinal axis
  115354. * @param radius defines the camera distance from its target
  115355. * @param target defines the camera target
  115356. * @param scene defines the scene the camera belongs to
  115357. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115358. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115359. */
  115360. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115361. /**
  115362. * Gets camera class name
  115363. * @returns VRDeviceOrientationArcRotateCamera
  115364. */
  115365. getClassName(): string;
  115366. }
  115367. }
  115368. declare module BABYLON {
  115369. /**
  115370. * Camera used to simulate VR rendering (based on FreeCamera)
  115371. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115372. */
  115373. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  115374. /**
  115375. * Creates a new VRDeviceOrientationFreeCamera
  115376. * @param name defines camera name
  115377. * @param position defines the start position of the camera
  115378. * @param scene defines the scene the camera belongs to
  115379. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115380. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115381. */
  115382. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115383. /**
  115384. * Gets camera class name
  115385. * @returns VRDeviceOrientationFreeCamera
  115386. */
  115387. getClassName(): string;
  115388. }
  115389. }
  115390. declare module BABYLON {
  115391. /**
  115392. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  115393. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115394. */
  115395. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  115396. /**
  115397. * Creates a new VRDeviceOrientationGamepadCamera
  115398. * @param name defines camera name
  115399. * @param position defines the start position of the camera
  115400. * @param scene defines the scene the camera belongs to
  115401. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115402. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115403. */
  115404. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115405. /**
  115406. * Gets camera class name
  115407. * @returns VRDeviceOrientationGamepadCamera
  115408. */
  115409. getClassName(): string;
  115410. }
  115411. }
  115412. declare module BABYLON {
  115413. /** @hidden */
  115414. export var imageProcessingPixelShader: {
  115415. name: string;
  115416. shader: string;
  115417. };
  115418. }
  115419. declare module BABYLON {
  115420. /**
  115421. * ImageProcessingPostProcess
  115422. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  115423. */
  115424. export class ImageProcessingPostProcess extends PostProcess {
  115425. /**
  115426. * Default configuration related to image processing available in the PBR Material.
  115427. */
  115428. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115429. /**
  115430. * Gets the image processing configuration used either in this material.
  115431. */
  115432. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115433. /**
  115434. * Sets the Default image processing configuration used either in the this material.
  115435. *
  115436. * If sets to null, the scene one is in use.
  115437. */
  115438. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  115439. /**
  115440. * Keep track of the image processing observer to allow dispose and replace.
  115441. */
  115442. private _imageProcessingObserver;
  115443. /**
  115444. * Attaches a new image processing configuration to the PBR Material.
  115445. * @param configuration
  115446. */
  115447. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  115448. /**
  115449. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115450. */
  115451. get colorCurves(): Nullable<ColorCurves>;
  115452. /**
  115453. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115454. */
  115455. set colorCurves(value: Nullable<ColorCurves>);
  115456. /**
  115457. * Gets wether the color curves effect is enabled.
  115458. */
  115459. get colorCurvesEnabled(): boolean;
  115460. /**
  115461. * Sets wether the color curves effect is enabled.
  115462. */
  115463. set colorCurvesEnabled(value: boolean);
  115464. /**
  115465. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115466. */
  115467. get colorGradingTexture(): Nullable<BaseTexture>;
  115468. /**
  115469. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115470. */
  115471. set colorGradingTexture(value: Nullable<BaseTexture>);
  115472. /**
  115473. * Gets wether the color grading effect is enabled.
  115474. */
  115475. get colorGradingEnabled(): boolean;
  115476. /**
  115477. * Gets wether the color grading effect is enabled.
  115478. */
  115479. set colorGradingEnabled(value: boolean);
  115480. /**
  115481. * Gets exposure used in the effect.
  115482. */
  115483. get exposure(): number;
  115484. /**
  115485. * Sets exposure used in the effect.
  115486. */
  115487. set exposure(value: number);
  115488. /**
  115489. * Gets wether tonemapping is enabled or not.
  115490. */
  115491. get toneMappingEnabled(): boolean;
  115492. /**
  115493. * Sets wether tonemapping is enabled or not
  115494. */
  115495. set toneMappingEnabled(value: boolean);
  115496. /**
  115497. * Gets the type of tone mapping effect.
  115498. */
  115499. get toneMappingType(): number;
  115500. /**
  115501. * Sets the type of tone mapping effect.
  115502. */
  115503. set toneMappingType(value: number);
  115504. /**
  115505. * Gets contrast used in the effect.
  115506. */
  115507. get contrast(): number;
  115508. /**
  115509. * Sets contrast used in the effect.
  115510. */
  115511. set contrast(value: number);
  115512. /**
  115513. * Gets Vignette stretch size.
  115514. */
  115515. get vignetteStretch(): number;
  115516. /**
  115517. * Sets Vignette stretch size.
  115518. */
  115519. set vignetteStretch(value: number);
  115520. /**
  115521. * Gets Vignette centre X Offset.
  115522. */
  115523. get vignetteCentreX(): number;
  115524. /**
  115525. * Sets Vignette centre X Offset.
  115526. */
  115527. set vignetteCentreX(value: number);
  115528. /**
  115529. * Gets Vignette centre Y Offset.
  115530. */
  115531. get vignetteCentreY(): number;
  115532. /**
  115533. * Sets Vignette centre Y Offset.
  115534. */
  115535. set vignetteCentreY(value: number);
  115536. /**
  115537. * Gets Vignette weight or intensity of the vignette effect.
  115538. */
  115539. get vignetteWeight(): number;
  115540. /**
  115541. * Sets Vignette weight or intensity of the vignette effect.
  115542. */
  115543. set vignetteWeight(value: number);
  115544. /**
  115545. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115546. * if vignetteEnabled is set to true.
  115547. */
  115548. get vignetteColor(): Color4;
  115549. /**
  115550. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115551. * if vignetteEnabled is set to true.
  115552. */
  115553. set vignetteColor(value: Color4);
  115554. /**
  115555. * Gets Camera field of view used by the Vignette effect.
  115556. */
  115557. get vignetteCameraFov(): number;
  115558. /**
  115559. * Sets Camera field of view used by the Vignette effect.
  115560. */
  115561. set vignetteCameraFov(value: number);
  115562. /**
  115563. * Gets the vignette blend mode allowing different kind of effect.
  115564. */
  115565. get vignetteBlendMode(): number;
  115566. /**
  115567. * Sets the vignette blend mode allowing different kind of effect.
  115568. */
  115569. set vignetteBlendMode(value: number);
  115570. /**
  115571. * Gets wether the vignette effect is enabled.
  115572. */
  115573. get vignetteEnabled(): boolean;
  115574. /**
  115575. * Sets wether the vignette effect is enabled.
  115576. */
  115577. set vignetteEnabled(value: boolean);
  115578. private _fromLinearSpace;
  115579. /**
  115580. * Gets wether the input of the processing is in Gamma or Linear Space.
  115581. */
  115582. get fromLinearSpace(): boolean;
  115583. /**
  115584. * Sets wether the input of the processing is in Gamma or Linear Space.
  115585. */
  115586. set fromLinearSpace(value: boolean);
  115587. /**
  115588. * Defines cache preventing GC.
  115589. */
  115590. private _defines;
  115591. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  115592. /**
  115593. * "ImageProcessingPostProcess"
  115594. * @returns "ImageProcessingPostProcess"
  115595. */
  115596. getClassName(): string;
  115597. protected _updateParameters(): void;
  115598. dispose(camera?: Camera): void;
  115599. }
  115600. }
  115601. declare module BABYLON {
  115602. /**
  115603. * Class containing static functions to help procedurally build meshes
  115604. */
  115605. export class GroundBuilder {
  115606. /**
  115607. * Creates a ground mesh
  115608. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115609. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115611. * @param name defines the name of the mesh
  115612. * @param options defines the options used to create the mesh
  115613. * @param scene defines the hosting scene
  115614. * @returns the ground mesh
  115615. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115616. */
  115617. static CreateGround(name: string, options: {
  115618. width?: number;
  115619. height?: number;
  115620. subdivisions?: number;
  115621. subdivisionsX?: number;
  115622. subdivisionsY?: number;
  115623. updatable?: boolean;
  115624. }, scene: any): Mesh;
  115625. /**
  115626. * Creates a tiled ground mesh
  115627. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115628. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115629. * * 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
  115630. * * 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
  115631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115632. * @param name defines the name of the mesh
  115633. * @param options defines the options used to create the mesh
  115634. * @param scene defines the hosting scene
  115635. * @returns the tiled ground mesh
  115636. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115637. */
  115638. static CreateTiledGround(name: string, options: {
  115639. xmin: number;
  115640. zmin: number;
  115641. xmax: number;
  115642. zmax: number;
  115643. subdivisions?: {
  115644. w: number;
  115645. h: number;
  115646. };
  115647. precision?: {
  115648. w: number;
  115649. h: number;
  115650. };
  115651. updatable?: boolean;
  115652. }, scene?: Nullable<Scene>): Mesh;
  115653. /**
  115654. * Creates a ground mesh from a height map
  115655. * * The parameter `url` sets the URL of the height map image resource.
  115656. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115657. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115658. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115659. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115660. * * 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.
  115661. * * 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).
  115662. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115664. * @param name defines the name of the mesh
  115665. * @param url defines the url to the height map
  115666. * @param options defines the options used to create the mesh
  115667. * @param scene defines the hosting scene
  115668. * @returns the ground mesh
  115669. * @see https://doc.babylonjs.com/babylon101/height_map
  115670. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115671. */
  115672. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115673. width?: number;
  115674. height?: number;
  115675. subdivisions?: number;
  115676. minHeight?: number;
  115677. maxHeight?: number;
  115678. colorFilter?: Color3;
  115679. alphaFilter?: number;
  115680. updatable?: boolean;
  115681. onReady?: (mesh: GroundMesh) => void;
  115682. }, scene?: Nullable<Scene>): GroundMesh;
  115683. }
  115684. }
  115685. declare module BABYLON {
  115686. /**
  115687. * Class containing static functions to help procedurally build meshes
  115688. */
  115689. export class TorusBuilder {
  115690. /**
  115691. * Creates a torus mesh
  115692. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115693. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115694. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115696. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115698. * @param name defines the name of the mesh
  115699. * @param options defines the options used to create the mesh
  115700. * @param scene defines the hosting scene
  115701. * @returns the torus mesh
  115702. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115703. */
  115704. static CreateTorus(name: string, options: {
  115705. diameter?: number;
  115706. thickness?: number;
  115707. tessellation?: number;
  115708. updatable?: boolean;
  115709. sideOrientation?: number;
  115710. frontUVs?: Vector4;
  115711. backUVs?: Vector4;
  115712. }, scene: any): Mesh;
  115713. }
  115714. }
  115715. declare module BABYLON {
  115716. /**
  115717. * Class containing static functions to help procedurally build meshes
  115718. */
  115719. export class CylinderBuilder {
  115720. /**
  115721. * Creates a cylinder or a cone mesh
  115722. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115723. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115724. * * 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.
  115725. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115726. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115727. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115728. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115729. * * 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).
  115730. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115731. * * 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).
  115732. * * 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
  115733. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115734. * * 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
  115735. * * 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.
  115736. * * If `enclose` is false, a ring surface is one element.
  115737. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115738. * * 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
  115739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115740. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115742. * @param name defines the name of the mesh
  115743. * @param options defines the options used to create the mesh
  115744. * @param scene defines the hosting scene
  115745. * @returns the cylinder mesh
  115746. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115747. */
  115748. static CreateCylinder(name: string, options: {
  115749. height?: number;
  115750. diameterTop?: number;
  115751. diameterBottom?: number;
  115752. diameter?: number;
  115753. tessellation?: number;
  115754. subdivisions?: number;
  115755. arc?: number;
  115756. faceColors?: Color4[];
  115757. faceUV?: Vector4[];
  115758. updatable?: boolean;
  115759. hasRings?: boolean;
  115760. enclose?: boolean;
  115761. cap?: number;
  115762. sideOrientation?: number;
  115763. frontUVs?: Vector4;
  115764. backUVs?: Vector4;
  115765. }, scene: any): Mesh;
  115766. }
  115767. }
  115768. declare module BABYLON {
  115769. /**
  115770. * States of the webXR experience
  115771. */
  115772. export enum WebXRState {
  115773. /**
  115774. * Transitioning to being in XR mode
  115775. */
  115776. ENTERING_XR = 0,
  115777. /**
  115778. * Transitioning to non XR mode
  115779. */
  115780. EXITING_XR = 1,
  115781. /**
  115782. * In XR mode and presenting
  115783. */
  115784. IN_XR = 2,
  115785. /**
  115786. * Not entered XR mode
  115787. */
  115788. NOT_IN_XR = 3
  115789. }
  115790. /**
  115791. * Abstraction of the XR render target
  115792. */
  115793. export interface WebXRRenderTarget extends IDisposable {
  115794. /**
  115795. * xrpresent context of the canvas which can be used to display/mirror xr content
  115796. */
  115797. canvasContext: WebGLRenderingContext;
  115798. /**
  115799. * xr layer for the canvas
  115800. */
  115801. xrLayer: Nullable<XRWebGLLayer>;
  115802. /**
  115803. * Initializes the xr layer for the session
  115804. * @param xrSession xr session
  115805. * @returns a promise that will resolve once the XR Layer has been created
  115806. */
  115807. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115808. }
  115809. }
  115810. declare module BABYLON {
  115811. /**
  115812. * COnfiguration object for WebXR output canvas
  115813. */
  115814. export class WebXRManagedOutputCanvasOptions {
  115815. /**
  115816. * An optional canvas in case you wish to create it yourself and provide it here.
  115817. * If not provided, a new canvas will be created
  115818. */
  115819. canvasElement?: HTMLCanvasElement;
  115820. /**
  115821. * Options for this XR Layer output
  115822. */
  115823. canvasOptions?: XRWebGLLayerOptions;
  115824. /**
  115825. * CSS styling for a newly created canvas (if not provided)
  115826. */
  115827. newCanvasCssStyle?: string;
  115828. /**
  115829. * Get the default values of the configuration object
  115830. * @returns default values of this configuration object
  115831. */
  115832. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  115833. }
  115834. /**
  115835. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  115836. */
  115837. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  115838. private _options;
  115839. private _canvas;
  115840. private _engine;
  115841. /**
  115842. * Rendering context of the canvas which can be used to display/mirror xr content
  115843. */
  115844. canvasContext: WebGLRenderingContext;
  115845. /**
  115846. * xr layer for the canvas
  115847. */
  115848. xrLayer: Nullable<XRWebGLLayer>;
  115849. /**
  115850. * Initializes the canvas to be added/removed upon entering/exiting xr
  115851. * @param _xrSessionManager The XR Session manager
  115852. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  115853. */
  115854. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  115855. /**
  115856. * Disposes of the object
  115857. */
  115858. dispose(): void;
  115859. /**
  115860. * Initializes the xr layer for the session
  115861. * @param xrSession xr session
  115862. * @returns a promise that will resolve once the XR Layer has been created
  115863. */
  115864. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115865. private _addCanvas;
  115866. private _removeCanvas;
  115867. private _setManagedOutputCanvas;
  115868. }
  115869. }
  115870. declare module BABYLON {
  115871. /**
  115872. * Manages an XRSession to work with Babylon's engine
  115873. * @see https://doc.babylonjs.com/how_to/webxr
  115874. */
  115875. export class WebXRSessionManager implements IDisposable {
  115876. /** The scene which the session should be created for */
  115877. scene: Scene;
  115878. private _referenceSpace;
  115879. private _rttProvider;
  115880. private _sessionEnded;
  115881. private _xrNavigator;
  115882. private baseLayer;
  115883. /**
  115884. * The base reference space from which the session started. good if you want to reset your
  115885. * reference space
  115886. */
  115887. baseReferenceSpace: XRReferenceSpace;
  115888. /**
  115889. * Current XR frame
  115890. */
  115891. currentFrame: Nullable<XRFrame>;
  115892. /** WebXR timestamp updated every frame */
  115893. currentTimestamp: number;
  115894. /**
  115895. * Used just in case of a failure to initialize an immersive session.
  115896. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  115897. */
  115898. defaultHeightCompensation: number;
  115899. /**
  115900. * Fires every time a new xrFrame arrives which can be used to update the camera
  115901. */
  115902. onXRFrameObservable: Observable<XRFrame>;
  115903. /**
  115904. * Fires when the reference space changed
  115905. */
  115906. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  115907. /**
  115908. * Fires when the xr session is ended either by the device or manually done
  115909. */
  115910. onXRSessionEnded: Observable<any>;
  115911. /**
  115912. * Fires when the xr session is ended either by the device or manually done
  115913. */
  115914. onXRSessionInit: Observable<XRSession>;
  115915. /**
  115916. * Underlying xr session
  115917. */
  115918. session: XRSession;
  115919. /**
  115920. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  115921. * or get the offset the player is currently at.
  115922. */
  115923. viewerReferenceSpace: XRReferenceSpace;
  115924. /**
  115925. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  115926. * @param scene The scene which the session should be created for
  115927. */
  115928. constructor(
  115929. /** The scene which the session should be created for */
  115930. scene: Scene);
  115931. /**
  115932. * The current reference space used in this session. This reference space can constantly change!
  115933. * It is mainly used to offset the camera's position.
  115934. */
  115935. get referenceSpace(): XRReferenceSpace;
  115936. /**
  115937. * Set a new reference space and triggers the observable
  115938. */
  115939. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  115940. /**
  115941. * Disposes of the session manager
  115942. */
  115943. dispose(): void;
  115944. /**
  115945. * Stops the xrSession and restores the render loop
  115946. * @returns Promise which resolves after it exits XR
  115947. */
  115948. exitXRAsync(): Promise<void>;
  115949. /**
  115950. * Gets the correct render target texture to be rendered this frame for this eye
  115951. * @param eye the eye for which to get the render target
  115952. * @returns the render target for the specified eye
  115953. */
  115954. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  115955. /**
  115956. * Creates a WebXRRenderTarget object for the XR session
  115957. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  115958. * @param options optional options to provide when creating a new render target
  115959. * @returns a WebXR render target to which the session can render
  115960. */
  115961. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  115962. /**
  115963. * Initializes the manager
  115964. * After initialization enterXR can be called to start an XR session
  115965. * @returns Promise which resolves after it is initialized
  115966. */
  115967. initializeAsync(): Promise<void>;
  115968. /**
  115969. * Initializes an xr session
  115970. * @param xrSessionMode mode to initialize
  115971. * @param xrSessionInit defines optional and required values to pass to the session builder
  115972. * @returns a promise which will resolve once the session has been initialized
  115973. */
  115974. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  115975. /**
  115976. * Checks if a session would be supported for the creation options specified
  115977. * @param sessionMode session mode to check if supported eg. immersive-vr
  115978. * @returns A Promise that resolves to true if supported and false if not
  115979. */
  115980. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115981. /**
  115982. * Resets the reference space to the one started the session
  115983. */
  115984. resetReferenceSpace(): void;
  115985. /**
  115986. * Starts rendering to the xr layer
  115987. */
  115988. runXRRenderLoop(): void;
  115989. /**
  115990. * Sets the reference space on the xr session
  115991. * @param referenceSpaceType space to set
  115992. * @returns a promise that will resolve once the reference space has been set
  115993. */
  115994. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  115995. /**
  115996. * Updates the render state of the session
  115997. * @param state state to set
  115998. * @returns a promise that resolves once the render state has been updated
  115999. */
  116000. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  116001. /**
  116002. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  116003. * @param sessionMode defines the session to test
  116004. * @returns a promise with boolean as final value
  116005. */
  116006. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116007. private _createRenderTargetTexture;
  116008. }
  116009. }
  116010. declare module BABYLON {
  116011. /**
  116012. * WebXR Camera which holds the views for the xrSession
  116013. * @see https://doc.babylonjs.com/how_to/webxr_camera
  116014. */
  116015. export class WebXRCamera extends FreeCamera {
  116016. private _xrSessionManager;
  116017. private _firstFrame;
  116018. private _referenceQuaternion;
  116019. private _referencedPosition;
  116020. private _xrInvPositionCache;
  116021. private _xrInvQuaternionCache;
  116022. /**
  116023. * Should position compensation execute on first frame.
  116024. * This is used when copying the position from a native (non XR) camera
  116025. */
  116026. compensateOnFirstFrame: boolean;
  116027. /**
  116028. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  116029. * @param name the name of the camera
  116030. * @param scene the scene to add the camera to
  116031. * @param _xrSessionManager a constructed xr session manager
  116032. */
  116033. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  116034. /**
  116035. * Return the user's height, unrelated to the current ground.
  116036. * This will be the y position of this camera, when ground level is 0.
  116037. */
  116038. get realWorldHeight(): number;
  116039. /** @hidden */
  116040. _updateForDualEyeDebugging(): void;
  116041. /**
  116042. * Sets this camera's transformation based on a non-vr camera
  116043. * @param otherCamera the non-vr camera to copy the transformation from
  116044. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  116045. */
  116046. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  116047. /**
  116048. * Gets the current instance class name ("WebXRCamera").
  116049. * @returns the class name
  116050. */
  116051. getClassName(): string;
  116052. private _updateFromXRSession;
  116053. private _updateNumberOfRigCameras;
  116054. private _updateReferenceSpace;
  116055. private _updateReferenceSpaceOffset;
  116056. }
  116057. }
  116058. declare module BABYLON {
  116059. /**
  116060. * Defining the interface required for a (webxr) feature
  116061. */
  116062. export interface IWebXRFeature extends IDisposable {
  116063. /**
  116064. * Is this feature attached
  116065. */
  116066. attached: boolean;
  116067. /**
  116068. * Should auto-attach be disabled?
  116069. */
  116070. disableAutoAttach: boolean;
  116071. /**
  116072. * Attach the feature to the session
  116073. * Will usually be called by the features manager
  116074. *
  116075. * @param force should attachment be forced (even when already attached)
  116076. * @returns true if successful.
  116077. */
  116078. attach(force?: boolean): boolean;
  116079. /**
  116080. * Detach the feature from the session
  116081. * Will usually be called by the features manager
  116082. *
  116083. * @returns true if successful.
  116084. */
  116085. detach(): boolean;
  116086. }
  116087. /**
  116088. * A list of the currently available features without referencing them
  116089. */
  116090. export class WebXRFeatureName {
  116091. /**
  116092. * The name of the anchor system feature
  116093. */
  116094. static ANCHOR_SYSTEM: string;
  116095. /**
  116096. * The name of the background remover feature
  116097. */
  116098. static BACKGROUND_REMOVER: string;
  116099. /**
  116100. * The name of the hit test feature
  116101. */
  116102. static HIT_TEST: string;
  116103. /**
  116104. * physics impostors for xr controllers feature
  116105. */
  116106. static PHYSICS_CONTROLLERS: string;
  116107. /**
  116108. * The name of the plane detection feature
  116109. */
  116110. static PLANE_DETECTION: string;
  116111. /**
  116112. * The name of the pointer selection feature
  116113. */
  116114. static POINTER_SELECTION: string;
  116115. /**
  116116. * The name of the teleportation feature
  116117. */
  116118. static TELEPORTATION: string;
  116119. }
  116120. /**
  116121. * Defining the constructor of a feature. Used to register the modules.
  116122. */
  116123. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  116124. /**
  116125. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  116126. * It is mainly used in AR sessions.
  116127. *
  116128. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  116129. */
  116130. export class WebXRFeaturesManager implements IDisposable {
  116131. private _xrSessionManager;
  116132. private static readonly _AvailableFeatures;
  116133. private _features;
  116134. /**
  116135. * constructs a new features manages.
  116136. *
  116137. * @param _xrSessionManager an instance of WebXRSessionManager
  116138. */
  116139. constructor(_xrSessionManager: WebXRSessionManager);
  116140. /**
  116141. * Used to register a module. After calling this function a developer can use this feature in the scene.
  116142. * Mainly used internally.
  116143. *
  116144. * @param featureName the name of the feature to register
  116145. * @param constructorFunction the function used to construct the module
  116146. * @param version the (babylon) version of the module
  116147. * @param stable is that a stable version of this module
  116148. */
  116149. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  116150. /**
  116151. * Returns a constructor of a specific feature.
  116152. *
  116153. * @param featureName the name of the feature to construct
  116154. * @param version the version of the feature to load
  116155. * @param xrSessionManager the xrSessionManager. Used to construct the module
  116156. * @param options optional options provided to the module.
  116157. * @returns a function that, when called, will return a new instance of this feature
  116158. */
  116159. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  116160. /**
  116161. * Can be used to return the list of features currently registered
  116162. *
  116163. * @returns an Array of available features
  116164. */
  116165. static GetAvailableFeatures(): string[];
  116166. /**
  116167. * Gets the versions available for a specific feature
  116168. * @param featureName the name of the feature
  116169. * @returns an array with the available versions
  116170. */
  116171. static GetAvailableVersions(featureName: string): string[];
  116172. /**
  116173. * Return the latest unstable version of this feature
  116174. * @param featureName the name of the feature to search
  116175. * @returns the version number. if not found will return -1
  116176. */
  116177. static GetLatestVersionOfFeature(featureName: string): number;
  116178. /**
  116179. * Return the latest stable version of this feature
  116180. * @param featureName the name of the feature to search
  116181. * @returns the version number. if not found will return -1
  116182. */
  116183. static GetStableVersionOfFeature(featureName: string): number;
  116184. /**
  116185. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  116186. * Can be used during a session to start a feature
  116187. * @param featureName the name of feature to attach
  116188. */
  116189. attachFeature(featureName: string): void;
  116190. /**
  116191. * Can be used inside a session or when the session ends to detach a specific feature
  116192. * @param featureName the name of the feature to detach
  116193. */
  116194. detachFeature(featureName: string): void;
  116195. /**
  116196. * Used to disable an already-enabled feature
  116197. * The feature will be disposed and will be recreated once enabled.
  116198. * @param featureName the feature to disable
  116199. * @returns true if disable was successful
  116200. */
  116201. disableFeature(featureName: string | {
  116202. Name: string;
  116203. }): boolean;
  116204. /**
  116205. * dispose this features manager
  116206. */
  116207. dispose(): void;
  116208. /**
  116209. * 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.
  116210. * 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.
  116211. *
  116212. * @param featureName the name of the feature to load or the class of the feature
  116213. * @param version optional version to load. if not provided the latest version will be enabled
  116214. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  116215. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  116216. * @returns a new constructed feature or throws an error if feature not found.
  116217. */
  116218. enableFeature(featureName: string | {
  116219. Name: string;
  116220. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  116221. /**
  116222. * get the implementation of an enabled feature.
  116223. * @param featureName the name of the feature to load
  116224. * @returns the feature class, if found
  116225. */
  116226. getEnabledFeature(featureName: string): IWebXRFeature;
  116227. /**
  116228. * Get the list of enabled features
  116229. * @returns an array of enabled features
  116230. */
  116231. getEnabledFeatures(): string[];
  116232. }
  116233. }
  116234. declare module BABYLON {
  116235. /**
  116236. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  116237. * @see https://doc.babylonjs.com/how_to/webxr
  116238. */
  116239. export class WebXRExperienceHelper implements IDisposable {
  116240. private scene;
  116241. private _nonVRCamera;
  116242. private _originalSceneAutoClear;
  116243. private _supported;
  116244. /**
  116245. * Camera used to render xr content
  116246. */
  116247. camera: WebXRCamera;
  116248. /** A features manager for this xr session */
  116249. featuresManager: WebXRFeaturesManager;
  116250. /**
  116251. * Observers registered here will be triggered after the camera's initial transformation is set
  116252. * This can be used to set a different ground level or an extra rotation.
  116253. *
  116254. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  116255. * to the position set after this observable is done executing.
  116256. */
  116257. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  116258. /**
  116259. * Fires when the state of the experience helper has changed
  116260. */
  116261. onStateChangedObservable: Observable<WebXRState>;
  116262. /** Session manager used to keep track of xr session */
  116263. sessionManager: WebXRSessionManager;
  116264. /**
  116265. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  116266. */
  116267. state: WebXRState;
  116268. /**
  116269. * Creates a WebXRExperienceHelper
  116270. * @param scene The scene the helper should be created in
  116271. */
  116272. private constructor();
  116273. /**
  116274. * Creates the experience helper
  116275. * @param scene the scene to attach the experience helper to
  116276. * @returns a promise for the experience helper
  116277. */
  116278. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  116279. /**
  116280. * Disposes of the experience helper
  116281. */
  116282. dispose(): void;
  116283. /**
  116284. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  116285. * @param sessionMode options for the XR session
  116286. * @param referenceSpaceType frame of reference of the XR session
  116287. * @param renderTarget the output canvas that will be used to enter XR mode
  116288. * @returns promise that resolves after xr mode has entered
  116289. */
  116290. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  116291. /**
  116292. * Exits XR mode and returns the scene to its original state
  116293. * @returns promise that resolves after xr mode has exited
  116294. */
  116295. exitXRAsync(): Promise<void>;
  116296. private _nonXRToXRCamera;
  116297. private _setState;
  116298. }
  116299. }
  116300. declare module BABYLON {
  116301. /**
  116302. * X-Y values for axes in WebXR
  116303. */
  116304. export interface IWebXRMotionControllerAxesValue {
  116305. /**
  116306. * The value of the x axis
  116307. */
  116308. x: number;
  116309. /**
  116310. * The value of the y-axis
  116311. */
  116312. y: number;
  116313. }
  116314. /**
  116315. * changed / previous values for the values of this component
  116316. */
  116317. export interface IWebXRMotionControllerComponentChangesValues<T> {
  116318. /**
  116319. * current (this frame) value
  116320. */
  116321. current: T;
  116322. /**
  116323. * previous (last change) value
  116324. */
  116325. previous: T;
  116326. }
  116327. /**
  116328. * Represents changes in the component between current frame and last values recorded
  116329. */
  116330. export interface IWebXRMotionControllerComponentChanges {
  116331. /**
  116332. * will be populated with previous and current values if axes changed
  116333. */
  116334. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  116335. /**
  116336. * will be populated with previous and current values if pressed changed
  116337. */
  116338. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116339. /**
  116340. * will be populated with previous and current values if touched changed
  116341. */
  116342. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116343. /**
  116344. * will be populated with previous and current values if value changed
  116345. */
  116346. value?: IWebXRMotionControllerComponentChangesValues<number>;
  116347. }
  116348. /**
  116349. * This class represents a single component (for example button or thumbstick) of a motion controller
  116350. */
  116351. export class WebXRControllerComponent implements IDisposable {
  116352. /**
  116353. * the id of this component
  116354. */
  116355. id: string;
  116356. /**
  116357. * the type of the component
  116358. */
  116359. type: MotionControllerComponentType;
  116360. private _buttonIndex;
  116361. private _axesIndices;
  116362. private _axes;
  116363. private _changes;
  116364. private _currentValue;
  116365. private _hasChanges;
  116366. private _pressed;
  116367. private _touched;
  116368. /**
  116369. * button component type
  116370. */
  116371. static BUTTON_TYPE: MotionControllerComponentType;
  116372. /**
  116373. * squeeze component type
  116374. */
  116375. static SQUEEZE_TYPE: MotionControllerComponentType;
  116376. /**
  116377. * Thumbstick component type
  116378. */
  116379. static THUMBSTICK_TYPE: MotionControllerComponentType;
  116380. /**
  116381. * Touchpad component type
  116382. */
  116383. static TOUCHPAD_TYPE: MotionControllerComponentType;
  116384. /**
  116385. * trigger component type
  116386. */
  116387. static TRIGGER_TYPE: MotionControllerComponentType;
  116388. /**
  116389. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  116390. * the axes data changes
  116391. */
  116392. onAxisValueChangedObservable: Observable<{
  116393. x: number;
  116394. y: number;
  116395. }>;
  116396. /**
  116397. * Observers registered here will be triggered when the state of a button changes
  116398. * State change is either pressed / touched / value
  116399. */
  116400. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  116401. /**
  116402. * Creates a new component for a motion controller.
  116403. * It is created by the motion controller itself
  116404. *
  116405. * @param id the id of this component
  116406. * @param type the type of the component
  116407. * @param _buttonIndex index in the buttons array of the gamepad
  116408. * @param _axesIndices indices of the values in the axes array of the gamepad
  116409. */
  116410. constructor(
  116411. /**
  116412. * the id of this component
  116413. */
  116414. id: string,
  116415. /**
  116416. * the type of the component
  116417. */
  116418. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  116419. /**
  116420. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  116421. */
  116422. get axes(): IWebXRMotionControllerAxesValue;
  116423. /**
  116424. * Get the changes. Elements will be populated only if they changed with their previous and current value
  116425. */
  116426. get changes(): IWebXRMotionControllerComponentChanges;
  116427. /**
  116428. * Return whether or not the component changed the last frame
  116429. */
  116430. get hasChanges(): boolean;
  116431. /**
  116432. * is the button currently pressed
  116433. */
  116434. get pressed(): boolean;
  116435. /**
  116436. * is the button currently touched
  116437. */
  116438. get touched(): boolean;
  116439. /**
  116440. * Get the current value of this component
  116441. */
  116442. get value(): number;
  116443. /**
  116444. * Dispose this component
  116445. */
  116446. dispose(): void;
  116447. /**
  116448. * Are there axes correlating to this component
  116449. * @return true is axes data is available
  116450. */
  116451. isAxes(): boolean;
  116452. /**
  116453. * Is this component a button (hence - pressable)
  116454. * @returns true if can be pressed
  116455. */
  116456. isButton(): boolean;
  116457. /**
  116458. * update this component using the gamepad object it is in. Called on every frame
  116459. * @param nativeController the native gamepad controller object
  116460. */
  116461. update(nativeController: IMinimalMotionControllerObject): void;
  116462. }
  116463. }
  116464. declare module BABYLON {
  116465. /**
  116466. * Class used to represent data loading progression
  116467. */
  116468. export class SceneLoaderProgressEvent {
  116469. /** defines if data length to load can be evaluated */
  116470. readonly lengthComputable: boolean;
  116471. /** defines the loaded data length */
  116472. readonly loaded: number;
  116473. /** defines the data length to load */
  116474. readonly total: number;
  116475. /**
  116476. * Create a new progress event
  116477. * @param lengthComputable defines if data length to load can be evaluated
  116478. * @param loaded defines the loaded data length
  116479. * @param total defines the data length to load
  116480. */
  116481. constructor(
  116482. /** defines if data length to load can be evaluated */
  116483. lengthComputable: boolean,
  116484. /** defines the loaded data length */
  116485. loaded: number,
  116486. /** defines the data length to load */
  116487. total: number);
  116488. /**
  116489. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  116490. * @param event defines the source event
  116491. * @returns a new SceneLoaderProgressEvent
  116492. */
  116493. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  116494. }
  116495. /**
  116496. * Interface used by SceneLoader plugins to define supported file extensions
  116497. */
  116498. export interface ISceneLoaderPluginExtensions {
  116499. /**
  116500. * Defines the list of supported extensions
  116501. */
  116502. [extension: string]: {
  116503. isBinary: boolean;
  116504. };
  116505. }
  116506. /**
  116507. * Interface used by SceneLoader plugin factory
  116508. */
  116509. export interface ISceneLoaderPluginFactory {
  116510. /**
  116511. * Defines the name of the factory
  116512. */
  116513. name: string;
  116514. /**
  116515. * Function called to create a new plugin
  116516. * @return the new plugin
  116517. */
  116518. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  116519. /**
  116520. * The callback that returns true if the data can be directly loaded.
  116521. * @param data string containing the file data
  116522. * @returns if the data can be loaded directly
  116523. */
  116524. canDirectLoad?(data: string): boolean;
  116525. }
  116526. /**
  116527. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  116528. */
  116529. export interface ISceneLoaderPluginBase {
  116530. /**
  116531. * The friendly name of this plugin.
  116532. */
  116533. name: string;
  116534. /**
  116535. * The file extensions supported by this plugin.
  116536. */
  116537. extensions: string | ISceneLoaderPluginExtensions;
  116538. /**
  116539. * The callback called when loading from a url.
  116540. * @param scene scene loading this url
  116541. * @param url url to load
  116542. * @param onSuccess callback called when the file successfully loads
  116543. * @param onProgress callback called while file is loading (if the server supports this mode)
  116544. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116545. * @param onError callback called when the file fails to load
  116546. * @returns a file request object
  116547. */
  116548. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116549. /**
  116550. * The callback called when loading from a file object.
  116551. * @param scene scene loading this file
  116552. * @param file defines the file to load
  116553. * @param onSuccess defines the callback to call when data is loaded
  116554. * @param onProgress defines the callback to call during loading process
  116555. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116556. * @param onError defines the callback to call when an error occurs
  116557. * @returns a file request object
  116558. */
  116559. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116560. /**
  116561. * The callback that returns true if the data can be directly loaded.
  116562. * @param data string containing the file data
  116563. * @returns if the data can be loaded directly
  116564. */
  116565. canDirectLoad?(data: string): boolean;
  116566. /**
  116567. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  116568. * @param scene scene loading this data
  116569. * @param data string containing the data
  116570. * @returns data to pass to the plugin
  116571. */
  116572. directLoad?(scene: Scene, data: string): any;
  116573. /**
  116574. * The callback that allows custom handling of the root url based on the response url.
  116575. * @param rootUrl the original root url
  116576. * @param responseURL the response url if available
  116577. * @returns the new root url
  116578. */
  116579. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  116580. }
  116581. /**
  116582. * Interface used to define a SceneLoader plugin
  116583. */
  116584. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  116585. /**
  116586. * Import meshes into a scene.
  116587. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116588. * @param scene The scene to import into
  116589. * @param data The data to import
  116590. * @param rootUrl The root url for scene and resources
  116591. * @param meshes The meshes array to import into
  116592. * @param particleSystems The particle systems array to import into
  116593. * @param skeletons The skeletons array to import into
  116594. * @param onError The callback when import fails
  116595. * @returns True if successful or false otherwise
  116596. */
  116597. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  116598. /**
  116599. * Load into a scene.
  116600. * @param scene The scene to load into
  116601. * @param data The data to import
  116602. * @param rootUrl The root url for scene and resources
  116603. * @param onError The callback when import fails
  116604. * @returns True if successful or false otherwise
  116605. */
  116606. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  116607. /**
  116608. * Load into an asset container.
  116609. * @param scene The scene to load into
  116610. * @param data The data to import
  116611. * @param rootUrl The root url for scene and resources
  116612. * @param onError The callback when import fails
  116613. * @returns The loaded asset container
  116614. */
  116615. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  116616. }
  116617. /**
  116618. * Interface used to define an async SceneLoader plugin
  116619. */
  116620. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  116621. /**
  116622. * Import meshes into a scene.
  116623. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116624. * @param scene The scene to import into
  116625. * @param data The data to import
  116626. * @param rootUrl The root url for scene and resources
  116627. * @param onProgress The callback when the load progresses
  116628. * @param fileName Defines the name of the file to load
  116629. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  116630. */
  116631. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  116632. meshes: AbstractMesh[];
  116633. particleSystems: IParticleSystem[];
  116634. skeletons: Skeleton[];
  116635. animationGroups: AnimationGroup[];
  116636. }>;
  116637. /**
  116638. * Load into a scene.
  116639. * @param scene The scene to load into
  116640. * @param data The data to import
  116641. * @param rootUrl The root url for scene and resources
  116642. * @param onProgress The callback when the load progresses
  116643. * @param fileName Defines the name of the file to load
  116644. * @returns Nothing
  116645. */
  116646. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  116647. /**
  116648. * Load into an asset container.
  116649. * @param scene The scene to load into
  116650. * @param data The data to import
  116651. * @param rootUrl The root url for scene and resources
  116652. * @param onProgress The callback when the load progresses
  116653. * @param fileName Defines the name of the file to load
  116654. * @returns The loaded asset container
  116655. */
  116656. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  116657. }
  116658. /**
  116659. * Mode that determines how to handle old animation groups before loading new ones.
  116660. */
  116661. export enum SceneLoaderAnimationGroupLoadingMode {
  116662. /**
  116663. * Reset all old animations to initial state then dispose them.
  116664. */
  116665. Clean = 0,
  116666. /**
  116667. * Stop all old animations.
  116668. */
  116669. Stop = 1,
  116670. /**
  116671. * Restart old animations from first frame.
  116672. */
  116673. Sync = 2,
  116674. /**
  116675. * Old animations remains untouched.
  116676. */
  116677. NoSync = 3
  116678. }
  116679. /**
  116680. * Class used to load scene from various file formats using registered plugins
  116681. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  116682. */
  116683. export class SceneLoader {
  116684. /**
  116685. * No logging while loading
  116686. */
  116687. static readonly NO_LOGGING: number;
  116688. /**
  116689. * Minimal logging while loading
  116690. */
  116691. static readonly MINIMAL_LOGGING: number;
  116692. /**
  116693. * Summary logging while loading
  116694. */
  116695. static readonly SUMMARY_LOGGING: number;
  116696. /**
  116697. * Detailled logging while loading
  116698. */
  116699. static readonly DETAILED_LOGGING: number;
  116700. /**
  116701. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  116702. */
  116703. static get ForceFullSceneLoadingForIncremental(): boolean;
  116704. static set ForceFullSceneLoadingForIncremental(value: boolean);
  116705. /**
  116706. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  116707. */
  116708. static get ShowLoadingScreen(): boolean;
  116709. static set ShowLoadingScreen(value: boolean);
  116710. /**
  116711. * Defines the current logging level (while loading the scene)
  116712. * @ignorenaming
  116713. */
  116714. static get loggingLevel(): number;
  116715. static set loggingLevel(value: number);
  116716. /**
  116717. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  116718. */
  116719. static get CleanBoneMatrixWeights(): boolean;
  116720. static set CleanBoneMatrixWeights(value: boolean);
  116721. /**
  116722. * Event raised when a plugin is used to load a scene
  116723. */
  116724. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  116725. private static _registeredPlugins;
  116726. private static _getDefaultPlugin;
  116727. private static _getPluginForExtension;
  116728. private static _getPluginForDirectLoad;
  116729. private static _getPluginForFilename;
  116730. private static _getDirectLoad;
  116731. private static _loadData;
  116732. private static _getFileInfo;
  116733. /**
  116734. * Gets a plugin that can load the given extension
  116735. * @param extension defines the extension to load
  116736. * @returns a plugin or null if none works
  116737. */
  116738. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  116739. /**
  116740. * Gets a boolean indicating that the given extension can be loaded
  116741. * @param extension defines the extension to load
  116742. * @returns true if the extension is supported
  116743. */
  116744. static IsPluginForExtensionAvailable(extension: string): boolean;
  116745. /**
  116746. * Adds a new plugin to the list of registered plugins
  116747. * @param plugin defines the plugin to add
  116748. */
  116749. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  116750. /**
  116751. * Import meshes into a scene
  116752. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116753. * @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)
  116754. * @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)
  116755. * @param scene the instance of BABYLON.Scene to append to
  116756. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  116757. * @param onProgress a callback with a progress event for each file being loaded
  116758. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116759. * @param pluginExtension the extension used to determine the plugin
  116760. * @returns The loaded plugin
  116761. */
  116762. 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>;
  116763. /**
  116764. * Import meshes into a scene
  116765. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116766. * @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)
  116767. * @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)
  116768. * @param scene the instance of BABYLON.Scene to append to
  116769. * @param onProgress a callback with a progress event for each file being loaded
  116770. * @param pluginExtension the extension used to determine the plugin
  116771. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  116772. */
  116773. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  116774. meshes: AbstractMesh[];
  116775. particleSystems: IParticleSystem[];
  116776. skeletons: Skeleton[];
  116777. animationGroups: AnimationGroup[];
  116778. }>;
  116779. /**
  116780. * Load a scene
  116781. * @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)
  116782. * @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)
  116783. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116784. * @param onSuccess a callback with the scene when import succeeds
  116785. * @param onProgress a callback with a progress event for each file being loaded
  116786. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116787. * @param pluginExtension the extension used to determine the plugin
  116788. * @returns The loaded plugin
  116789. */
  116790. 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>;
  116791. /**
  116792. * Load a scene
  116793. * @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)
  116794. * @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)
  116795. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116796. * @param onProgress a callback with a progress event for each file being loaded
  116797. * @param pluginExtension the extension used to determine the plugin
  116798. * @returns The loaded scene
  116799. */
  116800. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116801. /**
  116802. * Append a scene
  116803. * @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)
  116804. * @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)
  116805. * @param scene is the instance of BABYLON.Scene to append to
  116806. * @param onSuccess a callback with the scene when import succeeds
  116807. * @param onProgress a callback with a progress event for each file being loaded
  116808. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116809. * @param pluginExtension the extension used to determine the plugin
  116810. * @returns The loaded plugin
  116811. */
  116812. 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>;
  116813. /**
  116814. * Append a scene
  116815. * @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)
  116816. * @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)
  116817. * @param scene is the instance of BABYLON.Scene to append to
  116818. * @param onProgress a callback with a progress event for each file being loaded
  116819. * @param pluginExtension the extension used to determine the plugin
  116820. * @returns The given scene
  116821. */
  116822. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116823. /**
  116824. * Load a scene into an asset container
  116825. * @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)
  116826. * @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)
  116827. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116828. * @param onSuccess a callback with the scene when import succeeds
  116829. * @param onProgress a callback with a progress event for each file being loaded
  116830. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116831. * @param pluginExtension the extension used to determine the plugin
  116832. * @returns The loaded plugin
  116833. */
  116834. 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>;
  116835. /**
  116836. * Load a scene into an asset container
  116837. * @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)
  116838. * @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)
  116839. * @param scene is the instance of Scene to append to
  116840. * @param onProgress a callback with a progress event for each file being loaded
  116841. * @param pluginExtension the extension used to determine the plugin
  116842. * @returns The loaded asset container
  116843. */
  116844. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  116845. /**
  116846. * Import animations from a file into a scene
  116847. * @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)
  116848. * @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)
  116849. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116850. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116851. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116852. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116853. * @param onSuccess a callback with the scene when import succeeds
  116854. * @param onProgress a callback with a progress event for each file being loaded
  116855. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116856. */
  116857. 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;
  116858. /**
  116859. * Import animations from a file into a scene
  116860. * @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)
  116861. * @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)
  116862. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116863. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116864. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116865. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116866. * @param onSuccess a callback with the scene when import succeeds
  116867. * @param onProgress a callback with a progress event for each file being loaded
  116868. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116869. * @returns the updated scene with imported animations
  116870. */
  116871. 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>;
  116872. }
  116873. }
  116874. declare module BABYLON {
  116875. /**
  116876. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  116877. */
  116878. export type MotionControllerHandness = "none" | "left" | "right";
  116879. /**
  116880. * The type of components available in motion controllers.
  116881. * This is not the name of the component.
  116882. */
  116883. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  116884. /**
  116885. * The state of a controller component
  116886. */
  116887. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  116888. /**
  116889. * The schema of motion controller layout.
  116890. * No object will be initialized using this interface
  116891. * This is used just to define the profile.
  116892. */
  116893. export interface IMotionControllerLayout {
  116894. /**
  116895. * Path to load the assets. Usually relative to the base path
  116896. */
  116897. assetPath: string;
  116898. /**
  116899. * Available components (unsorted)
  116900. */
  116901. components: {
  116902. /**
  116903. * A map of component Ids
  116904. */
  116905. [componentId: string]: {
  116906. /**
  116907. * The type of input the component outputs
  116908. */
  116909. type: MotionControllerComponentType;
  116910. /**
  116911. * The indices of this component in the gamepad object
  116912. */
  116913. gamepadIndices: {
  116914. /**
  116915. * Index of button
  116916. */
  116917. button?: number;
  116918. /**
  116919. * If available, index of x-axis
  116920. */
  116921. xAxis?: number;
  116922. /**
  116923. * If available, index of y-axis
  116924. */
  116925. yAxis?: number;
  116926. };
  116927. /**
  116928. * The mesh's root node name
  116929. */
  116930. rootNodeName: string;
  116931. /**
  116932. * Animation definitions for this model
  116933. */
  116934. visualResponses: {
  116935. [stateKey: string]: {
  116936. /**
  116937. * What property will be animated
  116938. */
  116939. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  116940. /**
  116941. * What states influence this visual response
  116942. */
  116943. states: MotionControllerComponentStateType[];
  116944. /**
  116945. * Type of animation - movement or visibility
  116946. */
  116947. valueNodeProperty: "transform" | "visibility";
  116948. /**
  116949. * Base node name to move. Its position will be calculated according to the min and max nodes
  116950. */
  116951. valueNodeName?: string;
  116952. /**
  116953. * Minimum movement node
  116954. */
  116955. minNodeName?: string;
  116956. /**
  116957. * Max movement node
  116958. */
  116959. maxNodeName?: string;
  116960. };
  116961. };
  116962. /**
  116963. * If touch enabled, what is the name of node to display user feedback
  116964. */
  116965. touchPointNodeName?: string;
  116966. };
  116967. };
  116968. /**
  116969. * Is it xr standard mapping or not
  116970. */
  116971. gamepadMapping: "" | "xr-standard";
  116972. /**
  116973. * Base root node of this entire model
  116974. */
  116975. rootNodeName: string;
  116976. /**
  116977. * Defines the main button component id
  116978. */
  116979. selectComponentId: string;
  116980. }
  116981. /**
  116982. * A definition for the layout map in the input profile
  116983. */
  116984. export interface IMotionControllerLayoutMap {
  116985. /**
  116986. * Layouts with handness type as a key
  116987. */
  116988. [handness: string]: IMotionControllerLayout;
  116989. }
  116990. /**
  116991. * The XR Input profile schema
  116992. * Profiles can be found here:
  116993. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  116994. */
  116995. export interface IMotionControllerProfile {
  116996. /**
  116997. * fallback profiles for this profileId
  116998. */
  116999. fallbackProfileIds: string[];
  117000. /**
  117001. * The layout map, with handness as key
  117002. */
  117003. layouts: IMotionControllerLayoutMap;
  117004. /**
  117005. * The id of this profile
  117006. * correlates to the profile(s) in the xrInput.profiles array
  117007. */
  117008. profileId: string;
  117009. }
  117010. /**
  117011. * A helper-interface for the 3 meshes needed for controller button animation
  117012. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  117013. */
  117014. export interface IMotionControllerButtonMeshMap {
  117015. /**
  117016. * the mesh that defines the pressed value mesh position.
  117017. * This is used to find the max-position of this button
  117018. */
  117019. pressedMesh: AbstractMesh;
  117020. /**
  117021. * the mesh that defines the unpressed value mesh position.
  117022. * This is used to find the min (or initial) position of this button
  117023. */
  117024. unpressedMesh: AbstractMesh;
  117025. /**
  117026. * The mesh that will be changed when value changes
  117027. */
  117028. valueMesh: AbstractMesh;
  117029. }
  117030. /**
  117031. * A helper-interface for the 3 meshes needed for controller axis animation.
  117032. * This will be expanded when touchpad animations are fully supported
  117033. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  117034. */
  117035. export interface IMotionControllerMeshMap {
  117036. /**
  117037. * the mesh that defines the maximum value mesh position.
  117038. */
  117039. maxMesh?: AbstractMesh;
  117040. /**
  117041. * the mesh that defines the minimum value mesh position.
  117042. */
  117043. minMesh?: AbstractMesh;
  117044. /**
  117045. * The mesh that will be changed when axis value changes
  117046. */
  117047. valueMesh: AbstractMesh;
  117048. }
  117049. /**
  117050. * The elements needed for change-detection of the gamepad objects in motion controllers
  117051. */
  117052. export interface IMinimalMotionControllerObject {
  117053. /**
  117054. * Available axes of this controller
  117055. */
  117056. axes: number[];
  117057. /**
  117058. * An array of available buttons
  117059. */
  117060. buttons: Array<{
  117061. /**
  117062. * Value of the button/trigger
  117063. */
  117064. value: number;
  117065. /**
  117066. * If the button/trigger is currently touched
  117067. */
  117068. touched: boolean;
  117069. /**
  117070. * If the button/trigger is currently pressed
  117071. */
  117072. pressed: boolean;
  117073. }>;
  117074. }
  117075. /**
  117076. * An Abstract Motion controller
  117077. * This class receives an xrInput and a profile layout and uses those to initialize the components
  117078. * Each component has an observable to check for changes in value and state
  117079. */
  117080. export abstract class WebXRAbstractMotionController implements IDisposable {
  117081. protected scene: Scene;
  117082. protected layout: IMotionControllerLayout;
  117083. /**
  117084. * The gamepad object correlating to this controller
  117085. */
  117086. gamepadObject: IMinimalMotionControllerObject;
  117087. /**
  117088. * handness (left/right/none) of this controller
  117089. */
  117090. handness: MotionControllerHandness;
  117091. private _initComponent;
  117092. private _modelReady;
  117093. /**
  117094. * A map of components (WebXRControllerComponent) in this motion controller
  117095. * Components have a ComponentType and can also have both button and axis definitions
  117096. */
  117097. readonly components: {
  117098. [id: string]: WebXRControllerComponent;
  117099. };
  117100. /**
  117101. * Disable the model's animation. Can be set at any time.
  117102. */
  117103. disableAnimation: boolean;
  117104. /**
  117105. * Observers registered here will be triggered when the model of this controller is done loading
  117106. */
  117107. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  117108. /**
  117109. * The profile id of this motion controller
  117110. */
  117111. abstract profileId: string;
  117112. /**
  117113. * The root mesh of the model. It is null if the model was not yet initialized
  117114. */
  117115. rootMesh: Nullable<AbstractMesh>;
  117116. /**
  117117. * constructs a new abstract motion controller
  117118. * @param scene the scene to which the model of the controller will be added
  117119. * @param layout The profile layout to load
  117120. * @param gamepadObject The gamepad object correlating to this controller
  117121. * @param handness handness (left/right/none) of this controller
  117122. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  117123. */
  117124. constructor(scene: Scene, layout: IMotionControllerLayout,
  117125. /**
  117126. * The gamepad object correlating to this controller
  117127. */
  117128. gamepadObject: IMinimalMotionControllerObject,
  117129. /**
  117130. * handness (left/right/none) of this controller
  117131. */
  117132. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  117133. /**
  117134. * Dispose this controller, the model mesh and all its components
  117135. */
  117136. dispose(): void;
  117137. /**
  117138. * Returns all components of specific type
  117139. * @param type the type to search for
  117140. * @return an array of components with this type
  117141. */
  117142. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  117143. /**
  117144. * get a component based an its component id as defined in layout.components
  117145. * @param id the id of the component
  117146. * @returns the component correlates to the id or undefined if not found
  117147. */
  117148. getComponent(id: string): WebXRControllerComponent;
  117149. /**
  117150. * Get the list of components available in this motion controller
  117151. * @returns an array of strings correlating to available components
  117152. */
  117153. getComponentIds(): string[];
  117154. /**
  117155. * Get the first component of specific type
  117156. * @param type type of component to find
  117157. * @return a controller component or null if not found
  117158. */
  117159. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  117160. /**
  117161. * Get the main (Select) component of this controller as defined in the layout
  117162. * @returns the main component of this controller
  117163. */
  117164. getMainComponent(): WebXRControllerComponent;
  117165. /**
  117166. * Loads the model correlating to this controller
  117167. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  117168. * @returns A promise fulfilled with the result of the model loading
  117169. */
  117170. loadModel(): Promise<boolean>;
  117171. /**
  117172. * Update this model using the current XRFrame
  117173. * @param xrFrame the current xr frame to use and update the model
  117174. */
  117175. updateFromXRFrame(xrFrame: XRFrame): void;
  117176. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117177. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117178. /**
  117179. * Moves the axis on the controller mesh based on its current state
  117180. * @param axis the index of the axis
  117181. * @param axisValue the value of the axis which determines the meshes new position
  117182. * @hidden
  117183. */
  117184. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  117185. /**
  117186. * Update the model itself with the current frame data
  117187. * @param xrFrame the frame to use for updating the model mesh
  117188. */
  117189. protected updateModel(xrFrame: XRFrame): void;
  117190. /**
  117191. * Get the filename and path for this controller's model
  117192. * @returns a map of filename and path
  117193. */
  117194. protected abstract _getFilenameAndPath(): {
  117195. filename: string;
  117196. path: string;
  117197. };
  117198. /**
  117199. * This function is called before the mesh is loaded. It checks for loading constraints.
  117200. * For example, this function can check if the GLB loader is available
  117201. * If this function returns false, the generic controller will be loaded instead
  117202. * @returns Is the client ready to load the mesh
  117203. */
  117204. protected abstract _getModelLoadingConstraints(): boolean;
  117205. /**
  117206. * This function will be called after the model was successfully loaded and can be used
  117207. * for mesh transformations before it is available for the user
  117208. * @param meshes the loaded meshes
  117209. */
  117210. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  117211. /**
  117212. * Set the root mesh for this controller. Important for the WebXR controller class
  117213. * @param meshes the loaded meshes
  117214. */
  117215. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  117216. /**
  117217. * A function executed each frame that updates the mesh (if needed)
  117218. * @param xrFrame the current xrFrame
  117219. */
  117220. protected abstract _updateModel(xrFrame: XRFrame): void;
  117221. private _getGenericFilenameAndPath;
  117222. private _getGenericParentMesh;
  117223. }
  117224. }
  117225. declare module BABYLON {
  117226. /**
  117227. * A generic trigger-only motion controller for WebXR
  117228. */
  117229. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  117230. /**
  117231. * Static version of the profile id of this controller
  117232. */
  117233. static ProfileId: string;
  117234. profileId: string;
  117235. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117236. protected _getFilenameAndPath(): {
  117237. filename: string;
  117238. path: string;
  117239. };
  117240. protected _getModelLoadingConstraints(): boolean;
  117241. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  117242. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117243. protected _updateModel(): void;
  117244. }
  117245. }
  117246. declare module BABYLON {
  117247. /**
  117248. * Class containing static functions to help procedurally build meshes
  117249. */
  117250. export class SphereBuilder {
  117251. /**
  117252. * Creates a sphere mesh
  117253. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117254. * * 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`)
  117255. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117256. * * 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
  117257. * * 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)
  117258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117259. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117261. * @param name defines the name of the mesh
  117262. * @param options defines the options used to create the mesh
  117263. * @param scene defines the hosting scene
  117264. * @returns the sphere mesh
  117265. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117266. */
  117267. static CreateSphere(name: string, options: {
  117268. segments?: number;
  117269. diameter?: number;
  117270. diameterX?: number;
  117271. diameterY?: number;
  117272. diameterZ?: number;
  117273. arc?: number;
  117274. slice?: number;
  117275. sideOrientation?: number;
  117276. frontUVs?: Vector4;
  117277. backUVs?: Vector4;
  117278. updatable?: boolean;
  117279. }, scene?: Nullable<Scene>): Mesh;
  117280. }
  117281. }
  117282. declare module BABYLON {
  117283. /**
  117284. * A profiled motion controller has its profile loaded from an online repository.
  117285. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  117286. */
  117287. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  117288. private _repositoryUrl;
  117289. private _buttonMeshMapping;
  117290. private _touchDots;
  117291. /**
  117292. * The profile ID of this controller. Will be populated when the controller initializes.
  117293. */
  117294. profileId: string;
  117295. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  117296. dispose(): void;
  117297. protected _getFilenameAndPath(): {
  117298. filename: string;
  117299. path: string;
  117300. };
  117301. protected _getModelLoadingConstraints(): boolean;
  117302. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117303. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117304. protected _updateModel(_xrFrame: XRFrame): void;
  117305. }
  117306. }
  117307. declare module BABYLON {
  117308. /**
  117309. * A construction function type to create a new controller based on an xrInput object
  117310. */
  117311. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  117312. /**
  117313. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  117314. *
  117315. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  117316. * it should be replaced with auto-loaded controllers.
  117317. *
  117318. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  117319. */
  117320. export class WebXRMotionControllerManager {
  117321. private static _AvailableControllers;
  117322. private static _Fallbacks;
  117323. private static _ProfileLoadingPromises;
  117324. private static _ProfilesList;
  117325. /**
  117326. * The base URL of the online controller repository. Can be changed at any time.
  117327. */
  117328. static BaseRepositoryUrl: string;
  117329. /**
  117330. * Which repository gets priority - local or online
  117331. */
  117332. static PrioritizeOnlineRepository: boolean;
  117333. /**
  117334. * Use the online repository, or use only locally-defined controllers
  117335. */
  117336. static UseOnlineRepository: boolean;
  117337. /**
  117338. * Clear the cache used for profile loading and reload when requested again
  117339. */
  117340. static ClearProfilesCache(): void;
  117341. /**
  117342. * Register the default fallbacks.
  117343. * This function is called automatically when this file is imported.
  117344. */
  117345. static DefaultFallbacks(): void;
  117346. /**
  117347. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  117348. * @param profileId the profile to which a fallback needs to be found
  117349. * @return an array with corresponding fallback profiles
  117350. */
  117351. static FindFallbackWithProfileId(profileId: string): string[];
  117352. /**
  117353. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  117354. * The order of search:
  117355. *
  117356. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  117357. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  117358. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  117359. * 4) return the generic trigger controller if none were found
  117360. *
  117361. * @param xrInput the xrInput to which a new controller is initialized
  117362. * @param scene the scene to which the model will be added
  117363. * @param forceProfile force a certain profile for this controller
  117364. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  117365. */
  117366. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  117367. /**
  117368. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  117369. *
  117370. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  117371. *
  117372. * @param type the profile type to register
  117373. * @param constructFunction the function to be called when loading this profile
  117374. */
  117375. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  117376. /**
  117377. * Register a fallback to a specific profile.
  117378. * @param profileId the profileId that will receive the fallbacks
  117379. * @param fallbacks A list of fallback profiles
  117380. */
  117381. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  117382. /**
  117383. * Will update the list of profiles available in the repository
  117384. * @return a promise that resolves to a map of profiles available online
  117385. */
  117386. static UpdateProfilesList(): Promise<{
  117387. [profile: string]: string;
  117388. }>;
  117389. private static _LoadProfileFromRepository;
  117390. private static _LoadProfilesFromAvailableControllers;
  117391. }
  117392. }
  117393. declare module BABYLON {
  117394. /**
  117395. * Configuration options for the WebXR controller creation
  117396. */
  117397. export interface IWebXRControllerOptions {
  117398. /**
  117399. * Should the controller mesh be animated when a user interacts with it
  117400. * The pressed buttons / thumbstick and touchpad animations will be disabled
  117401. */
  117402. disableMotionControllerAnimation?: boolean;
  117403. /**
  117404. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  117405. */
  117406. doNotLoadControllerMesh?: boolean;
  117407. /**
  117408. * Force a specific controller type for this controller.
  117409. * This can be used when creating your own profile or when testing different controllers
  117410. */
  117411. forceControllerProfile?: string;
  117412. }
  117413. /**
  117414. * Represents an XR controller
  117415. */
  117416. export class WebXRInputSource {
  117417. private _scene;
  117418. /** The underlying input source for the controller */
  117419. inputSource: XRInputSource;
  117420. private _options;
  117421. private _tmpQuaternion;
  117422. private _tmpVector;
  117423. private _uniqueId;
  117424. /**
  117425. * 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
  117426. */
  117427. grip?: AbstractMesh;
  117428. /**
  117429. * If available, this is the gamepad object related to this controller.
  117430. * Using this object it is possible to get click events and trackpad changes of the
  117431. * webxr controller that is currently being used.
  117432. */
  117433. motionController?: WebXRAbstractMotionController;
  117434. /**
  117435. * Event that fires when the controller is removed/disposed.
  117436. * The object provided as event data is this controller, after associated assets were disposed.
  117437. * uniqueId is still available.
  117438. */
  117439. onDisposeObservable: Observable<WebXRInputSource>;
  117440. /**
  117441. * Will be triggered when the mesh associated with the motion controller is done loading.
  117442. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  117443. * A shortened version of controller -> motion controller -> on mesh loaded.
  117444. */
  117445. onMeshLoadedObservable: Observable<AbstractMesh>;
  117446. /**
  117447. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  117448. */
  117449. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  117450. /**
  117451. * Pointer which can be used to select objects or attach a visible laser to
  117452. */
  117453. pointer: AbstractMesh;
  117454. /**
  117455. * Creates the controller
  117456. * @see https://doc.babylonjs.com/how_to/webxr
  117457. * @param _scene the scene which the controller should be associated to
  117458. * @param inputSource the underlying input source for the controller
  117459. * @param _options options for this controller creation
  117460. */
  117461. constructor(_scene: Scene,
  117462. /** The underlying input source for the controller */
  117463. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  117464. /**
  117465. * Get this controllers unique id
  117466. */
  117467. get uniqueId(): string;
  117468. /**
  117469. * Disposes of the object
  117470. */
  117471. dispose(): void;
  117472. /**
  117473. * Gets a world space ray coming from the pointer or grip
  117474. * @param result the resulting ray
  117475. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  117476. */
  117477. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  117478. /**
  117479. * Updates the controller pose based on the given XRFrame
  117480. * @param xrFrame xr frame to update the pose with
  117481. * @param referenceSpace reference space to use
  117482. */
  117483. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  117484. }
  117485. }
  117486. declare module BABYLON {
  117487. /**
  117488. * The schema for initialization options of the XR Input class
  117489. */
  117490. export interface IWebXRInputOptions {
  117491. /**
  117492. * If set to true no model will be automatically loaded
  117493. */
  117494. doNotLoadControllerMeshes?: boolean;
  117495. /**
  117496. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  117497. * If not found, the xr input profile data will be used.
  117498. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  117499. */
  117500. forceInputProfile?: string;
  117501. /**
  117502. * Do not send a request to the controller repository to load the profile.
  117503. *
  117504. * Instead, use the controllers available in babylon itself.
  117505. */
  117506. disableOnlineControllerRepository?: boolean;
  117507. /**
  117508. * A custom URL for the controllers repository
  117509. */
  117510. customControllersRepositoryURL?: string;
  117511. /**
  117512. * Should the controller model's components not move according to the user input
  117513. */
  117514. disableControllerAnimation?: boolean;
  117515. }
  117516. /**
  117517. * XR input used to track XR inputs such as controllers/rays
  117518. */
  117519. export class WebXRInput implements IDisposable {
  117520. /**
  117521. * the xr session manager for this session
  117522. */
  117523. xrSessionManager: WebXRSessionManager;
  117524. /**
  117525. * the WebXR camera for this session. Mainly used for teleportation
  117526. */
  117527. xrCamera: WebXRCamera;
  117528. private readonly options;
  117529. /**
  117530. * XR controllers being tracked
  117531. */
  117532. controllers: Array<WebXRInputSource>;
  117533. private _frameObserver;
  117534. private _sessionEndedObserver;
  117535. private _sessionInitObserver;
  117536. /**
  117537. * Event when a controller has been connected/added
  117538. */
  117539. onControllerAddedObservable: Observable<WebXRInputSource>;
  117540. /**
  117541. * Event when a controller has been removed/disconnected
  117542. */
  117543. onControllerRemovedObservable: Observable<WebXRInputSource>;
  117544. /**
  117545. * Initializes the WebXRInput
  117546. * @param xrSessionManager the xr session manager for this session
  117547. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  117548. * @param options = initialization options for this xr input
  117549. */
  117550. constructor(
  117551. /**
  117552. * the xr session manager for this session
  117553. */
  117554. xrSessionManager: WebXRSessionManager,
  117555. /**
  117556. * the WebXR camera for this session. Mainly used for teleportation
  117557. */
  117558. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  117559. private _onInputSourcesChange;
  117560. private _addAndRemoveControllers;
  117561. /**
  117562. * Disposes of the object
  117563. */
  117564. dispose(): void;
  117565. }
  117566. }
  117567. declare module BABYLON {
  117568. /**
  117569. * This is the base class for all WebXR features.
  117570. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  117571. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  117572. */
  117573. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  117574. protected _xrSessionManager: WebXRSessionManager;
  117575. private _attached;
  117576. private _removeOnDetach;
  117577. /**
  117578. * Should auto-attach be disabled?
  117579. */
  117580. disableAutoAttach: boolean;
  117581. /**
  117582. * Construct a new (abstract) WebXR feature
  117583. * @param _xrSessionManager the xr session manager for this feature
  117584. */
  117585. constructor(_xrSessionManager: WebXRSessionManager);
  117586. /**
  117587. * Is this feature attached
  117588. */
  117589. get attached(): boolean;
  117590. /**
  117591. * attach this feature
  117592. *
  117593. * @param force should attachment be forced (even when already attached)
  117594. * @returns true if successful, false is failed or already attached
  117595. */
  117596. attach(force?: boolean): boolean;
  117597. /**
  117598. * detach this feature.
  117599. *
  117600. * @returns true if successful, false if failed or already detached
  117601. */
  117602. detach(): boolean;
  117603. /**
  117604. * Dispose this feature and all of the resources attached
  117605. */
  117606. dispose(): void;
  117607. /**
  117608. * This is used to register callbacks that will automatically be removed when detach is called.
  117609. * @param observable the observable to which the observer will be attached
  117610. * @param callback the callback to register
  117611. */
  117612. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  117613. /**
  117614. * Code in this function will be executed on each xrFrame received from the browser.
  117615. * This function will not execute after the feature is detached.
  117616. * @param _xrFrame the current frame
  117617. */
  117618. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  117619. }
  117620. }
  117621. declare module BABYLON {
  117622. /**
  117623. * Renders a layer on top of an existing scene
  117624. */
  117625. export class UtilityLayerRenderer implements IDisposable {
  117626. /** the original scene that will be rendered on top of */
  117627. originalScene: Scene;
  117628. private _pointerCaptures;
  117629. private _lastPointerEvents;
  117630. private static _DefaultUtilityLayer;
  117631. private static _DefaultKeepDepthUtilityLayer;
  117632. private _sharedGizmoLight;
  117633. private _renderCamera;
  117634. /**
  117635. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  117636. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  117637. * @returns the camera that is used when rendering the utility layer
  117638. */
  117639. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  117640. /**
  117641. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  117642. * @param cam the camera that should be used when rendering the utility layer
  117643. */
  117644. setRenderCamera(cam: Nullable<Camera>): void;
  117645. /**
  117646. * @hidden
  117647. * Light which used by gizmos to get light shading
  117648. */
  117649. _getSharedGizmoLight(): HemisphericLight;
  117650. /**
  117651. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  117652. */
  117653. pickUtilitySceneFirst: boolean;
  117654. /**
  117655. * 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)
  117656. */
  117657. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  117658. /**
  117659. * 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)
  117660. */
  117661. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  117662. /**
  117663. * The scene that is rendered on top of the original scene
  117664. */
  117665. utilityLayerScene: Scene;
  117666. /**
  117667. * If the utility layer should automatically be rendered on top of existing scene
  117668. */
  117669. shouldRender: boolean;
  117670. /**
  117671. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  117672. */
  117673. onlyCheckPointerDownEvents: boolean;
  117674. /**
  117675. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  117676. */
  117677. processAllEvents: boolean;
  117678. /**
  117679. * Observable raised when the pointer move from the utility layer scene to the main scene
  117680. */
  117681. onPointerOutObservable: Observable<number>;
  117682. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  117683. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  117684. private _afterRenderObserver;
  117685. private _sceneDisposeObserver;
  117686. private _originalPointerObserver;
  117687. /**
  117688. * Instantiates a UtilityLayerRenderer
  117689. * @param originalScene the original scene that will be rendered on top of
  117690. * @param handleEvents boolean indicating if the utility layer should handle events
  117691. */
  117692. constructor(
  117693. /** the original scene that will be rendered on top of */
  117694. originalScene: Scene, handleEvents?: boolean);
  117695. private _notifyObservers;
  117696. /**
  117697. * Renders the utility layers scene on top of the original scene
  117698. */
  117699. render(): void;
  117700. /**
  117701. * Disposes of the renderer
  117702. */
  117703. dispose(): void;
  117704. private _updateCamera;
  117705. }
  117706. }
  117707. declare module BABYLON {
  117708. /**
  117709. * Options interface for the pointer selection module
  117710. */
  117711. export interface IWebXRControllerPointerSelectionOptions {
  117712. /**
  117713. * if provided, this scene will be used to render meshes.
  117714. */
  117715. customUtilityLayerScene?: Scene;
  117716. /**
  117717. * 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)
  117718. * If not disabled, the last picked point will be used to execute a pointer up event
  117719. * If disabled, pointer up event will be triggered right after the pointer down event.
  117720. * Used in screen and gaze target ray mode only
  117721. */
  117722. disablePointerUpOnTouchOut: boolean;
  117723. /**
  117724. * For gaze mode (time to select instead of press)
  117725. */
  117726. forceGazeMode: boolean;
  117727. /**
  117728. * 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
  117729. * to start a new countdown to the pointer down event.
  117730. * Defaults to 1.
  117731. */
  117732. gazeModePointerMovedFactor?: number;
  117733. /**
  117734. * Different button type to use instead of the main component
  117735. */
  117736. overrideButtonId?: string;
  117737. /**
  117738. * use this rendering group id for the meshes (optional)
  117739. */
  117740. renderingGroupId?: number;
  117741. /**
  117742. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  117743. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  117744. * 3000 means 3 seconds between pointing at something and selecting it
  117745. */
  117746. timeToSelect?: number;
  117747. /**
  117748. * Should meshes created here be added to a utility layer or the main scene
  117749. */
  117750. useUtilityLayer?: boolean;
  117751. /**
  117752. * the xr input to use with this pointer selection
  117753. */
  117754. xrInput: WebXRInput;
  117755. }
  117756. /**
  117757. * A module that will enable pointer selection for motion controllers of XR Input Sources
  117758. */
  117759. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  117760. private readonly _options;
  117761. private static _idCounter;
  117762. private _attachController;
  117763. private _controllers;
  117764. private _scene;
  117765. private _tmpVectorForPickCompare;
  117766. /**
  117767. * The module's name
  117768. */
  117769. static readonly Name: string;
  117770. /**
  117771. * The (Babylon) version of this module.
  117772. * This is an integer representing the implementation version.
  117773. * This number does not correspond to the WebXR specs version
  117774. */
  117775. static readonly Version: number;
  117776. /**
  117777. * Disable lighting on the laser pointer (so it will always be visible)
  117778. */
  117779. disablePointerLighting: boolean;
  117780. /**
  117781. * Disable lighting on the selection mesh (so it will always be visible)
  117782. */
  117783. disableSelectionMeshLighting: boolean;
  117784. /**
  117785. * Should the laser pointer be displayed
  117786. */
  117787. displayLaserPointer: boolean;
  117788. /**
  117789. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  117790. */
  117791. displaySelectionMesh: boolean;
  117792. /**
  117793. * This color will be set to the laser pointer when selection is triggered
  117794. */
  117795. laserPointerPickedColor: Color3;
  117796. /**
  117797. * Default color of the laser pointer
  117798. */
  117799. lasterPointerDefaultColor: Color3;
  117800. /**
  117801. * default color of the selection ring
  117802. */
  117803. selectionMeshDefaultColor: Color3;
  117804. /**
  117805. * This color will be applied to the selection ring when selection is triggered
  117806. */
  117807. selectionMeshPickedColor: Color3;
  117808. /**
  117809. * constructs a new background remover module
  117810. * @param _xrSessionManager the session manager for this module
  117811. * @param _options read-only options to be used in this module
  117812. */
  117813. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  117814. /**
  117815. * attach this feature
  117816. * Will usually be called by the features manager
  117817. *
  117818. * @returns true if successful.
  117819. */
  117820. attach(): boolean;
  117821. /**
  117822. * detach this feature.
  117823. * Will usually be called by the features manager
  117824. *
  117825. * @returns true if successful.
  117826. */
  117827. detach(): boolean;
  117828. /**
  117829. * Will get the mesh under a specific pointer.
  117830. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  117831. * @param controllerId the controllerId to check
  117832. * @returns The mesh under pointer or null if no mesh is under the pointer
  117833. */
  117834. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  117835. /**
  117836. * Get the xr controller that correlates to the pointer id in the pointer event
  117837. *
  117838. * @param id the pointer id to search for
  117839. * @returns the controller that correlates to this id or null if not found
  117840. */
  117841. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  117842. protected _onXRFrame(_xrFrame: XRFrame): void;
  117843. private _attachGazeMode;
  117844. private _attachScreenRayMode;
  117845. private _attachTrackedPointerRayMode;
  117846. private _convertNormalToDirectionOfRay;
  117847. private _detachController;
  117848. private _generateNewMeshPair;
  117849. private _pickingMoved;
  117850. private _updatePointerDistance;
  117851. }
  117852. }
  117853. declare module BABYLON {
  117854. /**
  117855. * Button which can be used to enter a different mode of XR
  117856. */
  117857. export class WebXREnterExitUIButton {
  117858. /** button element */
  117859. element: HTMLElement;
  117860. /** XR initialization options for the button */
  117861. sessionMode: XRSessionMode;
  117862. /** Reference space type */
  117863. referenceSpaceType: XRReferenceSpaceType;
  117864. /**
  117865. * Creates a WebXREnterExitUIButton
  117866. * @param element button element
  117867. * @param sessionMode XR initialization session mode
  117868. * @param referenceSpaceType the type of reference space to be used
  117869. */
  117870. constructor(
  117871. /** button element */
  117872. element: HTMLElement,
  117873. /** XR initialization options for the button */
  117874. sessionMode: XRSessionMode,
  117875. /** Reference space type */
  117876. referenceSpaceType: XRReferenceSpaceType);
  117877. /**
  117878. * Extendable function which can be used to update the button's visuals when the state changes
  117879. * @param activeButton the current active button in the UI
  117880. */
  117881. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  117882. }
  117883. /**
  117884. * Options to create the webXR UI
  117885. */
  117886. export class WebXREnterExitUIOptions {
  117887. /**
  117888. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  117889. */
  117890. customButtons?: Array<WebXREnterExitUIButton>;
  117891. /**
  117892. * A reference space type to use when creating the default button.
  117893. * Default is local-floor
  117894. */
  117895. referenceSpaceType?: XRReferenceSpaceType;
  117896. /**
  117897. * Context to enter xr with
  117898. */
  117899. renderTarget?: Nullable<WebXRRenderTarget>;
  117900. /**
  117901. * A session mode to use when creating the default button.
  117902. * Default is immersive-vr
  117903. */
  117904. sessionMode?: XRSessionMode;
  117905. }
  117906. /**
  117907. * UI to allow the user to enter/exit XR mode
  117908. */
  117909. export class WebXREnterExitUI implements IDisposable {
  117910. private scene;
  117911. /** version of the options passed to this UI */
  117912. options: WebXREnterExitUIOptions;
  117913. private _activeButton;
  117914. private _buttons;
  117915. private _overlay;
  117916. /**
  117917. * Fired every time the active button is changed.
  117918. *
  117919. * When xr is entered via a button that launches xr that button will be the callback parameter
  117920. *
  117921. * When exiting xr the callback parameter will be null)
  117922. */
  117923. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  117924. /**
  117925. *
  117926. * @param scene babylon scene object to use
  117927. * @param options (read-only) version of the options passed to this UI
  117928. */
  117929. private constructor();
  117930. /**
  117931. * Creates UI to allow the user to enter/exit XR mode
  117932. * @param scene the scene to add the ui to
  117933. * @param helper the xr experience helper to enter/exit xr with
  117934. * @param options options to configure the UI
  117935. * @returns the created ui
  117936. */
  117937. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  117938. /**
  117939. * Disposes of the XR UI component
  117940. */
  117941. dispose(): void;
  117942. private _updateButtons;
  117943. }
  117944. }
  117945. declare module BABYLON {
  117946. /**
  117947. * Class containing static functions to help procedurally build meshes
  117948. */
  117949. export class LinesBuilder {
  117950. /**
  117951. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  117952. * * 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
  117953. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  117954. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  117955. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  117956. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  117957. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117958. * * 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
  117959. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  117960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117961. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  117962. * @param name defines the name of the new line system
  117963. * @param options defines the options used to create the line system
  117964. * @param scene defines the hosting scene
  117965. * @returns a new line system mesh
  117966. */
  117967. static CreateLineSystem(name: string, options: {
  117968. lines: Vector3[][];
  117969. updatable?: boolean;
  117970. instance?: Nullable<LinesMesh>;
  117971. colors?: Nullable<Color4[][]>;
  117972. useVertexAlpha?: boolean;
  117973. }, scene: Nullable<Scene>): LinesMesh;
  117974. /**
  117975. * Creates a line mesh
  117976. * 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
  117977. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117978. * * The parameter `points` is an array successive Vector3
  117979. * * 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
  117980. * * The optional parameter `colors` is an array of successive Color4, one per line point
  117981. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  117982. * * When updating an instance, remember that only point positions can change, not the number of points
  117983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117984. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  117985. * @param name defines the name of the new line system
  117986. * @param options defines the options used to create the line system
  117987. * @param scene defines the hosting scene
  117988. * @returns a new line mesh
  117989. */
  117990. static CreateLines(name: string, options: {
  117991. points: Vector3[];
  117992. updatable?: boolean;
  117993. instance?: Nullable<LinesMesh>;
  117994. colors?: Color4[];
  117995. useVertexAlpha?: boolean;
  117996. }, scene?: Nullable<Scene>): LinesMesh;
  117997. /**
  117998. * Creates a dashed line mesh
  117999. * * 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
  118000. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118001. * * The parameter `points` is an array successive Vector3
  118002. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  118003. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  118004. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118005. * * 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
  118006. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118007. * * When updating an instance, remember that only point positions can change, not the number of points
  118008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118009. * @param name defines the name of the mesh
  118010. * @param options defines the options used to create the mesh
  118011. * @param scene defines the hosting scene
  118012. * @returns the dashed line mesh
  118013. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  118014. */
  118015. static CreateDashedLines(name: string, options: {
  118016. points: Vector3[];
  118017. dashSize?: number;
  118018. gapSize?: number;
  118019. dashNb?: number;
  118020. updatable?: boolean;
  118021. instance?: LinesMesh;
  118022. useVertexAlpha?: boolean;
  118023. }, scene?: Nullable<Scene>): LinesMesh;
  118024. }
  118025. }
  118026. declare module BABYLON {
  118027. /**
  118028. * The options container for the teleportation module
  118029. */
  118030. export interface IWebXRTeleportationOptions {
  118031. /**
  118032. * if provided, this scene will be used to render meshes.
  118033. */
  118034. customUtilityLayerScene?: Scene;
  118035. /**
  118036. * Values to configure the default target mesh
  118037. */
  118038. defaultTargetMeshOptions?: {
  118039. /**
  118040. * Fill color of the teleportation area
  118041. */
  118042. teleportationFillColor?: string;
  118043. /**
  118044. * Border color for the teleportation area
  118045. */
  118046. teleportationBorderColor?: string;
  118047. /**
  118048. * Disable the mesh's animation sequence
  118049. */
  118050. disableAnimation?: boolean;
  118051. /**
  118052. * Disable lighting on the material or the ring and arrow
  118053. */
  118054. disableLighting?: boolean;
  118055. /**
  118056. * Override the default material of the torus and arrow
  118057. */
  118058. torusArrowMaterial?: Material;
  118059. };
  118060. /**
  118061. * A list of meshes to use as floor meshes.
  118062. * Meshes can be added and removed after initializing the feature using the
  118063. * addFloorMesh and removeFloorMesh functions
  118064. * If empty, rotation will still work
  118065. */
  118066. floorMeshes?: AbstractMesh[];
  118067. /**
  118068. * use this rendering group id for the meshes (optional)
  118069. */
  118070. renderingGroupId?: number;
  118071. /**
  118072. * Should teleportation move only to snap points
  118073. */
  118074. snapPointsOnly?: boolean;
  118075. /**
  118076. * An array of points to which the teleportation will snap to.
  118077. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  118078. */
  118079. snapPositions?: Vector3[];
  118080. /**
  118081. * How close should the teleportation ray be in order to snap to position.
  118082. * Default to 0.8 units (meters)
  118083. */
  118084. snapToPositionRadius?: number;
  118085. /**
  118086. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  118087. * If you want to support rotation, make sure your mesh has a direction indicator.
  118088. *
  118089. * When left untouched, the default mesh will be initialized.
  118090. */
  118091. teleportationTargetMesh?: AbstractMesh;
  118092. /**
  118093. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  118094. */
  118095. timeToTeleport?: number;
  118096. /**
  118097. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  118098. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  118099. */
  118100. useMainComponentOnly?: boolean;
  118101. /**
  118102. * Should meshes created here be added to a utility layer or the main scene
  118103. */
  118104. useUtilityLayer?: boolean;
  118105. /**
  118106. * Babylon XR Input class for controller
  118107. */
  118108. xrInput: WebXRInput;
  118109. }
  118110. /**
  118111. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  118112. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  118113. * the input of the attached controllers.
  118114. */
  118115. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  118116. private _options;
  118117. private _controllers;
  118118. private _currentTeleportationControllerId;
  118119. private _floorMeshes;
  118120. private _quadraticBezierCurve;
  118121. private _selectionFeature;
  118122. private _snapToPositions;
  118123. private _snappedToPoint;
  118124. private _teleportationRingMaterial?;
  118125. private _tmpRay;
  118126. private _tmpVector;
  118127. /**
  118128. * The module's name
  118129. */
  118130. static readonly Name: string;
  118131. /**
  118132. * The (Babylon) version of this module.
  118133. * This is an integer representing the implementation version.
  118134. * This number does not correspond to the webxr specs version
  118135. */
  118136. static readonly Version: number;
  118137. /**
  118138. * Is movement backwards enabled
  118139. */
  118140. backwardsMovementEnabled: boolean;
  118141. /**
  118142. * Distance to travel when moving backwards
  118143. */
  118144. backwardsTeleportationDistance: number;
  118145. /**
  118146. * The distance from the user to the inspection point in the direction of the controller
  118147. * A higher number will allow the user to move further
  118148. * defaults to 5 (meters, in xr units)
  118149. */
  118150. parabolicCheckRadius: number;
  118151. /**
  118152. * Should the module support parabolic ray on top of direct ray
  118153. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  118154. * Very helpful when moving between floors / different heights
  118155. */
  118156. parabolicRayEnabled: boolean;
  118157. /**
  118158. * How much rotation should be applied when rotating right and left
  118159. */
  118160. rotationAngle: number;
  118161. /**
  118162. * Is rotation enabled when moving forward?
  118163. * Disabling this feature will prevent the user from deciding the direction when teleporting
  118164. */
  118165. rotationEnabled: boolean;
  118166. /**
  118167. * constructs a new anchor system
  118168. * @param _xrSessionManager an instance of WebXRSessionManager
  118169. * @param _options configuration object for this feature
  118170. */
  118171. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  118172. /**
  118173. * Get the snapPointsOnly flag
  118174. */
  118175. get snapPointsOnly(): boolean;
  118176. /**
  118177. * Sets the snapPointsOnly flag
  118178. * @param snapToPoints should teleportation be exclusively to snap points
  118179. */
  118180. set snapPointsOnly(snapToPoints: boolean);
  118181. /**
  118182. * Add a new mesh to the floor meshes array
  118183. * @param mesh the mesh to use as floor mesh
  118184. */
  118185. addFloorMesh(mesh: AbstractMesh): void;
  118186. /**
  118187. * Add a new snap-to point to fix teleportation to this position
  118188. * @param newSnapPoint The new Snap-To point
  118189. */
  118190. addSnapPoint(newSnapPoint: Vector3): void;
  118191. attach(): boolean;
  118192. detach(): boolean;
  118193. dispose(): void;
  118194. /**
  118195. * Remove a mesh from the floor meshes array
  118196. * @param mesh the mesh to remove
  118197. */
  118198. removeFloorMesh(mesh: AbstractMesh): void;
  118199. /**
  118200. * Remove a mesh from the floor meshes array using its name
  118201. * @param name the mesh name to remove
  118202. */
  118203. removeFloorMeshByName(name: string): void;
  118204. /**
  118205. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  118206. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  118207. * @returns was the point found and removed or not
  118208. */
  118209. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  118210. /**
  118211. * This function sets a selection feature that will be disabled when
  118212. * the forward ray is shown and will be reattached when hidden.
  118213. * This is used to remove the selection rays when moving.
  118214. * @param selectionFeature the feature to disable when forward movement is enabled
  118215. */
  118216. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  118217. protected _onXRFrame(_xrFrame: XRFrame): void;
  118218. private _attachController;
  118219. private _createDefaultTargetMesh;
  118220. private _detachController;
  118221. private _findClosestSnapPointWithRadius;
  118222. private _setTargetMeshPosition;
  118223. private _setTargetMeshVisibility;
  118224. private _showParabolicPath;
  118225. private _teleportForward;
  118226. }
  118227. }
  118228. declare module BABYLON {
  118229. /**
  118230. * Options for the default xr helper
  118231. */
  118232. export class WebXRDefaultExperienceOptions {
  118233. /**
  118234. * Enable or disable default UI to enter XR
  118235. */
  118236. disableDefaultUI?: boolean;
  118237. /**
  118238. * Should teleportation not initialize. defaults to false.
  118239. */
  118240. disableTeleportation?: boolean;
  118241. /**
  118242. * Floor meshes that will be used for teleport
  118243. */
  118244. floorMeshes?: Array<AbstractMesh>;
  118245. /**
  118246. * If set to true, the first frame will not be used to reset position
  118247. * The first frame is mainly used when copying transformation from the old camera
  118248. * Mainly used in AR
  118249. */
  118250. ignoreNativeCameraTransformation?: boolean;
  118251. /**
  118252. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  118253. */
  118254. inputOptions?: IWebXRInputOptions;
  118255. /**
  118256. * optional configuration for the output canvas
  118257. */
  118258. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  118259. /**
  118260. * optional UI options. This can be used among other to change session mode and reference space type
  118261. */
  118262. uiOptions?: WebXREnterExitUIOptions;
  118263. /**
  118264. * When loading teleportation and pointer select, use stable versions instead of latest.
  118265. */
  118266. useStablePlugins?: boolean;
  118267. }
  118268. /**
  118269. * Default experience which provides a similar setup to the previous webVRExperience
  118270. */
  118271. export class WebXRDefaultExperience {
  118272. /**
  118273. * Base experience
  118274. */
  118275. baseExperience: WebXRExperienceHelper;
  118276. /**
  118277. * Enables ui for entering/exiting xr
  118278. */
  118279. enterExitUI: WebXREnterExitUI;
  118280. /**
  118281. * Input experience extension
  118282. */
  118283. input: WebXRInput;
  118284. /**
  118285. * Enables laser pointer and selection
  118286. */
  118287. pointerSelection: WebXRControllerPointerSelection;
  118288. /**
  118289. * Default target xr should render to
  118290. */
  118291. renderTarget: WebXRRenderTarget;
  118292. /**
  118293. * Enables teleportation
  118294. */
  118295. teleportation: WebXRMotionControllerTeleportation;
  118296. private constructor();
  118297. /**
  118298. * Creates the default xr experience
  118299. * @param scene scene
  118300. * @param options options for basic configuration
  118301. * @returns resulting WebXRDefaultExperience
  118302. */
  118303. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118304. /**
  118305. * DIsposes of the experience helper
  118306. */
  118307. dispose(): void;
  118308. }
  118309. }
  118310. declare module BABYLON {
  118311. /**
  118312. * Options to modify the vr teleportation behavior.
  118313. */
  118314. export interface VRTeleportationOptions {
  118315. /**
  118316. * The name of the mesh which should be used as the teleportation floor. (default: null)
  118317. */
  118318. floorMeshName?: string;
  118319. /**
  118320. * A list of meshes to be used as the teleportation floor. (default: empty)
  118321. */
  118322. floorMeshes?: Mesh[];
  118323. /**
  118324. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  118325. */
  118326. teleportationMode?: number;
  118327. /**
  118328. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  118329. */
  118330. teleportationTime?: number;
  118331. /**
  118332. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  118333. */
  118334. teleportationSpeed?: number;
  118335. /**
  118336. * The easing function used in the animation or null for Linear. (default CircleEase)
  118337. */
  118338. easingFunction?: EasingFunction;
  118339. }
  118340. /**
  118341. * Options to modify the vr experience helper's behavior.
  118342. */
  118343. export interface VRExperienceHelperOptions extends WebVROptions {
  118344. /**
  118345. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  118346. */
  118347. createDeviceOrientationCamera?: boolean;
  118348. /**
  118349. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  118350. */
  118351. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  118352. /**
  118353. * Uses the main button on the controller to toggle the laser casted. (default: true)
  118354. */
  118355. laserToggle?: boolean;
  118356. /**
  118357. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  118358. */
  118359. floorMeshes?: Mesh[];
  118360. /**
  118361. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  118362. */
  118363. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  118364. /**
  118365. * Defines if WebXR should be used instead of WebVR (if available)
  118366. */
  118367. useXR?: boolean;
  118368. }
  118369. /**
  118370. * Event containing information after VR has been entered
  118371. */
  118372. export class OnAfterEnteringVRObservableEvent {
  118373. /**
  118374. * If entering vr was successful
  118375. */
  118376. success: boolean;
  118377. }
  118378. /**
  118379. * Helps to quickly add VR support to an existing scene.
  118380. * See http://doc.babylonjs.com/how_to/webvr_helper
  118381. */
  118382. export class VRExperienceHelper {
  118383. /** Options to modify the vr experience helper's behavior. */
  118384. webVROptions: VRExperienceHelperOptions;
  118385. private _scene;
  118386. private _position;
  118387. private _btnVR;
  118388. private _btnVRDisplayed;
  118389. private _webVRsupported;
  118390. private _webVRready;
  118391. private _webVRrequesting;
  118392. private _webVRpresenting;
  118393. private _hasEnteredVR;
  118394. private _fullscreenVRpresenting;
  118395. private _inputElement;
  118396. private _webVRCamera;
  118397. private _vrDeviceOrientationCamera;
  118398. private _deviceOrientationCamera;
  118399. private _existingCamera;
  118400. private _onKeyDown;
  118401. private _onVrDisplayPresentChange;
  118402. private _onVRDisplayChanged;
  118403. private _onVRRequestPresentStart;
  118404. private _onVRRequestPresentComplete;
  118405. /**
  118406. * 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)
  118407. */
  118408. enableGazeEvenWhenNoPointerLock: boolean;
  118409. /**
  118410. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  118411. */
  118412. exitVROnDoubleTap: boolean;
  118413. /**
  118414. * Observable raised right before entering VR.
  118415. */
  118416. onEnteringVRObservable: Observable<VRExperienceHelper>;
  118417. /**
  118418. * Observable raised when entering VR has completed.
  118419. */
  118420. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  118421. /**
  118422. * Observable raised when exiting VR.
  118423. */
  118424. onExitingVRObservable: Observable<VRExperienceHelper>;
  118425. /**
  118426. * Observable raised when controller mesh is loaded.
  118427. */
  118428. onControllerMeshLoadedObservable: Observable<WebVRController>;
  118429. /** Return this.onEnteringVRObservable
  118430. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  118431. */
  118432. get onEnteringVR(): Observable<VRExperienceHelper>;
  118433. /** Return this.onExitingVRObservable
  118434. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  118435. */
  118436. get onExitingVR(): Observable<VRExperienceHelper>;
  118437. /** Return this.onControllerMeshLoadedObservable
  118438. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  118439. */
  118440. get onControllerMeshLoaded(): Observable<WebVRController>;
  118441. private _rayLength;
  118442. private _useCustomVRButton;
  118443. private _teleportationRequested;
  118444. private _teleportActive;
  118445. private _floorMeshName;
  118446. private _floorMeshesCollection;
  118447. private _teleportationMode;
  118448. private _teleportationTime;
  118449. private _teleportationSpeed;
  118450. private _teleportationEasing;
  118451. private _rotationAllowed;
  118452. private _teleportBackwardsVector;
  118453. private _teleportationTarget;
  118454. private _isDefaultTeleportationTarget;
  118455. private _postProcessMove;
  118456. private _teleportationFillColor;
  118457. private _teleportationBorderColor;
  118458. private _rotationAngle;
  118459. private _haloCenter;
  118460. private _cameraGazer;
  118461. private _padSensibilityUp;
  118462. private _padSensibilityDown;
  118463. private _leftController;
  118464. private _rightController;
  118465. private _gazeColor;
  118466. private _laserColor;
  118467. private _pickedLaserColor;
  118468. private _pickedGazeColor;
  118469. /**
  118470. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  118471. */
  118472. onNewMeshSelected: Observable<AbstractMesh>;
  118473. /**
  118474. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  118475. * This observable will provide the mesh and the controller used to select the mesh
  118476. */
  118477. onMeshSelectedWithController: Observable<{
  118478. mesh: AbstractMesh;
  118479. controller: WebVRController;
  118480. }>;
  118481. /**
  118482. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  118483. */
  118484. onNewMeshPicked: Observable<PickingInfo>;
  118485. private _circleEase;
  118486. /**
  118487. * Observable raised before camera teleportation
  118488. */
  118489. onBeforeCameraTeleport: Observable<Vector3>;
  118490. /**
  118491. * Observable raised after camera teleportation
  118492. */
  118493. onAfterCameraTeleport: Observable<Vector3>;
  118494. /**
  118495. * Observable raised when current selected mesh gets unselected
  118496. */
  118497. onSelectedMeshUnselected: Observable<AbstractMesh>;
  118498. private _raySelectionPredicate;
  118499. /**
  118500. * To be optionaly changed by user to define custom ray selection
  118501. */
  118502. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118503. /**
  118504. * To be optionaly changed by user to define custom selection logic (after ray selection)
  118505. */
  118506. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118507. /**
  118508. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  118509. */
  118510. teleportationEnabled: boolean;
  118511. private _defaultHeight;
  118512. private _teleportationInitialized;
  118513. private _interactionsEnabled;
  118514. private _interactionsRequested;
  118515. private _displayGaze;
  118516. private _displayLaserPointer;
  118517. /**
  118518. * The mesh used to display where the user is going to teleport.
  118519. */
  118520. get teleportationTarget(): Mesh;
  118521. /**
  118522. * Sets the mesh to be used to display where the user is going to teleport.
  118523. */
  118524. set teleportationTarget(value: Mesh);
  118525. /**
  118526. * 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
  118527. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  118528. * See http://doc.babylonjs.com/resources/baking_transformations
  118529. */
  118530. get gazeTrackerMesh(): Mesh;
  118531. set gazeTrackerMesh(value: Mesh);
  118532. /**
  118533. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  118534. */
  118535. updateGazeTrackerScale: boolean;
  118536. /**
  118537. * If the gaze trackers color should be updated when selecting meshes
  118538. */
  118539. updateGazeTrackerColor: boolean;
  118540. /**
  118541. * If the controller laser color should be updated when selecting meshes
  118542. */
  118543. updateControllerLaserColor: boolean;
  118544. /**
  118545. * The gaze tracking mesh corresponding to the left controller
  118546. */
  118547. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  118548. /**
  118549. * The gaze tracking mesh corresponding to the right controller
  118550. */
  118551. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  118552. /**
  118553. * If the ray of the gaze should be displayed.
  118554. */
  118555. get displayGaze(): boolean;
  118556. /**
  118557. * Sets if the ray of the gaze should be displayed.
  118558. */
  118559. set displayGaze(value: boolean);
  118560. /**
  118561. * If the ray of the LaserPointer should be displayed.
  118562. */
  118563. get displayLaserPointer(): boolean;
  118564. /**
  118565. * Sets if the ray of the LaserPointer should be displayed.
  118566. */
  118567. set displayLaserPointer(value: boolean);
  118568. /**
  118569. * The deviceOrientationCamera used as the camera when not in VR.
  118570. */
  118571. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  118572. /**
  118573. * Based on the current WebVR support, returns the current VR camera used.
  118574. */
  118575. get currentVRCamera(): Nullable<Camera>;
  118576. /**
  118577. * The webVRCamera which is used when in VR.
  118578. */
  118579. get webVRCamera(): WebVRFreeCamera;
  118580. /**
  118581. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  118582. */
  118583. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  118584. /**
  118585. * The html button that is used to trigger entering into VR.
  118586. */
  118587. get vrButton(): Nullable<HTMLButtonElement>;
  118588. private get _teleportationRequestInitiated();
  118589. /**
  118590. * Defines whether or not Pointer lock should be requested when switching to
  118591. * full screen.
  118592. */
  118593. requestPointerLockOnFullScreen: boolean;
  118594. /**
  118595. * If asking to force XR, this will be populated with the default xr experience
  118596. */
  118597. xr: WebXRDefaultExperience;
  118598. /**
  118599. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  118600. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  118601. */
  118602. xrTestDone: boolean;
  118603. /**
  118604. * Instantiates a VRExperienceHelper.
  118605. * Helps to quickly add VR support to an existing scene.
  118606. * @param scene The scene the VRExperienceHelper belongs to.
  118607. * @param webVROptions Options to modify the vr experience helper's behavior.
  118608. */
  118609. constructor(scene: Scene,
  118610. /** Options to modify the vr experience helper's behavior. */
  118611. webVROptions?: VRExperienceHelperOptions);
  118612. private completeVRInit;
  118613. private _onDefaultMeshLoaded;
  118614. private _onResize;
  118615. private _onFullscreenChange;
  118616. /**
  118617. * Gets a value indicating if we are currently in VR mode.
  118618. */
  118619. get isInVRMode(): boolean;
  118620. private onVrDisplayPresentChange;
  118621. private onVRDisplayChanged;
  118622. private moveButtonToBottomRight;
  118623. private displayVRButton;
  118624. private updateButtonVisibility;
  118625. private _cachedAngularSensibility;
  118626. /**
  118627. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  118628. * Otherwise, will use the fullscreen API.
  118629. */
  118630. enterVR(): void;
  118631. /**
  118632. * Attempt to exit VR, or fullscreen.
  118633. */
  118634. exitVR(): void;
  118635. /**
  118636. * The position of the vr experience helper.
  118637. */
  118638. get position(): Vector3;
  118639. /**
  118640. * Sets the position of the vr experience helper.
  118641. */
  118642. set position(value: Vector3);
  118643. /**
  118644. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  118645. */
  118646. enableInteractions(): void;
  118647. private get _noControllerIsActive();
  118648. private beforeRender;
  118649. private _isTeleportationFloor;
  118650. /**
  118651. * Adds a floor mesh to be used for teleportation.
  118652. * @param floorMesh the mesh to be used for teleportation.
  118653. */
  118654. addFloorMesh(floorMesh: Mesh): void;
  118655. /**
  118656. * Removes a floor mesh from being used for teleportation.
  118657. * @param floorMesh the mesh to be removed.
  118658. */
  118659. removeFloorMesh(floorMesh: Mesh): void;
  118660. /**
  118661. * Enables interactions and teleportation using the VR controllers and gaze.
  118662. * @param vrTeleportationOptions options to modify teleportation behavior.
  118663. */
  118664. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  118665. private _onNewGamepadConnected;
  118666. private _tryEnableInteractionOnController;
  118667. private _onNewGamepadDisconnected;
  118668. private _enableInteractionOnController;
  118669. private _checkTeleportWithRay;
  118670. private _checkRotate;
  118671. private _checkTeleportBackwards;
  118672. private _enableTeleportationOnController;
  118673. private _createTeleportationCircles;
  118674. private _displayTeleportationTarget;
  118675. private _hideTeleportationTarget;
  118676. private _rotateCamera;
  118677. private _moveTeleportationSelectorTo;
  118678. private _workingVector;
  118679. private _workingQuaternion;
  118680. private _workingMatrix;
  118681. /**
  118682. * Time Constant Teleportation Mode
  118683. */
  118684. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  118685. /**
  118686. * Speed Constant Teleportation Mode
  118687. */
  118688. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  118689. /**
  118690. * Teleports the users feet to the desired location
  118691. * @param location The location where the user's feet should be placed
  118692. */
  118693. teleportCamera(location: Vector3): void;
  118694. private _convertNormalToDirectionOfRay;
  118695. private _castRayAndSelectObject;
  118696. private _notifySelectedMeshUnselected;
  118697. /**
  118698. * Permanently set new colors for the laser pointer
  118699. * @param color the new laser color
  118700. * @param pickedColor the new laser color when picked mesh detected
  118701. */
  118702. setLaserColor(color: Color3, pickedColor?: Color3): void;
  118703. /**
  118704. * Set lighting enabled / disabled on the laser pointer of both controllers
  118705. * @param enabled should the lighting be enabled on the laser pointer
  118706. */
  118707. setLaserLightingState(enabled?: boolean): void;
  118708. /**
  118709. * Permanently set new colors for the gaze pointer
  118710. * @param color the new gaze color
  118711. * @param pickedColor the new gaze color when picked mesh detected
  118712. */
  118713. setGazeColor(color: Color3, pickedColor?: Color3): void;
  118714. /**
  118715. * Sets the color of the laser ray from the vr controllers.
  118716. * @param color new color for the ray.
  118717. */
  118718. changeLaserColor(color: Color3): void;
  118719. /**
  118720. * Sets the color of the ray from the vr headsets gaze.
  118721. * @param color new color for the ray.
  118722. */
  118723. changeGazeColor(color: Color3): void;
  118724. /**
  118725. * Exits VR and disposes of the vr experience helper
  118726. */
  118727. dispose(): void;
  118728. /**
  118729. * Gets the name of the VRExperienceHelper class
  118730. * @returns "VRExperienceHelper"
  118731. */
  118732. getClassName(): string;
  118733. }
  118734. }
  118735. declare module BABYLON {
  118736. /**
  118737. * Contains an array of blocks representing the octree
  118738. */
  118739. export interface IOctreeContainer<T> {
  118740. /**
  118741. * Blocks within the octree
  118742. */
  118743. blocks: Array<OctreeBlock<T>>;
  118744. }
  118745. /**
  118746. * Class used to store a cell in an octree
  118747. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118748. */
  118749. export class OctreeBlock<T> {
  118750. /**
  118751. * Gets the content of the current block
  118752. */
  118753. entries: T[];
  118754. /**
  118755. * Gets the list of block children
  118756. */
  118757. blocks: Array<OctreeBlock<T>>;
  118758. private _depth;
  118759. private _maxDepth;
  118760. private _capacity;
  118761. private _minPoint;
  118762. private _maxPoint;
  118763. private _boundingVectors;
  118764. private _creationFunc;
  118765. /**
  118766. * Creates a new block
  118767. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  118768. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  118769. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118770. * @param depth defines the current depth of this block in the octree
  118771. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  118772. * @param creationFunc defines a callback to call when an element is added to the block
  118773. */
  118774. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  118775. /**
  118776. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118777. */
  118778. get capacity(): number;
  118779. /**
  118780. * Gets the minimum vector (in world space) of the block's bounding box
  118781. */
  118782. get minPoint(): Vector3;
  118783. /**
  118784. * Gets the maximum vector (in world space) of the block's bounding box
  118785. */
  118786. get maxPoint(): Vector3;
  118787. /**
  118788. * Add a new element to this block
  118789. * @param entry defines the element to add
  118790. */
  118791. addEntry(entry: T): void;
  118792. /**
  118793. * Remove an element from this block
  118794. * @param entry defines the element to remove
  118795. */
  118796. removeEntry(entry: T): void;
  118797. /**
  118798. * Add an array of elements to this block
  118799. * @param entries defines the array of elements to add
  118800. */
  118801. addEntries(entries: T[]): void;
  118802. /**
  118803. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  118804. * @param frustumPlanes defines the frustum planes to test
  118805. * @param selection defines the array to store current content if selection is positive
  118806. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118807. */
  118808. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118809. /**
  118810. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  118811. * @param sphereCenter defines the bounding sphere center
  118812. * @param sphereRadius defines the bounding sphere radius
  118813. * @param selection defines the array to store current content if selection is positive
  118814. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118815. */
  118816. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118817. /**
  118818. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  118819. * @param ray defines the ray to test with
  118820. * @param selection defines the array to store current content if selection is positive
  118821. */
  118822. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  118823. /**
  118824. * Subdivide the content into child blocks (this block will then be empty)
  118825. */
  118826. createInnerBlocks(): void;
  118827. /**
  118828. * @hidden
  118829. */
  118830. 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;
  118831. }
  118832. }
  118833. declare module BABYLON {
  118834. /**
  118835. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  118836. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118837. */
  118838. export class Octree<T> {
  118839. /** 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.) */
  118840. maxDepth: number;
  118841. /**
  118842. * Blocks within the octree containing objects
  118843. */
  118844. blocks: Array<OctreeBlock<T>>;
  118845. /**
  118846. * Content stored in the octree
  118847. */
  118848. dynamicContent: T[];
  118849. private _maxBlockCapacity;
  118850. private _selectionContent;
  118851. private _creationFunc;
  118852. /**
  118853. * Creates a octree
  118854. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118855. * @param creationFunc function to be used to instatiate the octree
  118856. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  118857. * @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.)
  118858. */
  118859. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  118860. /** 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.) */
  118861. maxDepth?: number);
  118862. /**
  118863. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  118864. * @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);
  118865. * @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);
  118866. * @param entries meshes to be added to the octree blocks
  118867. */
  118868. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  118869. /**
  118870. * Adds a mesh to the octree
  118871. * @param entry Mesh to add to the octree
  118872. */
  118873. addMesh(entry: T): void;
  118874. /**
  118875. * Remove an element from the octree
  118876. * @param entry defines the element to remove
  118877. */
  118878. removeMesh(entry: T): void;
  118879. /**
  118880. * Selects an array of meshes within the frustum
  118881. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  118882. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  118883. * @returns array of meshes within the frustum
  118884. */
  118885. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  118886. /**
  118887. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  118888. * @param sphereCenter defines the bounding sphere center
  118889. * @param sphereRadius defines the bounding sphere radius
  118890. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118891. * @returns an array of objects that intersect the sphere
  118892. */
  118893. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  118894. /**
  118895. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  118896. * @param ray defines the ray to test with
  118897. * @returns array of intersected objects
  118898. */
  118899. intersectsRay(ray: Ray): SmartArray<T>;
  118900. /**
  118901. * Adds a mesh into the octree block if it intersects the block
  118902. */
  118903. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  118904. /**
  118905. * Adds a submesh into the octree block if it intersects the block
  118906. */
  118907. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  118908. }
  118909. }
  118910. declare module BABYLON {
  118911. interface Scene {
  118912. /**
  118913. * @hidden
  118914. * Backing Filed
  118915. */
  118916. _selectionOctree: Octree<AbstractMesh>;
  118917. /**
  118918. * Gets the octree used to boost mesh selection (picking)
  118919. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118920. */
  118921. selectionOctree: Octree<AbstractMesh>;
  118922. /**
  118923. * Creates or updates the octree used to boost selection (picking)
  118924. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118925. * @param maxCapacity defines the maximum capacity per leaf
  118926. * @param maxDepth defines the maximum depth of the octree
  118927. * @returns an octree of AbstractMesh
  118928. */
  118929. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  118930. }
  118931. interface AbstractMesh {
  118932. /**
  118933. * @hidden
  118934. * Backing Field
  118935. */
  118936. _submeshesOctree: Octree<SubMesh>;
  118937. /**
  118938. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  118939. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  118940. * @param maxCapacity defines the maximum size of each block (64 by default)
  118941. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  118942. * @returns the new octree
  118943. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  118944. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118945. */
  118946. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  118947. }
  118948. /**
  118949. * Defines the octree scene component responsible to manage any octrees
  118950. * in a given scene.
  118951. */
  118952. export class OctreeSceneComponent {
  118953. /**
  118954. * The component name help to identify the component in the list of scene components.
  118955. */
  118956. readonly name: string;
  118957. /**
  118958. * The scene the component belongs to.
  118959. */
  118960. scene: Scene;
  118961. /**
  118962. * Indicates if the meshes have been checked to make sure they are isEnabled()
  118963. */
  118964. readonly checksIsEnabled: boolean;
  118965. /**
  118966. * Creates a new instance of the component for the given scene
  118967. * @param scene Defines the scene to register the component in
  118968. */
  118969. constructor(scene: Scene);
  118970. /**
  118971. * Registers the component in a given scene
  118972. */
  118973. register(): void;
  118974. /**
  118975. * Return the list of active meshes
  118976. * @returns the list of active meshes
  118977. */
  118978. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118979. /**
  118980. * Return the list of active sub meshes
  118981. * @param mesh The mesh to get the candidates sub meshes from
  118982. * @returns the list of active sub meshes
  118983. */
  118984. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  118985. private _tempRay;
  118986. /**
  118987. * Return the list of sub meshes intersecting with a given local ray
  118988. * @param mesh defines the mesh to find the submesh for
  118989. * @param localRay defines the ray in local space
  118990. * @returns the list of intersecting sub meshes
  118991. */
  118992. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  118993. /**
  118994. * Return the list of sub meshes colliding with a collider
  118995. * @param mesh defines the mesh to find the submesh for
  118996. * @param collider defines the collider to evaluate the collision against
  118997. * @returns the list of colliding sub meshes
  118998. */
  118999. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  119000. /**
  119001. * Rebuilds the elements related to this component in case of
  119002. * context lost for instance.
  119003. */
  119004. rebuild(): void;
  119005. /**
  119006. * Disposes the component and the associated ressources.
  119007. */
  119008. dispose(): void;
  119009. }
  119010. }
  119011. declare module BABYLON {
  119012. /**
  119013. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  119014. */
  119015. export class Gizmo implements IDisposable {
  119016. /** The utility layer the gizmo will be added to */
  119017. gizmoLayer: UtilityLayerRenderer;
  119018. /**
  119019. * The root mesh of the gizmo
  119020. */
  119021. _rootMesh: Mesh;
  119022. private _attachedMesh;
  119023. /**
  119024. * Ratio for the scale of the gizmo (Default: 1)
  119025. */
  119026. scaleRatio: number;
  119027. /**
  119028. * If a custom mesh has been set (Default: false)
  119029. */
  119030. protected _customMeshSet: boolean;
  119031. /**
  119032. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  119033. * * When set, interactions will be enabled
  119034. */
  119035. get attachedMesh(): Nullable<AbstractMesh>;
  119036. set attachedMesh(value: Nullable<AbstractMesh>);
  119037. /**
  119038. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  119039. * @param mesh The mesh to replace the default mesh of the gizmo
  119040. */
  119041. setCustomMesh(mesh: Mesh): void;
  119042. /**
  119043. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  119044. */
  119045. updateGizmoRotationToMatchAttachedMesh: boolean;
  119046. /**
  119047. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  119048. */
  119049. updateGizmoPositionToMatchAttachedMesh: boolean;
  119050. /**
  119051. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  119052. */
  119053. updateScale: boolean;
  119054. protected _interactionsEnabled: boolean;
  119055. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119056. private _beforeRenderObserver;
  119057. private _tempVector;
  119058. /**
  119059. * Creates a gizmo
  119060. * @param gizmoLayer The utility layer the gizmo will be added to
  119061. */
  119062. constructor(
  119063. /** The utility layer the gizmo will be added to */
  119064. gizmoLayer?: UtilityLayerRenderer);
  119065. /**
  119066. * Updates the gizmo to match the attached mesh's position/rotation
  119067. */
  119068. protected _update(): void;
  119069. /**
  119070. * Disposes of the gizmo
  119071. */
  119072. dispose(): void;
  119073. }
  119074. }
  119075. declare module BABYLON {
  119076. /**
  119077. * Single plane drag gizmo
  119078. */
  119079. export class PlaneDragGizmo extends Gizmo {
  119080. /**
  119081. * Drag behavior responsible for the gizmos dragging interactions
  119082. */
  119083. dragBehavior: PointerDragBehavior;
  119084. private _pointerObserver;
  119085. /**
  119086. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119087. */
  119088. snapDistance: number;
  119089. /**
  119090. * Event that fires each time the gizmo snaps to a new location.
  119091. * * snapDistance is the the change in distance
  119092. */
  119093. onSnapObservable: Observable<{
  119094. snapDistance: number;
  119095. }>;
  119096. private _plane;
  119097. private _coloredMaterial;
  119098. private _hoverMaterial;
  119099. private _isEnabled;
  119100. private _parent;
  119101. /** @hidden */
  119102. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  119103. /** @hidden */
  119104. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119105. /**
  119106. * Creates a PlaneDragGizmo
  119107. * @param gizmoLayer The utility layer the gizmo will be added to
  119108. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  119109. * @param color The color of the gizmo
  119110. */
  119111. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119112. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119113. /**
  119114. * If the gizmo is enabled
  119115. */
  119116. set isEnabled(value: boolean);
  119117. get isEnabled(): boolean;
  119118. /**
  119119. * Disposes of the gizmo
  119120. */
  119121. dispose(): void;
  119122. }
  119123. }
  119124. declare module BABYLON {
  119125. /**
  119126. * Gizmo that enables dragging a mesh along 3 axis
  119127. */
  119128. export class PositionGizmo extends Gizmo {
  119129. /**
  119130. * Internal gizmo used for interactions on the x axis
  119131. */
  119132. xGizmo: AxisDragGizmo;
  119133. /**
  119134. * Internal gizmo used for interactions on the y axis
  119135. */
  119136. yGizmo: AxisDragGizmo;
  119137. /**
  119138. * Internal gizmo used for interactions on the z axis
  119139. */
  119140. zGizmo: AxisDragGizmo;
  119141. /**
  119142. * Internal gizmo used for interactions on the yz plane
  119143. */
  119144. xPlaneGizmo: PlaneDragGizmo;
  119145. /**
  119146. * Internal gizmo used for interactions on the xz plane
  119147. */
  119148. yPlaneGizmo: PlaneDragGizmo;
  119149. /**
  119150. * Internal gizmo used for interactions on the xy plane
  119151. */
  119152. zPlaneGizmo: PlaneDragGizmo;
  119153. /**
  119154. * private variables
  119155. */
  119156. private _meshAttached;
  119157. private _updateGizmoRotationToMatchAttachedMesh;
  119158. private _snapDistance;
  119159. private _scaleRatio;
  119160. /** Fires an event when any of it's sub gizmos are dragged */
  119161. onDragStartObservable: Observable<unknown>;
  119162. /** Fires an event when any of it's sub gizmos are released from dragging */
  119163. onDragEndObservable: Observable<unknown>;
  119164. /**
  119165. * If set to true, planar drag is enabled
  119166. */
  119167. private _planarGizmoEnabled;
  119168. get attachedMesh(): Nullable<AbstractMesh>;
  119169. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119170. /**
  119171. * Creates a PositionGizmo
  119172. * @param gizmoLayer The utility layer the gizmo will be added to
  119173. */
  119174. constructor(gizmoLayer?: UtilityLayerRenderer);
  119175. /**
  119176. * If the planar drag gizmo is enabled
  119177. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  119178. */
  119179. set planarGizmoEnabled(value: boolean);
  119180. get planarGizmoEnabled(): boolean;
  119181. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119182. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119183. /**
  119184. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119185. */
  119186. set snapDistance(value: number);
  119187. get snapDistance(): number;
  119188. /**
  119189. * Ratio for the scale of the gizmo (Default: 1)
  119190. */
  119191. set scaleRatio(value: number);
  119192. get scaleRatio(): number;
  119193. /**
  119194. * Disposes of the gizmo
  119195. */
  119196. dispose(): void;
  119197. /**
  119198. * CustomMeshes are not supported by this gizmo
  119199. * @param mesh The mesh to replace the default mesh of the gizmo
  119200. */
  119201. setCustomMesh(mesh: Mesh): void;
  119202. }
  119203. }
  119204. declare module BABYLON {
  119205. /**
  119206. * Single axis drag gizmo
  119207. */
  119208. export class AxisDragGizmo extends Gizmo {
  119209. /**
  119210. * Drag behavior responsible for the gizmos dragging interactions
  119211. */
  119212. dragBehavior: PointerDragBehavior;
  119213. private _pointerObserver;
  119214. /**
  119215. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119216. */
  119217. snapDistance: number;
  119218. /**
  119219. * Event that fires each time the gizmo snaps to a new location.
  119220. * * snapDistance is the the change in distance
  119221. */
  119222. onSnapObservable: Observable<{
  119223. snapDistance: number;
  119224. }>;
  119225. private _isEnabled;
  119226. private _parent;
  119227. private _arrow;
  119228. private _coloredMaterial;
  119229. private _hoverMaterial;
  119230. /** @hidden */
  119231. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  119232. /** @hidden */
  119233. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119234. /**
  119235. * Creates an AxisDragGizmo
  119236. * @param gizmoLayer The utility layer the gizmo will be added to
  119237. * @param dragAxis The axis which the gizmo will be able to drag on
  119238. * @param color The color of the gizmo
  119239. */
  119240. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119241. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119242. /**
  119243. * If the gizmo is enabled
  119244. */
  119245. set isEnabled(value: boolean);
  119246. get isEnabled(): boolean;
  119247. /**
  119248. * Disposes of the gizmo
  119249. */
  119250. dispose(): void;
  119251. }
  119252. }
  119253. declare module BABYLON.Debug {
  119254. /**
  119255. * The Axes viewer will show 3 axes in a specific point in space
  119256. */
  119257. export class AxesViewer {
  119258. private _xAxis;
  119259. private _yAxis;
  119260. private _zAxis;
  119261. private _scaleLinesFactor;
  119262. private _instanced;
  119263. /**
  119264. * Gets the hosting scene
  119265. */
  119266. scene: Scene;
  119267. /**
  119268. * Gets or sets a number used to scale line length
  119269. */
  119270. scaleLines: number;
  119271. /** Gets the node hierarchy used to render x-axis */
  119272. get xAxis(): TransformNode;
  119273. /** Gets the node hierarchy used to render y-axis */
  119274. get yAxis(): TransformNode;
  119275. /** Gets the node hierarchy used to render z-axis */
  119276. get zAxis(): TransformNode;
  119277. /**
  119278. * Creates a new AxesViewer
  119279. * @param scene defines the hosting scene
  119280. * @param scaleLines defines a number used to scale line length (1 by default)
  119281. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  119282. * @param xAxis defines the node hierarchy used to render the x-axis
  119283. * @param yAxis defines the node hierarchy used to render the y-axis
  119284. * @param zAxis defines the node hierarchy used to render the z-axis
  119285. */
  119286. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  119287. /**
  119288. * Force the viewer to update
  119289. * @param position defines the position of the viewer
  119290. * @param xaxis defines the x axis of the viewer
  119291. * @param yaxis defines the y axis of the viewer
  119292. * @param zaxis defines the z axis of the viewer
  119293. */
  119294. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  119295. /**
  119296. * Creates an instance of this axes viewer.
  119297. * @returns a new axes viewer with instanced meshes
  119298. */
  119299. createInstance(): AxesViewer;
  119300. /** Releases resources */
  119301. dispose(): void;
  119302. private static _SetRenderingGroupId;
  119303. }
  119304. }
  119305. declare module BABYLON.Debug {
  119306. /**
  119307. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  119308. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  119309. */
  119310. export class BoneAxesViewer extends AxesViewer {
  119311. /**
  119312. * Gets or sets the target mesh where to display the axes viewer
  119313. */
  119314. mesh: Nullable<Mesh>;
  119315. /**
  119316. * Gets or sets the target bone where to display the axes viewer
  119317. */
  119318. bone: Nullable<Bone>;
  119319. /** Gets current position */
  119320. pos: Vector3;
  119321. /** Gets direction of X axis */
  119322. xaxis: Vector3;
  119323. /** Gets direction of Y axis */
  119324. yaxis: Vector3;
  119325. /** Gets direction of Z axis */
  119326. zaxis: Vector3;
  119327. /**
  119328. * Creates a new BoneAxesViewer
  119329. * @param scene defines the hosting scene
  119330. * @param bone defines the target bone
  119331. * @param mesh defines the target mesh
  119332. * @param scaleLines defines a scaling factor for line length (1 by default)
  119333. */
  119334. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  119335. /**
  119336. * Force the viewer to update
  119337. */
  119338. update(): void;
  119339. /** Releases resources */
  119340. dispose(): void;
  119341. }
  119342. }
  119343. declare module BABYLON {
  119344. /**
  119345. * Interface used to define scene explorer extensibility option
  119346. */
  119347. export interface IExplorerExtensibilityOption {
  119348. /**
  119349. * Define the option label
  119350. */
  119351. label: string;
  119352. /**
  119353. * Defines the action to execute on click
  119354. */
  119355. action: (entity: any) => void;
  119356. }
  119357. /**
  119358. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  119359. */
  119360. export interface IExplorerExtensibilityGroup {
  119361. /**
  119362. * Defines a predicate to test if a given type mut be extended
  119363. */
  119364. predicate: (entity: any) => boolean;
  119365. /**
  119366. * Gets the list of options added to a type
  119367. */
  119368. entries: IExplorerExtensibilityOption[];
  119369. }
  119370. /**
  119371. * Interface used to define the options to use to create the Inspector
  119372. */
  119373. export interface IInspectorOptions {
  119374. /**
  119375. * Display in overlay mode (default: false)
  119376. */
  119377. overlay?: boolean;
  119378. /**
  119379. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  119380. */
  119381. globalRoot?: HTMLElement;
  119382. /**
  119383. * Display the Scene explorer
  119384. */
  119385. showExplorer?: boolean;
  119386. /**
  119387. * Display the property inspector
  119388. */
  119389. showInspector?: boolean;
  119390. /**
  119391. * Display in embed mode (both panes on the right)
  119392. */
  119393. embedMode?: boolean;
  119394. /**
  119395. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  119396. */
  119397. handleResize?: boolean;
  119398. /**
  119399. * Allow the panes to popup (default: true)
  119400. */
  119401. enablePopup?: boolean;
  119402. /**
  119403. * Allow the panes to be closed by users (default: true)
  119404. */
  119405. enableClose?: boolean;
  119406. /**
  119407. * Optional list of extensibility entries
  119408. */
  119409. explorerExtensibility?: IExplorerExtensibilityGroup[];
  119410. /**
  119411. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  119412. */
  119413. inspectorURL?: string;
  119414. /**
  119415. * Optional initial tab (default to DebugLayerTab.Properties)
  119416. */
  119417. initialTab?: DebugLayerTab;
  119418. }
  119419. interface Scene {
  119420. /**
  119421. * @hidden
  119422. * Backing field
  119423. */
  119424. _debugLayer: DebugLayer;
  119425. /**
  119426. * Gets the debug layer (aka Inspector) associated with the scene
  119427. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119428. */
  119429. debugLayer: DebugLayer;
  119430. }
  119431. /**
  119432. * Enum of inspector action tab
  119433. */
  119434. export enum DebugLayerTab {
  119435. /**
  119436. * Properties tag (default)
  119437. */
  119438. Properties = 0,
  119439. /**
  119440. * Debug tab
  119441. */
  119442. Debug = 1,
  119443. /**
  119444. * Statistics tab
  119445. */
  119446. Statistics = 2,
  119447. /**
  119448. * Tools tab
  119449. */
  119450. Tools = 3,
  119451. /**
  119452. * Settings tab
  119453. */
  119454. Settings = 4
  119455. }
  119456. /**
  119457. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119458. * what is happening in your scene
  119459. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119460. */
  119461. export class DebugLayer {
  119462. /**
  119463. * Define the url to get the inspector script from.
  119464. * By default it uses the babylonjs CDN.
  119465. * @ignoreNaming
  119466. */
  119467. static InspectorURL: string;
  119468. private _scene;
  119469. private BJSINSPECTOR;
  119470. private _onPropertyChangedObservable?;
  119471. /**
  119472. * Observable triggered when a property is changed through the inspector.
  119473. */
  119474. get onPropertyChangedObservable(): any;
  119475. /**
  119476. * Instantiates a new debug layer.
  119477. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119478. * what is happening in your scene
  119479. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119480. * @param scene Defines the scene to inspect
  119481. */
  119482. constructor(scene: Scene);
  119483. /** Creates the inspector window. */
  119484. private _createInspector;
  119485. /**
  119486. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  119487. * @param entity defines the entity to select
  119488. * @param lineContainerTitle defines the specific block to highlight
  119489. */
  119490. select(entity: any, lineContainerTitle?: string): void;
  119491. /** Get the inspector from bundle or global */
  119492. private _getGlobalInspector;
  119493. /**
  119494. * Get if the inspector is visible or not.
  119495. * @returns true if visible otherwise, false
  119496. */
  119497. isVisible(): boolean;
  119498. /**
  119499. * Hide the inspector and close its window.
  119500. */
  119501. hide(): void;
  119502. /**
  119503. * Launch the debugLayer.
  119504. * @param config Define the configuration of the inspector
  119505. * @return a promise fulfilled when the debug layer is visible
  119506. */
  119507. show(config?: IInspectorOptions): Promise<DebugLayer>;
  119508. }
  119509. }
  119510. declare module BABYLON {
  119511. /**
  119512. * Class containing static functions to help procedurally build meshes
  119513. */
  119514. export class BoxBuilder {
  119515. /**
  119516. * Creates a box mesh
  119517. * * The parameter `size` sets the size (float) of each box side (default 1)
  119518. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119519. * * 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)
  119520. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119522. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119524. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119525. * @param name defines the name of the mesh
  119526. * @param options defines the options used to create the mesh
  119527. * @param scene defines the hosting scene
  119528. * @returns the box mesh
  119529. */
  119530. static CreateBox(name: string, options: {
  119531. size?: number;
  119532. width?: number;
  119533. height?: number;
  119534. depth?: number;
  119535. faceUV?: Vector4[];
  119536. faceColors?: Color4[];
  119537. sideOrientation?: number;
  119538. frontUVs?: Vector4;
  119539. backUVs?: Vector4;
  119540. wrap?: boolean;
  119541. topBaseAt?: number;
  119542. bottomBaseAt?: number;
  119543. updatable?: boolean;
  119544. }, scene?: Nullable<Scene>): Mesh;
  119545. }
  119546. }
  119547. declare module BABYLON.Debug {
  119548. /**
  119549. * Used to show the physics impostor around the specific mesh
  119550. */
  119551. export class PhysicsViewer {
  119552. /** @hidden */
  119553. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  119554. /** @hidden */
  119555. protected _meshes: Array<Nullable<AbstractMesh>>;
  119556. /** @hidden */
  119557. protected _scene: Nullable<Scene>;
  119558. /** @hidden */
  119559. protected _numMeshes: number;
  119560. /** @hidden */
  119561. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  119562. private _renderFunction;
  119563. private _utilityLayer;
  119564. private _debugBoxMesh;
  119565. private _debugSphereMesh;
  119566. private _debugCylinderMesh;
  119567. private _debugMaterial;
  119568. private _debugMeshMeshes;
  119569. /**
  119570. * Creates a new PhysicsViewer
  119571. * @param scene defines the hosting scene
  119572. */
  119573. constructor(scene: Scene);
  119574. /** @hidden */
  119575. protected _updateDebugMeshes(): void;
  119576. /**
  119577. * Renders a specified physic impostor
  119578. * @param impostor defines the impostor to render
  119579. * @param targetMesh defines the mesh represented by the impostor
  119580. * @returns the new debug mesh used to render the impostor
  119581. */
  119582. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  119583. /**
  119584. * Hides a specified physic impostor
  119585. * @param impostor defines the impostor to hide
  119586. */
  119587. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  119588. private _getDebugMaterial;
  119589. private _getDebugBoxMesh;
  119590. private _getDebugSphereMesh;
  119591. private _getDebugCylinderMesh;
  119592. private _getDebugMeshMesh;
  119593. private _getDebugMesh;
  119594. /** Releases all resources */
  119595. dispose(): void;
  119596. }
  119597. }
  119598. declare module BABYLON {
  119599. /**
  119600. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119601. * in order to better appreciate the issue one might have.
  119602. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119603. */
  119604. export class RayHelper {
  119605. /**
  119606. * Defines the ray we are currently tryin to visualize.
  119607. */
  119608. ray: Nullable<Ray>;
  119609. private _renderPoints;
  119610. private _renderLine;
  119611. private _renderFunction;
  119612. private _scene;
  119613. private _updateToMeshFunction;
  119614. private _attachedToMesh;
  119615. private _meshSpaceDirection;
  119616. private _meshSpaceOrigin;
  119617. /**
  119618. * Helper function to create a colored helper in a scene in one line.
  119619. * @param ray Defines the ray we are currently tryin to visualize
  119620. * @param scene Defines the scene the ray is used in
  119621. * @param color Defines the color we want to see the ray in
  119622. * @returns The newly created ray helper.
  119623. */
  119624. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  119625. /**
  119626. * Instantiate a new ray helper.
  119627. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119628. * in order to better appreciate the issue one might have.
  119629. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119630. * @param ray Defines the ray we are currently tryin to visualize
  119631. */
  119632. constructor(ray: Ray);
  119633. /**
  119634. * Shows the ray we are willing to debug.
  119635. * @param scene Defines the scene the ray needs to be rendered in
  119636. * @param color Defines the color the ray needs to be rendered in
  119637. */
  119638. show(scene: Scene, color?: Color3): void;
  119639. /**
  119640. * Hides the ray we are debugging.
  119641. */
  119642. hide(): void;
  119643. private _render;
  119644. /**
  119645. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  119646. * @param mesh Defines the mesh we want the helper attached to
  119647. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  119648. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  119649. * @param length Defines the length of the ray
  119650. */
  119651. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  119652. /**
  119653. * Detach the ray helper from the mesh it has previously been attached to.
  119654. */
  119655. detachFromMesh(): void;
  119656. private _updateToMesh;
  119657. /**
  119658. * Dispose the helper and release its associated resources.
  119659. */
  119660. dispose(): void;
  119661. }
  119662. }
  119663. declare module BABYLON.Debug {
  119664. /**
  119665. * Class used to render a debug view of a given skeleton
  119666. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  119667. */
  119668. export class SkeletonViewer {
  119669. /** defines the skeleton to render */
  119670. skeleton: Skeleton;
  119671. /** defines the mesh attached to the skeleton */
  119672. mesh: AbstractMesh;
  119673. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119674. autoUpdateBonesMatrices: boolean;
  119675. /** defines the rendering group id to use with the viewer */
  119676. renderingGroupId: number;
  119677. /** Gets or sets the color used to render the skeleton */
  119678. color: Color3;
  119679. private _scene;
  119680. private _debugLines;
  119681. private _debugMesh;
  119682. private _isEnabled;
  119683. private _renderFunction;
  119684. private _utilityLayer;
  119685. /**
  119686. * Returns the mesh used to render the bones
  119687. */
  119688. get debugMesh(): Nullable<LinesMesh>;
  119689. /**
  119690. * Creates a new SkeletonViewer
  119691. * @param skeleton defines the skeleton to render
  119692. * @param mesh defines the mesh attached to the skeleton
  119693. * @param scene defines the hosting scene
  119694. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119695. * @param renderingGroupId defines the rendering group id to use with the viewer
  119696. */
  119697. constructor(
  119698. /** defines the skeleton to render */
  119699. skeleton: Skeleton,
  119700. /** defines the mesh attached to the skeleton */
  119701. mesh: AbstractMesh, scene: Scene,
  119702. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119703. autoUpdateBonesMatrices?: boolean,
  119704. /** defines the rendering group id to use with the viewer */
  119705. renderingGroupId?: number);
  119706. /** Gets or sets a boolean indicating if the viewer is enabled */
  119707. set isEnabled(value: boolean);
  119708. get isEnabled(): boolean;
  119709. private _getBonePosition;
  119710. private _getLinesForBonesWithLength;
  119711. private _getLinesForBonesNoLength;
  119712. /** Update the viewer to sync with current skeleton state */
  119713. update(): void;
  119714. /** Release associated resources */
  119715. dispose(): void;
  119716. }
  119717. }
  119718. declare module BABYLON {
  119719. /**
  119720. * Options to create the null engine
  119721. */
  119722. export class NullEngineOptions {
  119723. /**
  119724. * Render width (Default: 512)
  119725. */
  119726. renderWidth: number;
  119727. /**
  119728. * Render height (Default: 256)
  119729. */
  119730. renderHeight: number;
  119731. /**
  119732. * Texture size (Default: 512)
  119733. */
  119734. textureSize: number;
  119735. /**
  119736. * If delta time between frames should be constant
  119737. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119738. */
  119739. deterministicLockstep: boolean;
  119740. /**
  119741. * Maximum about of steps between frames (Default: 4)
  119742. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119743. */
  119744. lockstepMaxSteps: number;
  119745. }
  119746. /**
  119747. * The null engine class provides support for headless version of babylon.js.
  119748. * This can be used in server side scenario or for testing purposes
  119749. */
  119750. export class NullEngine extends Engine {
  119751. private _options;
  119752. /**
  119753. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119754. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119755. * @returns true if engine is in deterministic lock step mode
  119756. */
  119757. isDeterministicLockStep(): boolean;
  119758. /**
  119759. * Gets the max steps when engine is running in deterministic lock step
  119760. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119761. * @returns the max steps
  119762. */
  119763. getLockstepMaxSteps(): number;
  119764. /**
  119765. * Gets the current hardware scaling level.
  119766. * By default the hardware scaling level is computed from the window device ratio.
  119767. * 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.
  119768. * @returns a number indicating the current hardware scaling level
  119769. */
  119770. getHardwareScalingLevel(): number;
  119771. constructor(options?: NullEngineOptions);
  119772. /**
  119773. * Creates a vertex buffer
  119774. * @param vertices the data for the vertex buffer
  119775. * @returns the new WebGL static buffer
  119776. */
  119777. createVertexBuffer(vertices: FloatArray): DataBuffer;
  119778. /**
  119779. * Creates a new index buffer
  119780. * @param indices defines the content of the index buffer
  119781. * @param updatable defines if the index buffer must be updatable
  119782. * @returns a new webGL buffer
  119783. */
  119784. createIndexBuffer(indices: IndicesArray): DataBuffer;
  119785. /**
  119786. * Clear the current render buffer or the current render target (if any is set up)
  119787. * @param color defines the color to use
  119788. * @param backBuffer defines if the back buffer must be cleared
  119789. * @param depth defines if the depth buffer must be cleared
  119790. * @param stencil defines if the stencil buffer must be cleared
  119791. */
  119792. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119793. /**
  119794. * Gets the current render width
  119795. * @param useScreen defines if screen size must be used (or the current render target if any)
  119796. * @returns a number defining the current render width
  119797. */
  119798. getRenderWidth(useScreen?: boolean): number;
  119799. /**
  119800. * Gets the current render height
  119801. * @param useScreen defines if screen size must be used (or the current render target if any)
  119802. * @returns a number defining the current render height
  119803. */
  119804. getRenderHeight(useScreen?: boolean): number;
  119805. /**
  119806. * Set the WebGL's viewport
  119807. * @param viewport defines the viewport element to be used
  119808. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119809. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119810. */
  119811. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119812. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  119813. /**
  119814. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119815. * @param pipelineContext defines the pipeline context to use
  119816. * @param uniformsNames defines the list of uniform names
  119817. * @returns an array of webGL uniform locations
  119818. */
  119819. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119820. /**
  119821. * Gets the lsit of active attributes for a given webGL program
  119822. * @param pipelineContext defines the pipeline context to use
  119823. * @param attributesNames defines the list of attribute names to get
  119824. * @returns an array of indices indicating the offset of each attribute
  119825. */
  119826. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119827. /**
  119828. * Binds an effect to the webGL context
  119829. * @param effect defines the effect to bind
  119830. */
  119831. bindSamplers(effect: Effect): void;
  119832. /**
  119833. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119834. * @param effect defines the effect to activate
  119835. */
  119836. enableEffect(effect: Effect): void;
  119837. /**
  119838. * Set various states to the webGL context
  119839. * @param culling defines backface culling state
  119840. * @param zOffset defines the value to apply to zOffset (0 by default)
  119841. * @param force defines if states must be applied even if cache is up to date
  119842. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  119843. */
  119844. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  119845. /**
  119846. * Set the value of an uniform to an array of int32
  119847. * @param uniform defines the webGL uniform location where to store the value
  119848. * @param array defines the array of int32 to store
  119849. */
  119850. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  119851. /**
  119852. * Set the value of an uniform to an array of int32 (stored as vec2)
  119853. * @param uniform defines the webGL uniform location where to store the value
  119854. * @param array defines the array of int32 to store
  119855. */
  119856. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  119857. /**
  119858. * Set the value of an uniform to an array of int32 (stored as vec3)
  119859. * @param uniform defines the webGL uniform location where to store the value
  119860. * @param array defines the array of int32 to store
  119861. */
  119862. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  119863. /**
  119864. * Set the value of an uniform to an array of int32 (stored as vec4)
  119865. * @param uniform defines the webGL uniform location where to store the value
  119866. * @param array defines the array of int32 to store
  119867. */
  119868. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  119869. /**
  119870. * Set the value of an uniform to an array of float32
  119871. * @param uniform defines the webGL uniform location where to store the value
  119872. * @param array defines the array of float32 to store
  119873. */
  119874. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  119875. /**
  119876. * Set the value of an uniform to an array of float32 (stored as vec2)
  119877. * @param uniform defines the webGL uniform location where to store the value
  119878. * @param array defines the array of float32 to store
  119879. */
  119880. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  119881. /**
  119882. * Set the value of an uniform to an array of float32 (stored as vec3)
  119883. * @param uniform defines the webGL uniform location where to store the value
  119884. * @param array defines the array of float32 to store
  119885. */
  119886. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  119887. /**
  119888. * Set the value of an uniform to an array of float32 (stored as vec4)
  119889. * @param uniform defines the webGL uniform location where to store the value
  119890. * @param array defines the array of float32 to store
  119891. */
  119892. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  119893. /**
  119894. * Set the value of an uniform to an array of number
  119895. * @param uniform defines the webGL uniform location where to store the value
  119896. * @param array defines the array of number to store
  119897. */
  119898. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  119899. /**
  119900. * Set the value of an uniform to an array of number (stored as vec2)
  119901. * @param uniform defines the webGL uniform location where to store the value
  119902. * @param array defines the array of number to store
  119903. */
  119904. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  119905. /**
  119906. * Set the value of an uniform to an array of number (stored as vec3)
  119907. * @param uniform defines the webGL uniform location where to store the value
  119908. * @param array defines the array of number to store
  119909. */
  119910. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  119911. /**
  119912. * Set the value of an uniform to an array of number (stored as vec4)
  119913. * @param uniform defines the webGL uniform location where to store the value
  119914. * @param array defines the array of number to store
  119915. */
  119916. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  119917. /**
  119918. * Set the value of an uniform to an array of float32 (stored as matrices)
  119919. * @param uniform defines the webGL uniform location where to store the value
  119920. * @param matrices defines the array of float32 to store
  119921. */
  119922. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  119923. /**
  119924. * Set the value of an uniform to a matrix (3x3)
  119925. * @param uniform defines the webGL uniform location where to store the value
  119926. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119927. */
  119928. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119929. /**
  119930. * Set the value of an uniform to a matrix (2x2)
  119931. * @param uniform defines the webGL uniform location where to store the value
  119932. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119933. */
  119934. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119935. /**
  119936. * Set the value of an uniform to a number (float)
  119937. * @param uniform defines the webGL uniform location where to store the value
  119938. * @param value defines the float number to store
  119939. */
  119940. setFloat(uniform: WebGLUniformLocation, value: number): void;
  119941. /**
  119942. * Set the value of an uniform to a vec2
  119943. * @param uniform defines the webGL uniform location where to store the value
  119944. * @param x defines the 1st component of the value
  119945. * @param y defines the 2nd component of the value
  119946. */
  119947. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  119948. /**
  119949. * Set the value of an uniform to a vec3
  119950. * @param uniform defines the webGL uniform location where to store the value
  119951. * @param x defines the 1st component of the value
  119952. * @param y defines the 2nd component of the value
  119953. * @param z defines the 3rd component of the value
  119954. */
  119955. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  119956. /**
  119957. * Set the value of an uniform to a boolean
  119958. * @param uniform defines the webGL uniform location where to store the value
  119959. * @param bool defines the boolean to store
  119960. */
  119961. setBool(uniform: WebGLUniformLocation, bool: number): void;
  119962. /**
  119963. * Set the value of an uniform to a vec4
  119964. * @param uniform defines the webGL uniform location where to store the value
  119965. * @param x defines the 1st component of the value
  119966. * @param y defines the 2nd component of the value
  119967. * @param z defines the 3rd component of the value
  119968. * @param w defines the 4th component of the value
  119969. */
  119970. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  119971. /**
  119972. * Sets the current alpha mode
  119973. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  119974. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  119975. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  119976. */
  119977. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  119978. /**
  119979. * Bind webGl buffers directly to the webGL context
  119980. * @param vertexBuffers defines the vertex buffer to bind
  119981. * @param indexBuffer defines the index buffer to bind
  119982. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119983. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119984. * @param effect defines the effect associated with the vertex buffer
  119985. */
  119986. bindBuffers(vertexBuffers: {
  119987. [key: string]: VertexBuffer;
  119988. }, indexBuffer: DataBuffer, effect: Effect): void;
  119989. /**
  119990. * Force the entire cache to be cleared
  119991. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  119992. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  119993. */
  119994. wipeCaches(bruteForce?: boolean): void;
  119995. /**
  119996. * Send a draw order
  119997. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119998. * @param indexStart defines the starting index
  119999. * @param indexCount defines the number of index to draw
  120000. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120001. */
  120002. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  120003. /**
  120004. * Draw a list of indexed primitives
  120005. * @param fillMode defines the primitive to use
  120006. * @param indexStart defines the starting index
  120007. * @param indexCount defines the number of index to draw
  120008. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120009. */
  120010. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120011. /**
  120012. * Draw a list of unindexed primitives
  120013. * @param fillMode defines the primitive to use
  120014. * @param verticesStart defines the index of first vertex to draw
  120015. * @param verticesCount defines the count of vertices to draw
  120016. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120017. */
  120018. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120019. /** @hidden */
  120020. _createTexture(): WebGLTexture;
  120021. /** @hidden */
  120022. _releaseTexture(texture: InternalTexture): void;
  120023. /**
  120024. * Usually called from Texture.ts.
  120025. * Passed information to create a WebGLTexture
  120026. * @param urlArg defines a value which contains one of the following:
  120027. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120028. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120029. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120030. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120031. * @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)
  120032. * @param scene needed for loading to the correct scene
  120033. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120034. * @param onLoad optional callback to be called upon successful completion
  120035. * @param onError optional callback to be called upon failure
  120036. * @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
  120037. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120038. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120039. * @param forcedExtension defines the extension to use to pick the right loader
  120040. * @param mimeType defines an optional mime type
  120041. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120042. */
  120043. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  120044. /**
  120045. * Creates a new render target texture
  120046. * @param size defines the size of the texture
  120047. * @param options defines the options used to create the texture
  120048. * @returns a new render target texture stored in an InternalTexture
  120049. */
  120050. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  120051. /**
  120052. * Update the sampling mode of a given texture
  120053. * @param samplingMode defines the required sampling mode
  120054. * @param texture defines the texture to update
  120055. */
  120056. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120057. /**
  120058. * Binds the frame buffer to the specified texture.
  120059. * @param texture The texture to render to or null for the default canvas
  120060. * @param faceIndex The face of the texture to render to in case of cube texture
  120061. * @param requiredWidth The width of the target to render to
  120062. * @param requiredHeight The height of the target to render to
  120063. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120064. * @param lodLevel defines le lod level to bind to the frame buffer
  120065. */
  120066. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120067. /**
  120068. * Unbind the current render target texture from the webGL context
  120069. * @param texture defines the render target texture to unbind
  120070. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120071. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120072. */
  120073. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120074. /**
  120075. * Creates a dynamic vertex buffer
  120076. * @param vertices the data for the dynamic vertex buffer
  120077. * @returns the new WebGL dynamic buffer
  120078. */
  120079. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  120080. /**
  120081. * Update the content of a dynamic texture
  120082. * @param texture defines the texture to update
  120083. * @param canvas defines the canvas containing the source
  120084. * @param invertY defines if data must be stored with Y axis inverted
  120085. * @param premulAlpha defines if alpha is stored as premultiplied
  120086. * @param format defines the format of the data
  120087. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  120088. */
  120089. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  120090. /**
  120091. * Gets a boolean indicating if all created effects are ready
  120092. * @returns true if all effects are ready
  120093. */
  120094. areAllEffectsReady(): boolean;
  120095. /**
  120096. * @hidden
  120097. * Get the current error code of the webGL context
  120098. * @returns the error code
  120099. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120100. */
  120101. getError(): number;
  120102. /** @hidden */
  120103. _getUnpackAlignement(): number;
  120104. /** @hidden */
  120105. _unpackFlipY(value: boolean): void;
  120106. /**
  120107. * Update a dynamic index buffer
  120108. * @param indexBuffer defines the target index buffer
  120109. * @param indices defines the data to update
  120110. * @param offset defines the offset in the target index buffer where update should start
  120111. */
  120112. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  120113. /**
  120114. * Updates a dynamic vertex buffer.
  120115. * @param vertexBuffer the vertex buffer to update
  120116. * @param vertices the data used to update the vertex buffer
  120117. * @param byteOffset the byte offset of the data (optional)
  120118. * @param byteLength the byte length of the data (optional)
  120119. */
  120120. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  120121. /** @hidden */
  120122. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  120123. /** @hidden */
  120124. _bindTexture(channel: number, texture: InternalTexture): void;
  120125. protected _deleteBuffer(buffer: WebGLBuffer): void;
  120126. /**
  120127. * 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
  120128. */
  120129. releaseEffects(): void;
  120130. displayLoadingUI(): void;
  120131. hideLoadingUI(): void;
  120132. /** @hidden */
  120133. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120134. /** @hidden */
  120135. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120136. /** @hidden */
  120137. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120138. /** @hidden */
  120139. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120140. }
  120141. }
  120142. declare module BABYLON {
  120143. /**
  120144. * @hidden
  120145. **/
  120146. export class _TimeToken {
  120147. _startTimeQuery: Nullable<WebGLQuery>;
  120148. _endTimeQuery: Nullable<WebGLQuery>;
  120149. _timeElapsedQuery: Nullable<WebGLQuery>;
  120150. _timeElapsedQueryEnded: boolean;
  120151. }
  120152. }
  120153. declare module BABYLON {
  120154. /** @hidden */
  120155. export class _OcclusionDataStorage {
  120156. /** @hidden */
  120157. occlusionInternalRetryCounter: number;
  120158. /** @hidden */
  120159. isOcclusionQueryInProgress: boolean;
  120160. /** @hidden */
  120161. isOccluded: boolean;
  120162. /** @hidden */
  120163. occlusionRetryCount: number;
  120164. /** @hidden */
  120165. occlusionType: number;
  120166. /** @hidden */
  120167. occlusionQueryAlgorithmType: number;
  120168. }
  120169. interface Engine {
  120170. /**
  120171. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  120172. * @return the new query
  120173. */
  120174. createQuery(): WebGLQuery;
  120175. /**
  120176. * Delete and release a webGL query
  120177. * @param query defines the query to delete
  120178. * @return the current engine
  120179. */
  120180. deleteQuery(query: WebGLQuery): Engine;
  120181. /**
  120182. * Check if a given query has resolved and got its value
  120183. * @param query defines the query to check
  120184. * @returns true if the query got its value
  120185. */
  120186. isQueryResultAvailable(query: WebGLQuery): boolean;
  120187. /**
  120188. * Gets the value of a given query
  120189. * @param query defines the query to check
  120190. * @returns the value of the query
  120191. */
  120192. getQueryResult(query: WebGLQuery): number;
  120193. /**
  120194. * Initiates an occlusion query
  120195. * @param algorithmType defines the algorithm to use
  120196. * @param query defines the query to use
  120197. * @returns the current engine
  120198. * @see http://doc.babylonjs.com/features/occlusionquery
  120199. */
  120200. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  120201. /**
  120202. * Ends an occlusion query
  120203. * @see http://doc.babylonjs.com/features/occlusionquery
  120204. * @param algorithmType defines the algorithm to use
  120205. * @returns the current engine
  120206. */
  120207. endOcclusionQuery(algorithmType: number): Engine;
  120208. /**
  120209. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  120210. * Please note that only one query can be issued at a time
  120211. * @returns a time token used to track the time span
  120212. */
  120213. startTimeQuery(): Nullable<_TimeToken>;
  120214. /**
  120215. * Ends a time query
  120216. * @param token defines the token used to measure the time span
  120217. * @returns the time spent (in ns)
  120218. */
  120219. endTimeQuery(token: _TimeToken): int;
  120220. /** @hidden */
  120221. _currentNonTimestampToken: Nullable<_TimeToken>;
  120222. /** @hidden */
  120223. _createTimeQuery(): WebGLQuery;
  120224. /** @hidden */
  120225. _deleteTimeQuery(query: WebGLQuery): void;
  120226. /** @hidden */
  120227. _getGlAlgorithmType(algorithmType: number): number;
  120228. /** @hidden */
  120229. _getTimeQueryResult(query: WebGLQuery): any;
  120230. /** @hidden */
  120231. _getTimeQueryAvailability(query: WebGLQuery): any;
  120232. }
  120233. interface AbstractMesh {
  120234. /**
  120235. * Backing filed
  120236. * @hidden
  120237. */
  120238. __occlusionDataStorage: _OcclusionDataStorage;
  120239. /**
  120240. * Access property
  120241. * @hidden
  120242. */
  120243. _occlusionDataStorage: _OcclusionDataStorage;
  120244. /**
  120245. * 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.
  120246. * The default value is -1 which means don't break the query and wait till the result
  120247. * @see http://doc.babylonjs.com/features/occlusionquery
  120248. */
  120249. occlusionRetryCount: number;
  120250. /**
  120251. * 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:
  120252. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  120253. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  120254. * * 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.
  120255. * @see http://doc.babylonjs.com/features/occlusionquery
  120256. */
  120257. occlusionType: number;
  120258. /**
  120259. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  120260. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  120261. * * 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.
  120262. * @see http://doc.babylonjs.com/features/occlusionquery
  120263. */
  120264. occlusionQueryAlgorithmType: number;
  120265. /**
  120266. * 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
  120267. * @see http://doc.babylonjs.com/features/occlusionquery
  120268. */
  120269. isOccluded: boolean;
  120270. /**
  120271. * Flag to check the progress status of the query
  120272. * @see http://doc.babylonjs.com/features/occlusionquery
  120273. */
  120274. isOcclusionQueryInProgress: boolean;
  120275. }
  120276. }
  120277. declare module BABYLON {
  120278. /** @hidden */
  120279. export var _forceTransformFeedbackToBundle: boolean;
  120280. interface Engine {
  120281. /**
  120282. * Creates a webGL transform feedback object
  120283. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  120284. * @returns the webGL transform feedback object
  120285. */
  120286. createTransformFeedback(): WebGLTransformFeedback;
  120287. /**
  120288. * Delete a webGL transform feedback object
  120289. * @param value defines the webGL transform feedback object to delete
  120290. */
  120291. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  120292. /**
  120293. * Bind a webGL transform feedback object to the webgl context
  120294. * @param value defines the webGL transform feedback object to bind
  120295. */
  120296. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  120297. /**
  120298. * Begins a transform feedback operation
  120299. * @param usePoints defines if points or triangles must be used
  120300. */
  120301. beginTransformFeedback(usePoints: boolean): void;
  120302. /**
  120303. * Ends a transform feedback operation
  120304. */
  120305. endTransformFeedback(): void;
  120306. /**
  120307. * Specify the varyings to use with transform feedback
  120308. * @param program defines the associated webGL program
  120309. * @param value defines the list of strings representing the varying names
  120310. */
  120311. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  120312. /**
  120313. * Bind a webGL buffer for a transform feedback operation
  120314. * @param value defines the webGL buffer to bind
  120315. */
  120316. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  120317. }
  120318. }
  120319. declare module BABYLON {
  120320. /**
  120321. * Creation options of the multi render target texture.
  120322. */
  120323. export interface IMultiRenderTargetOptions {
  120324. /**
  120325. * Define if the texture needs to create mip maps after render.
  120326. */
  120327. generateMipMaps?: boolean;
  120328. /**
  120329. * Define the types of all the draw buffers we want to create
  120330. */
  120331. types?: number[];
  120332. /**
  120333. * Define the sampling modes of all the draw buffers we want to create
  120334. */
  120335. samplingModes?: number[];
  120336. /**
  120337. * Define if a depth buffer is required
  120338. */
  120339. generateDepthBuffer?: boolean;
  120340. /**
  120341. * Define if a stencil buffer is required
  120342. */
  120343. generateStencilBuffer?: boolean;
  120344. /**
  120345. * Define if a depth texture is required instead of a depth buffer
  120346. */
  120347. generateDepthTexture?: boolean;
  120348. /**
  120349. * Define the number of desired draw buffers
  120350. */
  120351. textureCount?: number;
  120352. /**
  120353. * Define if aspect ratio should be adapted to the texture or stay the scene one
  120354. */
  120355. doNotChangeAspectRatio?: boolean;
  120356. /**
  120357. * Define the default type of the buffers we are creating
  120358. */
  120359. defaultType?: number;
  120360. }
  120361. /**
  120362. * A multi render target, like a render target provides the ability to render to a texture.
  120363. * Unlike the render target, it can render to several draw buffers in one draw.
  120364. * This is specially interesting in deferred rendering or for any effects requiring more than
  120365. * just one color from a single pass.
  120366. */
  120367. export class MultiRenderTarget extends RenderTargetTexture {
  120368. private _internalTextures;
  120369. private _textures;
  120370. private _multiRenderTargetOptions;
  120371. /**
  120372. * Get if draw buffers are currently supported by the used hardware and browser.
  120373. */
  120374. get isSupported(): boolean;
  120375. /**
  120376. * Get the list of textures generated by the multi render target.
  120377. */
  120378. get textures(): Texture[];
  120379. /**
  120380. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  120381. */
  120382. get depthTexture(): Texture;
  120383. /**
  120384. * Set the wrapping mode on U of all the textures we are rendering to.
  120385. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120386. */
  120387. set wrapU(wrap: number);
  120388. /**
  120389. * Set the wrapping mode on V of all the textures we are rendering to.
  120390. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120391. */
  120392. set wrapV(wrap: number);
  120393. /**
  120394. * Instantiate a new multi render target texture.
  120395. * A multi render target, like a render target provides the ability to render to a texture.
  120396. * Unlike the render target, it can render to several draw buffers in one draw.
  120397. * This is specially interesting in deferred rendering or for any effects requiring more than
  120398. * just one color from a single pass.
  120399. * @param name Define the name of the texture
  120400. * @param size Define the size of the buffers to render to
  120401. * @param count Define the number of target we are rendering into
  120402. * @param scene Define the scene the texture belongs to
  120403. * @param options Define the options used to create the multi render target
  120404. */
  120405. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  120406. /** @hidden */
  120407. _rebuild(): void;
  120408. private _createInternalTextures;
  120409. private _createTextures;
  120410. /**
  120411. * Define the number of samples used if MSAA is enabled.
  120412. */
  120413. get samples(): number;
  120414. set samples(value: number);
  120415. /**
  120416. * Resize all the textures in the multi render target.
  120417. * Be carrefull as it will recreate all the data in the new texture.
  120418. * @param size Define the new size
  120419. */
  120420. resize(size: any): void;
  120421. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  120422. /**
  120423. * Dispose the render targets and their associated resources
  120424. */
  120425. dispose(): void;
  120426. /**
  120427. * Release all the underlying texture used as draw buffers.
  120428. */
  120429. releaseInternalTextures(): void;
  120430. }
  120431. }
  120432. declare module BABYLON {
  120433. interface ThinEngine {
  120434. /**
  120435. * Unbind a list of render target textures from the webGL context
  120436. * This is used only when drawBuffer extension or webGL2 are active
  120437. * @param textures defines the render target textures to unbind
  120438. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120439. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120440. */
  120441. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  120442. /**
  120443. * Create a multi render target texture
  120444. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  120445. * @param size defines the size of the texture
  120446. * @param options defines the creation options
  120447. * @returns the cube texture as an InternalTexture
  120448. */
  120449. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  120450. /**
  120451. * Update the sample count for a given multiple render target texture
  120452. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  120453. * @param textures defines the textures to update
  120454. * @param samples defines the sample count to set
  120455. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  120456. */
  120457. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  120458. }
  120459. }
  120460. declare module BABYLON {
  120461. /**
  120462. * Class used to define an additional view for the engine
  120463. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120464. */
  120465. export class EngineView {
  120466. /** Defines the canvas where to render the view */
  120467. target: HTMLCanvasElement;
  120468. /** Defines an optional camera used to render the view (will use active camera else) */
  120469. camera?: Camera;
  120470. }
  120471. interface Engine {
  120472. /**
  120473. * Gets or sets the HTML element to use for attaching events
  120474. */
  120475. inputElement: Nullable<HTMLElement>;
  120476. /**
  120477. * Gets the current engine view
  120478. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120479. */
  120480. activeView: Nullable<EngineView>;
  120481. /** Gets or sets the list of views */
  120482. views: EngineView[];
  120483. /**
  120484. * Register a new child canvas
  120485. * @param canvas defines the canvas to register
  120486. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  120487. * @returns the associated view
  120488. */
  120489. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  120490. /**
  120491. * Remove a registered child canvas
  120492. * @param canvas defines the canvas to remove
  120493. * @returns the current engine
  120494. */
  120495. unRegisterView(canvas: HTMLCanvasElement): Engine;
  120496. }
  120497. }
  120498. declare module BABYLON {
  120499. /**
  120500. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  120501. */
  120502. export interface CubeMapInfo {
  120503. /**
  120504. * The pixel array for the front face.
  120505. * This is stored in format, left to right, up to down format.
  120506. */
  120507. front: Nullable<ArrayBufferView>;
  120508. /**
  120509. * The pixel array for the back face.
  120510. * This is stored in format, left to right, up to down format.
  120511. */
  120512. back: Nullable<ArrayBufferView>;
  120513. /**
  120514. * The pixel array for the left face.
  120515. * This is stored in format, left to right, up to down format.
  120516. */
  120517. left: Nullable<ArrayBufferView>;
  120518. /**
  120519. * The pixel array for the right face.
  120520. * This is stored in format, left to right, up to down format.
  120521. */
  120522. right: Nullable<ArrayBufferView>;
  120523. /**
  120524. * The pixel array for the up face.
  120525. * This is stored in format, left to right, up to down format.
  120526. */
  120527. up: Nullable<ArrayBufferView>;
  120528. /**
  120529. * The pixel array for the down face.
  120530. * This is stored in format, left to right, up to down format.
  120531. */
  120532. down: Nullable<ArrayBufferView>;
  120533. /**
  120534. * The size of the cubemap stored.
  120535. *
  120536. * Each faces will be size * size pixels.
  120537. */
  120538. size: number;
  120539. /**
  120540. * The format of the texture.
  120541. *
  120542. * RGBA, RGB.
  120543. */
  120544. format: number;
  120545. /**
  120546. * The type of the texture data.
  120547. *
  120548. * UNSIGNED_INT, FLOAT.
  120549. */
  120550. type: number;
  120551. /**
  120552. * Specifies whether the texture is in gamma space.
  120553. */
  120554. gammaSpace: boolean;
  120555. }
  120556. /**
  120557. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  120558. */
  120559. export class PanoramaToCubeMapTools {
  120560. private static FACE_FRONT;
  120561. private static FACE_BACK;
  120562. private static FACE_RIGHT;
  120563. private static FACE_LEFT;
  120564. private static FACE_DOWN;
  120565. private static FACE_UP;
  120566. /**
  120567. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  120568. *
  120569. * @param float32Array The source data.
  120570. * @param inputWidth The width of the input panorama.
  120571. * @param inputHeight The height of the input panorama.
  120572. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  120573. * @return The cubemap data
  120574. */
  120575. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  120576. private static CreateCubemapTexture;
  120577. private static CalcProjectionSpherical;
  120578. }
  120579. }
  120580. declare module BABYLON {
  120581. /**
  120582. * Helper class dealing with the extraction of spherical polynomial dataArray
  120583. * from a cube map.
  120584. */
  120585. export class CubeMapToSphericalPolynomialTools {
  120586. private static FileFaces;
  120587. /**
  120588. * Converts a texture to the according Spherical Polynomial data.
  120589. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120590. *
  120591. * @param texture The texture to extract the information from.
  120592. * @return The Spherical Polynomial data.
  120593. */
  120594. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  120595. /**
  120596. * Converts a cubemap to the according Spherical Polynomial data.
  120597. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120598. *
  120599. * @param cubeInfo The Cube map to extract the information from.
  120600. * @return The Spherical Polynomial data.
  120601. */
  120602. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  120603. }
  120604. }
  120605. declare module BABYLON {
  120606. interface BaseTexture {
  120607. /**
  120608. * Get the polynomial representation of the texture data.
  120609. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  120610. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  120611. */
  120612. sphericalPolynomial: Nullable<SphericalPolynomial>;
  120613. }
  120614. }
  120615. declare module BABYLON {
  120616. /** @hidden */
  120617. export var rgbdEncodePixelShader: {
  120618. name: string;
  120619. shader: string;
  120620. };
  120621. }
  120622. declare module BABYLON {
  120623. /** @hidden */
  120624. export var rgbdDecodePixelShader: {
  120625. name: string;
  120626. shader: string;
  120627. };
  120628. }
  120629. declare module BABYLON {
  120630. /**
  120631. * Raw texture data and descriptor sufficient for WebGL texture upload
  120632. */
  120633. export interface EnvironmentTextureInfo {
  120634. /**
  120635. * Version of the environment map
  120636. */
  120637. version: number;
  120638. /**
  120639. * Width of image
  120640. */
  120641. width: number;
  120642. /**
  120643. * Irradiance information stored in the file.
  120644. */
  120645. irradiance: any;
  120646. /**
  120647. * Specular information stored in the file.
  120648. */
  120649. specular: any;
  120650. }
  120651. /**
  120652. * Defines One Image in the file. It requires only the position in the file
  120653. * as well as the length.
  120654. */
  120655. interface BufferImageData {
  120656. /**
  120657. * Length of the image data.
  120658. */
  120659. length: number;
  120660. /**
  120661. * Position of the data from the null terminator delimiting the end of the JSON.
  120662. */
  120663. position: number;
  120664. }
  120665. /**
  120666. * Defines the specular data enclosed in the file.
  120667. * This corresponds to the version 1 of the data.
  120668. */
  120669. export interface EnvironmentTextureSpecularInfoV1 {
  120670. /**
  120671. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  120672. */
  120673. specularDataPosition?: number;
  120674. /**
  120675. * This contains all the images data needed to reconstruct the cubemap.
  120676. */
  120677. mipmaps: Array<BufferImageData>;
  120678. /**
  120679. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  120680. */
  120681. lodGenerationScale: number;
  120682. }
  120683. /**
  120684. * Sets of helpers addressing the serialization and deserialization of environment texture
  120685. * stored in a BabylonJS env file.
  120686. * Those files are usually stored as .env files.
  120687. */
  120688. export class EnvironmentTextureTools {
  120689. /**
  120690. * Magic number identifying the env file.
  120691. */
  120692. private static _MagicBytes;
  120693. /**
  120694. * Gets the environment info from an env file.
  120695. * @param data The array buffer containing the .env bytes.
  120696. * @returns the environment file info (the json header) if successfully parsed.
  120697. */
  120698. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  120699. /**
  120700. * Creates an environment texture from a loaded cube texture.
  120701. * @param texture defines the cube texture to convert in env file
  120702. * @return a promise containing the environment data if succesfull.
  120703. */
  120704. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120705. /**
  120706. * Creates a JSON representation of the spherical data.
  120707. * @param texture defines the texture containing the polynomials
  120708. * @return the JSON representation of the spherical info
  120709. */
  120710. private static _CreateEnvTextureIrradiance;
  120711. /**
  120712. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120713. * @param data the image data
  120714. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120715. * @return the views described by info providing access to the underlying buffer
  120716. */
  120717. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120718. /**
  120719. * Uploads the texture info contained in the env file to the GPU.
  120720. * @param texture defines the internal texture to upload to
  120721. * @param data defines the data to load
  120722. * @param info defines the texture info retrieved through the GetEnvInfo method
  120723. * @returns a promise
  120724. */
  120725. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  120726. private static _OnImageReadyAsync;
  120727. /**
  120728. * Uploads the levels of image data to the GPU.
  120729. * @param texture defines the internal texture to upload to
  120730. * @param imageData defines the array buffer views of image data [mipmap][face]
  120731. * @returns a promise
  120732. */
  120733. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120734. /**
  120735. * Uploads spherical polynomials information to the texture.
  120736. * @param texture defines the texture we are trying to upload the information to
  120737. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120738. */
  120739. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120740. /** @hidden */
  120741. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120742. }
  120743. }
  120744. declare module BABYLON {
  120745. /**
  120746. * Contains position and normal vectors for a vertex
  120747. */
  120748. export class PositionNormalVertex {
  120749. /** the position of the vertex (defaut: 0,0,0) */
  120750. position: Vector3;
  120751. /** the normal of the vertex (defaut: 0,1,0) */
  120752. normal: Vector3;
  120753. /**
  120754. * Creates a PositionNormalVertex
  120755. * @param position the position of the vertex (defaut: 0,0,0)
  120756. * @param normal the normal of the vertex (defaut: 0,1,0)
  120757. */
  120758. constructor(
  120759. /** the position of the vertex (defaut: 0,0,0) */
  120760. position?: Vector3,
  120761. /** the normal of the vertex (defaut: 0,1,0) */
  120762. normal?: Vector3);
  120763. /**
  120764. * Clones the PositionNormalVertex
  120765. * @returns the cloned PositionNormalVertex
  120766. */
  120767. clone(): PositionNormalVertex;
  120768. }
  120769. /**
  120770. * Contains position, normal and uv vectors for a vertex
  120771. */
  120772. export class PositionNormalTextureVertex {
  120773. /** the position of the vertex (defaut: 0,0,0) */
  120774. position: Vector3;
  120775. /** the normal of the vertex (defaut: 0,1,0) */
  120776. normal: Vector3;
  120777. /** the uv of the vertex (default: 0,0) */
  120778. uv: Vector2;
  120779. /**
  120780. * Creates a PositionNormalTextureVertex
  120781. * @param position the position of the vertex (defaut: 0,0,0)
  120782. * @param normal the normal of the vertex (defaut: 0,1,0)
  120783. * @param uv the uv of the vertex (default: 0,0)
  120784. */
  120785. constructor(
  120786. /** the position of the vertex (defaut: 0,0,0) */
  120787. position?: Vector3,
  120788. /** the normal of the vertex (defaut: 0,1,0) */
  120789. normal?: Vector3,
  120790. /** the uv of the vertex (default: 0,0) */
  120791. uv?: Vector2);
  120792. /**
  120793. * Clones the PositionNormalTextureVertex
  120794. * @returns the cloned PositionNormalTextureVertex
  120795. */
  120796. clone(): PositionNormalTextureVertex;
  120797. }
  120798. }
  120799. declare module BABYLON {
  120800. /** @hidden */
  120801. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  120802. private _genericAttributeLocation;
  120803. private _varyingLocationCount;
  120804. private _varyingLocationMap;
  120805. private _replacements;
  120806. private _textureCount;
  120807. private _uniforms;
  120808. lineProcessor(line: string): string;
  120809. attributeProcessor(attribute: string): string;
  120810. varyingProcessor(varying: string, isFragment: boolean): string;
  120811. uniformProcessor(uniform: string): string;
  120812. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  120813. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120814. }
  120815. }
  120816. declare module BABYLON {
  120817. /**
  120818. * Container for accessors for natively-stored mesh data buffers.
  120819. */
  120820. class NativeDataBuffer extends DataBuffer {
  120821. /**
  120822. * Accessor value used to identify/retrieve a natively-stored index buffer.
  120823. */
  120824. nativeIndexBuffer?: any;
  120825. /**
  120826. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  120827. */
  120828. nativeVertexBuffer?: any;
  120829. }
  120830. /** @hidden */
  120831. class NativeTexture extends InternalTexture {
  120832. getInternalTexture(): InternalTexture;
  120833. getViewCount(): number;
  120834. }
  120835. /** @hidden */
  120836. export class NativeEngine extends Engine {
  120837. private readonly _native;
  120838. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  120839. private readonly INVALID_HANDLE;
  120840. getHardwareScalingLevel(): number;
  120841. constructor();
  120842. /**
  120843. * Can be used to override the current requestAnimationFrame requester.
  120844. * @hidden
  120845. */
  120846. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120847. /**
  120848. * Override default engine behavior.
  120849. * @param color
  120850. * @param backBuffer
  120851. * @param depth
  120852. * @param stencil
  120853. */
  120854. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120855. /**
  120856. * Gets host document
  120857. * @returns the host document object
  120858. */
  120859. getHostDocument(): Nullable<Document>;
  120860. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120861. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  120862. createVertexBuffer(data: DataArray): NativeDataBuffer;
  120863. recordVertexArrayObject(vertexBuffers: {
  120864. [key: string]: VertexBuffer;
  120865. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120866. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120867. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120868. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120869. /**
  120870. * Draw a list of indexed primitives
  120871. * @param fillMode defines the primitive to use
  120872. * @param indexStart defines the starting index
  120873. * @param indexCount defines the number of index to draw
  120874. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120875. */
  120876. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120877. /**
  120878. * Draw a list of unindexed primitives
  120879. * @param fillMode defines the primitive to use
  120880. * @param verticesStart defines the index of first vertex to draw
  120881. * @param verticesCount defines the count of vertices to draw
  120882. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120883. */
  120884. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120885. createPipelineContext(): IPipelineContext;
  120886. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120887. /** @hidden */
  120888. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120889. /** @hidden */
  120890. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120891. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120892. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120893. protected _setProgram(program: WebGLProgram): void;
  120894. _releaseEffect(effect: Effect): void;
  120895. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120896. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  120897. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  120898. bindSamplers(effect: Effect): void;
  120899. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  120900. getRenderWidth(useScreen?: boolean): number;
  120901. getRenderHeight(useScreen?: boolean): number;
  120902. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  120903. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120904. /**
  120905. * Set the z offset to apply to current rendering
  120906. * @param value defines the offset to apply
  120907. */
  120908. setZOffset(value: number): void;
  120909. /**
  120910. * Gets the current value of the zOffset
  120911. * @returns the current zOffset state
  120912. */
  120913. getZOffset(): number;
  120914. /**
  120915. * Enable or disable depth buffering
  120916. * @param enable defines the state to set
  120917. */
  120918. setDepthBuffer(enable: boolean): void;
  120919. /**
  120920. * Gets a boolean indicating if depth writing is enabled
  120921. * @returns the current depth writing state
  120922. */
  120923. getDepthWrite(): boolean;
  120924. /**
  120925. * Enable or disable depth writing
  120926. * @param enable defines the state to set
  120927. */
  120928. setDepthWrite(enable: boolean): void;
  120929. /**
  120930. * Enable or disable color writing
  120931. * @param enable defines the state to set
  120932. */
  120933. setColorWrite(enable: boolean): void;
  120934. /**
  120935. * Gets a boolean indicating if color writing is enabled
  120936. * @returns the current color writing state
  120937. */
  120938. getColorWrite(): boolean;
  120939. /**
  120940. * Sets alpha constants used by some alpha blending modes
  120941. * @param r defines the red component
  120942. * @param g defines the green component
  120943. * @param b defines the blue component
  120944. * @param a defines the alpha component
  120945. */
  120946. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  120947. /**
  120948. * Sets the current alpha mode
  120949. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  120950. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120951. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120952. */
  120953. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120954. /**
  120955. * Gets the current alpha mode
  120956. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120957. * @returns the current alpha mode
  120958. */
  120959. getAlphaMode(): number;
  120960. setInt(uniform: WebGLUniformLocation, int: number): void;
  120961. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120962. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120963. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120964. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120965. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120966. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120967. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120968. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120969. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120970. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120971. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120972. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120973. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120974. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120975. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120976. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120977. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120978. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120979. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120980. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  120981. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  120982. wipeCaches(bruteForce?: boolean): void;
  120983. _createTexture(): WebGLTexture;
  120984. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120985. /**
  120986. * Usually called from Texture.ts.
  120987. * Passed information to create a WebGLTexture
  120988. * @param urlArg defines a value which contains one of the following:
  120989. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120990. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120991. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120992. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120993. * @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)
  120994. * @param scene needed for loading to the correct scene
  120995. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120996. * @param onLoad optional callback to be called upon successful completion
  120997. * @param onError optional callback to be called upon failure
  120998. * @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
  120999. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121000. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121001. * @param forcedExtension defines the extension to use to pick the right loader
  121002. * @param mimeType defines an optional mime type
  121003. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121004. */
  121005. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  121006. /**
  121007. * Creates a cube texture
  121008. * @param rootUrl defines the url where the files to load is located
  121009. * @param scene defines the current scene
  121010. * @param files defines the list of files to load (1 per face)
  121011. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  121012. * @param onLoad defines an optional callback raised when the texture is loaded
  121013. * @param onError defines an optional callback raised if there is an issue to load the texture
  121014. * @param format defines the format of the data
  121015. * @param forcedExtension defines the extension to use to pick the right loader
  121016. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  121017. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  121018. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  121019. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  121020. * @returns the cube texture as an InternalTexture
  121021. */
  121022. 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;
  121023. private _getSamplingFilter;
  121024. private static _GetNativeTextureFormat;
  121025. createRenderTargetTexture(size: number | {
  121026. width: number;
  121027. height: number;
  121028. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  121029. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  121030. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  121031. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121032. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  121033. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  121034. /**
  121035. * Updates a dynamic vertex buffer.
  121036. * @param vertexBuffer the vertex buffer to update
  121037. * @param data the data used to update the vertex buffer
  121038. * @param byteOffset the byte offset of the data (optional)
  121039. * @param byteLength the byte length of the data (optional)
  121040. */
  121041. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  121042. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  121043. private _updateAnisotropicLevel;
  121044. private _getAddressMode;
  121045. /** @hidden */
  121046. _bindTexture(channel: number, texture: InternalTexture): void;
  121047. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  121048. releaseEffects(): void;
  121049. /** @hidden */
  121050. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121051. /** @hidden */
  121052. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121053. /** @hidden */
  121054. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121055. /** @hidden */
  121056. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121057. }
  121058. }
  121059. declare module BABYLON {
  121060. /**
  121061. * Gather the list of clipboard event types as constants.
  121062. */
  121063. export class ClipboardEventTypes {
  121064. /**
  121065. * The clipboard event is fired when a copy command is active (pressed).
  121066. */
  121067. static readonly COPY: number;
  121068. /**
  121069. * The clipboard event is fired when a cut command is active (pressed).
  121070. */
  121071. static readonly CUT: number;
  121072. /**
  121073. * The clipboard event is fired when a paste command is active (pressed).
  121074. */
  121075. static readonly PASTE: number;
  121076. }
  121077. /**
  121078. * This class is used to store clipboard related info for the onClipboardObservable event.
  121079. */
  121080. export class ClipboardInfo {
  121081. /**
  121082. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121083. */
  121084. type: number;
  121085. /**
  121086. * Defines the related dom event
  121087. */
  121088. event: ClipboardEvent;
  121089. /**
  121090. *Creates an instance of ClipboardInfo.
  121091. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  121092. * @param event Defines the related dom event
  121093. */
  121094. constructor(
  121095. /**
  121096. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121097. */
  121098. type: number,
  121099. /**
  121100. * Defines the related dom event
  121101. */
  121102. event: ClipboardEvent);
  121103. /**
  121104. * Get the clipboard event's type from the keycode.
  121105. * @param keyCode Defines the keyCode for the current keyboard event.
  121106. * @return {number}
  121107. */
  121108. static GetTypeFromCharacter(keyCode: number): number;
  121109. }
  121110. }
  121111. declare module BABYLON {
  121112. /**
  121113. * Google Daydream controller
  121114. */
  121115. export class DaydreamController extends WebVRController {
  121116. /**
  121117. * Base Url for the controller model.
  121118. */
  121119. static MODEL_BASE_URL: string;
  121120. /**
  121121. * File name for the controller model.
  121122. */
  121123. static MODEL_FILENAME: string;
  121124. /**
  121125. * Gamepad Id prefix used to identify Daydream Controller.
  121126. */
  121127. static readonly GAMEPAD_ID_PREFIX: string;
  121128. /**
  121129. * Creates a new DaydreamController from a gamepad
  121130. * @param vrGamepad the gamepad that the controller should be created from
  121131. */
  121132. constructor(vrGamepad: any);
  121133. /**
  121134. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121135. * @param scene scene in which to add meshes
  121136. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121137. */
  121138. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121139. /**
  121140. * Called once for each button that changed state since the last frame
  121141. * @param buttonIdx Which button index changed
  121142. * @param state New state of the button
  121143. * @param changes Which properties on the state changed since last frame
  121144. */
  121145. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121146. }
  121147. }
  121148. declare module BABYLON {
  121149. /**
  121150. * Gear VR Controller
  121151. */
  121152. export class GearVRController extends WebVRController {
  121153. /**
  121154. * Base Url for the controller model.
  121155. */
  121156. static MODEL_BASE_URL: string;
  121157. /**
  121158. * File name for the controller model.
  121159. */
  121160. static MODEL_FILENAME: string;
  121161. /**
  121162. * Gamepad Id prefix used to identify this controller.
  121163. */
  121164. static readonly GAMEPAD_ID_PREFIX: string;
  121165. private readonly _buttonIndexToObservableNameMap;
  121166. /**
  121167. * Creates a new GearVRController from a gamepad
  121168. * @param vrGamepad the gamepad that the controller should be created from
  121169. */
  121170. constructor(vrGamepad: any);
  121171. /**
  121172. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121173. * @param scene scene in which to add meshes
  121174. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121175. */
  121176. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121177. /**
  121178. * Called once for each button that changed state since the last frame
  121179. * @param buttonIdx Which button index changed
  121180. * @param state New state of the button
  121181. * @param changes Which properties on the state changed since last frame
  121182. */
  121183. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121184. }
  121185. }
  121186. declare module BABYLON {
  121187. /**
  121188. * Generic Controller
  121189. */
  121190. export class GenericController extends WebVRController {
  121191. /**
  121192. * Base Url for the controller model.
  121193. */
  121194. static readonly MODEL_BASE_URL: string;
  121195. /**
  121196. * File name for the controller model.
  121197. */
  121198. static readonly MODEL_FILENAME: string;
  121199. /**
  121200. * Creates a new GenericController from a gamepad
  121201. * @param vrGamepad the gamepad that the controller should be created from
  121202. */
  121203. constructor(vrGamepad: any);
  121204. /**
  121205. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121206. * @param scene scene in which to add meshes
  121207. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121208. */
  121209. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121210. /**
  121211. * Called once for each button that changed state since the last frame
  121212. * @param buttonIdx Which button index changed
  121213. * @param state New state of the button
  121214. * @param changes Which properties on the state changed since last frame
  121215. */
  121216. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121217. }
  121218. }
  121219. declare module BABYLON {
  121220. /**
  121221. * Oculus Touch Controller
  121222. */
  121223. export class OculusTouchController extends WebVRController {
  121224. /**
  121225. * Base Url for the controller model.
  121226. */
  121227. static MODEL_BASE_URL: string;
  121228. /**
  121229. * File name for the left controller model.
  121230. */
  121231. static MODEL_LEFT_FILENAME: string;
  121232. /**
  121233. * File name for the right controller model.
  121234. */
  121235. static MODEL_RIGHT_FILENAME: string;
  121236. /**
  121237. * Base Url for the Quest controller model.
  121238. */
  121239. static QUEST_MODEL_BASE_URL: string;
  121240. /**
  121241. * @hidden
  121242. * If the controllers are running on a device that needs the updated Quest controller models
  121243. */
  121244. static _IsQuest: boolean;
  121245. /**
  121246. * Fired when the secondary trigger on this controller is modified
  121247. */
  121248. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  121249. /**
  121250. * Fired when the thumb rest on this controller is modified
  121251. */
  121252. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  121253. /**
  121254. * Creates a new OculusTouchController from a gamepad
  121255. * @param vrGamepad the gamepad that the controller should be created from
  121256. */
  121257. constructor(vrGamepad: any);
  121258. /**
  121259. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121260. * @param scene scene in which to add meshes
  121261. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121262. */
  121263. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121264. /**
  121265. * Fired when the A button on this controller is modified
  121266. */
  121267. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121268. /**
  121269. * Fired when the B button on this controller is modified
  121270. */
  121271. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121272. /**
  121273. * Fired when the X button on this controller is modified
  121274. */
  121275. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121276. /**
  121277. * Fired when the Y button on this controller is modified
  121278. */
  121279. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121280. /**
  121281. * Called once for each button that changed state since the last frame
  121282. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  121283. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  121284. * 2) secondary trigger (same)
  121285. * 3) A (right) X (left), touch, pressed = value
  121286. * 4) B / Y
  121287. * 5) thumb rest
  121288. * @param buttonIdx Which button index changed
  121289. * @param state New state of the button
  121290. * @param changes Which properties on the state changed since last frame
  121291. */
  121292. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121293. }
  121294. }
  121295. declare module BABYLON {
  121296. /**
  121297. * Vive Controller
  121298. */
  121299. export class ViveController extends WebVRController {
  121300. /**
  121301. * Base Url for the controller model.
  121302. */
  121303. static MODEL_BASE_URL: string;
  121304. /**
  121305. * File name for the controller model.
  121306. */
  121307. static MODEL_FILENAME: string;
  121308. /**
  121309. * Creates a new ViveController from a gamepad
  121310. * @param vrGamepad the gamepad that the controller should be created from
  121311. */
  121312. constructor(vrGamepad: any);
  121313. /**
  121314. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121315. * @param scene scene in which to add meshes
  121316. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121317. */
  121318. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121319. /**
  121320. * Fired when the left button on this controller is modified
  121321. */
  121322. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121323. /**
  121324. * Fired when the right button on this controller is modified
  121325. */
  121326. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121327. /**
  121328. * Fired when the menu button on this controller is modified
  121329. */
  121330. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121331. /**
  121332. * Called once for each button that changed state since the last frame
  121333. * Vive mapping:
  121334. * 0: touchpad
  121335. * 1: trigger
  121336. * 2: left AND right buttons
  121337. * 3: menu button
  121338. * @param buttonIdx Which button index changed
  121339. * @param state New state of the button
  121340. * @param changes Which properties on the state changed since last frame
  121341. */
  121342. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121343. }
  121344. }
  121345. declare module BABYLON {
  121346. /**
  121347. * Defines the WindowsMotionController object that the state of the windows motion controller
  121348. */
  121349. export class WindowsMotionController extends WebVRController {
  121350. /**
  121351. * The base url used to load the left and right controller models
  121352. */
  121353. static MODEL_BASE_URL: string;
  121354. /**
  121355. * The name of the left controller model file
  121356. */
  121357. static MODEL_LEFT_FILENAME: string;
  121358. /**
  121359. * The name of the right controller model file
  121360. */
  121361. static MODEL_RIGHT_FILENAME: string;
  121362. /**
  121363. * The controller name prefix for this controller type
  121364. */
  121365. static readonly GAMEPAD_ID_PREFIX: string;
  121366. /**
  121367. * The controller id pattern for this controller type
  121368. */
  121369. private static readonly GAMEPAD_ID_PATTERN;
  121370. private _loadedMeshInfo;
  121371. protected readonly _mapping: {
  121372. buttons: string[];
  121373. buttonMeshNames: {
  121374. 'trigger': string;
  121375. 'menu': string;
  121376. 'grip': string;
  121377. 'thumbstick': string;
  121378. 'trackpad': string;
  121379. };
  121380. buttonObservableNames: {
  121381. 'trigger': string;
  121382. 'menu': string;
  121383. 'grip': string;
  121384. 'thumbstick': string;
  121385. 'trackpad': string;
  121386. };
  121387. axisMeshNames: string[];
  121388. pointingPoseMeshName: string;
  121389. };
  121390. /**
  121391. * Fired when the trackpad on this controller is clicked
  121392. */
  121393. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121394. /**
  121395. * Fired when the trackpad on this controller is modified
  121396. */
  121397. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121398. /**
  121399. * The current x and y values of this controller's trackpad
  121400. */
  121401. trackpad: StickValues;
  121402. /**
  121403. * Creates a new WindowsMotionController from a gamepad
  121404. * @param vrGamepad the gamepad that the controller should be created from
  121405. */
  121406. constructor(vrGamepad: any);
  121407. /**
  121408. * Fired when the trigger on this controller is modified
  121409. */
  121410. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121411. /**
  121412. * Fired when the menu button on this controller is modified
  121413. */
  121414. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121415. /**
  121416. * Fired when the grip button on this controller is modified
  121417. */
  121418. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121419. /**
  121420. * Fired when the thumbstick button on this controller is modified
  121421. */
  121422. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121423. /**
  121424. * Fired when the touchpad button on this controller is modified
  121425. */
  121426. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121427. /**
  121428. * Fired when the touchpad values on this controller are modified
  121429. */
  121430. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  121431. protected _updateTrackpad(): void;
  121432. /**
  121433. * Called once per frame by the engine.
  121434. */
  121435. update(): void;
  121436. /**
  121437. * Called once for each button that changed state since the last frame
  121438. * @param buttonIdx Which button index changed
  121439. * @param state New state of the button
  121440. * @param changes Which properties on the state changed since last frame
  121441. */
  121442. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121443. /**
  121444. * Moves the buttons on the controller mesh based on their current state
  121445. * @param buttonName the name of the button to move
  121446. * @param buttonValue the value of the button which determines the buttons new position
  121447. */
  121448. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  121449. /**
  121450. * Moves the axis on the controller mesh based on its current state
  121451. * @param axis the index of the axis
  121452. * @param axisValue the value of the axis which determines the meshes new position
  121453. * @hidden
  121454. */
  121455. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  121456. /**
  121457. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121458. * @param scene scene in which to add meshes
  121459. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121460. */
  121461. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  121462. /**
  121463. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  121464. * can be transformed by button presses and axes values, based on this._mapping.
  121465. *
  121466. * @param scene scene in which the meshes exist
  121467. * @param meshes list of meshes that make up the controller model to process
  121468. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  121469. */
  121470. private processModel;
  121471. private createMeshInfo;
  121472. /**
  121473. * Gets the ray of the controller in the direction the controller is pointing
  121474. * @param length the length the resulting ray should be
  121475. * @returns a ray in the direction the controller is pointing
  121476. */
  121477. getForwardRay(length?: number): Ray;
  121478. /**
  121479. * Disposes of the controller
  121480. */
  121481. dispose(): void;
  121482. }
  121483. /**
  121484. * This class represents a new windows motion controller in XR.
  121485. */
  121486. export class XRWindowsMotionController extends WindowsMotionController {
  121487. /**
  121488. * Changing the original WIndowsMotionController mapping to fir the new mapping
  121489. */
  121490. protected readonly _mapping: {
  121491. buttons: string[];
  121492. buttonMeshNames: {
  121493. 'trigger': string;
  121494. 'menu': string;
  121495. 'grip': string;
  121496. 'thumbstick': string;
  121497. 'trackpad': string;
  121498. };
  121499. buttonObservableNames: {
  121500. 'trigger': string;
  121501. 'menu': string;
  121502. 'grip': string;
  121503. 'thumbstick': string;
  121504. 'trackpad': string;
  121505. };
  121506. axisMeshNames: string[];
  121507. pointingPoseMeshName: string;
  121508. };
  121509. /**
  121510. * Construct a new XR-Based windows motion controller
  121511. *
  121512. * @param gamepadInfo the gamepad object from the browser
  121513. */
  121514. constructor(gamepadInfo: any);
  121515. /**
  121516. * holds the thumbstick values (X,Y)
  121517. */
  121518. thumbstickValues: StickValues;
  121519. /**
  121520. * Fired when the thumbstick on this controller is clicked
  121521. */
  121522. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  121523. /**
  121524. * Fired when the thumbstick on this controller is modified
  121525. */
  121526. onThumbstickValuesChangedObservable: Observable<StickValues>;
  121527. /**
  121528. * Fired when the touchpad button on this controller is modified
  121529. */
  121530. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121531. /**
  121532. * Fired when the touchpad values on this controller are modified
  121533. */
  121534. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121535. /**
  121536. * Fired when the thumbstick button on this controller is modified
  121537. * here to prevent breaking changes
  121538. */
  121539. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121540. /**
  121541. * updating the thumbstick(!) and not the trackpad.
  121542. * This is named this way due to the difference between WebVR and XR and to avoid
  121543. * changing the parent class.
  121544. */
  121545. protected _updateTrackpad(): void;
  121546. /**
  121547. * Disposes the class with joy
  121548. */
  121549. dispose(): void;
  121550. }
  121551. }
  121552. declare module BABYLON {
  121553. /**
  121554. * Class containing static functions to help procedurally build meshes
  121555. */
  121556. export class PolyhedronBuilder {
  121557. /**
  121558. * Creates a polyhedron mesh
  121559. * * 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
  121560. * * The parameter `size` (positive float, default 1) sets the polygon size
  121561. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121562. * * 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`
  121563. * * 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
  121564. * * 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)`)
  121565. * * 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
  121566. * * 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
  121567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121568. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121570. * @param name defines the name of the mesh
  121571. * @param options defines the options used to create the mesh
  121572. * @param scene defines the hosting scene
  121573. * @returns the polyhedron mesh
  121574. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121575. */
  121576. static CreatePolyhedron(name: string, options: {
  121577. type?: number;
  121578. size?: number;
  121579. sizeX?: number;
  121580. sizeY?: number;
  121581. sizeZ?: number;
  121582. custom?: any;
  121583. faceUV?: Vector4[];
  121584. faceColors?: Color4[];
  121585. flat?: boolean;
  121586. updatable?: boolean;
  121587. sideOrientation?: number;
  121588. frontUVs?: Vector4;
  121589. backUVs?: Vector4;
  121590. }, scene?: Nullable<Scene>): Mesh;
  121591. }
  121592. }
  121593. declare module BABYLON {
  121594. /**
  121595. * Gizmo that enables scaling a mesh along 3 axis
  121596. */
  121597. export class ScaleGizmo extends Gizmo {
  121598. /**
  121599. * Internal gizmo used for interactions on the x axis
  121600. */
  121601. xGizmo: AxisScaleGizmo;
  121602. /**
  121603. * Internal gizmo used for interactions on the y axis
  121604. */
  121605. yGizmo: AxisScaleGizmo;
  121606. /**
  121607. * Internal gizmo used for interactions on the z axis
  121608. */
  121609. zGizmo: AxisScaleGizmo;
  121610. /**
  121611. * Internal gizmo used to scale all axis equally
  121612. */
  121613. uniformScaleGizmo: AxisScaleGizmo;
  121614. private _meshAttached;
  121615. private _updateGizmoRotationToMatchAttachedMesh;
  121616. private _snapDistance;
  121617. private _scaleRatio;
  121618. private _uniformScalingMesh;
  121619. private _octahedron;
  121620. private _sensitivity;
  121621. /** Fires an event when any of it's sub gizmos are dragged */
  121622. onDragStartObservable: Observable<unknown>;
  121623. /** Fires an event when any of it's sub gizmos are released from dragging */
  121624. onDragEndObservable: Observable<unknown>;
  121625. get attachedMesh(): Nullable<AbstractMesh>;
  121626. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121627. /**
  121628. * Creates a ScaleGizmo
  121629. * @param gizmoLayer The utility layer the gizmo will be added to
  121630. */
  121631. constructor(gizmoLayer?: UtilityLayerRenderer);
  121632. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121633. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121634. /**
  121635. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121636. */
  121637. set snapDistance(value: number);
  121638. get snapDistance(): number;
  121639. /**
  121640. * Ratio for the scale of the gizmo (Default: 1)
  121641. */
  121642. set scaleRatio(value: number);
  121643. get scaleRatio(): number;
  121644. /**
  121645. * Sensitivity factor for dragging (Default: 1)
  121646. */
  121647. set sensitivity(value: number);
  121648. get sensitivity(): number;
  121649. /**
  121650. * Disposes of the gizmo
  121651. */
  121652. dispose(): void;
  121653. }
  121654. }
  121655. declare module BABYLON {
  121656. /**
  121657. * Single axis scale gizmo
  121658. */
  121659. export class AxisScaleGizmo extends Gizmo {
  121660. /**
  121661. * Drag behavior responsible for the gizmos dragging interactions
  121662. */
  121663. dragBehavior: PointerDragBehavior;
  121664. private _pointerObserver;
  121665. /**
  121666. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121667. */
  121668. snapDistance: number;
  121669. /**
  121670. * Event that fires each time the gizmo snaps to a new location.
  121671. * * snapDistance is the the change in distance
  121672. */
  121673. onSnapObservable: Observable<{
  121674. snapDistance: number;
  121675. }>;
  121676. /**
  121677. * If the scaling operation should be done on all axis (default: false)
  121678. */
  121679. uniformScaling: boolean;
  121680. /**
  121681. * Custom sensitivity value for the drag strength
  121682. */
  121683. sensitivity: number;
  121684. private _isEnabled;
  121685. private _parent;
  121686. private _arrow;
  121687. private _coloredMaterial;
  121688. private _hoverMaterial;
  121689. /**
  121690. * Creates an AxisScaleGizmo
  121691. * @param gizmoLayer The utility layer the gizmo will be added to
  121692. * @param dragAxis The axis which the gizmo will be able to scale on
  121693. * @param color The color of the gizmo
  121694. */
  121695. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121696. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121697. /**
  121698. * If the gizmo is enabled
  121699. */
  121700. set isEnabled(value: boolean);
  121701. get isEnabled(): boolean;
  121702. /**
  121703. * Disposes of the gizmo
  121704. */
  121705. dispose(): void;
  121706. /**
  121707. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121708. * @param mesh The mesh to replace the default mesh of the gizmo
  121709. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121710. */
  121711. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121712. }
  121713. }
  121714. declare module BABYLON {
  121715. /**
  121716. * Bounding box gizmo
  121717. */
  121718. export class BoundingBoxGizmo extends Gizmo {
  121719. private _lineBoundingBox;
  121720. private _rotateSpheresParent;
  121721. private _scaleBoxesParent;
  121722. private _boundingDimensions;
  121723. private _renderObserver;
  121724. private _pointerObserver;
  121725. private _scaleDragSpeed;
  121726. private _tmpQuaternion;
  121727. private _tmpVector;
  121728. private _tmpRotationMatrix;
  121729. /**
  121730. * 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)
  121731. */
  121732. ignoreChildren: boolean;
  121733. /**
  121734. * 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)
  121735. */
  121736. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121737. /**
  121738. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121739. */
  121740. rotationSphereSize: number;
  121741. /**
  121742. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121743. */
  121744. scaleBoxSize: number;
  121745. /**
  121746. * 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)
  121747. */
  121748. fixedDragMeshScreenSize: boolean;
  121749. /**
  121750. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121751. */
  121752. fixedDragMeshScreenSizeDistanceFactor: number;
  121753. /**
  121754. * Fired when a rotation sphere or scale box is dragged
  121755. */
  121756. onDragStartObservable: Observable<{}>;
  121757. /**
  121758. * Fired when a scale box is dragged
  121759. */
  121760. onScaleBoxDragObservable: Observable<{}>;
  121761. /**
  121762. * Fired when a scale box drag is ended
  121763. */
  121764. onScaleBoxDragEndObservable: Observable<{}>;
  121765. /**
  121766. * Fired when a rotation sphere is dragged
  121767. */
  121768. onRotationSphereDragObservable: Observable<{}>;
  121769. /**
  121770. * Fired when a rotation sphere drag is ended
  121771. */
  121772. onRotationSphereDragEndObservable: Observable<{}>;
  121773. /**
  121774. * 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)
  121775. */
  121776. scalePivot: Nullable<Vector3>;
  121777. /**
  121778. * Mesh used as a pivot to rotate the attached mesh
  121779. */
  121780. private _anchorMesh;
  121781. private _existingMeshScale;
  121782. private _dragMesh;
  121783. private pointerDragBehavior;
  121784. private coloredMaterial;
  121785. private hoverColoredMaterial;
  121786. /**
  121787. * Sets the color of the bounding box gizmo
  121788. * @param color the color to set
  121789. */
  121790. setColor(color: Color3): void;
  121791. /**
  121792. * Creates an BoundingBoxGizmo
  121793. * @param gizmoLayer The utility layer the gizmo will be added to
  121794. * @param color The color of the gizmo
  121795. */
  121796. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  121797. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121798. private _selectNode;
  121799. /**
  121800. * Updates the bounding box information for the Gizmo
  121801. */
  121802. updateBoundingBox(): void;
  121803. private _updateRotationSpheres;
  121804. private _updateScaleBoxes;
  121805. /**
  121806. * Enables rotation on the specified axis and disables rotation on the others
  121807. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  121808. */
  121809. setEnabledRotationAxis(axis: string): void;
  121810. /**
  121811. * Enables/disables scaling
  121812. * @param enable if scaling should be enabled
  121813. */
  121814. setEnabledScaling(enable: boolean): void;
  121815. private _updateDummy;
  121816. /**
  121817. * Enables a pointer drag behavior on the bounding box of the gizmo
  121818. */
  121819. enableDragBehavior(): void;
  121820. /**
  121821. * Disposes of the gizmo
  121822. */
  121823. dispose(): void;
  121824. /**
  121825. * 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)
  121826. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  121827. * @returns the bounding box mesh with the passed in mesh as a child
  121828. */
  121829. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  121830. /**
  121831. * CustomMeshes are not supported by this gizmo
  121832. * @param mesh The mesh to replace the default mesh of the gizmo
  121833. */
  121834. setCustomMesh(mesh: Mesh): void;
  121835. }
  121836. }
  121837. declare module BABYLON {
  121838. /**
  121839. * Single plane rotation gizmo
  121840. */
  121841. export class PlaneRotationGizmo extends Gizmo {
  121842. /**
  121843. * Drag behavior responsible for the gizmos dragging interactions
  121844. */
  121845. dragBehavior: PointerDragBehavior;
  121846. private _pointerObserver;
  121847. /**
  121848. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  121849. */
  121850. snapDistance: number;
  121851. /**
  121852. * Event that fires each time the gizmo snaps to a new location.
  121853. * * snapDistance is the the change in distance
  121854. */
  121855. onSnapObservable: Observable<{
  121856. snapDistance: number;
  121857. }>;
  121858. private _isEnabled;
  121859. private _parent;
  121860. /**
  121861. * Creates a PlaneRotationGizmo
  121862. * @param gizmoLayer The utility layer the gizmo will be added to
  121863. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  121864. * @param color The color of the gizmo
  121865. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121866. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121867. */
  121868. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  121869. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121870. /**
  121871. * If the gizmo is enabled
  121872. */
  121873. set isEnabled(value: boolean);
  121874. get isEnabled(): boolean;
  121875. /**
  121876. * Disposes of the gizmo
  121877. */
  121878. dispose(): void;
  121879. }
  121880. }
  121881. declare module BABYLON {
  121882. /**
  121883. * Gizmo that enables rotating a mesh along 3 axis
  121884. */
  121885. export class RotationGizmo extends Gizmo {
  121886. /**
  121887. * Internal gizmo used for interactions on the x axis
  121888. */
  121889. xGizmo: PlaneRotationGizmo;
  121890. /**
  121891. * Internal gizmo used for interactions on the y axis
  121892. */
  121893. yGizmo: PlaneRotationGizmo;
  121894. /**
  121895. * Internal gizmo used for interactions on the z axis
  121896. */
  121897. zGizmo: PlaneRotationGizmo;
  121898. /** Fires an event when any of it's sub gizmos are dragged */
  121899. onDragStartObservable: Observable<unknown>;
  121900. /** Fires an event when any of it's sub gizmos are released from dragging */
  121901. onDragEndObservable: Observable<unknown>;
  121902. private _meshAttached;
  121903. get attachedMesh(): Nullable<AbstractMesh>;
  121904. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121905. /**
  121906. * Creates a RotationGizmo
  121907. * @param gizmoLayer The utility layer the gizmo will be added to
  121908. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121909. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121910. */
  121911. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  121912. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121913. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121914. /**
  121915. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121916. */
  121917. set snapDistance(value: number);
  121918. get snapDistance(): number;
  121919. /**
  121920. * Ratio for the scale of the gizmo (Default: 1)
  121921. */
  121922. set scaleRatio(value: number);
  121923. get scaleRatio(): number;
  121924. /**
  121925. * Disposes of the gizmo
  121926. */
  121927. dispose(): void;
  121928. /**
  121929. * CustomMeshes are not supported by this gizmo
  121930. * @param mesh The mesh to replace the default mesh of the gizmo
  121931. */
  121932. setCustomMesh(mesh: Mesh): void;
  121933. }
  121934. }
  121935. declare module BABYLON {
  121936. /**
  121937. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  121938. */
  121939. export class GizmoManager implements IDisposable {
  121940. private scene;
  121941. /**
  121942. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  121943. */
  121944. gizmos: {
  121945. positionGizmo: Nullable<PositionGizmo>;
  121946. rotationGizmo: Nullable<RotationGizmo>;
  121947. scaleGizmo: Nullable<ScaleGizmo>;
  121948. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  121949. };
  121950. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  121951. clearGizmoOnEmptyPointerEvent: boolean;
  121952. /** Fires an event when the manager is attached to a mesh */
  121953. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  121954. private _gizmosEnabled;
  121955. private _pointerObserver;
  121956. private _attachedMesh;
  121957. private _boundingBoxColor;
  121958. private _defaultUtilityLayer;
  121959. private _defaultKeepDepthUtilityLayer;
  121960. /**
  121961. * When bounding box gizmo is enabled, this can be used to track drag/end events
  121962. */
  121963. boundingBoxDragBehavior: SixDofDragBehavior;
  121964. /**
  121965. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  121966. */
  121967. attachableMeshes: Nullable<Array<AbstractMesh>>;
  121968. /**
  121969. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  121970. */
  121971. usePointerToAttachGizmos: boolean;
  121972. /**
  121973. * Utility layer that the bounding box gizmo belongs to
  121974. */
  121975. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  121976. /**
  121977. * Utility layer that all gizmos besides bounding box belong to
  121978. */
  121979. get utilityLayer(): UtilityLayerRenderer;
  121980. /**
  121981. * Instatiates a gizmo manager
  121982. * @param scene the scene to overlay the gizmos on top of
  121983. */
  121984. constructor(scene: Scene);
  121985. /**
  121986. * Attaches a set of gizmos to the specified mesh
  121987. * @param mesh The mesh the gizmo's should be attached to
  121988. */
  121989. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121990. /**
  121991. * If the position gizmo is enabled
  121992. */
  121993. set positionGizmoEnabled(value: boolean);
  121994. get positionGizmoEnabled(): boolean;
  121995. /**
  121996. * If the rotation gizmo is enabled
  121997. */
  121998. set rotationGizmoEnabled(value: boolean);
  121999. get rotationGizmoEnabled(): boolean;
  122000. /**
  122001. * If the scale gizmo is enabled
  122002. */
  122003. set scaleGizmoEnabled(value: boolean);
  122004. get scaleGizmoEnabled(): boolean;
  122005. /**
  122006. * If the boundingBox gizmo is enabled
  122007. */
  122008. set boundingBoxGizmoEnabled(value: boolean);
  122009. get boundingBoxGizmoEnabled(): boolean;
  122010. /**
  122011. * Disposes of the gizmo manager
  122012. */
  122013. dispose(): void;
  122014. }
  122015. }
  122016. declare module BABYLON {
  122017. /**
  122018. * A directional light is defined by a direction (what a surprise!).
  122019. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  122020. * 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.
  122021. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122022. */
  122023. export class DirectionalLight extends ShadowLight {
  122024. private _shadowFrustumSize;
  122025. /**
  122026. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  122027. */
  122028. get shadowFrustumSize(): number;
  122029. /**
  122030. * Specifies a fix frustum size for the shadow generation.
  122031. */
  122032. set shadowFrustumSize(value: number);
  122033. private _shadowOrthoScale;
  122034. /**
  122035. * Gets the shadow projection scale against the optimal computed one.
  122036. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122037. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122038. */
  122039. get shadowOrthoScale(): number;
  122040. /**
  122041. * Sets the shadow projection scale against the optimal computed one.
  122042. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122043. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122044. */
  122045. set shadowOrthoScale(value: number);
  122046. /**
  122047. * Automatically compute the projection matrix to best fit (including all the casters)
  122048. * on each frame.
  122049. */
  122050. autoUpdateExtends: boolean;
  122051. /**
  122052. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  122053. * on each frame. autoUpdateExtends must be set to true for this to work
  122054. */
  122055. autoCalcShadowZBounds: boolean;
  122056. private _orthoLeft;
  122057. private _orthoRight;
  122058. private _orthoTop;
  122059. private _orthoBottom;
  122060. /**
  122061. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  122062. * The directional light is emitted from everywhere in the given direction.
  122063. * It can cast shadows.
  122064. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122065. * @param name The friendly name of the light
  122066. * @param direction The direction of the light
  122067. * @param scene The scene the light belongs to
  122068. */
  122069. constructor(name: string, direction: Vector3, scene: Scene);
  122070. /**
  122071. * Returns the string "DirectionalLight".
  122072. * @return The class name
  122073. */
  122074. getClassName(): string;
  122075. /**
  122076. * Returns the integer 1.
  122077. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122078. */
  122079. getTypeID(): number;
  122080. /**
  122081. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  122082. * Returns the DirectionalLight Shadow projection matrix.
  122083. */
  122084. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122085. /**
  122086. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  122087. * Returns the DirectionalLight Shadow projection matrix.
  122088. */
  122089. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  122090. /**
  122091. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  122092. * Returns the DirectionalLight Shadow projection matrix.
  122093. */
  122094. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122095. protected _buildUniformLayout(): void;
  122096. /**
  122097. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  122098. * @param effect The effect to update
  122099. * @param lightIndex The index of the light in the effect to update
  122100. * @returns The directional light
  122101. */
  122102. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  122103. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  122104. /**
  122105. * Gets the minZ used for shadow according to both the scene and the light.
  122106. *
  122107. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122108. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122109. * @param activeCamera The camera we are returning the min for
  122110. * @returns the depth min z
  122111. */
  122112. getDepthMinZ(activeCamera: Camera): number;
  122113. /**
  122114. * Gets the maxZ used for shadow according to both the scene and the light.
  122115. *
  122116. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122117. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122118. * @param activeCamera The camera we are returning the max for
  122119. * @returns the depth max z
  122120. */
  122121. getDepthMaxZ(activeCamera: Camera): number;
  122122. /**
  122123. * Prepares the list of defines specific to the light type.
  122124. * @param defines the list of defines
  122125. * @param lightIndex defines the index of the light for the effect
  122126. */
  122127. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122128. }
  122129. }
  122130. declare module BABYLON {
  122131. /**
  122132. * Class containing static functions to help procedurally build meshes
  122133. */
  122134. export class HemisphereBuilder {
  122135. /**
  122136. * Creates a hemisphere mesh
  122137. * @param name defines the name of the mesh
  122138. * @param options defines the options used to create the mesh
  122139. * @param scene defines the hosting scene
  122140. * @returns the hemisphere mesh
  122141. */
  122142. static CreateHemisphere(name: string, options: {
  122143. segments?: number;
  122144. diameter?: number;
  122145. sideOrientation?: number;
  122146. }, scene: any): Mesh;
  122147. }
  122148. }
  122149. declare module BABYLON {
  122150. /**
  122151. * A spot light is defined by a position, a direction, an angle, and an exponent.
  122152. * These values define a cone of light starting from the position, emitting toward the direction.
  122153. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  122154. * and the exponent defines the speed of the decay of the light with distance (reach).
  122155. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122156. */
  122157. export class SpotLight extends ShadowLight {
  122158. private _angle;
  122159. private _innerAngle;
  122160. private _cosHalfAngle;
  122161. private _lightAngleScale;
  122162. private _lightAngleOffset;
  122163. /**
  122164. * Gets the cone angle of the spot light in Radians.
  122165. */
  122166. get angle(): number;
  122167. /**
  122168. * Sets the cone angle of the spot light in Radians.
  122169. */
  122170. set angle(value: number);
  122171. /**
  122172. * Only used in gltf falloff mode, this defines the angle where
  122173. * the directional falloff will start before cutting at angle which could be seen
  122174. * as outer angle.
  122175. */
  122176. get innerAngle(): number;
  122177. /**
  122178. * Only used in gltf falloff mode, this defines the angle where
  122179. * the directional falloff will start before cutting at angle which could be seen
  122180. * as outer angle.
  122181. */
  122182. set innerAngle(value: number);
  122183. private _shadowAngleScale;
  122184. /**
  122185. * Allows scaling the angle of the light for shadow generation only.
  122186. */
  122187. get shadowAngleScale(): number;
  122188. /**
  122189. * Allows scaling the angle of the light for shadow generation only.
  122190. */
  122191. set shadowAngleScale(value: number);
  122192. /**
  122193. * The light decay speed with the distance from the emission spot.
  122194. */
  122195. exponent: number;
  122196. private _projectionTextureMatrix;
  122197. /**
  122198. * Allows reading the projecton texture
  122199. */
  122200. get projectionTextureMatrix(): Matrix;
  122201. protected _projectionTextureLightNear: number;
  122202. /**
  122203. * Gets the near clip of the Spotlight for texture projection.
  122204. */
  122205. get projectionTextureLightNear(): number;
  122206. /**
  122207. * Sets the near clip of the Spotlight for texture projection.
  122208. */
  122209. set projectionTextureLightNear(value: number);
  122210. protected _projectionTextureLightFar: number;
  122211. /**
  122212. * Gets the far clip of the Spotlight for texture projection.
  122213. */
  122214. get projectionTextureLightFar(): number;
  122215. /**
  122216. * Sets the far clip of the Spotlight for texture projection.
  122217. */
  122218. set projectionTextureLightFar(value: number);
  122219. protected _projectionTextureUpDirection: Vector3;
  122220. /**
  122221. * Gets the Up vector of the Spotlight for texture projection.
  122222. */
  122223. get projectionTextureUpDirection(): Vector3;
  122224. /**
  122225. * Sets the Up vector of the Spotlight for texture projection.
  122226. */
  122227. set projectionTextureUpDirection(value: Vector3);
  122228. private _projectionTexture;
  122229. /**
  122230. * Gets the projection texture of the light.
  122231. */
  122232. get projectionTexture(): Nullable<BaseTexture>;
  122233. /**
  122234. * Sets the projection texture of the light.
  122235. */
  122236. set projectionTexture(value: Nullable<BaseTexture>);
  122237. private _projectionTextureViewLightDirty;
  122238. private _projectionTextureProjectionLightDirty;
  122239. private _projectionTextureDirty;
  122240. private _projectionTextureViewTargetVector;
  122241. private _projectionTextureViewLightMatrix;
  122242. private _projectionTextureProjectionLightMatrix;
  122243. private _projectionTextureScalingMatrix;
  122244. /**
  122245. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  122246. * It can cast shadows.
  122247. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122248. * @param name The light friendly name
  122249. * @param position The position of the spot light in the scene
  122250. * @param direction The direction of the light in the scene
  122251. * @param angle The cone angle of the light in Radians
  122252. * @param exponent The light decay speed with the distance from the emission spot
  122253. * @param scene The scene the lights belongs to
  122254. */
  122255. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  122256. /**
  122257. * Returns the string "SpotLight".
  122258. * @returns the class name
  122259. */
  122260. getClassName(): string;
  122261. /**
  122262. * Returns the integer 2.
  122263. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122264. */
  122265. getTypeID(): number;
  122266. /**
  122267. * Overrides the direction setter to recompute the projection texture view light Matrix.
  122268. */
  122269. protected _setDirection(value: Vector3): void;
  122270. /**
  122271. * Overrides the position setter to recompute the projection texture view light Matrix.
  122272. */
  122273. protected _setPosition(value: Vector3): void;
  122274. /**
  122275. * 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.
  122276. * Returns the SpotLight.
  122277. */
  122278. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122279. protected _computeProjectionTextureViewLightMatrix(): void;
  122280. protected _computeProjectionTextureProjectionLightMatrix(): void;
  122281. /**
  122282. * Main function for light texture projection matrix computing.
  122283. */
  122284. protected _computeProjectionTextureMatrix(): void;
  122285. protected _buildUniformLayout(): void;
  122286. private _computeAngleValues;
  122287. /**
  122288. * Sets the passed Effect "effect" with the Light textures.
  122289. * @param effect The effect to update
  122290. * @param lightIndex The index of the light in the effect to update
  122291. * @returns The light
  122292. */
  122293. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  122294. /**
  122295. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  122296. * @param effect The effect to update
  122297. * @param lightIndex The index of the light in the effect to update
  122298. * @returns The spot light
  122299. */
  122300. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  122301. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  122302. /**
  122303. * Disposes the light and the associated resources.
  122304. */
  122305. dispose(): void;
  122306. /**
  122307. * Prepares the list of defines specific to the light type.
  122308. * @param defines the list of defines
  122309. * @param lightIndex defines the index of the light for the effect
  122310. */
  122311. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122312. }
  122313. }
  122314. declare module BABYLON {
  122315. /**
  122316. * Gizmo that enables viewing a light
  122317. */
  122318. export class LightGizmo extends Gizmo {
  122319. private _lightMesh;
  122320. private _material;
  122321. private _cachedPosition;
  122322. private _cachedForward;
  122323. private _attachedMeshParent;
  122324. /**
  122325. * Creates a LightGizmo
  122326. * @param gizmoLayer The utility layer the gizmo will be added to
  122327. */
  122328. constructor(gizmoLayer?: UtilityLayerRenderer);
  122329. private _light;
  122330. /**
  122331. * The light that the gizmo is attached to
  122332. */
  122333. set light(light: Nullable<Light>);
  122334. get light(): Nullable<Light>;
  122335. /**
  122336. * Gets the material used to render the light gizmo
  122337. */
  122338. get material(): StandardMaterial;
  122339. /**
  122340. * @hidden
  122341. * Updates the gizmo to match the attached mesh's position/rotation
  122342. */
  122343. protected _update(): void;
  122344. private static _Scale;
  122345. /**
  122346. * Creates the lines for a light mesh
  122347. */
  122348. private static _CreateLightLines;
  122349. /**
  122350. * Disposes of the light gizmo
  122351. */
  122352. dispose(): void;
  122353. private static _CreateHemisphericLightMesh;
  122354. private static _CreatePointLightMesh;
  122355. private static _CreateSpotLightMesh;
  122356. private static _CreateDirectionalLightMesh;
  122357. }
  122358. }
  122359. declare module BABYLON {
  122360. /** @hidden */
  122361. export var backgroundFragmentDeclaration: {
  122362. name: string;
  122363. shader: string;
  122364. };
  122365. }
  122366. declare module BABYLON {
  122367. /** @hidden */
  122368. export var backgroundUboDeclaration: {
  122369. name: string;
  122370. shader: string;
  122371. };
  122372. }
  122373. declare module BABYLON {
  122374. /** @hidden */
  122375. export var backgroundPixelShader: {
  122376. name: string;
  122377. shader: string;
  122378. };
  122379. }
  122380. declare module BABYLON {
  122381. /** @hidden */
  122382. export var backgroundVertexDeclaration: {
  122383. name: string;
  122384. shader: string;
  122385. };
  122386. }
  122387. declare module BABYLON {
  122388. /** @hidden */
  122389. export var backgroundVertexShader: {
  122390. name: string;
  122391. shader: string;
  122392. };
  122393. }
  122394. declare module BABYLON {
  122395. /**
  122396. * Background material used to create an efficient environement around your scene.
  122397. */
  122398. export class BackgroundMaterial extends PushMaterial {
  122399. /**
  122400. * Standard reflectance value at parallel view angle.
  122401. */
  122402. static StandardReflectance0: number;
  122403. /**
  122404. * Standard reflectance value at grazing angle.
  122405. */
  122406. static StandardReflectance90: number;
  122407. protected _primaryColor: Color3;
  122408. /**
  122409. * Key light Color (multiply against the environement texture)
  122410. */
  122411. primaryColor: Color3;
  122412. protected __perceptualColor: Nullable<Color3>;
  122413. /**
  122414. * Experimental Internal Use Only.
  122415. *
  122416. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  122417. * This acts as a helper to set the primary color to a more "human friendly" value.
  122418. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  122419. * output color as close as possible from the chosen value.
  122420. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  122421. * part of lighting setup.)
  122422. */
  122423. get _perceptualColor(): Nullable<Color3>;
  122424. set _perceptualColor(value: Nullable<Color3>);
  122425. protected _primaryColorShadowLevel: float;
  122426. /**
  122427. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  122428. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  122429. */
  122430. get primaryColorShadowLevel(): float;
  122431. set primaryColorShadowLevel(value: float);
  122432. protected _primaryColorHighlightLevel: float;
  122433. /**
  122434. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  122435. * The primary color is used at the level chosen to define what the white area would look.
  122436. */
  122437. get primaryColorHighlightLevel(): float;
  122438. set primaryColorHighlightLevel(value: float);
  122439. protected _reflectionTexture: Nullable<BaseTexture>;
  122440. /**
  122441. * Reflection Texture used in the material.
  122442. * Should be author in a specific way for the best result (refer to the documentation).
  122443. */
  122444. reflectionTexture: Nullable<BaseTexture>;
  122445. protected _reflectionBlur: float;
  122446. /**
  122447. * Reflection Texture level of blur.
  122448. *
  122449. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  122450. * texture twice.
  122451. */
  122452. reflectionBlur: float;
  122453. protected _diffuseTexture: Nullable<BaseTexture>;
  122454. /**
  122455. * Diffuse Texture used in the material.
  122456. * Should be author in a specific way for the best result (refer to the documentation).
  122457. */
  122458. diffuseTexture: Nullable<BaseTexture>;
  122459. protected _shadowLights: Nullable<IShadowLight[]>;
  122460. /**
  122461. * Specify the list of lights casting shadow on the material.
  122462. * All scene shadow lights will be included if null.
  122463. */
  122464. shadowLights: Nullable<IShadowLight[]>;
  122465. protected _shadowLevel: float;
  122466. /**
  122467. * Helps adjusting the shadow to a softer level if required.
  122468. * 0 means black shadows and 1 means no shadows.
  122469. */
  122470. shadowLevel: float;
  122471. protected _sceneCenter: Vector3;
  122472. /**
  122473. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  122474. * It is usually zero but might be interesting to modify according to your setup.
  122475. */
  122476. sceneCenter: Vector3;
  122477. protected _opacityFresnel: boolean;
  122478. /**
  122479. * This helps specifying that the material is falling off to the sky box at grazing angle.
  122480. * This helps ensuring a nice transition when the camera goes under the ground.
  122481. */
  122482. opacityFresnel: boolean;
  122483. protected _reflectionFresnel: boolean;
  122484. /**
  122485. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  122486. * This helps adding a mirror texture on the ground.
  122487. */
  122488. reflectionFresnel: boolean;
  122489. protected _reflectionFalloffDistance: number;
  122490. /**
  122491. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  122492. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  122493. */
  122494. reflectionFalloffDistance: number;
  122495. protected _reflectionAmount: number;
  122496. /**
  122497. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  122498. */
  122499. reflectionAmount: number;
  122500. protected _reflectionReflectance0: number;
  122501. /**
  122502. * This specifies the weight of the reflection at grazing angle.
  122503. */
  122504. reflectionReflectance0: number;
  122505. protected _reflectionReflectance90: number;
  122506. /**
  122507. * This specifies the weight of the reflection at a perpendicular point of view.
  122508. */
  122509. reflectionReflectance90: number;
  122510. /**
  122511. * Sets the reflection reflectance fresnel values according to the default standard
  122512. * empirically know to work well :-)
  122513. */
  122514. set reflectionStandardFresnelWeight(value: number);
  122515. protected _useRGBColor: boolean;
  122516. /**
  122517. * Helps to directly use the maps channels instead of their level.
  122518. */
  122519. useRGBColor: boolean;
  122520. protected _enableNoise: boolean;
  122521. /**
  122522. * This helps reducing the banding effect that could occur on the background.
  122523. */
  122524. enableNoise: boolean;
  122525. /**
  122526. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122527. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  122528. * Recommended to be keep at 1.0 except for special cases.
  122529. */
  122530. get fovMultiplier(): number;
  122531. set fovMultiplier(value: number);
  122532. private _fovMultiplier;
  122533. /**
  122534. * Enable the FOV adjustment feature controlled by fovMultiplier.
  122535. */
  122536. useEquirectangularFOV: boolean;
  122537. private _maxSimultaneousLights;
  122538. /**
  122539. * Number of Simultaneous lights allowed on the material.
  122540. */
  122541. maxSimultaneousLights: int;
  122542. /**
  122543. * Default configuration related to image processing available in the Background Material.
  122544. */
  122545. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122546. /**
  122547. * Keep track of the image processing observer to allow dispose and replace.
  122548. */
  122549. private _imageProcessingObserver;
  122550. /**
  122551. * Attaches a new image processing configuration to the PBR Material.
  122552. * @param configuration (if null the scene configuration will be use)
  122553. */
  122554. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122555. /**
  122556. * Gets the image processing configuration used either in this material.
  122557. */
  122558. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  122559. /**
  122560. * Sets the Default image processing configuration used either in the this material.
  122561. *
  122562. * If sets to null, the scene one is in use.
  122563. */
  122564. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  122565. /**
  122566. * Gets wether the color curves effect is enabled.
  122567. */
  122568. get cameraColorCurvesEnabled(): boolean;
  122569. /**
  122570. * Sets wether the color curves effect is enabled.
  122571. */
  122572. set cameraColorCurvesEnabled(value: boolean);
  122573. /**
  122574. * Gets wether the color grading effect is enabled.
  122575. */
  122576. get cameraColorGradingEnabled(): boolean;
  122577. /**
  122578. * Gets wether the color grading effect is enabled.
  122579. */
  122580. set cameraColorGradingEnabled(value: boolean);
  122581. /**
  122582. * Gets wether tonemapping is enabled or not.
  122583. */
  122584. get cameraToneMappingEnabled(): boolean;
  122585. /**
  122586. * Sets wether tonemapping is enabled or not
  122587. */
  122588. set cameraToneMappingEnabled(value: boolean);
  122589. /**
  122590. * The camera exposure used on this material.
  122591. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122592. * This corresponds to a photographic exposure.
  122593. */
  122594. get cameraExposure(): float;
  122595. /**
  122596. * The camera exposure used on this material.
  122597. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122598. * This corresponds to a photographic exposure.
  122599. */
  122600. set cameraExposure(value: float);
  122601. /**
  122602. * Gets The camera contrast used on this material.
  122603. */
  122604. get cameraContrast(): float;
  122605. /**
  122606. * Sets The camera contrast used on this material.
  122607. */
  122608. set cameraContrast(value: float);
  122609. /**
  122610. * Gets the Color Grading 2D Lookup Texture.
  122611. */
  122612. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122613. /**
  122614. * Sets the Color Grading 2D Lookup Texture.
  122615. */
  122616. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122617. /**
  122618. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122619. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122620. * 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;
  122621. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122622. */
  122623. get cameraColorCurves(): Nullable<ColorCurves>;
  122624. /**
  122625. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122626. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122627. * 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;
  122628. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122629. */
  122630. set cameraColorCurves(value: Nullable<ColorCurves>);
  122631. /**
  122632. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  122633. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  122634. */
  122635. switchToBGR: boolean;
  122636. private _renderTargets;
  122637. private _reflectionControls;
  122638. private _white;
  122639. private _primaryShadowColor;
  122640. private _primaryHighlightColor;
  122641. /**
  122642. * Instantiates a Background Material in the given scene
  122643. * @param name The friendly name of the material
  122644. * @param scene The scene to add the material to
  122645. */
  122646. constructor(name: string, scene: Scene);
  122647. /**
  122648. * Gets a boolean indicating that current material needs to register RTT
  122649. */
  122650. get hasRenderTargetTextures(): boolean;
  122651. /**
  122652. * The entire material has been created in order to prevent overdraw.
  122653. * @returns false
  122654. */
  122655. needAlphaTesting(): boolean;
  122656. /**
  122657. * The entire material has been created in order to prevent overdraw.
  122658. * @returns true if blending is enable
  122659. */
  122660. needAlphaBlending(): boolean;
  122661. /**
  122662. * Checks wether the material is ready to be rendered for a given mesh.
  122663. * @param mesh The mesh to render
  122664. * @param subMesh The submesh to check against
  122665. * @param useInstances Specify wether or not the material is used with instances
  122666. * @returns true if all the dependencies are ready (Textures, Effects...)
  122667. */
  122668. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122669. /**
  122670. * Compute the primary color according to the chosen perceptual color.
  122671. */
  122672. private _computePrimaryColorFromPerceptualColor;
  122673. /**
  122674. * Compute the highlights and shadow colors according to their chosen levels.
  122675. */
  122676. private _computePrimaryColors;
  122677. /**
  122678. * Build the uniform buffer used in the material.
  122679. */
  122680. buildUniformLayout(): void;
  122681. /**
  122682. * Unbind the material.
  122683. */
  122684. unbind(): void;
  122685. /**
  122686. * Bind only the world matrix to the material.
  122687. * @param world The world matrix to bind.
  122688. */
  122689. bindOnlyWorldMatrix(world: Matrix): void;
  122690. /**
  122691. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122692. * @param world The world matrix to bind.
  122693. * @param subMesh The submesh to bind for.
  122694. */
  122695. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122696. /**
  122697. * Checks to see if a texture is used in the material.
  122698. * @param texture - Base texture to use.
  122699. * @returns - Boolean specifying if a texture is used in the material.
  122700. */
  122701. hasTexture(texture: BaseTexture): boolean;
  122702. /**
  122703. * Dispose the material.
  122704. * @param forceDisposeEffect Force disposal of the associated effect.
  122705. * @param forceDisposeTextures Force disposal of the associated textures.
  122706. */
  122707. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122708. /**
  122709. * Clones the material.
  122710. * @param name The cloned name.
  122711. * @returns The cloned material.
  122712. */
  122713. clone(name: string): BackgroundMaterial;
  122714. /**
  122715. * Serializes the current material to its JSON representation.
  122716. * @returns The JSON representation.
  122717. */
  122718. serialize(): any;
  122719. /**
  122720. * Gets the class name of the material
  122721. * @returns "BackgroundMaterial"
  122722. */
  122723. getClassName(): string;
  122724. /**
  122725. * Parse a JSON input to create back a background material.
  122726. * @param source The JSON data to parse
  122727. * @param scene The scene to create the parsed material in
  122728. * @param rootUrl The root url of the assets the material depends upon
  122729. * @returns the instantiated BackgroundMaterial.
  122730. */
  122731. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122732. }
  122733. }
  122734. declare module BABYLON {
  122735. /**
  122736. * Represents the different options available during the creation of
  122737. * a Environment helper.
  122738. *
  122739. * This can control the default ground, skybox and image processing setup of your scene.
  122740. */
  122741. export interface IEnvironmentHelperOptions {
  122742. /**
  122743. * Specifies whether or not to create a ground.
  122744. * True by default.
  122745. */
  122746. createGround: boolean;
  122747. /**
  122748. * Specifies the ground size.
  122749. * 15 by default.
  122750. */
  122751. groundSize: number;
  122752. /**
  122753. * The texture used on the ground for the main color.
  122754. * Comes from the BabylonJS CDN by default.
  122755. *
  122756. * Remarks: Can be either a texture or a url.
  122757. */
  122758. groundTexture: string | BaseTexture;
  122759. /**
  122760. * The color mixed in the ground texture by default.
  122761. * BabylonJS clearColor by default.
  122762. */
  122763. groundColor: Color3;
  122764. /**
  122765. * Specifies the ground opacity.
  122766. * 1 by default.
  122767. */
  122768. groundOpacity: number;
  122769. /**
  122770. * Enables the ground to receive shadows.
  122771. * True by default.
  122772. */
  122773. enableGroundShadow: boolean;
  122774. /**
  122775. * Helps preventing the shadow to be fully black on the ground.
  122776. * 0.5 by default.
  122777. */
  122778. groundShadowLevel: number;
  122779. /**
  122780. * Creates a mirror texture attach to the ground.
  122781. * false by default.
  122782. */
  122783. enableGroundMirror: boolean;
  122784. /**
  122785. * Specifies the ground mirror size ratio.
  122786. * 0.3 by default as the default kernel is 64.
  122787. */
  122788. groundMirrorSizeRatio: number;
  122789. /**
  122790. * Specifies the ground mirror blur kernel size.
  122791. * 64 by default.
  122792. */
  122793. groundMirrorBlurKernel: number;
  122794. /**
  122795. * Specifies the ground mirror visibility amount.
  122796. * 1 by default
  122797. */
  122798. groundMirrorAmount: number;
  122799. /**
  122800. * Specifies the ground mirror reflectance weight.
  122801. * This uses the standard weight of the background material to setup the fresnel effect
  122802. * of the mirror.
  122803. * 1 by default.
  122804. */
  122805. groundMirrorFresnelWeight: number;
  122806. /**
  122807. * Specifies the ground mirror Falloff distance.
  122808. * This can helps reducing the size of the reflection.
  122809. * 0 by Default.
  122810. */
  122811. groundMirrorFallOffDistance: number;
  122812. /**
  122813. * Specifies the ground mirror texture type.
  122814. * Unsigned Int by Default.
  122815. */
  122816. groundMirrorTextureType: number;
  122817. /**
  122818. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  122819. * the shown objects.
  122820. */
  122821. groundYBias: number;
  122822. /**
  122823. * Specifies whether or not to create a skybox.
  122824. * True by default.
  122825. */
  122826. createSkybox: boolean;
  122827. /**
  122828. * Specifies the skybox size.
  122829. * 20 by default.
  122830. */
  122831. skyboxSize: number;
  122832. /**
  122833. * The texture used on the skybox for the main color.
  122834. * Comes from the BabylonJS CDN by default.
  122835. *
  122836. * Remarks: Can be either a texture or a url.
  122837. */
  122838. skyboxTexture: string | BaseTexture;
  122839. /**
  122840. * The color mixed in the skybox texture by default.
  122841. * BabylonJS clearColor by default.
  122842. */
  122843. skyboxColor: Color3;
  122844. /**
  122845. * The background rotation around the Y axis of the scene.
  122846. * This helps aligning the key lights of your scene with the background.
  122847. * 0 by default.
  122848. */
  122849. backgroundYRotation: number;
  122850. /**
  122851. * Compute automatically the size of the elements to best fit with the scene.
  122852. */
  122853. sizeAuto: boolean;
  122854. /**
  122855. * Default position of the rootMesh if autoSize is not true.
  122856. */
  122857. rootPosition: Vector3;
  122858. /**
  122859. * Sets up the image processing in the scene.
  122860. * true by default.
  122861. */
  122862. setupImageProcessing: boolean;
  122863. /**
  122864. * The texture used as your environment texture in the scene.
  122865. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  122866. *
  122867. * Remarks: Can be either a texture or a url.
  122868. */
  122869. environmentTexture: string | BaseTexture;
  122870. /**
  122871. * The value of the exposure to apply to the scene.
  122872. * 0.6 by default if setupImageProcessing is true.
  122873. */
  122874. cameraExposure: number;
  122875. /**
  122876. * The value of the contrast to apply to the scene.
  122877. * 1.6 by default if setupImageProcessing is true.
  122878. */
  122879. cameraContrast: number;
  122880. /**
  122881. * Specifies whether or not tonemapping should be enabled in the scene.
  122882. * true by default if setupImageProcessing is true.
  122883. */
  122884. toneMappingEnabled: boolean;
  122885. }
  122886. /**
  122887. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  122888. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  122889. * It also helps with the default setup of your imageProcessing configuration.
  122890. */
  122891. export class EnvironmentHelper {
  122892. /**
  122893. * Default ground texture URL.
  122894. */
  122895. private static _groundTextureCDNUrl;
  122896. /**
  122897. * Default skybox texture URL.
  122898. */
  122899. private static _skyboxTextureCDNUrl;
  122900. /**
  122901. * Default environment texture URL.
  122902. */
  122903. private static _environmentTextureCDNUrl;
  122904. /**
  122905. * Creates the default options for the helper.
  122906. */
  122907. private static _getDefaultOptions;
  122908. private _rootMesh;
  122909. /**
  122910. * Gets the root mesh created by the helper.
  122911. */
  122912. get rootMesh(): Mesh;
  122913. private _skybox;
  122914. /**
  122915. * Gets the skybox created by the helper.
  122916. */
  122917. get skybox(): Nullable<Mesh>;
  122918. private _skyboxTexture;
  122919. /**
  122920. * Gets the skybox texture created by the helper.
  122921. */
  122922. get skyboxTexture(): Nullable<BaseTexture>;
  122923. private _skyboxMaterial;
  122924. /**
  122925. * Gets the skybox material created by the helper.
  122926. */
  122927. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  122928. private _ground;
  122929. /**
  122930. * Gets the ground mesh created by the helper.
  122931. */
  122932. get ground(): Nullable<Mesh>;
  122933. private _groundTexture;
  122934. /**
  122935. * Gets the ground texture created by the helper.
  122936. */
  122937. get groundTexture(): Nullable<BaseTexture>;
  122938. private _groundMirror;
  122939. /**
  122940. * Gets the ground mirror created by the helper.
  122941. */
  122942. get groundMirror(): Nullable<MirrorTexture>;
  122943. /**
  122944. * Gets the ground mirror render list to helps pushing the meshes
  122945. * you wish in the ground reflection.
  122946. */
  122947. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  122948. private _groundMaterial;
  122949. /**
  122950. * Gets the ground material created by the helper.
  122951. */
  122952. get groundMaterial(): Nullable<BackgroundMaterial>;
  122953. /**
  122954. * Stores the creation options.
  122955. */
  122956. private readonly _scene;
  122957. private _options;
  122958. /**
  122959. * This observable will be notified with any error during the creation of the environment,
  122960. * mainly texture creation errors.
  122961. */
  122962. onErrorObservable: Observable<{
  122963. message?: string;
  122964. exception?: any;
  122965. }>;
  122966. /**
  122967. * constructor
  122968. * @param options Defines the options we want to customize the helper
  122969. * @param scene The scene to add the material to
  122970. */
  122971. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  122972. /**
  122973. * Updates the background according to the new options
  122974. * @param options
  122975. */
  122976. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  122977. /**
  122978. * Sets the primary color of all the available elements.
  122979. * @param color the main color to affect to the ground and the background
  122980. */
  122981. setMainColor(color: Color3): void;
  122982. /**
  122983. * Setup the image processing according to the specified options.
  122984. */
  122985. private _setupImageProcessing;
  122986. /**
  122987. * Setup the environment texture according to the specified options.
  122988. */
  122989. private _setupEnvironmentTexture;
  122990. /**
  122991. * Setup the background according to the specified options.
  122992. */
  122993. private _setupBackground;
  122994. /**
  122995. * Get the scene sizes according to the setup.
  122996. */
  122997. private _getSceneSize;
  122998. /**
  122999. * Setup the ground according to the specified options.
  123000. */
  123001. private _setupGround;
  123002. /**
  123003. * Setup the ground material according to the specified options.
  123004. */
  123005. private _setupGroundMaterial;
  123006. /**
  123007. * Setup the ground diffuse texture according to the specified options.
  123008. */
  123009. private _setupGroundDiffuseTexture;
  123010. /**
  123011. * Setup the ground mirror texture according to the specified options.
  123012. */
  123013. private _setupGroundMirrorTexture;
  123014. /**
  123015. * Setup the ground to receive the mirror texture.
  123016. */
  123017. private _setupMirrorInGroundMaterial;
  123018. /**
  123019. * Setup the skybox according to the specified options.
  123020. */
  123021. private _setupSkybox;
  123022. /**
  123023. * Setup the skybox material according to the specified options.
  123024. */
  123025. private _setupSkyboxMaterial;
  123026. /**
  123027. * Setup the skybox reflection texture according to the specified options.
  123028. */
  123029. private _setupSkyboxReflectionTexture;
  123030. private _errorHandler;
  123031. /**
  123032. * Dispose all the elements created by the Helper.
  123033. */
  123034. dispose(): void;
  123035. }
  123036. }
  123037. declare module BABYLON {
  123038. /**
  123039. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  123040. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  123041. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  123042. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  123043. */
  123044. export class PhotoDome extends TransformNode {
  123045. /**
  123046. * Define the image as a Monoscopic panoramic 360 image.
  123047. */
  123048. static readonly MODE_MONOSCOPIC: number;
  123049. /**
  123050. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123051. */
  123052. static readonly MODE_TOPBOTTOM: number;
  123053. /**
  123054. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123055. */
  123056. static readonly MODE_SIDEBYSIDE: number;
  123057. private _useDirectMapping;
  123058. /**
  123059. * The texture being displayed on the sphere
  123060. */
  123061. protected _photoTexture: Texture;
  123062. /**
  123063. * Gets or sets the texture being displayed on the sphere
  123064. */
  123065. get photoTexture(): Texture;
  123066. set photoTexture(value: Texture);
  123067. /**
  123068. * Observable raised when an error occured while loading the 360 image
  123069. */
  123070. onLoadErrorObservable: Observable<string>;
  123071. /**
  123072. * The skybox material
  123073. */
  123074. protected _material: BackgroundMaterial;
  123075. /**
  123076. * The surface used for the skybox
  123077. */
  123078. protected _mesh: Mesh;
  123079. /**
  123080. * Gets the mesh used for the skybox.
  123081. */
  123082. get mesh(): Mesh;
  123083. /**
  123084. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123085. * Also see the options.resolution property.
  123086. */
  123087. get fovMultiplier(): number;
  123088. set fovMultiplier(value: number);
  123089. private _imageMode;
  123090. /**
  123091. * Gets or set the current video mode for the video. It can be:
  123092. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  123093. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123094. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123095. */
  123096. get imageMode(): number;
  123097. set imageMode(value: number);
  123098. /**
  123099. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  123100. * @param name Element's name, child elements will append suffixes for their own names.
  123101. * @param urlsOfPhoto defines the url of the photo to display
  123102. * @param options defines an object containing optional or exposed sub element properties
  123103. * @param onError defines a callback called when an error occured while loading the texture
  123104. */
  123105. constructor(name: string, urlOfPhoto: string, options: {
  123106. resolution?: number;
  123107. size?: number;
  123108. useDirectMapping?: boolean;
  123109. faceForward?: boolean;
  123110. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  123111. private _onBeforeCameraRenderObserver;
  123112. private _changeImageMode;
  123113. /**
  123114. * Releases resources associated with this node.
  123115. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123116. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123117. */
  123118. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123119. }
  123120. }
  123121. declare module BABYLON {
  123122. /**
  123123. * Class used to host RGBD texture specific utilities
  123124. */
  123125. export class RGBDTextureTools {
  123126. /**
  123127. * Expand the RGBD Texture from RGBD to Half Float if possible.
  123128. * @param texture the texture to expand.
  123129. */
  123130. static ExpandRGBDTexture(texture: Texture): void;
  123131. }
  123132. }
  123133. declare module BABYLON {
  123134. /**
  123135. * Class used to host texture specific utilities
  123136. */
  123137. export class BRDFTextureTools {
  123138. /**
  123139. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  123140. * @param scene defines the hosting scene
  123141. * @returns the environment BRDF texture
  123142. */
  123143. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  123144. private static _environmentBRDFBase64Texture;
  123145. }
  123146. }
  123147. declare module BABYLON {
  123148. /**
  123149. * @hidden
  123150. */
  123151. export interface IMaterialClearCoatDefines {
  123152. CLEARCOAT: boolean;
  123153. CLEARCOAT_DEFAULTIOR: boolean;
  123154. CLEARCOAT_TEXTURE: boolean;
  123155. CLEARCOAT_TEXTUREDIRECTUV: number;
  123156. CLEARCOAT_BUMP: boolean;
  123157. CLEARCOAT_BUMPDIRECTUV: number;
  123158. CLEARCOAT_TINT: boolean;
  123159. CLEARCOAT_TINT_TEXTURE: boolean;
  123160. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123161. /** @hidden */
  123162. _areTexturesDirty: boolean;
  123163. }
  123164. /**
  123165. * Define the code related to the clear coat parameters of the pbr material.
  123166. */
  123167. export class PBRClearCoatConfiguration {
  123168. /**
  123169. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123170. * The default fits with a polyurethane material.
  123171. */
  123172. private static readonly _DefaultIndexOfRefraction;
  123173. private _isEnabled;
  123174. /**
  123175. * Defines if the clear coat is enabled in the material.
  123176. */
  123177. isEnabled: boolean;
  123178. /**
  123179. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  123180. */
  123181. intensity: number;
  123182. /**
  123183. * Defines the clear coat layer roughness.
  123184. */
  123185. roughness: number;
  123186. private _indexOfRefraction;
  123187. /**
  123188. * Defines the index of refraction of the clear coat.
  123189. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123190. * The default fits with a polyurethane material.
  123191. * Changing the default value is more performance intensive.
  123192. */
  123193. indexOfRefraction: number;
  123194. private _texture;
  123195. /**
  123196. * Stores the clear coat values in a texture.
  123197. */
  123198. texture: Nullable<BaseTexture>;
  123199. private _bumpTexture;
  123200. /**
  123201. * Define the clear coat specific bump texture.
  123202. */
  123203. bumpTexture: Nullable<BaseTexture>;
  123204. private _isTintEnabled;
  123205. /**
  123206. * Defines if the clear coat tint is enabled in the material.
  123207. */
  123208. isTintEnabled: boolean;
  123209. /**
  123210. * Defines the clear coat tint of the material.
  123211. * This is only use if tint is enabled
  123212. */
  123213. tintColor: Color3;
  123214. /**
  123215. * Defines the distance at which the tint color should be found in the
  123216. * clear coat media.
  123217. * This is only use if tint is enabled
  123218. */
  123219. tintColorAtDistance: number;
  123220. /**
  123221. * Defines the clear coat layer thickness.
  123222. * This is only use if tint is enabled
  123223. */
  123224. tintThickness: number;
  123225. private _tintTexture;
  123226. /**
  123227. * Stores the clear tint values in a texture.
  123228. * rgb is tint
  123229. * a is a thickness factor
  123230. */
  123231. tintTexture: Nullable<BaseTexture>;
  123232. /** @hidden */
  123233. private _internalMarkAllSubMeshesAsTexturesDirty;
  123234. /** @hidden */
  123235. _markAllSubMeshesAsTexturesDirty(): void;
  123236. /**
  123237. * Instantiate a new istance of clear coat configuration.
  123238. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123239. */
  123240. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123241. /**
  123242. * Gets wehter the submesh is ready to be used or not.
  123243. * @param defines the list of "defines" to update.
  123244. * @param scene defines the scene the material belongs to.
  123245. * @param engine defines the engine the material belongs to.
  123246. * @param disableBumpMap defines wether the material disables bump or not.
  123247. * @returns - boolean indicating that the submesh is ready or not.
  123248. */
  123249. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  123250. /**
  123251. * Checks to see if a texture is used in the material.
  123252. * @param defines the list of "defines" to update.
  123253. * @param scene defines the scene to the material belongs to.
  123254. */
  123255. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  123256. /**
  123257. * Binds the material data.
  123258. * @param uniformBuffer defines the Uniform buffer to fill in.
  123259. * @param scene defines the scene the material belongs to.
  123260. * @param engine defines the engine the material belongs to.
  123261. * @param disableBumpMap defines wether the material disables bump or not.
  123262. * @param isFrozen defines wether the material is frozen or not.
  123263. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123264. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123265. */
  123266. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  123267. /**
  123268. * Checks to see if a texture is used in the material.
  123269. * @param texture - Base texture to use.
  123270. * @returns - Boolean specifying if a texture is used in the material.
  123271. */
  123272. hasTexture(texture: BaseTexture): boolean;
  123273. /**
  123274. * Returns an array of the actively used textures.
  123275. * @param activeTextures Array of BaseTextures
  123276. */
  123277. getActiveTextures(activeTextures: BaseTexture[]): void;
  123278. /**
  123279. * Returns the animatable textures.
  123280. * @param animatables Array of animatable textures.
  123281. */
  123282. getAnimatables(animatables: IAnimatable[]): void;
  123283. /**
  123284. * Disposes the resources of the material.
  123285. * @param forceDisposeTextures - Forces the disposal of all textures.
  123286. */
  123287. dispose(forceDisposeTextures?: boolean): void;
  123288. /**
  123289. * Get the current class name of the texture useful for serialization or dynamic coding.
  123290. * @returns "PBRClearCoatConfiguration"
  123291. */
  123292. getClassName(): string;
  123293. /**
  123294. * Add fallbacks to the effect fallbacks list.
  123295. * @param defines defines the Base texture to use.
  123296. * @param fallbacks defines the current fallback list.
  123297. * @param currentRank defines the current fallback rank.
  123298. * @returns the new fallback rank.
  123299. */
  123300. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123301. /**
  123302. * Add the required uniforms to the current list.
  123303. * @param uniforms defines the current uniform list.
  123304. */
  123305. static AddUniforms(uniforms: string[]): void;
  123306. /**
  123307. * Add the required samplers to the current list.
  123308. * @param samplers defines the current sampler list.
  123309. */
  123310. static AddSamplers(samplers: string[]): void;
  123311. /**
  123312. * Add the required uniforms to the current buffer.
  123313. * @param uniformBuffer defines the current uniform buffer.
  123314. */
  123315. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123316. /**
  123317. * Makes a duplicate of the current configuration into another one.
  123318. * @param clearCoatConfiguration define the config where to copy the info
  123319. */
  123320. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  123321. /**
  123322. * Serializes this clear coat configuration.
  123323. * @returns - An object with the serialized config.
  123324. */
  123325. serialize(): any;
  123326. /**
  123327. * Parses a anisotropy Configuration from a serialized object.
  123328. * @param source - Serialized object.
  123329. * @param scene Defines the scene we are parsing for
  123330. * @param rootUrl Defines the rootUrl to load from
  123331. */
  123332. parse(source: any, scene: Scene, rootUrl: string): void;
  123333. }
  123334. }
  123335. declare module BABYLON {
  123336. /**
  123337. * @hidden
  123338. */
  123339. export interface IMaterialAnisotropicDefines {
  123340. ANISOTROPIC: boolean;
  123341. ANISOTROPIC_TEXTURE: boolean;
  123342. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123343. MAINUV1: boolean;
  123344. _areTexturesDirty: boolean;
  123345. _needUVs: boolean;
  123346. }
  123347. /**
  123348. * Define the code related to the anisotropic parameters of the pbr material.
  123349. */
  123350. export class PBRAnisotropicConfiguration {
  123351. private _isEnabled;
  123352. /**
  123353. * Defines if the anisotropy is enabled in the material.
  123354. */
  123355. isEnabled: boolean;
  123356. /**
  123357. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  123358. */
  123359. intensity: number;
  123360. /**
  123361. * Defines if the effect is along the tangents, bitangents or in between.
  123362. * By default, the effect is "strectching" the highlights along the tangents.
  123363. */
  123364. direction: Vector2;
  123365. private _texture;
  123366. /**
  123367. * Stores the anisotropy values in a texture.
  123368. * rg is direction (like normal from -1 to 1)
  123369. * b is a intensity
  123370. */
  123371. texture: Nullable<BaseTexture>;
  123372. /** @hidden */
  123373. private _internalMarkAllSubMeshesAsTexturesDirty;
  123374. /** @hidden */
  123375. _markAllSubMeshesAsTexturesDirty(): void;
  123376. /**
  123377. * Instantiate a new istance of anisotropy configuration.
  123378. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123379. */
  123380. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123381. /**
  123382. * Specifies that the submesh is ready to be used.
  123383. * @param defines the list of "defines" to update.
  123384. * @param scene defines the scene the material belongs to.
  123385. * @returns - boolean indicating that the submesh is ready or not.
  123386. */
  123387. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  123388. /**
  123389. * Checks to see if a texture is used in the material.
  123390. * @param defines the list of "defines" to update.
  123391. * @param mesh the mesh we are preparing the defines for.
  123392. * @param scene defines the scene the material belongs to.
  123393. */
  123394. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  123395. /**
  123396. * Binds the material data.
  123397. * @param uniformBuffer defines the Uniform buffer to fill in.
  123398. * @param scene defines the scene the material belongs to.
  123399. * @param isFrozen defines wether the material is frozen or not.
  123400. */
  123401. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123402. /**
  123403. * Checks to see if a texture is used in the material.
  123404. * @param texture - Base texture to use.
  123405. * @returns - Boolean specifying if a texture is used in the material.
  123406. */
  123407. hasTexture(texture: BaseTexture): boolean;
  123408. /**
  123409. * Returns an array of the actively used textures.
  123410. * @param activeTextures Array of BaseTextures
  123411. */
  123412. getActiveTextures(activeTextures: BaseTexture[]): void;
  123413. /**
  123414. * Returns the animatable textures.
  123415. * @param animatables Array of animatable textures.
  123416. */
  123417. getAnimatables(animatables: IAnimatable[]): void;
  123418. /**
  123419. * Disposes the resources of the material.
  123420. * @param forceDisposeTextures - Forces the disposal of all textures.
  123421. */
  123422. dispose(forceDisposeTextures?: boolean): void;
  123423. /**
  123424. * Get the current class name of the texture useful for serialization or dynamic coding.
  123425. * @returns "PBRAnisotropicConfiguration"
  123426. */
  123427. getClassName(): string;
  123428. /**
  123429. * Add fallbacks to the effect fallbacks list.
  123430. * @param defines defines the Base texture to use.
  123431. * @param fallbacks defines the current fallback list.
  123432. * @param currentRank defines the current fallback rank.
  123433. * @returns the new fallback rank.
  123434. */
  123435. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123436. /**
  123437. * Add the required uniforms to the current list.
  123438. * @param uniforms defines the current uniform list.
  123439. */
  123440. static AddUniforms(uniforms: string[]): void;
  123441. /**
  123442. * Add the required uniforms to the current buffer.
  123443. * @param uniformBuffer defines the current uniform buffer.
  123444. */
  123445. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123446. /**
  123447. * Add the required samplers to the current list.
  123448. * @param samplers defines the current sampler list.
  123449. */
  123450. static AddSamplers(samplers: string[]): void;
  123451. /**
  123452. * Makes a duplicate of the current configuration into another one.
  123453. * @param anisotropicConfiguration define the config where to copy the info
  123454. */
  123455. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  123456. /**
  123457. * Serializes this anisotropy configuration.
  123458. * @returns - An object with the serialized config.
  123459. */
  123460. serialize(): any;
  123461. /**
  123462. * Parses a anisotropy Configuration from a serialized object.
  123463. * @param source - Serialized object.
  123464. * @param scene Defines the scene we are parsing for
  123465. * @param rootUrl Defines the rootUrl to load from
  123466. */
  123467. parse(source: any, scene: Scene, rootUrl: string): void;
  123468. }
  123469. }
  123470. declare module BABYLON {
  123471. /**
  123472. * @hidden
  123473. */
  123474. export interface IMaterialBRDFDefines {
  123475. BRDF_V_HEIGHT_CORRELATED: boolean;
  123476. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123477. SPHERICAL_HARMONICS: boolean;
  123478. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123479. /** @hidden */
  123480. _areMiscDirty: boolean;
  123481. }
  123482. /**
  123483. * Define the code related to the BRDF parameters of the pbr material.
  123484. */
  123485. export class PBRBRDFConfiguration {
  123486. /**
  123487. * Default value used for the energy conservation.
  123488. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123489. */
  123490. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  123491. /**
  123492. * Default value used for the Smith Visibility Height Correlated mode.
  123493. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123494. */
  123495. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  123496. /**
  123497. * Default value used for the IBL diffuse part.
  123498. * This can help switching back to the polynomials mode globally which is a tiny bit
  123499. * less GPU intensive at the drawback of a lower quality.
  123500. */
  123501. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  123502. /**
  123503. * Default value used for activating energy conservation for the specular workflow.
  123504. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123505. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123506. */
  123507. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  123508. private _useEnergyConservation;
  123509. /**
  123510. * Defines if the material uses energy conservation.
  123511. */
  123512. useEnergyConservation: boolean;
  123513. private _useSmithVisibilityHeightCorrelated;
  123514. /**
  123515. * LEGACY Mode set to false
  123516. * Defines if the material uses height smith correlated visibility term.
  123517. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  123518. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  123519. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  123520. * Not relying on height correlated will also disable energy conservation.
  123521. */
  123522. useSmithVisibilityHeightCorrelated: boolean;
  123523. private _useSphericalHarmonics;
  123524. /**
  123525. * LEGACY Mode set to false
  123526. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  123527. * diffuse part of the IBL.
  123528. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  123529. * to the ground truth.
  123530. */
  123531. useSphericalHarmonics: boolean;
  123532. private _useSpecularGlossinessInputEnergyConservation;
  123533. /**
  123534. * Defines if the material uses energy conservation, when the specular workflow is active.
  123535. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123536. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123537. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  123538. */
  123539. useSpecularGlossinessInputEnergyConservation: boolean;
  123540. /** @hidden */
  123541. private _internalMarkAllSubMeshesAsMiscDirty;
  123542. /** @hidden */
  123543. _markAllSubMeshesAsMiscDirty(): void;
  123544. /**
  123545. * Instantiate a new istance of clear coat configuration.
  123546. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  123547. */
  123548. constructor(markAllSubMeshesAsMiscDirty: () => void);
  123549. /**
  123550. * Checks to see if a texture is used in the material.
  123551. * @param defines the list of "defines" to update.
  123552. */
  123553. prepareDefines(defines: IMaterialBRDFDefines): void;
  123554. /**
  123555. * Get the current class name of the texture useful for serialization or dynamic coding.
  123556. * @returns "PBRClearCoatConfiguration"
  123557. */
  123558. getClassName(): string;
  123559. /**
  123560. * Makes a duplicate of the current configuration into another one.
  123561. * @param brdfConfiguration define the config where to copy the info
  123562. */
  123563. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  123564. /**
  123565. * Serializes this BRDF configuration.
  123566. * @returns - An object with the serialized config.
  123567. */
  123568. serialize(): any;
  123569. /**
  123570. * Parses a anisotropy Configuration from a serialized object.
  123571. * @param source - Serialized object.
  123572. * @param scene Defines the scene we are parsing for
  123573. * @param rootUrl Defines the rootUrl to load from
  123574. */
  123575. parse(source: any, scene: Scene, rootUrl: string): void;
  123576. }
  123577. }
  123578. declare module BABYLON {
  123579. /**
  123580. * @hidden
  123581. */
  123582. export interface IMaterialSheenDefines {
  123583. SHEEN: boolean;
  123584. SHEEN_TEXTURE: boolean;
  123585. SHEEN_TEXTUREDIRECTUV: number;
  123586. SHEEN_LINKWITHALBEDO: boolean;
  123587. /** @hidden */
  123588. _areTexturesDirty: boolean;
  123589. }
  123590. /**
  123591. * Define the code related to the Sheen parameters of the pbr material.
  123592. */
  123593. export class PBRSheenConfiguration {
  123594. private _isEnabled;
  123595. /**
  123596. * Defines if the material uses sheen.
  123597. */
  123598. isEnabled: boolean;
  123599. private _linkSheenWithAlbedo;
  123600. /**
  123601. * Defines if the sheen is linked to the sheen color.
  123602. */
  123603. linkSheenWithAlbedo: boolean;
  123604. /**
  123605. * Defines the sheen intensity.
  123606. */
  123607. intensity: number;
  123608. /**
  123609. * Defines the sheen color.
  123610. */
  123611. color: Color3;
  123612. private _texture;
  123613. /**
  123614. * Stores the sheen tint values in a texture.
  123615. * rgb is tint
  123616. * a is a intensity
  123617. */
  123618. texture: Nullable<BaseTexture>;
  123619. /** @hidden */
  123620. private _internalMarkAllSubMeshesAsTexturesDirty;
  123621. /** @hidden */
  123622. _markAllSubMeshesAsTexturesDirty(): void;
  123623. /**
  123624. * Instantiate a new istance of clear coat configuration.
  123625. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123626. */
  123627. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123628. /**
  123629. * Specifies that the submesh is ready to be used.
  123630. * @param defines the list of "defines" to update.
  123631. * @param scene defines the scene the material belongs to.
  123632. * @returns - boolean indicating that the submesh is ready or not.
  123633. */
  123634. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  123635. /**
  123636. * Checks to see if a texture is used in the material.
  123637. * @param defines the list of "defines" to update.
  123638. * @param scene defines the scene the material belongs to.
  123639. */
  123640. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  123641. /**
  123642. * Binds the material data.
  123643. * @param uniformBuffer defines the Uniform buffer to fill in.
  123644. * @param scene defines the scene the material belongs to.
  123645. * @param isFrozen defines wether the material is frozen or not.
  123646. */
  123647. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123648. /**
  123649. * Checks to see if a texture is used in the material.
  123650. * @param texture - Base texture to use.
  123651. * @returns - Boolean specifying if a texture is used in the material.
  123652. */
  123653. hasTexture(texture: BaseTexture): boolean;
  123654. /**
  123655. * Returns an array of the actively used textures.
  123656. * @param activeTextures Array of BaseTextures
  123657. */
  123658. getActiveTextures(activeTextures: BaseTexture[]): void;
  123659. /**
  123660. * Returns the animatable textures.
  123661. * @param animatables Array of animatable textures.
  123662. */
  123663. getAnimatables(animatables: IAnimatable[]): void;
  123664. /**
  123665. * Disposes the resources of the material.
  123666. * @param forceDisposeTextures - Forces the disposal of all textures.
  123667. */
  123668. dispose(forceDisposeTextures?: boolean): void;
  123669. /**
  123670. * Get the current class name of the texture useful for serialization or dynamic coding.
  123671. * @returns "PBRSheenConfiguration"
  123672. */
  123673. getClassName(): string;
  123674. /**
  123675. * Add fallbacks to the effect fallbacks list.
  123676. * @param defines defines the Base texture to use.
  123677. * @param fallbacks defines the current fallback list.
  123678. * @param currentRank defines the current fallback rank.
  123679. * @returns the new fallback rank.
  123680. */
  123681. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123682. /**
  123683. * Add the required uniforms to the current list.
  123684. * @param uniforms defines the current uniform list.
  123685. */
  123686. static AddUniforms(uniforms: string[]): void;
  123687. /**
  123688. * Add the required uniforms to the current buffer.
  123689. * @param uniformBuffer defines the current uniform buffer.
  123690. */
  123691. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123692. /**
  123693. * Add the required samplers to the current list.
  123694. * @param samplers defines the current sampler list.
  123695. */
  123696. static AddSamplers(samplers: string[]): void;
  123697. /**
  123698. * Makes a duplicate of the current configuration into another one.
  123699. * @param sheenConfiguration define the config where to copy the info
  123700. */
  123701. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123702. /**
  123703. * Serializes this BRDF configuration.
  123704. * @returns - An object with the serialized config.
  123705. */
  123706. serialize(): any;
  123707. /**
  123708. * Parses a anisotropy Configuration from a serialized object.
  123709. * @param source - Serialized object.
  123710. * @param scene Defines the scene we are parsing for
  123711. * @param rootUrl Defines the rootUrl to load from
  123712. */
  123713. parse(source: any, scene: Scene, rootUrl: string): void;
  123714. }
  123715. }
  123716. declare module BABYLON {
  123717. /**
  123718. * @hidden
  123719. */
  123720. export interface IMaterialSubSurfaceDefines {
  123721. SUBSURFACE: boolean;
  123722. SS_REFRACTION: boolean;
  123723. SS_TRANSLUCENCY: boolean;
  123724. SS_SCATERRING: boolean;
  123725. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123726. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123727. SS_REFRACTIONMAP_3D: boolean;
  123728. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123729. SS_LODINREFRACTIONALPHA: boolean;
  123730. SS_GAMMAREFRACTION: boolean;
  123731. SS_RGBDREFRACTION: boolean;
  123732. SS_LINEARSPECULARREFRACTION: boolean;
  123733. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123734. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123735. /** @hidden */
  123736. _areTexturesDirty: boolean;
  123737. }
  123738. /**
  123739. * Define the code related to the sub surface parameters of the pbr material.
  123740. */
  123741. export class PBRSubSurfaceConfiguration {
  123742. private _isRefractionEnabled;
  123743. /**
  123744. * Defines if the refraction is enabled in the material.
  123745. */
  123746. isRefractionEnabled: boolean;
  123747. private _isTranslucencyEnabled;
  123748. /**
  123749. * Defines if the translucency is enabled in the material.
  123750. */
  123751. isTranslucencyEnabled: boolean;
  123752. private _isScatteringEnabled;
  123753. /**
  123754. * Defines the refraction intensity of the material.
  123755. * The refraction when enabled replaces the Diffuse part of the material.
  123756. * The intensity helps transitionning between diffuse and refraction.
  123757. */
  123758. refractionIntensity: number;
  123759. /**
  123760. * Defines the translucency intensity of the material.
  123761. * When translucency has been enabled, this defines how much of the "translucency"
  123762. * is addded to the diffuse part of the material.
  123763. */
  123764. translucencyIntensity: number;
  123765. /**
  123766. * Defines the scattering intensity of the material.
  123767. * When scattering has been enabled, this defines how much of the "scattered light"
  123768. * is addded to the diffuse part of the material.
  123769. */
  123770. scatteringIntensity: number;
  123771. private _thicknessTexture;
  123772. /**
  123773. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  123774. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  123775. * 0 would mean minimumThickness
  123776. * 1 would mean maximumThickness
  123777. * The other channels might be use as a mask to vary the different effects intensity.
  123778. */
  123779. thicknessTexture: Nullable<BaseTexture>;
  123780. private _refractionTexture;
  123781. /**
  123782. * Defines the texture to use for refraction.
  123783. */
  123784. refractionTexture: Nullable<BaseTexture>;
  123785. private _indexOfRefraction;
  123786. /**
  123787. * Defines the index of refraction used in the material.
  123788. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  123789. */
  123790. indexOfRefraction: number;
  123791. private _invertRefractionY;
  123792. /**
  123793. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  123794. */
  123795. invertRefractionY: boolean;
  123796. private _linkRefractionWithTransparency;
  123797. /**
  123798. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  123799. * Materials half opaque for instance using refraction could benefit from this control.
  123800. */
  123801. linkRefractionWithTransparency: boolean;
  123802. /**
  123803. * Defines the minimum thickness stored in the thickness map.
  123804. * If no thickness map is defined, this value will be used to simulate thickness.
  123805. */
  123806. minimumThickness: number;
  123807. /**
  123808. * Defines the maximum thickness stored in the thickness map.
  123809. */
  123810. maximumThickness: number;
  123811. /**
  123812. * Defines the volume tint of the material.
  123813. * This is used for both translucency and scattering.
  123814. */
  123815. tintColor: Color3;
  123816. /**
  123817. * Defines the distance at which the tint color should be found in the media.
  123818. * This is used for refraction only.
  123819. */
  123820. tintColorAtDistance: number;
  123821. /**
  123822. * Defines how far each channel transmit through the media.
  123823. * It is defined as a color to simplify it selection.
  123824. */
  123825. diffusionDistance: Color3;
  123826. private _useMaskFromThicknessTexture;
  123827. /**
  123828. * Stores the intensity of the different subsurface effects in the thickness texture.
  123829. * * the green channel is the translucency intensity.
  123830. * * the blue channel is the scattering intensity.
  123831. * * the alpha channel is the refraction intensity.
  123832. */
  123833. useMaskFromThicknessTexture: boolean;
  123834. /** @hidden */
  123835. private _internalMarkAllSubMeshesAsTexturesDirty;
  123836. /** @hidden */
  123837. _markAllSubMeshesAsTexturesDirty(): void;
  123838. /**
  123839. * Instantiate a new istance of sub surface configuration.
  123840. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123841. */
  123842. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123843. /**
  123844. * Gets wehter the submesh is ready to be used or not.
  123845. * @param defines the list of "defines" to update.
  123846. * @param scene defines the scene the material belongs to.
  123847. * @returns - boolean indicating that the submesh is ready or not.
  123848. */
  123849. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  123850. /**
  123851. * Checks to see if a texture is used in the material.
  123852. * @param defines the list of "defines" to update.
  123853. * @param scene defines the scene to the material belongs to.
  123854. */
  123855. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  123856. /**
  123857. * Binds the material data.
  123858. * @param uniformBuffer defines the Uniform buffer to fill in.
  123859. * @param scene defines the scene the material belongs to.
  123860. * @param engine defines the engine the material belongs to.
  123861. * @param isFrozen defines wether the material is frozen or not.
  123862. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  123863. */
  123864. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  123865. /**
  123866. * Unbinds the material from the mesh.
  123867. * @param activeEffect defines the effect that should be unbound from.
  123868. * @returns true if unbound, otherwise false
  123869. */
  123870. unbind(activeEffect: Effect): boolean;
  123871. /**
  123872. * Returns the texture used for refraction or null if none is used.
  123873. * @param scene defines the scene the material belongs to.
  123874. * @returns - Refraction texture if present. If no refraction texture and refraction
  123875. * is linked with transparency, returns environment texture. Otherwise, returns null.
  123876. */
  123877. private _getRefractionTexture;
  123878. /**
  123879. * Returns true if alpha blending should be disabled.
  123880. */
  123881. get disableAlphaBlending(): boolean;
  123882. /**
  123883. * Fills the list of render target textures.
  123884. * @param renderTargets the list of render targets to update
  123885. */
  123886. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  123887. /**
  123888. * Checks to see if a texture is used in the material.
  123889. * @param texture - Base texture to use.
  123890. * @returns - Boolean specifying if a texture is used in the material.
  123891. */
  123892. hasTexture(texture: BaseTexture): boolean;
  123893. /**
  123894. * Gets a boolean indicating that current material needs to register RTT
  123895. * @returns true if this uses a render target otherwise false.
  123896. */
  123897. hasRenderTargetTextures(): boolean;
  123898. /**
  123899. * Returns an array of the actively used textures.
  123900. * @param activeTextures Array of BaseTextures
  123901. */
  123902. getActiveTextures(activeTextures: BaseTexture[]): void;
  123903. /**
  123904. * Returns the animatable textures.
  123905. * @param animatables Array of animatable textures.
  123906. */
  123907. getAnimatables(animatables: IAnimatable[]): void;
  123908. /**
  123909. * Disposes the resources of the material.
  123910. * @param forceDisposeTextures - Forces the disposal of all textures.
  123911. */
  123912. dispose(forceDisposeTextures?: boolean): void;
  123913. /**
  123914. * Get the current class name of the texture useful for serialization or dynamic coding.
  123915. * @returns "PBRSubSurfaceConfiguration"
  123916. */
  123917. getClassName(): string;
  123918. /**
  123919. * Add fallbacks to the effect fallbacks list.
  123920. * @param defines defines the Base texture to use.
  123921. * @param fallbacks defines the current fallback list.
  123922. * @param currentRank defines the current fallback rank.
  123923. * @returns the new fallback rank.
  123924. */
  123925. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123926. /**
  123927. * Add the required uniforms to the current list.
  123928. * @param uniforms defines the current uniform list.
  123929. */
  123930. static AddUniforms(uniforms: string[]): void;
  123931. /**
  123932. * Add the required samplers to the current list.
  123933. * @param samplers defines the current sampler list.
  123934. */
  123935. static AddSamplers(samplers: string[]): void;
  123936. /**
  123937. * Add the required uniforms to the current buffer.
  123938. * @param uniformBuffer defines the current uniform buffer.
  123939. */
  123940. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123941. /**
  123942. * Makes a duplicate of the current configuration into another one.
  123943. * @param configuration define the config where to copy the info
  123944. */
  123945. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  123946. /**
  123947. * Serializes this Sub Surface configuration.
  123948. * @returns - An object with the serialized config.
  123949. */
  123950. serialize(): any;
  123951. /**
  123952. * Parses a anisotropy Configuration from a serialized object.
  123953. * @param source - Serialized object.
  123954. * @param scene Defines the scene we are parsing for
  123955. * @param rootUrl Defines the rootUrl to load from
  123956. */
  123957. parse(source: any, scene: Scene, rootUrl: string): void;
  123958. }
  123959. }
  123960. declare module BABYLON {
  123961. /** @hidden */
  123962. export var pbrFragmentDeclaration: {
  123963. name: string;
  123964. shader: string;
  123965. };
  123966. }
  123967. declare module BABYLON {
  123968. /** @hidden */
  123969. export var pbrUboDeclaration: {
  123970. name: string;
  123971. shader: string;
  123972. };
  123973. }
  123974. declare module BABYLON {
  123975. /** @hidden */
  123976. export var pbrFragmentExtraDeclaration: {
  123977. name: string;
  123978. shader: string;
  123979. };
  123980. }
  123981. declare module BABYLON {
  123982. /** @hidden */
  123983. export var pbrFragmentSamplersDeclaration: {
  123984. name: string;
  123985. shader: string;
  123986. };
  123987. }
  123988. declare module BABYLON {
  123989. /** @hidden */
  123990. export var pbrHelperFunctions: {
  123991. name: string;
  123992. shader: string;
  123993. };
  123994. }
  123995. declare module BABYLON {
  123996. /** @hidden */
  123997. export var harmonicsFunctions: {
  123998. name: string;
  123999. shader: string;
  124000. };
  124001. }
  124002. declare module BABYLON {
  124003. /** @hidden */
  124004. export var pbrDirectLightingSetupFunctions: {
  124005. name: string;
  124006. shader: string;
  124007. };
  124008. }
  124009. declare module BABYLON {
  124010. /** @hidden */
  124011. export var pbrDirectLightingFalloffFunctions: {
  124012. name: string;
  124013. shader: string;
  124014. };
  124015. }
  124016. declare module BABYLON {
  124017. /** @hidden */
  124018. export var pbrBRDFFunctions: {
  124019. name: string;
  124020. shader: string;
  124021. };
  124022. }
  124023. declare module BABYLON {
  124024. /** @hidden */
  124025. export var pbrDirectLightingFunctions: {
  124026. name: string;
  124027. shader: string;
  124028. };
  124029. }
  124030. declare module BABYLON {
  124031. /** @hidden */
  124032. export var pbrIBLFunctions: {
  124033. name: string;
  124034. shader: string;
  124035. };
  124036. }
  124037. declare module BABYLON {
  124038. /** @hidden */
  124039. export var pbrDebug: {
  124040. name: string;
  124041. shader: string;
  124042. };
  124043. }
  124044. declare module BABYLON {
  124045. /** @hidden */
  124046. export var pbrPixelShader: {
  124047. name: string;
  124048. shader: string;
  124049. };
  124050. }
  124051. declare module BABYLON {
  124052. /** @hidden */
  124053. export var pbrVertexDeclaration: {
  124054. name: string;
  124055. shader: string;
  124056. };
  124057. }
  124058. declare module BABYLON {
  124059. /** @hidden */
  124060. export var pbrVertexShader: {
  124061. name: string;
  124062. shader: string;
  124063. };
  124064. }
  124065. declare module BABYLON {
  124066. /**
  124067. * Manages the defines for the PBR Material.
  124068. * @hidden
  124069. */
  124070. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  124071. PBR: boolean;
  124072. MAINUV1: boolean;
  124073. MAINUV2: boolean;
  124074. UV1: boolean;
  124075. UV2: boolean;
  124076. ALBEDO: boolean;
  124077. GAMMAALBEDO: boolean;
  124078. ALBEDODIRECTUV: number;
  124079. VERTEXCOLOR: boolean;
  124080. AMBIENT: boolean;
  124081. AMBIENTDIRECTUV: number;
  124082. AMBIENTINGRAYSCALE: boolean;
  124083. OPACITY: boolean;
  124084. VERTEXALPHA: boolean;
  124085. OPACITYDIRECTUV: number;
  124086. OPACITYRGB: boolean;
  124087. ALPHATEST: boolean;
  124088. DEPTHPREPASS: boolean;
  124089. ALPHABLEND: boolean;
  124090. ALPHAFROMALBEDO: boolean;
  124091. ALPHATESTVALUE: string;
  124092. SPECULAROVERALPHA: boolean;
  124093. RADIANCEOVERALPHA: boolean;
  124094. ALPHAFRESNEL: boolean;
  124095. LINEARALPHAFRESNEL: boolean;
  124096. PREMULTIPLYALPHA: boolean;
  124097. EMISSIVE: boolean;
  124098. EMISSIVEDIRECTUV: number;
  124099. REFLECTIVITY: boolean;
  124100. REFLECTIVITYDIRECTUV: number;
  124101. SPECULARTERM: boolean;
  124102. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  124103. MICROSURFACEAUTOMATIC: boolean;
  124104. LODBASEDMICROSFURACE: boolean;
  124105. MICROSURFACEMAP: boolean;
  124106. MICROSURFACEMAPDIRECTUV: number;
  124107. METALLICWORKFLOW: boolean;
  124108. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  124109. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  124110. METALLNESSSTOREINMETALMAPBLUE: boolean;
  124111. AOSTOREINMETALMAPRED: boolean;
  124112. METALLICF0FACTORFROMMETALLICMAP: boolean;
  124113. ENVIRONMENTBRDF: boolean;
  124114. ENVIRONMENTBRDF_RGBD: boolean;
  124115. NORMAL: boolean;
  124116. TANGENT: boolean;
  124117. BUMP: boolean;
  124118. BUMPDIRECTUV: number;
  124119. OBJECTSPACE_NORMALMAP: boolean;
  124120. PARALLAX: boolean;
  124121. PARALLAXOCCLUSION: boolean;
  124122. NORMALXYSCALE: boolean;
  124123. LIGHTMAP: boolean;
  124124. LIGHTMAPDIRECTUV: number;
  124125. USELIGHTMAPASSHADOWMAP: boolean;
  124126. GAMMALIGHTMAP: boolean;
  124127. RGBDLIGHTMAP: boolean;
  124128. REFLECTION: boolean;
  124129. REFLECTIONMAP_3D: boolean;
  124130. REFLECTIONMAP_SPHERICAL: boolean;
  124131. REFLECTIONMAP_PLANAR: boolean;
  124132. REFLECTIONMAP_CUBIC: boolean;
  124133. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  124134. REFLECTIONMAP_PROJECTION: boolean;
  124135. REFLECTIONMAP_SKYBOX: boolean;
  124136. REFLECTIONMAP_EXPLICIT: boolean;
  124137. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  124138. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  124139. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  124140. INVERTCUBICMAP: boolean;
  124141. USESPHERICALFROMREFLECTIONMAP: boolean;
  124142. USEIRRADIANCEMAP: boolean;
  124143. SPHERICAL_HARMONICS: boolean;
  124144. USESPHERICALINVERTEX: boolean;
  124145. REFLECTIONMAP_OPPOSITEZ: boolean;
  124146. LODINREFLECTIONALPHA: boolean;
  124147. GAMMAREFLECTION: boolean;
  124148. RGBDREFLECTION: boolean;
  124149. LINEARSPECULARREFLECTION: boolean;
  124150. RADIANCEOCCLUSION: boolean;
  124151. HORIZONOCCLUSION: boolean;
  124152. INSTANCES: boolean;
  124153. NUM_BONE_INFLUENCERS: number;
  124154. BonesPerMesh: number;
  124155. BONETEXTURE: boolean;
  124156. NONUNIFORMSCALING: boolean;
  124157. MORPHTARGETS: boolean;
  124158. MORPHTARGETS_NORMAL: boolean;
  124159. MORPHTARGETS_TANGENT: boolean;
  124160. MORPHTARGETS_UV: boolean;
  124161. NUM_MORPH_INFLUENCERS: number;
  124162. IMAGEPROCESSING: boolean;
  124163. VIGNETTE: boolean;
  124164. VIGNETTEBLENDMODEMULTIPLY: boolean;
  124165. VIGNETTEBLENDMODEOPAQUE: boolean;
  124166. TONEMAPPING: boolean;
  124167. TONEMAPPING_ACES: boolean;
  124168. CONTRAST: boolean;
  124169. COLORCURVES: boolean;
  124170. COLORGRADING: boolean;
  124171. COLORGRADING3D: boolean;
  124172. SAMPLER3DGREENDEPTH: boolean;
  124173. SAMPLER3DBGRMAP: boolean;
  124174. IMAGEPROCESSINGPOSTPROCESS: boolean;
  124175. EXPOSURE: boolean;
  124176. MULTIVIEW: boolean;
  124177. USEPHYSICALLIGHTFALLOFF: boolean;
  124178. USEGLTFLIGHTFALLOFF: boolean;
  124179. TWOSIDEDLIGHTING: boolean;
  124180. SHADOWFLOAT: boolean;
  124181. CLIPPLANE: boolean;
  124182. CLIPPLANE2: boolean;
  124183. CLIPPLANE3: boolean;
  124184. CLIPPLANE4: boolean;
  124185. CLIPPLANE5: boolean;
  124186. CLIPPLANE6: boolean;
  124187. POINTSIZE: boolean;
  124188. FOG: boolean;
  124189. LOGARITHMICDEPTH: boolean;
  124190. FORCENORMALFORWARD: boolean;
  124191. SPECULARAA: boolean;
  124192. CLEARCOAT: boolean;
  124193. CLEARCOAT_DEFAULTIOR: boolean;
  124194. CLEARCOAT_TEXTURE: boolean;
  124195. CLEARCOAT_TEXTUREDIRECTUV: number;
  124196. CLEARCOAT_BUMP: boolean;
  124197. CLEARCOAT_BUMPDIRECTUV: number;
  124198. CLEARCOAT_TINT: boolean;
  124199. CLEARCOAT_TINT_TEXTURE: boolean;
  124200. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124201. ANISOTROPIC: boolean;
  124202. ANISOTROPIC_TEXTURE: boolean;
  124203. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124204. BRDF_V_HEIGHT_CORRELATED: boolean;
  124205. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124206. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124207. SHEEN: boolean;
  124208. SHEEN_TEXTURE: boolean;
  124209. SHEEN_TEXTUREDIRECTUV: number;
  124210. SHEEN_LINKWITHALBEDO: boolean;
  124211. SUBSURFACE: boolean;
  124212. SS_REFRACTION: boolean;
  124213. SS_TRANSLUCENCY: boolean;
  124214. SS_SCATERRING: boolean;
  124215. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124216. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124217. SS_REFRACTIONMAP_3D: boolean;
  124218. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124219. SS_LODINREFRACTIONALPHA: boolean;
  124220. SS_GAMMAREFRACTION: boolean;
  124221. SS_RGBDREFRACTION: boolean;
  124222. SS_LINEARSPECULARREFRACTION: boolean;
  124223. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124224. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124225. UNLIT: boolean;
  124226. DEBUGMODE: number;
  124227. /**
  124228. * Initializes the PBR Material defines.
  124229. */
  124230. constructor();
  124231. /**
  124232. * Resets the PBR Material defines.
  124233. */
  124234. reset(): void;
  124235. }
  124236. /**
  124237. * The Physically based material base class of BJS.
  124238. *
  124239. * This offers the main features of a standard PBR material.
  124240. * For more information, please refer to the documentation :
  124241. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124242. */
  124243. export abstract class PBRBaseMaterial extends PushMaterial {
  124244. /**
  124245. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124246. */
  124247. static readonly PBRMATERIAL_OPAQUE: number;
  124248. /**
  124249. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124250. */
  124251. static readonly PBRMATERIAL_ALPHATEST: number;
  124252. /**
  124253. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124254. */
  124255. static readonly PBRMATERIAL_ALPHABLEND: number;
  124256. /**
  124257. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124258. * They are also discarded below the alpha cutoff threshold to improve performances.
  124259. */
  124260. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124261. /**
  124262. * Defines the default value of how much AO map is occluding the analytical lights
  124263. * (point spot...).
  124264. */
  124265. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124266. /**
  124267. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  124268. */
  124269. static readonly LIGHTFALLOFF_PHYSICAL: number;
  124270. /**
  124271. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  124272. * to enhance interoperability with other engines.
  124273. */
  124274. static readonly LIGHTFALLOFF_GLTF: number;
  124275. /**
  124276. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  124277. * to enhance interoperability with other materials.
  124278. */
  124279. static readonly LIGHTFALLOFF_STANDARD: number;
  124280. /**
  124281. * Intensity of the direct lights e.g. the four lights available in your scene.
  124282. * This impacts both the direct diffuse and specular highlights.
  124283. */
  124284. protected _directIntensity: number;
  124285. /**
  124286. * Intensity of the emissive part of the material.
  124287. * This helps controlling the emissive effect without modifying the emissive color.
  124288. */
  124289. protected _emissiveIntensity: number;
  124290. /**
  124291. * Intensity of the environment e.g. how much the environment will light the object
  124292. * either through harmonics for rough material or through the refelction for shiny ones.
  124293. */
  124294. protected _environmentIntensity: number;
  124295. /**
  124296. * This is a special control allowing the reduction of the specular highlights coming from the
  124297. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124298. */
  124299. protected _specularIntensity: number;
  124300. /**
  124301. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  124302. */
  124303. private _lightingInfos;
  124304. /**
  124305. * Debug Control allowing disabling the bump map on this material.
  124306. */
  124307. protected _disableBumpMap: boolean;
  124308. /**
  124309. * AKA Diffuse Texture in standard nomenclature.
  124310. */
  124311. protected _albedoTexture: Nullable<BaseTexture>;
  124312. /**
  124313. * AKA Occlusion Texture in other nomenclature.
  124314. */
  124315. protected _ambientTexture: Nullable<BaseTexture>;
  124316. /**
  124317. * AKA Occlusion Texture Intensity in other nomenclature.
  124318. */
  124319. protected _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. protected _ambientTextureImpactOnAnalyticalLights: number;
  124326. /**
  124327. * Stores the alpha values in a texture.
  124328. */
  124329. protected _opacityTexture: Nullable<BaseTexture>;
  124330. /**
  124331. * Stores the reflection values in a texture.
  124332. */
  124333. protected _reflectionTexture: Nullable<BaseTexture>;
  124334. /**
  124335. * Stores the emissive values in a texture.
  124336. */
  124337. protected _emissiveTexture: Nullable<BaseTexture>;
  124338. /**
  124339. * AKA Specular texture in other nomenclature.
  124340. */
  124341. protected _reflectivityTexture: Nullable<BaseTexture>;
  124342. /**
  124343. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124344. */
  124345. protected _metallicTexture: Nullable<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. protected _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. protected _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. protected _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. protected _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. protected _microSurfaceTexture: Nullable<BaseTexture>;
  124374. /**
  124375. * Stores surface normal data used to displace a mesh in a texture.
  124376. */
  124377. protected _bumpTexture: Nullable<BaseTexture>;
  124378. /**
  124379. * Stores the pre-calculated light information of a mesh in a texture.
  124380. */
  124381. protected _lightmapTexture: Nullable<BaseTexture>;
  124382. /**
  124383. * The color of a material in ambient lighting.
  124384. */
  124385. protected _ambientColor: Color3;
  124386. /**
  124387. * AKA Diffuse Color in other nomenclature.
  124388. */
  124389. protected _albedoColor: Color3;
  124390. /**
  124391. * AKA Specular Color in other nomenclature.
  124392. */
  124393. protected _reflectivityColor: Color3;
  124394. /**
  124395. * The color applied when light is reflected from a material.
  124396. */
  124397. protected _reflectionColor: Color3;
  124398. /**
  124399. * The color applied when light is emitted from a material.
  124400. */
  124401. protected _emissiveColor: Color3;
  124402. /**
  124403. * AKA Glossiness in other nomenclature.
  124404. */
  124405. protected _microSurface: number;
  124406. /**
  124407. * Specifies that the material will use the light map as a show map.
  124408. */
  124409. protected _useLightmapAsShadowmap: boolean;
  124410. /**
  124411. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124412. * makes the reflect vector face the model (under horizon).
  124413. */
  124414. protected _useHorizonOcclusion: boolean;
  124415. /**
  124416. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124417. * too much the area relying on ambient texture to define their ambient occlusion.
  124418. */
  124419. protected _useRadianceOcclusion: boolean;
  124420. /**
  124421. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124422. */
  124423. protected _useAlphaFromAlbedoTexture: boolean;
  124424. /**
  124425. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  124426. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124427. */
  124428. protected _useSpecularOverAlpha: boolean;
  124429. /**
  124430. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124431. */
  124432. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124433. /**
  124434. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124435. */
  124436. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  124437. /**
  124438. * Specifies if the metallic texture contains the roughness information in its green channel.
  124439. */
  124440. protected _useRoughnessFromMetallicTextureGreen: boolean;
  124441. /**
  124442. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124443. */
  124444. protected _useMetallnessFromMetallicTextureBlue: boolean;
  124445. /**
  124446. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124447. */
  124448. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  124449. /**
  124450. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124451. */
  124452. protected _useAmbientInGrayScale: boolean;
  124453. /**
  124454. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124455. * The material will try to infer what glossiness each pixel should be.
  124456. */
  124457. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  124458. /**
  124459. * Defines the falloff type used in this material.
  124460. * It by default is Physical.
  124461. */
  124462. protected _lightFalloff: number;
  124463. /**
  124464. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124465. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124466. */
  124467. protected _useRadianceOverAlpha: boolean;
  124468. /**
  124469. * Allows using an object space normal map (instead of tangent space).
  124470. */
  124471. protected _useObjectSpaceNormalMap: boolean;
  124472. /**
  124473. * Allows using the bump map in parallax mode.
  124474. */
  124475. protected _useParallax: boolean;
  124476. /**
  124477. * Allows using the bump map in parallax occlusion mode.
  124478. */
  124479. protected _useParallaxOcclusion: boolean;
  124480. /**
  124481. * Controls the scale bias of the parallax mode.
  124482. */
  124483. protected _parallaxScaleBias: number;
  124484. /**
  124485. * If sets to true, disables all the lights affecting the material.
  124486. */
  124487. protected _disableLighting: boolean;
  124488. /**
  124489. * Number of Simultaneous lights allowed on the material.
  124490. */
  124491. protected _maxSimultaneousLights: number;
  124492. /**
  124493. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124494. */
  124495. protected _invertNormalMapX: boolean;
  124496. /**
  124497. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124498. */
  124499. protected _invertNormalMapY: boolean;
  124500. /**
  124501. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124502. */
  124503. protected _twoSidedLighting: boolean;
  124504. /**
  124505. * Defines the alpha limits in alpha test mode.
  124506. */
  124507. protected _alphaCutOff: number;
  124508. /**
  124509. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124510. */
  124511. protected _forceAlphaTest: boolean;
  124512. /**
  124513. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124514. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124515. */
  124516. protected _useAlphaFresnel: boolean;
  124517. /**
  124518. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124519. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124520. */
  124521. protected _useLinearAlphaFresnel: boolean;
  124522. /**
  124523. * The transparency mode of the material.
  124524. */
  124525. protected _transparencyMode: Nullable<number>;
  124526. /**
  124527. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  124528. * from cos thetav and roughness:
  124529. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  124530. */
  124531. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  124532. /**
  124533. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124534. */
  124535. protected _forceIrradianceInFragment: boolean;
  124536. /**
  124537. * Force normal to face away from face.
  124538. */
  124539. protected _forceNormalForward: boolean;
  124540. /**
  124541. * Enables specular anti aliasing in the PBR shader.
  124542. * It will both interacts on the Geometry for analytical and IBL lighting.
  124543. * It also prefilter the roughness map based on the bump values.
  124544. */
  124545. protected _enableSpecularAntiAliasing: boolean;
  124546. /**
  124547. * Default configuration related to image processing available in the PBR Material.
  124548. */
  124549. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124550. /**
  124551. * Keep track of the image processing observer to allow dispose and replace.
  124552. */
  124553. private _imageProcessingObserver;
  124554. /**
  124555. * Attaches a new image processing configuration to the PBR Material.
  124556. * @param configuration
  124557. */
  124558. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124559. /**
  124560. * Stores the available render targets.
  124561. */
  124562. private _renderTargets;
  124563. /**
  124564. * Sets the global ambient color for the material used in lighting calculations.
  124565. */
  124566. private _globalAmbientColor;
  124567. /**
  124568. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  124569. */
  124570. private _useLogarithmicDepth;
  124571. /**
  124572. * If set to true, no lighting calculations will be applied.
  124573. */
  124574. private _unlit;
  124575. private _debugMode;
  124576. /**
  124577. * @hidden
  124578. * This is reserved for the inspector.
  124579. * Defines the material debug mode.
  124580. * It helps seeing only some components of the material while troubleshooting.
  124581. */
  124582. debugMode: number;
  124583. /**
  124584. * @hidden
  124585. * This is reserved for the inspector.
  124586. * Specify from where on screen the debug mode should start.
  124587. * The value goes from -1 (full screen) to 1 (not visible)
  124588. * It helps with side by side comparison against the final render
  124589. * This defaults to -1
  124590. */
  124591. private debugLimit;
  124592. /**
  124593. * @hidden
  124594. * This is reserved for the inspector.
  124595. * As the default viewing range might not be enough (if the ambient is really small for instance)
  124596. * You can use the factor to better multiply the final value.
  124597. */
  124598. private debugFactor;
  124599. /**
  124600. * Defines the clear coat layer parameters for the material.
  124601. */
  124602. readonly clearCoat: PBRClearCoatConfiguration;
  124603. /**
  124604. * Defines the anisotropic parameters for the material.
  124605. */
  124606. readonly anisotropy: PBRAnisotropicConfiguration;
  124607. /**
  124608. * Defines the BRDF parameters for the material.
  124609. */
  124610. readonly brdf: PBRBRDFConfiguration;
  124611. /**
  124612. * Defines the Sheen parameters for the material.
  124613. */
  124614. readonly sheen: PBRSheenConfiguration;
  124615. /**
  124616. * Defines the SubSurface parameters for the material.
  124617. */
  124618. readonly subSurface: PBRSubSurfaceConfiguration;
  124619. /**
  124620. * Custom callback helping to override the default shader used in the material.
  124621. */
  124622. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  124623. protected _rebuildInParallel: boolean;
  124624. /**
  124625. * Instantiates a new PBRMaterial instance.
  124626. *
  124627. * @param name The material name
  124628. * @param scene The scene the material will be use in.
  124629. */
  124630. constructor(name: string, scene: Scene);
  124631. /**
  124632. * Gets a boolean indicating that current material needs to register RTT
  124633. */
  124634. get hasRenderTargetTextures(): boolean;
  124635. /**
  124636. * Gets the name of the material class.
  124637. */
  124638. getClassName(): string;
  124639. /**
  124640. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124641. */
  124642. get useLogarithmicDepth(): boolean;
  124643. /**
  124644. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124645. */
  124646. set useLogarithmicDepth(value: boolean);
  124647. /**
  124648. * Gets the current transparency mode.
  124649. */
  124650. get transparencyMode(): Nullable<number>;
  124651. /**
  124652. * Sets the transparency mode of the material.
  124653. *
  124654. * | Value | Type | Description |
  124655. * | ----- | ----------------------------------- | ----------- |
  124656. * | 0 | OPAQUE | |
  124657. * | 1 | ALPHATEST | |
  124658. * | 2 | ALPHABLEND | |
  124659. * | 3 | ALPHATESTANDBLEND | |
  124660. *
  124661. */
  124662. set transparencyMode(value: Nullable<number>);
  124663. /**
  124664. * Returns true if alpha blending should be disabled.
  124665. */
  124666. private get _disableAlphaBlending();
  124667. /**
  124668. * Specifies whether or not this material should be rendered in alpha blend mode.
  124669. */
  124670. needAlphaBlending(): boolean;
  124671. /**
  124672. * Specifies if the mesh will require alpha blending.
  124673. * @param mesh - BJS mesh.
  124674. */
  124675. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  124676. /**
  124677. * Specifies whether or not this material should be rendered in alpha test mode.
  124678. */
  124679. needAlphaTesting(): boolean;
  124680. /**
  124681. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  124682. */
  124683. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  124684. /**
  124685. * Gets the texture used for the alpha test.
  124686. */
  124687. getAlphaTestTexture(): Nullable<BaseTexture>;
  124688. /**
  124689. * Specifies that the submesh is ready to be used.
  124690. * @param mesh - BJS mesh.
  124691. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124692. * @param useInstances - Specifies that instances should be used.
  124693. * @returns - boolean indicating that the submesh is ready or not.
  124694. */
  124695. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124696. /**
  124697. * Specifies if the material uses metallic roughness workflow.
  124698. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124699. */
  124700. isMetallicWorkflow(): boolean;
  124701. private _prepareEffect;
  124702. private _prepareDefines;
  124703. /**
  124704. * Force shader compilation
  124705. */
  124706. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124707. /**
  124708. * Initializes the uniform buffer layout for the shader.
  124709. */
  124710. buildUniformLayout(): void;
  124711. /**
  124712. * Unbinds the material from the mesh
  124713. */
  124714. unbind(): void;
  124715. /**
  124716. * Binds the submesh data.
  124717. * @param world - The world matrix.
  124718. * @param mesh - The BJS mesh.
  124719. * @param subMesh - A submesh of the BJS mesh.
  124720. */
  124721. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124722. /**
  124723. * Returns the animatable textures.
  124724. * @returns - Array of animatable textures.
  124725. */
  124726. getAnimatables(): IAnimatable[];
  124727. /**
  124728. * Returns the texture used for reflections.
  124729. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124730. */
  124731. private _getReflectionTexture;
  124732. /**
  124733. * Returns an array of the actively used textures.
  124734. * @returns - Array of BaseTextures
  124735. */
  124736. getActiveTextures(): BaseTexture[];
  124737. /**
  124738. * Checks to see if a texture is used in the material.
  124739. * @param texture - Base texture to use.
  124740. * @returns - Boolean specifying if a texture is used in the material.
  124741. */
  124742. hasTexture(texture: BaseTexture): boolean;
  124743. /**
  124744. * Disposes the resources of the material.
  124745. * @param forceDisposeEffect - Forces the disposal of effects.
  124746. * @param forceDisposeTextures - Forces the disposal of all textures.
  124747. */
  124748. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124749. }
  124750. }
  124751. declare module BABYLON {
  124752. /**
  124753. * The Physically based material of BJS.
  124754. *
  124755. * This offers the main features of a standard PBR material.
  124756. * For more information, please refer to the documentation :
  124757. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124758. */
  124759. export class PBRMaterial extends PBRBaseMaterial {
  124760. /**
  124761. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124762. */
  124763. static readonly PBRMATERIAL_OPAQUE: number;
  124764. /**
  124765. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124766. */
  124767. static readonly PBRMATERIAL_ALPHATEST: number;
  124768. /**
  124769. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124770. */
  124771. static readonly PBRMATERIAL_ALPHABLEND: number;
  124772. /**
  124773. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124774. * They are also discarded below the alpha cutoff threshold to improve performances.
  124775. */
  124776. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124777. /**
  124778. * Defines the default value of how much AO map is occluding the analytical lights
  124779. * (point spot...).
  124780. */
  124781. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124782. /**
  124783. * Intensity of the direct lights e.g. the four lights available in your scene.
  124784. * This impacts both the direct diffuse and specular highlights.
  124785. */
  124786. directIntensity: number;
  124787. /**
  124788. * Intensity of the emissive part of the material.
  124789. * This helps controlling the emissive effect without modifying the emissive color.
  124790. */
  124791. emissiveIntensity: number;
  124792. /**
  124793. * Intensity of the environment e.g. how much the environment will light the object
  124794. * either through harmonics for rough material or through the refelction for shiny ones.
  124795. */
  124796. environmentIntensity: number;
  124797. /**
  124798. * This is a special control allowing the reduction of the specular highlights coming from the
  124799. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124800. */
  124801. specularIntensity: number;
  124802. /**
  124803. * Debug Control allowing disabling the bump map on this material.
  124804. */
  124805. disableBumpMap: boolean;
  124806. /**
  124807. * AKA Diffuse Texture in standard nomenclature.
  124808. */
  124809. albedoTexture: BaseTexture;
  124810. /**
  124811. * AKA Occlusion Texture in other nomenclature.
  124812. */
  124813. ambientTexture: BaseTexture;
  124814. /**
  124815. * AKA Occlusion Texture Intensity in other nomenclature.
  124816. */
  124817. ambientTextureStrength: number;
  124818. /**
  124819. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124820. * 1 means it completely occludes it
  124821. * 0 mean it has no impact
  124822. */
  124823. ambientTextureImpactOnAnalyticalLights: number;
  124824. /**
  124825. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  124826. */
  124827. opacityTexture: BaseTexture;
  124828. /**
  124829. * Stores the reflection values in a texture.
  124830. */
  124831. reflectionTexture: Nullable<BaseTexture>;
  124832. /**
  124833. * Stores the emissive values in a texture.
  124834. */
  124835. emissiveTexture: BaseTexture;
  124836. /**
  124837. * AKA Specular texture in other nomenclature.
  124838. */
  124839. reflectivityTexture: BaseTexture;
  124840. /**
  124841. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124842. */
  124843. metallicTexture: BaseTexture;
  124844. /**
  124845. * Specifies the metallic scalar of the metallic/roughness workflow.
  124846. * Can also be used to scale the metalness values of the metallic texture.
  124847. */
  124848. metallic: Nullable<number>;
  124849. /**
  124850. * Specifies the roughness scalar of the metallic/roughness workflow.
  124851. * Can also be used to scale the roughness values of the metallic texture.
  124852. */
  124853. roughness: Nullable<number>;
  124854. /**
  124855. * Specifies the an F0 factor to help configuring the material F0.
  124856. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124857. * to 0.5 the previously hard coded value stays the same.
  124858. * Can also be used to scale the F0 values of the metallic texture.
  124859. */
  124860. metallicF0Factor: number;
  124861. /**
  124862. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124863. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124864. * your expectation as it multiplies with the texture data.
  124865. */
  124866. useMetallicF0FactorFromMetallicTexture: boolean;
  124867. /**
  124868. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124869. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124870. */
  124871. microSurfaceTexture: BaseTexture;
  124872. /**
  124873. * Stores surface normal data used to displace a mesh in a texture.
  124874. */
  124875. bumpTexture: BaseTexture;
  124876. /**
  124877. * Stores the pre-calculated light information of a mesh in a texture.
  124878. */
  124879. lightmapTexture: BaseTexture;
  124880. /**
  124881. * Stores the refracted light information in a texture.
  124882. */
  124883. get refractionTexture(): Nullable<BaseTexture>;
  124884. set refractionTexture(value: Nullable<BaseTexture>);
  124885. /**
  124886. * The color of a material in ambient lighting.
  124887. */
  124888. ambientColor: Color3;
  124889. /**
  124890. * AKA Diffuse Color in other nomenclature.
  124891. */
  124892. albedoColor: Color3;
  124893. /**
  124894. * AKA Specular Color in other nomenclature.
  124895. */
  124896. reflectivityColor: Color3;
  124897. /**
  124898. * The color reflected from the material.
  124899. */
  124900. reflectionColor: Color3;
  124901. /**
  124902. * The color emitted from the material.
  124903. */
  124904. emissiveColor: Color3;
  124905. /**
  124906. * AKA Glossiness in other nomenclature.
  124907. */
  124908. microSurface: number;
  124909. /**
  124910. * source material index of refraction (IOR)' / 'destination material IOR.
  124911. */
  124912. get indexOfRefraction(): number;
  124913. set indexOfRefraction(value: number);
  124914. /**
  124915. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124916. */
  124917. get invertRefractionY(): boolean;
  124918. set invertRefractionY(value: boolean);
  124919. /**
  124920. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124921. * Materials half opaque for instance using refraction could benefit from this control.
  124922. */
  124923. get linkRefractionWithTransparency(): boolean;
  124924. set linkRefractionWithTransparency(value: boolean);
  124925. /**
  124926. * If true, the light map contains occlusion information instead of lighting info.
  124927. */
  124928. useLightmapAsShadowmap: boolean;
  124929. /**
  124930. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124931. */
  124932. useAlphaFromAlbedoTexture: boolean;
  124933. /**
  124934. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124935. */
  124936. forceAlphaTest: boolean;
  124937. /**
  124938. * Defines the alpha limits in alpha test mode.
  124939. */
  124940. alphaCutOff: number;
  124941. /**
  124942. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  124943. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124944. */
  124945. useSpecularOverAlpha: boolean;
  124946. /**
  124947. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124948. */
  124949. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124950. /**
  124951. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124952. */
  124953. useRoughnessFromMetallicTextureAlpha: boolean;
  124954. /**
  124955. * Specifies if the metallic texture contains the roughness information in its green channel.
  124956. */
  124957. useRoughnessFromMetallicTextureGreen: boolean;
  124958. /**
  124959. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124960. */
  124961. useMetallnessFromMetallicTextureBlue: boolean;
  124962. /**
  124963. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124964. */
  124965. useAmbientOcclusionFromMetallicTextureRed: boolean;
  124966. /**
  124967. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124968. */
  124969. useAmbientInGrayScale: boolean;
  124970. /**
  124971. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124972. * The material will try to infer what glossiness each pixel should be.
  124973. */
  124974. useAutoMicroSurfaceFromReflectivityMap: boolean;
  124975. /**
  124976. * BJS is using an harcoded light falloff based on a manually sets up range.
  124977. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124978. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124979. */
  124980. get usePhysicalLightFalloff(): boolean;
  124981. /**
  124982. * BJS is using an harcoded light falloff based on a manually sets up range.
  124983. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124984. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124985. */
  124986. set usePhysicalLightFalloff(value: boolean);
  124987. /**
  124988. * In order to support the falloff compatibility with gltf, a special mode has been added
  124989. * to reproduce the gltf light falloff.
  124990. */
  124991. get useGLTFLightFalloff(): boolean;
  124992. /**
  124993. * In order to support the falloff compatibility with gltf, a special mode has been added
  124994. * to reproduce the gltf light falloff.
  124995. */
  124996. set useGLTFLightFalloff(value: boolean);
  124997. /**
  124998. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124999. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  125000. */
  125001. useRadianceOverAlpha: boolean;
  125002. /**
  125003. * Allows using an object space normal map (instead of tangent space).
  125004. */
  125005. useObjectSpaceNormalMap: boolean;
  125006. /**
  125007. * Allows using the bump map in parallax mode.
  125008. */
  125009. useParallax: boolean;
  125010. /**
  125011. * Allows using the bump map in parallax occlusion mode.
  125012. */
  125013. useParallaxOcclusion: boolean;
  125014. /**
  125015. * Controls the scale bias of the parallax mode.
  125016. */
  125017. parallaxScaleBias: number;
  125018. /**
  125019. * If sets to true, disables all the lights affecting the material.
  125020. */
  125021. disableLighting: boolean;
  125022. /**
  125023. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  125024. */
  125025. forceIrradianceInFragment: boolean;
  125026. /**
  125027. * Number of Simultaneous lights allowed on the material.
  125028. */
  125029. maxSimultaneousLights: number;
  125030. /**
  125031. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  125032. */
  125033. invertNormalMapX: boolean;
  125034. /**
  125035. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  125036. */
  125037. invertNormalMapY: boolean;
  125038. /**
  125039. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  125040. */
  125041. twoSidedLighting: boolean;
  125042. /**
  125043. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125044. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  125045. */
  125046. useAlphaFresnel: boolean;
  125047. /**
  125048. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125049. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  125050. */
  125051. useLinearAlphaFresnel: boolean;
  125052. /**
  125053. * Let user defines the brdf lookup texture used for IBL.
  125054. * A default 8bit version is embedded but you could point at :
  125055. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  125056. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  125057. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  125058. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  125059. */
  125060. environmentBRDFTexture: Nullable<BaseTexture>;
  125061. /**
  125062. * Force normal to face away from face.
  125063. */
  125064. forceNormalForward: boolean;
  125065. /**
  125066. * Enables specular anti aliasing in the PBR shader.
  125067. * It will both interacts on the Geometry for analytical and IBL lighting.
  125068. * It also prefilter the roughness map based on the bump values.
  125069. */
  125070. enableSpecularAntiAliasing: boolean;
  125071. /**
  125072. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  125073. * makes the reflect vector face the model (under horizon).
  125074. */
  125075. useHorizonOcclusion: boolean;
  125076. /**
  125077. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  125078. * too much the area relying on ambient texture to define their ambient occlusion.
  125079. */
  125080. useRadianceOcclusion: boolean;
  125081. /**
  125082. * If set to true, no lighting calculations will be applied.
  125083. */
  125084. unlit: boolean;
  125085. /**
  125086. * Gets the image processing configuration used either in this material.
  125087. */
  125088. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  125089. /**
  125090. * Sets the Default image processing configuration used either in the this material.
  125091. *
  125092. * If sets to null, the scene one is in use.
  125093. */
  125094. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  125095. /**
  125096. * Gets wether the color curves effect is enabled.
  125097. */
  125098. get cameraColorCurvesEnabled(): boolean;
  125099. /**
  125100. * Sets wether the color curves effect is enabled.
  125101. */
  125102. set cameraColorCurvesEnabled(value: boolean);
  125103. /**
  125104. * Gets wether the color grading effect is enabled.
  125105. */
  125106. get cameraColorGradingEnabled(): boolean;
  125107. /**
  125108. * Gets wether the color grading effect is enabled.
  125109. */
  125110. set cameraColorGradingEnabled(value: boolean);
  125111. /**
  125112. * Gets wether tonemapping is enabled or not.
  125113. */
  125114. get cameraToneMappingEnabled(): boolean;
  125115. /**
  125116. * Sets wether tonemapping is enabled or not
  125117. */
  125118. set cameraToneMappingEnabled(value: boolean);
  125119. /**
  125120. * The camera exposure used on this material.
  125121. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125122. * This corresponds to a photographic exposure.
  125123. */
  125124. get cameraExposure(): number;
  125125. /**
  125126. * The camera exposure used on this material.
  125127. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125128. * This corresponds to a photographic exposure.
  125129. */
  125130. set cameraExposure(value: number);
  125131. /**
  125132. * Gets The camera contrast used on this material.
  125133. */
  125134. get cameraContrast(): number;
  125135. /**
  125136. * Sets The camera contrast used on this material.
  125137. */
  125138. set cameraContrast(value: number);
  125139. /**
  125140. * Gets the Color Grading 2D Lookup Texture.
  125141. */
  125142. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125143. /**
  125144. * Sets the Color Grading 2D Lookup Texture.
  125145. */
  125146. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125147. /**
  125148. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125149. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125150. * 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;
  125151. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125152. */
  125153. get cameraColorCurves(): Nullable<ColorCurves>;
  125154. /**
  125155. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125156. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125157. * 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;
  125158. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125159. */
  125160. set cameraColorCurves(value: Nullable<ColorCurves>);
  125161. /**
  125162. * Instantiates a new PBRMaterial instance.
  125163. *
  125164. * @param name The material name
  125165. * @param scene The scene the material will be use in.
  125166. */
  125167. constructor(name: string, scene: Scene);
  125168. /**
  125169. * Returns the name of this material class.
  125170. */
  125171. getClassName(): string;
  125172. /**
  125173. * Makes a duplicate of the current material.
  125174. * @param name - name to use for the new material.
  125175. */
  125176. clone(name: string): PBRMaterial;
  125177. /**
  125178. * Serializes this PBR Material.
  125179. * @returns - An object with the serialized material.
  125180. */
  125181. serialize(): any;
  125182. /**
  125183. * Parses a PBR Material from a serialized object.
  125184. * @param source - Serialized object.
  125185. * @param scene - BJS scene instance.
  125186. * @param rootUrl - url for the scene object
  125187. * @returns - PBRMaterial
  125188. */
  125189. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  125190. }
  125191. }
  125192. declare module BABYLON {
  125193. /**
  125194. * Direct draw surface info
  125195. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  125196. */
  125197. export interface DDSInfo {
  125198. /**
  125199. * Width of the texture
  125200. */
  125201. width: number;
  125202. /**
  125203. * Width of the texture
  125204. */
  125205. height: number;
  125206. /**
  125207. * Number of Mipmaps for the texture
  125208. * @see https://en.wikipedia.org/wiki/Mipmap
  125209. */
  125210. mipmapCount: number;
  125211. /**
  125212. * If the textures format is a known fourCC format
  125213. * @see https://www.fourcc.org/
  125214. */
  125215. isFourCC: boolean;
  125216. /**
  125217. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  125218. */
  125219. isRGB: boolean;
  125220. /**
  125221. * If the texture is a lumincance format
  125222. */
  125223. isLuminance: boolean;
  125224. /**
  125225. * If this is a cube texture
  125226. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  125227. */
  125228. isCube: boolean;
  125229. /**
  125230. * If the texture is a compressed format eg. FOURCC_DXT1
  125231. */
  125232. isCompressed: boolean;
  125233. /**
  125234. * The dxgiFormat of the texture
  125235. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  125236. */
  125237. dxgiFormat: number;
  125238. /**
  125239. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  125240. */
  125241. textureType: number;
  125242. /**
  125243. * Sphericle polynomial created for the dds texture
  125244. */
  125245. sphericalPolynomial?: SphericalPolynomial;
  125246. }
  125247. /**
  125248. * Class used to provide DDS decompression tools
  125249. */
  125250. export class DDSTools {
  125251. /**
  125252. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  125253. */
  125254. static StoreLODInAlphaChannel: boolean;
  125255. /**
  125256. * Gets DDS information from an array buffer
  125257. * @param data defines the array buffer view to read data from
  125258. * @returns the DDS information
  125259. */
  125260. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  125261. private static _FloatView;
  125262. private static _Int32View;
  125263. private static _ToHalfFloat;
  125264. private static _FromHalfFloat;
  125265. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  125266. private static _GetHalfFloatRGBAArrayBuffer;
  125267. private static _GetFloatRGBAArrayBuffer;
  125268. private static _GetFloatAsUIntRGBAArrayBuffer;
  125269. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  125270. private static _GetRGBAArrayBuffer;
  125271. private static _ExtractLongWordOrder;
  125272. private static _GetRGBArrayBuffer;
  125273. private static _GetLuminanceArrayBuffer;
  125274. /**
  125275. * Uploads DDS Levels to a Babylon Texture
  125276. * @hidden
  125277. */
  125278. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  125279. }
  125280. interface ThinEngine {
  125281. /**
  125282. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  125283. * @param rootUrl defines the url where the file to load is located
  125284. * @param scene defines the current scene
  125285. * @param lodScale defines scale to apply to the mip map selection
  125286. * @param lodOffset defines offset to apply to the mip map selection
  125287. * @param onLoad defines an optional callback raised when the texture is loaded
  125288. * @param onError defines an optional callback raised if there is an issue to load the texture
  125289. * @param format defines the format of the data
  125290. * @param forcedExtension defines the extension to use to pick the right loader
  125291. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  125292. * @returns the cube texture as an InternalTexture
  125293. */
  125294. 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;
  125295. }
  125296. }
  125297. declare module BABYLON {
  125298. /**
  125299. * Implementation of the DDS Texture Loader.
  125300. * @hidden
  125301. */
  125302. export class _DDSTextureLoader implements IInternalTextureLoader {
  125303. /**
  125304. * Defines wether the loader supports cascade loading the different faces.
  125305. */
  125306. readonly supportCascades: boolean;
  125307. /**
  125308. * This returns if the loader support the current file information.
  125309. * @param extension defines the file extension of the file being loaded
  125310. * @returns true if the loader can load the specified file
  125311. */
  125312. canLoad(extension: string): boolean;
  125313. /**
  125314. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125315. * @param data contains the texture data
  125316. * @param texture defines the BabylonJS internal texture
  125317. * @param createPolynomials will be true if polynomials have been requested
  125318. * @param onLoad defines the callback to trigger once the texture is ready
  125319. * @param onError defines the callback to trigger in case of error
  125320. */
  125321. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125322. /**
  125323. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125324. * @param data contains the texture data
  125325. * @param texture defines the BabylonJS internal texture
  125326. * @param callback defines the method to call once ready to upload
  125327. */
  125328. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125329. }
  125330. }
  125331. declare module BABYLON {
  125332. /**
  125333. * Implementation of the ENV Texture Loader.
  125334. * @hidden
  125335. */
  125336. export class _ENVTextureLoader implements IInternalTextureLoader {
  125337. /**
  125338. * Defines wether the loader supports cascade loading the different faces.
  125339. */
  125340. readonly supportCascades: boolean;
  125341. /**
  125342. * This returns if the loader support the current file information.
  125343. * @param extension defines the file extension of the file being loaded
  125344. * @returns true if the loader can load the specified file
  125345. */
  125346. canLoad(extension: string): boolean;
  125347. /**
  125348. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125349. * @param data contains the texture data
  125350. * @param texture defines the BabylonJS internal texture
  125351. * @param createPolynomials will be true if polynomials have been requested
  125352. * @param onLoad defines the callback to trigger once the texture is ready
  125353. * @param onError defines the callback to trigger in case of error
  125354. */
  125355. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125356. /**
  125357. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125358. * @param data contains the texture data
  125359. * @param texture defines the BabylonJS internal texture
  125360. * @param callback defines the method to call once ready to upload
  125361. */
  125362. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125363. }
  125364. }
  125365. declare module BABYLON {
  125366. /**
  125367. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  125368. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  125369. */
  125370. export class KhronosTextureContainer {
  125371. /** contents of the KTX container file */
  125372. data: ArrayBufferView;
  125373. private static HEADER_LEN;
  125374. private static COMPRESSED_2D;
  125375. private static COMPRESSED_3D;
  125376. private static TEX_2D;
  125377. private static TEX_3D;
  125378. /**
  125379. * Gets the openGL type
  125380. */
  125381. glType: number;
  125382. /**
  125383. * Gets the openGL type size
  125384. */
  125385. glTypeSize: number;
  125386. /**
  125387. * Gets the openGL format
  125388. */
  125389. glFormat: number;
  125390. /**
  125391. * Gets the openGL internal format
  125392. */
  125393. glInternalFormat: number;
  125394. /**
  125395. * Gets the base internal format
  125396. */
  125397. glBaseInternalFormat: number;
  125398. /**
  125399. * Gets image width in pixel
  125400. */
  125401. pixelWidth: number;
  125402. /**
  125403. * Gets image height in pixel
  125404. */
  125405. pixelHeight: number;
  125406. /**
  125407. * Gets image depth in pixels
  125408. */
  125409. pixelDepth: number;
  125410. /**
  125411. * Gets the number of array elements
  125412. */
  125413. numberOfArrayElements: number;
  125414. /**
  125415. * Gets the number of faces
  125416. */
  125417. numberOfFaces: number;
  125418. /**
  125419. * Gets the number of mipmap levels
  125420. */
  125421. numberOfMipmapLevels: number;
  125422. /**
  125423. * Gets the bytes of key value data
  125424. */
  125425. bytesOfKeyValueData: number;
  125426. /**
  125427. * Gets the load type
  125428. */
  125429. loadType: number;
  125430. /**
  125431. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  125432. */
  125433. isInvalid: boolean;
  125434. /**
  125435. * Creates a new KhronosTextureContainer
  125436. * @param data contents of the KTX container file
  125437. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  125438. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  125439. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  125440. */
  125441. constructor(
  125442. /** contents of the KTX container file */
  125443. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  125444. /**
  125445. * Uploads KTX content to a Babylon Texture.
  125446. * It is assumed that the texture has already been created & is currently bound
  125447. * @hidden
  125448. */
  125449. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  125450. private _upload2DCompressedLevels;
  125451. /**
  125452. * Checks if the given data starts with a KTX file identifier.
  125453. * @param data the data to check
  125454. * @returns true if the data is a KTX file or false otherwise
  125455. */
  125456. static IsValid(data: ArrayBufferView): boolean;
  125457. }
  125458. }
  125459. declare module BABYLON {
  125460. /**
  125461. * Class for loading KTX2 files
  125462. * !!! Experimental Extension Subject to Changes !!!
  125463. * @hidden
  125464. */
  125465. export class KhronosTextureContainer2 {
  125466. private static _ModulePromise;
  125467. private static _TranscodeFormat;
  125468. constructor(engine: ThinEngine);
  125469. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  125470. private _determineTranscodeFormat;
  125471. /**
  125472. * Checks if the given data starts with a KTX2 file identifier.
  125473. * @param data the data to check
  125474. * @returns true if the data is a KTX2 file or false otherwise
  125475. */
  125476. static IsValid(data: ArrayBufferView): boolean;
  125477. }
  125478. }
  125479. declare module BABYLON {
  125480. /**
  125481. * Implementation of the KTX Texture Loader.
  125482. * @hidden
  125483. */
  125484. export class _KTXTextureLoader implements IInternalTextureLoader {
  125485. /**
  125486. * Defines wether the loader supports cascade loading the different faces.
  125487. */
  125488. readonly supportCascades: boolean;
  125489. /**
  125490. * This returns if the loader support the current file information.
  125491. * @param extension defines the file extension of the file being loaded
  125492. * @returns true if the loader can load the specified file
  125493. */
  125494. canLoad(extension: string): boolean;
  125495. /**
  125496. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125497. * @param data contains the texture data
  125498. * @param texture defines the BabylonJS internal texture
  125499. * @param createPolynomials will be true if polynomials have been requested
  125500. * @param onLoad defines the callback to trigger once the texture is ready
  125501. * @param onError defines the callback to trigger in case of error
  125502. */
  125503. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125504. /**
  125505. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125506. * @param data contains the texture data
  125507. * @param texture defines the BabylonJS internal texture
  125508. * @param callback defines the method to call once ready to upload
  125509. */
  125510. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  125511. }
  125512. }
  125513. declare module BABYLON {
  125514. /** @hidden */
  125515. export var _forceSceneHelpersToBundle: boolean;
  125516. interface Scene {
  125517. /**
  125518. * Creates a default light for the scene.
  125519. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  125520. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  125521. */
  125522. createDefaultLight(replace?: boolean): void;
  125523. /**
  125524. * Creates a default camera for the scene.
  125525. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  125526. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125527. * @param replace has default false, when true replaces the active camera in the scene
  125528. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  125529. */
  125530. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125531. /**
  125532. * Creates a default camera and a default light.
  125533. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  125534. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125535. * @param replace has the default false, when true replaces the active camera/light in the scene
  125536. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  125537. */
  125538. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125539. /**
  125540. * Creates a new sky box
  125541. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  125542. * @param environmentTexture defines the texture to use as environment texture
  125543. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  125544. * @param scale defines the overall scale of the skybox
  125545. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  125546. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  125547. * @returns a new mesh holding the sky box
  125548. */
  125549. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  125550. /**
  125551. * Creates a new environment
  125552. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  125553. * @param options defines the options you can use to configure the environment
  125554. * @returns the new EnvironmentHelper
  125555. */
  125556. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  125557. /**
  125558. * Creates a new VREXperienceHelper
  125559. * @see http://doc.babylonjs.com/how_to/webvr_helper
  125560. * @param webVROptions defines the options used to create the new VREXperienceHelper
  125561. * @returns a new VREXperienceHelper
  125562. */
  125563. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  125564. /**
  125565. * Creates a new WebXRDefaultExperience
  125566. * @see http://doc.babylonjs.com/how_to/webxr
  125567. * @param options experience options
  125568. * @returns a promise for a new WebXRDefaultExperience
  125569. */
  125570. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125571. }
  125572. }
  125573. declare module BABYLON {
  125574. /**
  125575. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  125576. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  125577. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  125578. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125579. */
  125580. export class VideoDome extends TransformNode {
  125581. /**
  125582. * Define the video source as a Monoscopic panoramic 360 video.
  125583. */
  125584. static readonly MODE_MONOSCOPIC: number;
  125585. /**
  125586. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125587. */
  125588. static readonly MODE_TOPBOTTOM: number;
  125589. /**
  125590. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125591. */
  125592. static readonly MODE_SIDEBYSIDE: number;
  125593. private _halfDome;
  125594. private _useDirectMapping;
  125595. /**
  125596. * The video texture being displayed on the sphere
  125597. */
  125598. protected _videoTexture: VideoTexture;
  125599. /**
  125600. * Gets the video texture being displayed on the sphere
  125601. */
  125602. get videoTexture(): VideoTexture;
  125603. /**
  125604. * The skybox material
  125605. */
  125606. protected _material: BackgroundMaterial;
  125607. /**
  125608. * The surface used for the skybox
  125609. */
  125610. protected _mesh: Mesh;
  125611. /**
  125612. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  125613. */
  125614. private _halfDomeMask;
  125615. /**
  125616. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125617. * Also see the options.resolution property.
  125618. */
  125619. get fovMultiplier(): number;
  125620. set fovMultiplier(value: number);
  125621. private _videoMode;
  125622. /**
  125623. * Gets or set the current video mode for the video. It can be:
  125624. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  125625. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125626. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125627. */
  125628. get videoMode(): number;
  125629. set videoMode(value: number);
  125630. /**
  125631. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  125632. *
  125633. */
  125634. get halfDome(): boolean;
  125635. /**
  125636. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  125637. */
  125638. set halfDome(enabled: boolean);
  125639. /**
  125640. * Oberserver used in Stereoscopic VR Mode.
  125641. */
  125642. private _onBeforeCameraRenderObserver;
  125643. /**
  125644. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  125645. * @param name Element's name, child elements will append suffixes for their own names.
  125646. * @param urlsOrVideo defines the url(s) or the video element to use
  125647. * @param options An object containing optional or exposed sub element properties
  125648. */
  125649. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  125650. resolution?: number;
  125651. clickToPlay?: boolean;
  125652. autoPlay?: boolean;
  125653. loop?: boolean;
  125654. size?: number;
  125655. poster?: string;
  125656. faceForward?: boolean;
  125657. useDirectMapping?: boolean;
  125658. halfDomeMode?: boolean;
  125659. }, scene: Scene);
  125660. private _changeVideoMode;
  125661. /**
  125662. * Releases resources associated with this node.
  125663. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125664. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125665. */
  125666. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125667. }
  125668. }
  125669. declare module BABYLON {
  125670. /**
  125671. * This class can be used to get instrumentation data from a Babylon engine
  125672. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125673. */
  125674. export class EngineInstrumentation implements IDisposable {
  125675. /**
  125676. * Define the instrumented engine.
  125677. */
  125678. engine: Engine;
  125679. private _captureGPUFrameTime;
  125680. private _gpuFrameTimeToken;
  125681. private _gpuFrameTime;
  125682. private _captureShaderCompilationTime;
  125683. private _shaderCompilationTime;
  125684. private _onBeginFrameObserver;
  125685. private _onEndFrameObserver;
  125686. private _onBeforeShaderCompilationObserver;
  125687. private _onAfterShaderCompilationObserver;
  125688. /**
  125689. * Gets the perf counter used for GPU frame time
  125690. */
  125691. get gpuFrameTimeCounter(): PerfCounter;
  125692. /**
  125693. * Gets the GPU frame time capture status
  125694. */
  125695. get captureGPUFrameTime(): boolean;
  125696. /**
  125697. * Enable or disable the GPU frame time capture
  125698. */
  125699. set captureGPUFrameTime(value: boolean);
  125700. /**
  125701. * Gets the perf counter used for shader compilation time
  125702. */
  125703. get shaderCompilationTimeCounter(): PerfCounter;
  125704. /**
  125705. * Gets the shader compilation time capture status
  125706. */
  125707. get captureShaderCompilationTime(): boolean;
  125708. /**
  125709. * Enable or disable the shader compilation time capture
  125710. */
  125711. set captureShaderCompilationTime(value: boolean);
  125712. /**
  125713. * Instantiates a new engine instrumentation.
  125714. * This class can be used to get instrumentation data from a Babylon engine
  125715. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125716. * @param engine Defines the engine to instrument
  125717. */
  125718. constructor(
  125719. /**
  125720. * Define the instrumented engine.
  125721. */
  125722. engine: Engine);
  125723. /**
  125724. * Dispose and release associated resources.
  125725. */
  125726. dispose(): void;
  125727. }
  125728. }
  125729. declare module BABYLON {
  125730. /**
  125731. * This class can be used to get instrumentation data from a Babylon engine
  125732. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125733. */
  125734. export class SceneInstrumentation implements IDisposable {
  125735. /**
  125736. * Defines the scene to instrument
  125737. */
  125738. scene: Scene;
  125739. private _captureActiveMeshesEvaluationTime;
  125740. private _activeMeshesEvaluationTime;
  125741. private _captureRenderTargetsRenderTime;
  125742. private _renderTargetsRenderTime;
  125743. private _captureFrameTime;
  125744. private _frameTime;
  125745. private _captureRenderTime;
  125746. private _renderTime;
  125747. private _captureInterFrameTime;
  125748. private _interFrameTime;
  125749. private _captureParticlesRenderTime;
  125750. private _particlesRenderTime;
  125751. private _captureSpritesRenderTime;
  125752. private _spritesRenderTime;
  125753. private _capturePhysicsTime;
  125754. private _physicsTime;
  125755. private _captureAnimationsTime;
  125756. private _animationsTime;
  125757. private _captureCameraRenderTime;
  125758. private _cameraRenderTime;
  125759. private _onBeforeActiveMeshesEvaluationObserver;
  125760. private _onAfterActiveMeshesEvaluationObserver;
  125761. private _onBeforeRenderTargetsRenderObserver;
  125762. private _onAfterRenderTargetsRenderObserver;
  125763. private _onAfterRenderObserver;
  125764. private _onBeforeDrawPhaseObserver;
  125765. private _onAfterDrawPhaseObserver;
  125766. private _onBeforeAnimationsObserver;
  125767. private _onBeforeParticlesRenderingObserver;
  125768. private _onAfterParticlesRenderingObserver;
  125769. private _onBeforeSpritesRenderingObserver;
  125770. private _onAfterSpritesRenderingObserver;
  125771. private _onBeforePhysicsObserver;
  125772. private _onAfterPhysicsObserver;
  125773. private _onAfterAnimationsObserver;
  125774. private _onBeforeCameraRenderObserver;
  125775. private _onAfterCameraRenderObserver;
  125776. /**
  125777. * Gets the perf counter used for active meshes evaluation time
  125778. */
  125779. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  125780. /**
  125781. * Gets the active meshes evaluation time capture status
  125782. */
  125783. get captureActiveMeshesEvaluationTime(): boolean;
  125784. /**
  125785. * Enable or disable the active meshes evaluation time capture
  125786. */
  125787. set captureActiveMeshesEvaluationTime(value: boolean);
  125788. /**
  125789. * Gets the perf counter used for render targets render time
  125790. */
  125791. get renderTargetsRenderTimeCounter(): PerfCounter;
  125792. /**
  125793. * Gets the render targets render time capture status
  125794. */
  125795. get captureRenderTargetsRenderTime(): boolean;
  125796. /**
  125797. * Enable or disable the render targets render time capture
  125798. */
  125799. set captureRenderTargetsRenderTime(value: boolean);
  125800. /**
  125801. * Gets the perf counter used for particles render time
  125802. */
  125803. get particlesRenderTimeCounter(): PerfCounter;
  125804. /**
  125805. * Gets the particles render time capture status
  125806. */
  125807. get captureParticlesRenderTime(): boolean;
  125808. /**
  125809. * Enable or disable the particles render time capture
  125810. */
  125811. set captureParticlesRenderTime(value: boolean);
  125812. /**
  125813. * Gets the perf counter used for sprites render time
  125814. */
  125815. get spritesRenderTimeCounter(): PerfCounter;
  125816. /**
  125817. * Gets the sprites render time capture status
  125818. */
  125819. get captureSpritesRenderTime(): boolean;
  125820. /**
  125821. * Enable or disable the sprites render time capture
  125822. */
  125823. set captureSpritesRenderTime(value: boolean);
  125824. /**
  125825. * Gets the perf counter used for physics time
  125826. */
  125827. get physicsTimeCounter(): PerfCounter;
  125828. /**
  125829. * Gets the physics time capture status
  125830. */
  125831. get capturePhysicsTime(): boolean;
  125832. /**
  125833. * Enable or disable the physics time capture
  125834. */
  125835. set capturePhysicsTime(value: boolean);
  125836. /**
  125837. * Gets the perf counter used for animations time
  125838. */
  125839. get animationsTimeCounter(): PerfCounter;
  125840. /**
  125841. * Gets the animations time capture status
  125842. */
  125843. get captureAnimationsTime(): boolean;
  125844. /**
  125845. * Enable or disable the animations time capture
  125846. */
  125847. set captureAnimationsTime(value: boolean);
  125848. /**
  125849. * Gets the perf counter used for frame time capture
  125850. */
  125851. get frameTimeCounter(): PerfCounter;
  125852. /**
  125853. * Gets the frame time capture status
  125854. */
  125855. get captureFrameTime(): boolean;
  125856. /**
  125857. * Enable or disable the frame time capture
  125858. */
  125859. set captureFrameTime(value: boolean);
  125860. /**
  125861. * Gets the perf counter used for inter-frames time capture
  125862. */
  125863. get interFrameTimeCounter(): PerfCounter;
  125864. /**
  125865. * Gets the inter-frames time capture status
  125866. */
  125867. get captureInterFrameTime(): boolean;
  125868. /**
  125869. * Enable or disable the inter-frames time capture
  125870. */
  125871. set captureInterFrameTime(value: boolean);
  125872. /**
  125873. * Gets the perf counter used for render time capture
  125874. */
  125875. get renderTimeCounter(): PerfCounter;
  125876. /**
  125877. * Gets the render time capture status
  125878. */
  125879. get captureRenderTime(): boolean;
  125880. /**
  125881. * Enable or disable the render time capture
  125882. */
  125883. set captureRenderTime(value: boolean);
  125884. /**
  125885. * Gets the perf counter used for camera render time capture
  125886. */
  125887. get cameraRenderTimeCounter(): PerfCounter;
  125888. /**
  125889. * Gets the camera render time capture status
  125890. */
  125891. get captureCameraRenderTime(): boolean;
  125892. /**
  125893. * Enable or disable the camera render time capture
  125894. */
  125895. set captureCameraRenderTime(value: boolean);
  125896. /**
  125897. * Gets the perf counter used for draw calls
  125898. */
  125899. get drawCallsCounter(): PerfCounter;
  125900. /**
  125901. * Instantiates a new scene instrumentation.
  125902. * This class can be used to get instrumentation data from a Babylon engine
  125903. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125904. * @param scene Defines the scene to instrument
  125905. */
  125906. constructor(
  125907. /**
  125908. * Defines the scene to instrument
  125909. */
  125910. scene: Scene);
  125911. /**
  125912. * Dispose and release associated resources.
  125913. */
  125914. dispose(): void;
  125915. }
  125916. }
  125917. declare module BABYLON {
  125918. /** @hidden */
  125919. export var glowMapGenerationPixelShader: {
  125920. name: string;
  125921. shader: string;
  125922. };
  125923. }
  125924. declare module BABYLON {
  125925. /** @hidden */
  125926. export var glowMapGenerationVertexShader: {
  125927. name: string;
  125928. shader: string;
  125929. };
  125930. }
  125931. declare module BABYLON {
  125932. /**
  125933. * Effect layer options. This helps customizing the behaviour
  125934. * of the effect layer.
  125935. */
  125936. export interface IEffectLayerOptions {
  125937. /**
  125938. * Multiplication factor apply to the canvas size to compute the render target size
  125939. * used to generated the objects (the smaller the faster).
  125940. */
  125941. mainTextureRatio: number;
  125942. /**
  125943. * Enforces a fixed size texture to ensure effect stability across devices.
  125944. */
  125945. mainTextureFixedSize?: number;
  125946. /**
  125947. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  125948. */
  125949. alphaBlendingMode: number;
  125950. /**
  125951. * The camera attached to the layer.
  125952. */
  125953. camera: Nullable<Camera>;
  125954. /**
  125955. * The rendering group to draw the layer in.
  125956. */
  125957. renderingGroupId: number;
  125958. }
  125959. /**
  125960. * The effect layer Helps adding post process effect blended with the main pass.
  125961. *
  125962. * This can be for instance use to generate glow or higlight effects on the scene.
  125963. *
  125964. * The effect layer class can not be used directly and is intented to inherited from to be
  125965. * customized per effects.
  125966. */
  125967. export abstract class EffectLayer {
  125968. private _vertexBuffers;
  125969. private _indexBuffer;
  125970. private _cachedDefines;
  125971. private _effectLayerMapGenerationEffect;
  125972. private _effectLayerOptions;
  125973. private _mergeEffect;
  125974. protected _scene: Scene;
  125975. protected _engine: Engine;
  125976. protected _maxSize: number;
  125977. protected _mainTextureDesiredSize: ISize;
  125978. protected _mainTexture: RenderTargetTexture;
  125979. protected _shouldRender: boolean;
  125980. protected _postProcesses: PostProcess[];
  125981. protected _textures: BaseTexture[];
  125982. protected _emissiveTextureAndColor: {
  125983. texture: Nullable<BaseTexture>;
  125984. color: Color4;
  125985. };
  125986. /**
  125987. * The name of the layer
  125988. */
  125989. name: string;
  125990. /**
  125991. * The clear color of the texture used to generate the glow map.
  125992. */
  125993. neutralColor: Color4;
  125994. /**
  125995. * Specifies whether the highlight layer is enabled or not.
  125996. */
  125997. isEnabled: boolean;
  125998. /**
  125999. * Gets the camera attached to the layer.
  126000. */
  126001. get camera(): Nullable<Camera>;
  126002. /**
  126003. * Gets the rendering group id the layer should render in.
  126004. */
  126005. get renderingGroupId(): number;
  126006. set renderingGroupId(renderingGroupId: number);
  126007. /**
  126008. * An event triggered when the effect layer has been disposed.
  126009. */
  126010. onDisposeObservable: Observable<EffectLayer>;
  126011. /**
  126012. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  126013. */
  126014. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  126015. /**
  126016. * An event triggered when the generated texture is being merged in the scene.
  126017. */
  126018. onBeforeComposeObservable: Observable<EffectLayer>;
  126019. /**
  126020. * An event triggered when the mesh is rendered into the effect render target.
  126021. */
  126022. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  126023. /**
  126024. * An event triggered after the mesh has been rendered into the effect render target.
  126025. */
  126026. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  126027. /**
  126028. * An event triggered when the generated texture has been merged in the scene.
  126029. */
  126030. onAfterComposeObservable: Observable<EffectLayer>;
  126031. /**
  126032. * An event triggered when the efffect layer changes its size.
  126033. */
  126034. onSizeChangedObservable: Observable<EffectLayer>;
  126035. /** @hidden */
  126036. static _SceneComponentInitialization: (scene: Scene) => void;
  126037. /**
  126038. * Instantiates a new effect Layer and references it in the scene.
  126039. * @param name The name of the layer
  126040. * @param scene The scene to use the layer in
  126041. */
  126042. constructor(
  126043. /** The Friendly of the effect in the scene */
  126044. name: string, scene: Scene);
  126045. /**
  126046. * Get the effect name of the layer.
  126047. * @return The effect name
  126048. */
  126049. abstract getEffectName(): string;
  126050. /**
  126051. * Checks for the readiness of the element composing the layer.
  126052. * @param subMesh the mesh to check for
  126053. * @param useInstances specify whether or not to use instances to render the mesh
  126054. * @return true if ready otherwise, false
  126055. */
  126056. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126057. /**
  126058. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126059. * @returns true if the effect requires stencil during the main canvas render pass.
  126060. */
  126061. abstract needStencil(): boolean;
  126062. /**
  126063. * Create the merge effect. This is the shader use to blit the information back
  126064. * to the main canvas at the end of the scene rendering.
  126065. * @returns The effect containing the shader used to merge the effect on the main canvas
  126066. */
  126067. protected abstract _createMergeEffect(): Effect;
  126068. /**
  126069. * Creates the render target textures and post processes used in the effect layer.
  126070. */
  126071. protected abstract _createTextureAndPostProcesses(): void;
  126072. /**
  126073. * Implementation specific of rendering the generating effect on the main canvas.
  126074. * @param effect The effect used to render through
  126075. */
  126076. protected abstract _internalRender(effect: Effect): void;
  126077. /**
  126078. * Sets the required values for both the emissive texture and and the main color.
  126079. */
  126080. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126081. /**
  126082. * Free any resources and references associated to a mesh.
  126083. * Internal use
  126084. * @param mesh The mesh to free.
  126085. */
  126086. abstract _disposeMesh(mesh: Mesh): void;
  126087. /**
  126088. * Serializes this layer (Glow or Highlight for example)
  126089. * @returns a serialized layer object
  126090. */
  126091. abstract serialize?(): any;
  126092. /**
  126093. * Initializes the effect layer with the required options.
  126094. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  126095. */
  126096. protected _init(options: Partial<IEffectLayerOptions>): void;
  126097. /**
  126098. * Generates the index buffer of the full screen quad blending to the main canvas.
  126099. */
  126100. private _generateIndexBuffer;
  126101. /**
  126102. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  126103. */
  126104. private _generateVertexBuffer;
  126105. /**
  126106. * Sets the main texture desired size which is the closest power of two
  126107. * of the engine canvas size.
  126108. */
  126109. private _setMainTextureSize;
  126110. /**
  126111. * Creates the main texture for the effect layer.
  126112. */
  126113. protected _createMainTexture(): void;
  126114. /**
  126115. * Adds specific effects defines.
  126116. * @param defines The defines to add specifics to.
  126117. */
  126118. protected _addCustomEffectDefines(defines: string[]): void;
  126119. /**
  126120. * Checks for the readiness of the element composing the layer.
  126121. * @param subMesh the mesh to check for
  126122. * @param useInstances specify whether or not to use instances to render the mesh
  126123. * @param emissiveTexture the associated emissive texture used to generate the glow
  126124. * @return true if ready otherwise, false
  126125. */
  126126. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  126127. /**
  126128. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  126129. */
  126130. render(): void;
  126131. /**
  126132. * Determine if a given mesh will be used in the current effect.
  126133. * @param mesh mesh to test
  126134. * @returns true if the mesh will be used
  126135. */
  126136. hasMesh(mesh: AbstractMesh): boolean;
  126137. /**
  126138. * Returns true if the layer contains information to display, otherwise false.
  126139. * @returns true if the glow layer should be rendered
  126140. */
  126141. shouldRender(): boolean;
  126142. /**
  126143. * Returns true if the mesh should render, otherwise false.
  126144. * @param mesh The mesh to render
  126145. * @returns true if it should render otherwise false
  126146. */
  126147. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  126148. /**
  126149. * Returns true if the mesh can be rendered, otherwise false.
  126150. * @param mesh The mesh to render
  126151. * @param material The material used on the mesh
  126152. * @returns true if it can be rendered otherwise false
  126153. */
  126154. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126155. /**
  126156. * Returns true if the mesh should render, otherwise false.
  126157. * @param mesh The mesh to render
  126158. * @returns true if it should render otherwise false
  126159. */
  126160. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  126161. /**
  126162. * Renders the submesh passed in parameter to the generation map.
  126163. */
  126164. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  126165. /**
  126166. * Defines whether the current material of the mesh should be use to render the effect.
  126167. * @param mesh defines the current mesh to render
  126168. */
  126169. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126170. /**
  126171. * Rebuild the required buffers.
  126172. * @hidden Internal use only.
  126173. */
  126174. _rebuild(): void;
  126175. /**
  126176. * Dispose only the render target textures and post process.
  126177. */
  126178. private _disposeTextureAndPostProcesses;
  126179. /**
  126180. * Dispose the highlight layer and free resources.
  126181. */
  126182. dispose(): void;
  126183. /**
  126184. * Gets the class name of the effect layer
  126185. * @returns the string with the class name of the effect layer
  126186. */
  126187. getClassName(): string;
  126188. /**
  126189. * Creates an effect layer from parsed effect layer data
  126190. * @param parsedEffectLayer defines effect layer data
  126191. * @param scene defines the current scene
  126192. * @param rootUrl defines the root URL containing the effect layer information
  126193. * @returns a parsed effect Layer
  126194. */
  126195. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  126196. }
  126197. }
  126198. declare module BABYLON {
  126199. interface AbstractScene {
  126200. /**
  126201. * The list of effect layers (highlights/glow) added to the scene
  126202. * @see http://doc.babylonjs.com/how_to/highlight_layer
  126203. * @see http://doc.babylonjs.com/how_to/glow_layer
  126204. */
  126205. effectLayers: Array<EffectLayer>;
  126206. /**
  126207. * Removes the given effect layer from this scene.
  126208. * @param toRemove defines the effect layer to remove
  126209. * @returns the index of the removed effect layer
  126210. */
  126211. removeEffectLayer(toRemove: EffectLayer): number;
  126212. /**
  126213. * Adds the given effect layer to this scene
  126214. * @param newEffectLayer defines the effect layer to add
  126215. */
  126216. addEffectLayer(newEffectLayer: EffectLayer): void;
  126217. }
  126218. /**
  126219. * Defines the layer scene component responsible to manage any effect layers
  126220. * in a given scene.
  126221. */
  126222. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  126223. /**
  126224. * The component name helpfull to identify the component in the list of scene components.
  126225. */
  126226. readonly name: string;
  126227. /**
  126228. * The scene the component belongs to.
  126229. */
  126230. scene: Scene;
  126231. private _engine;
  126232. private _renderEffects;
  126233. private _needStencil;
  126234. private _previousStencilState;
  126235. /**
  126236. * Creates a new instance of the component for the given scene
  126237. * @param scene Defines the scene to register the component in
  126238. */
  126239. constructor(scene: Scene);
  126240. /**
  126241. * Registers the component in a given scene
  126242. */
  126243. register(): void;
  126244. /**
  126245. * Rebuilds the elements related to this component in case of
  126246. * context lost for instance.
  126247. */
  126248. rebuild(): void;
  126249. /**
  126250. * Serializes the component data to the specified json object
  126251. * @param serializationObject The object to serialize to
  126252. */
  126253. serialize(serializationObject: any): void;
  126254. /**
  126255. * Adds all the elements from the container to the scene
  126256. * @param container the container holding the elements
  126257. */
  126258. addFromContainer(container: AbstractScene): void;
  126259. /**
  126260. * Removes all the elements in the container from the scene
  126261. * @param container contains the elements to remove
  126262. * @param dispose if the removed element should be disposed (default: false)
  126263. */
  126264. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126265. /**
  126266. * Disposes the component and the associated ressources.
  126267. */
  126268. dispose(): void;
  126269. private _isReadyForMesh;
  126270. private _renderMainTexture;
  126271. private _setStencil;
  126272. private _setStencilBack;
  126273. private _draw;
  126274. private _drawCamera;
  126275. private _drawRenderingGroup;
  126276. }
  126277. }
  126278. declare module BABYLON {
  126279. /** @hidden */
  126280. export var glowMapMergePixelShader: {
  126281. name: string;
  126282. shader: string;
  126283. };
  126284. }
  126285. declare module BABYLON {
  126286. /** @hidden */
  126287. export var glowMapMergeVertexShader: {
  126288. name: string;
  126289. shader: string;
  126290. };
  126291. }
  126292. declare module BABYLON {
  126293. interface AbstractScene {
  126294. /**
  126295. * Return a the first highlight layer of the scene with a given name.
  126296. * @param name The name of the highlight layer to look for.
  126297. * @return The highlight layer if found otherwise null.
  126298. */
  126299. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  126300. }
  126301. /**
  126302. * Glow layer options. This helps customizing the behaviour
  126303. * of the glow layer.
  126304. */
  126305. export interface IGlowLayerOptions {
  126306. /**
  126307. * Multiplication factor apply to the canvas size to compute the render target size
  126308. * used to generated the glowing objects (the smaller the faster).
  126309. */
  126310. mainTextureRatio: number;
  126311. /**
  126312. * Enforces a fixed size texture to ensure resize independant blur.
  126313. */
  126314. mainTextureFixedSize?: number;
  126315. /**
  126316. * How big is the kernel of the blur texture.
  126317. */
  126318. blurKernelSize: number;
  126319. /**
  126320. * The camera attached to the layer.
  126321. */
  126322. camera: Nullable<Camera>;
  126323. /**
  126324. * Enable MSAA by chosing the number of samples.
  126325. */
  126326. mainTextureSamples?: number;
  126327. /**
  126328. * The rendering group to draw the layer in.
  126329. */
  126330. renderingGroupId: number;
  126331. }
  126332. /**
  126333. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  126334. *
  126335. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  126336. *
  126337. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  126338. */
  126339. export class GlowLayer extends EffectLayer {
  126340. /**
  126341. * Effect Name of the layer.
  126342. */
  126343. static readonly EffectName: string;
  126344. /**
  126345. * The default blur kernel size used for the glow.
  126346. */
  126347. static DefaultBlurKernelSize: number;
  126348. /**
  126349. * The default texture size ratio used for the glow.
  126350. */
  126351. static DefaultTextureRatio: number;
  126352. /**
  126353. * Sets the kernel size of the blur.
  126354. */
  126355. set blurKernelSize(value: number);
  126356. /**
  126357. * Gets the kernel size of the blur.
  126358. */
  126359. get blurKernelSize(): number;
  126360. /**
  126361. * Sets the glow intensity.
  126362. */
  126363. set intensity(value: number);
  126364. /**
  126365. * Gets the glow intensity.
  126366. */
  126367. get intensity(): number;
  126368. private _options;
  126369. private _intensity;
  126370. private _horizontalBlurPostprocess1;
  126371. private _verticalBlurPostprocess1;
  126372. private _horizontalBlurPostprocess2;
  126373. private _verticalBlurPostprocess2;
  126374. private _blurTexture1;
  126375. private _blurTexture2;
  126376. private _postProcesses1;
  126377. private _postProcesses2;
  126378. private _includedOnlyMeshes;
  126379. private _excludedMeshes;
  126380. private _meshesUsingTheirOwnMaterials;
  126381. /**
  126382. * Callback used to let the user override the color selection on a per mesh basis
  126383. */
  126384. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  126385. /**
  126386. * Callback used to let the user override the texture selection on a per mesh basis
  126387. */
  126388. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  126389. /**
  126390. * Instantiates a new glow Layer and references it to the scene.
  126391. * @param name The name of the layer
  126392. * @param scene The scene to use the layer in
  126393. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  126394. */
  126395. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  126396. /**
  126397. * Get the effect name of the layer.
  126398. * @return The effect name
  126399. */
  126400. getEffectName(): string;
  126401. /**
  126402. * Create the merge effect. This is the shader use to blit the information back
  126403. * to the main canvas at the end of the scene rendering.
  126404. */
  126405. protected _createMergeEffect(): Effect;
  126406. /**
  126407. * Creates the render target textures and post processes used in the glow layer.
  126408. */
  126409. protected _createTextureAndPostProcesses(): void;
  126410. /**
  126411. * Checks for the readiness of the element composing the layer.
  126412. * @param subMesh the mesh to check for
  126413. * @param useInstances specify wether or not to use instances to render the mesh
  126414. * @param emissiveTexture the associated emissive texture used to generate the glow
  126415. * @return true if ready otherwise, false
  126416. */
  126417. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126418. /**
  126419. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126420. */
  126421. needStencil(): boolean;
  126422. /**
  126423. * Returns true if the mesh can be rendered, otherwise false.
  126424. * @param mesh The mesh to render
  126425. * @param material The material used on the mesh
  126426. * @returns true if it can be rendered otherwise false
  126427. */
  126428. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126429. /**
  126430. * Implementation specific of rendering the generating effect on the main canvas.
  126431. * @param effect The effect used to render through
  126432. */
  126433. protected _internalRender(effect: Effect): void;
  126434. /**
  126435. * Sets the required values for both the emissive texture and and the main color.
  126436. */
  126437. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126438. /**
  126439. * Returns true if the mesh should render, otherwise false.
  126440. * @param mesh The mesh to render
  126441. * @returns true if it should render otherwise false
  126442. */
  126443. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126444. /**
  126445. * Adds specific effects defines.
  126446. * @param defines The defines to add specifics to.
  126447. */
  126448. protected _addCustomEffectDefines(defines: string[]): void;
  126449. /**
  126450. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  126451. * @param mesh The mesh to exclude from the glow layer
  126452. */
  126453. addExcludedMesh(mesh: Mesh): void;
  126454. /**
  126455. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  126456. * @param mesh The mesh to remove
  126457. */
  126458. removeExcludedMesh(mesh: Mesh): void;
  126459. /**
  126460. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  126461. * @param mesh The mesh to include in the glow layer
  126462. */
  126463. addIncludedOnlyMesh(mesh: Mesh): void;
  126464. /**
  126465. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  126466. * @param mesh The mesh to remove
  126467. */
  126468. removeIncludedOnlyMesh(mesh: Mesh): void;
  126469. /**
  126470. * Determine if a given mesh will be used in the glow layer
  126471. * @param mesh The mesh to test
  126472. * @returns true if the mesh will be highlighted by the current glow layer
  126473. */
  126474. hasMesh(mesh: AbstractMesh): boolean;
  126475. /**
  126476. * Defines whether the current material of the mesh should be use to render the effect.
  126477. * @param mesh defines the current mesh to render
  126478. */
  126479. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126480. /**
  126481. * Add a mesh to be rendered through its own material and not with emissive only.
  126482. * @param mesh The mesh for which we need to use its material
  126483. */
  126484. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  126485. /**
  126486. * Remove a mesh from being rendered through its own material and not with emissive only.
  126487. * @param mesh The mesh for which we need to not use its material
  126488. */
  126489. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  126490. /**
  126491. * Free any resources and references associated to a mesh.
  126492. * Internal use
  126493. * @param mesh The mesh to free.
  126494. * @hidden
  126495. */
  126496. _disposeMesh(mesh: Mesh): void;
  126497. /**
  126498. * Gets the class name of the effect layer
  126499. * @returns the string with the class name of the effect layer
  126500. */
  126501. getClassName(): string;
  126502. /**
  126503. * Serializes this glow layer
  126504. * @returns a serialized glow layer object
  126505. */
  126506. serialize(): any;
  126507. /**
  126508. * Creates a Glow Layer from parsed glow layer data
  126509. * @param parsedGlowLayer defines glow layer data
  126510. * @param scene defines the current scene
  126511. * @param rootUrl defines the root URL containing the glow layer information
  126512. * @returns a parsed Glow Layer
  126513. */
  126514. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  126515. }
  126516. }
  126517. declare module BABYLON {
  126518. /** @hidden */
  126519. export var glowBlurPostProcessPixelShader: {
  126520. name: string;
  126521. shader: string;
  126522. };
  126523. }
  126524. declare module BABYLON {
  126525. interface AbstractScene {
  126526. /**
  126527. * Return a the first highlight layer of the scene with a given name.
  126528. * @param name The name of the highlight layer to look for.
  126529. * @return The highlight layer if found otherwise null.
  126530. */
  126531. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  126532. }
  126533. /**
  126534. * Highlight layer options. This helps customizing the behaviour
  126535. * of the highlight layer.
  126536. */
  126537. export interface IHighlightLayerOptions {
  126538. /**
  126539. * Multiplication factor apply to the canvas size to compute the render target size
  126540. * used to generated the glowing objects (the smaller the faster).
  126541. */
  126542. mainTextureRatio: number;
  126543. /**
  126544. * Enforces a fixed size texture to ensure resize independant blur.
  126545. */
  126546. mainTextureFixedSize?: number;
  126547. /**
  126548. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  126549. * of the picture to blur (the smaller the faster).
  126550. */
  126551. blurTextureSizeRatio: number;
  126552. /**
  126553. * How big in texel of the blur texture is the vertical blur.
  126554. */
  126555. blurVerticalSize: number;
  126556. /**
  126557. * How big in texel of the blur texture is the horizontal blur.
  126558. */
  126559. blurHorizontalSize: number;
  126560. /**
  126561. * Alpha blending mode used to apply the blur. Default is combine.
  126562. */
  126563. alphaBlendingMode: number;
  126564. /**
  126565. * The camera attached to the layer.
  126566. */
  126567. camera: Nullable<Camera>;
  126568. /**
  126569. * Should we display highlight as a solid stroke?
  126570. */
  126571. isStroke?: boolean;
  126572. /**
  126573. * The rendering group to draw the layer in.
  126574. */
  126575. renderingGroupId: number;
  126576. }
  126577. /**
  126578. * The highlight layer Helps adding a glow effect around a mesh.
  126579. *
  126580. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  126581. * glowy meshes to your scene.
  126582. *
  126583. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  126584. */
  126585. export class HighlightLayer extends EffectLayer {
  126586. name: string;
  126587. /**
  126588. * Effect Name of the highlight layer.
  126589. */
  126590. static readonly EffectName: string;
  126591. /**
  126592. * The neutral color used during the preparation of the glow effect.
  126593. * This is black by default as the blend operation is a blend operation.
  126594. */
  126595. static NeutralColor: Color4;
  126596. /**
  126597. * Stencil value used for glowing meshes.
  126598. */
  126599. static GlowingMeshStencilReference: number;
  126600. /**
  126601. * Stencil value used for the other meshes in the scene.
  126602. */
  126603. static NormalMeshStencilReference: number;
  126604. /**
  126605. * Specifies whether or not the inner glow is ACTIVE in the layer.
  126606. */
  126607. innerGlow: boolean;
  126608. /**
  126609. * Specifies whether or not the outer glow is ACTIVE in the layer.
  126610. */
  126611. outerGlow: boolean;
  126612. /**
  126613. * Specifies the horizontal size of the blur.
  126614. */
  126615. set blurHorizontalSize(value: number);
  126616. /**
  126617. * Specifies the vertical size of the blur.
  126618. */
  126619. set blurVerticalSize(value: number);
  126620. /**
  126621. * Gets the horizontal size of the blur.
  126622. */
  126623. get blurHorizontalSize(): number;
  126624. /**
  126625. * Gets the vertical size of the blur.
  126626. */
  126627. get blurVerticalSize(): number;
  126628. /**
  126629. * An event triggered when the highlight layer is being blurred.
  126630. */
  126631. onBeforeBlurObservable: Observable<HighlightLayer>;
  126632. /**
  126633. * An event triggered when the highlight layer has been blurred.
  126634. */
  126635. onAfterBlurObservable: Observable<HighlightLayer>;
  126636. private _instanceGlowingMeshStencilReference;
  126637. private _options;
  126638. private _downSamplePostprocess;
  126639. private _horizontalBlurPostprocess;
  126640. private _verticalBlurPostprocess;
  126641. private _blurTexture;
  126642. private _meshes;
  126643. private _excludedMeshes;
  126644. /**
  126645. * Instantiates a new highlight Layer and references it to the scene..
  126646. * @param name The name of the layer
  126647. * @param scene The scene to use the layer in
  126648. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  126649. */
  126650. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  126651. /**
  126652. * Get the effect name of the layer.
  126653. * @return The effect name
  126654. */
  126655. getEffectName(): string;
  126656. /**
  126657. * Create the merge effect. This is the shader use to blit the information back
  126658. * to the main canvas at the end of the scene rendering.
  126659. */
  126660. protected _createMergeEffect(): Effect;
  126661. /**
  126662. * Creates the render target textures and post processes used in the highlight layer.
  126663. */
  126664. protected _createTextureAndPostProcesses(): void;
  126665. /**
  126666. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126667. */
  126668. needStencil(): boolean;
  126669. /**
  126670. * Checks for the readiness of the element composing the layer.
  126671. * @param subMesh the mesh to check for
  126672. * @param useInstances specify wether or not to use instances to render the mesh
  126673. * @param emissiveTexture the associated emissive texture used to generate the glow
  126674. * @return true if ready otherwise, false
  126675. */
  126676. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126677. /**
  126678. * Implementation specific of rendering the generating effect on the main canvas.
  126679. * @param effect The effect used to render through
  126680. */
  126681. protected _internalRender(effect: Effect): void;
  126682. /**
  126683. * Returns true if the layer contains information to display, otherwise false.
  126684. */
  126685. shouldRender(): boolean;
  126686. /**
  126687. * Returns true if the mesh should render, otherwise false.
  126688. * @param mesh The mesh to render
  126689. * @returns true if it should render otherwise false
  126690. */
  126691. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126692. /**
  126693. * Sets the required values for both the emissive texture and and the main color.
  126694. */
  126695. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126696. /**
  126697. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126698. * @param mesh The mesh to exclude from the highlight layer
  126699. */
  126700. addExcludedMesh(mesh: Mesh): void;
  126701. /**
  126702. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126703. * @param mesh The mesh to highlight
  126704. */
  126705. removeExcludedMesh(mesh: Mesh): void;
  126706. /**
  126707. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126708. * @param mesh mesh to test
  126709. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126710. */
  126711. hasMesh(mesh: AbstractMesh): boolean;
  126712. /**
  126713. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126714. * @param mesh The mesh to highlight
  126715. * @param color The color of the highlight
  126716. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126717. */
  126718. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126719. /**
  126720. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126721. * @param mesh The mesh to highlight
  126722. */
  126723. removeMesh(mesh: Mesh): void;
  126724. /**
  126725. * Remove all the meshes currently referenced in the highlight layer
  126726. */
  126727. removeAllMeshes(): void;
  126728. /**
  126729. * Force the stencil to the normal expected value for none glowing parts
  126730. */
  126731. private _defaultStencilReference;
  126732. /**
  126733. * Free any resources and references associated to a mesh.
  126734. * Internal use
  126735. * @param mesh The mesh to free.
  126736. * @hidden
  126737. */
  126738. _disposeMesh(mesh: Mesh): void;
  126739. /**
  126740. * Dispose the highlight layer and free resources.
  126741. */
  126742. dispose(): void;
  126743. /**
  126744. * Gets the class name of the effect layer
  126745. * @returns the string with the class name of the effect layer
  126746. */
  126747. getClassName(): string;
  126748. /**
  126749. * Serializes this Highlight layer
  126750. * @returns a serialized Highlight layer object
  126751. */
  126752. serialize(): any;
  126753. /**
  126754. * Creates a Highlight layer from parsed Highlight layer data
  126755. * @param parsedHightlightLayer defines the Highlight layer data
  126756. * @param scene defines the current scene
  126757. * @param rootUrl defines the root URL containing the Highlight layer information
  126758. * @returns a parsed Highlight layer
  126759. */
  126760. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  126761. }
  126762. }
  126763. declare module BABYLON {
  126764. interface AbstractScene {
  126765. /**
  126766. * The list of layers (background and foreground) of the scene
  126767. */
  126768. layers: Array<Layer>;
  126769. }
  126770. /**
  126771. * Defines the layer scene component responsible to manage any layers
  126772. * in a given scene.
  126773. */
  126774. export class LayerSceneComponent implements ISceneComponent {
  126775. /**
  126776. * The component name helpfull to identify the component in the list of scene components.
  126777. */
  126778. readonly name: string;
  126779. /**
  126780. * The scene the component belongs to.
  126781. */
  126782. scene: Scene;
  126783. private _engine;
  126784. /**
  126785. * Creates a new instance of the component for the given scene
  126786. * @param scene Defines the scene to register the component in
  126787. */
  126788. constructor(scene: Scene);
  126789. /**
  126790. * Registers the component in a given scene
  126791. */
  126792. register(): void;
  126793. /**
  126794. * Rebuilds the elements related to this component in case of
  126795. * context lost for instance.
  126796. */
  126797. rebuild(): void;
  126798. /**
  126799. * Disposes the component and the associated ressources.
  126800. */
  126801. dispose(): void;
  126802. private _draw;
  126803. private _drawCameraPredicate;
  126804. private _drawCameraBackground;
  126805. private _drawCameraForeground;
  126806. private _drawRenderTargetPredicate;
  126807. private _drawRenderTargetBackground;
  126808. private _drawRenderTargetForeground;
  126809. /**
  126810. * Adds all the elements from the container to the scene
  126811. * @param container the container holding the elements
  126812. */
  126813. addFromContainer(container: AbstractScene): void;
  126814. /**
  126815. * Removes all the elements in the container from the scene
  126816. * @param container contains the elements to remove
  126817. * @param dispose if the removed element should be disposed (default: false)
  126818. */
  126819. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126820. }
  126821. }
  126822. declare module BABYLON {
  126823. /** @hidden */
  126824. export var layerPixelShader: {
  126825. name: string;
  126826. shader: string;
  126827. };
  126828. }
  126829. declare module BABYLON {
  126830. /** @hidden */
  126831. export var layerVertexShader: {
  126832. name: string;
  126833. shader: string;
  126834. };
  126835. }
  126836. declare module BABYLON {
  126837. /**
  126838. * This represents a full screen 2d layer.
  126839. * This can be useful to display a picture in the background of your scene for instance.
  126840. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126841. */
  126842. export class Layer {
  126843. /**
  126844. * Define the name of the layer.
  126845. */
  126846. name: string;
  126847. /**
  126848. * Define the texture the layer should display.
  126849. */
  126850. texture: Nullable<Texture>;
  126851. /**
  126852. * Is the layer in background or foreground.
  126853. */
  126854. isBackground: boolean;
  126855. /**
  126856. * Define the color of the layer (instead of texture).
  126857. */
  126858. color: Color4;
  126859. /**
  126860. * Define the scale of the layer in order to zoom in out of the texture.
  126861. */
  126862. scale: Vector2;
  126863. /**
  126864. * Define an offset for the layer in order to shift the texture.
  126865. */
  126866. offset: Vector2;
  126867. /**
  126868. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  126869. */
  126870. alphaBlendingMode: number;
  126871. /**
  126872. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  126873. * Alpha test will not mix with the background color in case of transparency.
  126874. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  126875. */
  126876. alphaTest: boolean;
  126877. /**
  126878. * Define a mask to restrict the layer to only some of the scene cameras.
  126879. */
  126880. layerMask: number;
  126881. /**
  126882. * Define the list of render target the layer is visible into.
  126883. */
  126884. renderTargetTextures: RenderTargetTexture[];
  126885. /**
  126886. * Define if the layer is only used in renderTarget or if it also
  126887. * renders in the main frame buffer of the canvas.
  126888. */
  126889. renderOnlyInRenderTargetTextures: boolean;
  126890. private _scene;
  126891. private _vertexBuffers;
  126892. private _indexBuffer;
  126893. private _effect;
  126894. private _previousDefines;
  126895. /**
  126896. * An event triggered when the layer is disposed.
  126897. */
  126898. onDisposeObservable: Observable<Layer>;
  126899. private _onDisposeObserver;
  126900. /**
  126901. * Back compatibility with callback before the onDisposeObservable existed.
  126902. * The set callback will be triggered when the layer has been disposed.
  126903. */
  126904. set onDispose(callback: () => void);
  126905. /**
  126906. * An event triggered before rendering the scene
  126907. */
  126908. onBeforeRenderObservable: Observable<Layer>;
  126909. private _onBeforeRenderObserver;
  126910. /**
  126911. * Back compatibility with callback before the onBeforeRenderObservable existed.
  126912. * The set callback will be triggered just before rendering the layer.
  126913. */
  126914. set onBeforeRender(callback: () => void);
  126915. /**
  126916. * An event triggered after rendering the scene
  126917. */
  126918. onAfterRenderObservable: Observable<Layer>;
  126919. private _onAfterRenderObserver;
  126920. /**
  126921. * Back compatibility with callback before the onAfterRenderObservable existed.
  126922. * The set callback will be triggered just after rendering the layer.
  126923. */
  126924. set onAfterRender(callback: () => void);
  126925. /**
  126926. * Instantiates a new layer.
  126927. * This represents a full screen 2d layer.
  126928. * This can be useful to display a picture in the background of your scene for instance.
  126929. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126930. * @param name Define the name of the layer in the scene
  126931. * @param imgUrl Define the url of the texture to display in the layer
  126932. * @param scene Define the scene the layer belongs to
  126933. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  126934. * @param color Defines a color for the layer
  126935. */
  126936. constructor(
  126937. /**
  126938. * Define the name of the layer.
  126939. */
  126940. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  126941. private _createIndexBuffer;
  126942. /** @hidden */
  126943. _rebuild(): void;
  126944. /**
  126945. * Renders the layer in the scene.
  126946. */
  126947. render(): void;
  126948. /**
  126949. * Disposes and releases the associated ressources.
  126950. */
  126951. dispose(): void;
  126952. }
  126953. }
  126954. declare module BABYLON {
  126955. /** @hidden */
  126956. export var lensFlarePixelShader: {
  126957. name: string;
  126958. shader: string;
  126959. };
  126960. }
  126961. declare module BABYLON {
  126962. /** @hidden */
  126963. export var lensFlareVertexShader: {
  126964. name: string;
  126965. shader: string;
  126966. };
  126967. }
  126968. declare module BABYLON {
  126969. /**
  126970. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126971. * It is usually composed of several `lensFlare`.
  126972. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126973. */
  126974. export class LensFlareSystem {
  126975. /**
  126976. * Define the name of the lens flare system
  126977. */
  126978. name: string;
  126979. /**
  126980. * List of lens flares used in this system.
  126981. */
  126982. lensFlares: LensFlare[];
  126983. /**
  126984. * Define a limit from the border the lens flare can be visible.
  126985. */
  126986. borderLimit: number;
  126987. /**
  126988. * Define a viewport border we do not want to see the lens flare in.
  126989. */
  126990. viewportBorder: number;
  126991. /**
  126992. * Define a predicate which could limit the list of meshes able to occlude the effect.
  126993. */
  126994. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126995. /**
  126996. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  126997. */
  126998. layerMask: number;
  126999. /**
  127000. * Define the id of the lens flare system in the scene.
  127001. * (equal to name by default)
  127002. */
  127003. id: string;
  127004. private _scene;
  127005. private _emitter;
  127006. private _vertexBuffers;
  127007. private _indexBuffer;
  127008. private _effect;
  127009. private _positionX;
  127010. private _positionY;
  127011. private _isEnabled;
  127012. /** @hidden */
  127013. static _SceneComponentInitialization: (scene: Scene) => void;
  127014. /**
  127015. * Instantiates a lens flare system.
  127016. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  127017. * It is usually composed of several `lensFlare`.
  127018. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127019. * @param name Define the name of the lens flare system in the scene
  127020. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  127021. * @param scene Define the scene the lens flare system belongs to
  127022. */
  127023. constructor(
  127024. /**
  127025. * Define the name of the lens flare system
  127026. */
  127027. name: string, emitter: any, scene: Scene);
  127028. /**
  127029. * Define if the lens flare system is enabled.
  127030. */
  127031. get isEnabled(): boolean;
  127032. set isEnabled(value: boolean);
  127033. /**
  127034. * Get the scene the effects belongs to.
  127035. * @returns the scene holding the lens flare system
  127036. */
  127037. getScene(): Scene;
  127038. /**
  127039. * Get the emitter of the lens flare system.
  127040. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127041. * @returns the emitter of the lens flare system
  127042. */
  127043. getEmitter(): any;
  127044. /**
  127045. * Set the emitter of the lens flare system.
  127046. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127047. * @param newEmitter Define the new emitter of the system
  127048. */
  127049. setEmitter(newEmitter: any): void;
  127050. /**
  127051. * Get the lens flare system emitter position.
  127052. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  127053. * @returns the position
  127054. */
  127055. getEmitterPosition(): Vector3;
  127056. /**
  127057. * @hidden
  127058. */
  127059. computeEffectivePosition(globalViewport: Viewport): boolean;
  127060. /** @hidden */
  127061. _isVisible(): boolean;
  127062. /**
  127063. * @hidden
  127064. */
  127065. render(): boolean;
  127066. /**
  127067. * Dispose and release the lens flare with its associated resources.
  127068. */
  127069. dispose(): void;
  127070. /**
  127071. * Parse a lens flare system from a JSON repressentation
  127072. * @param parsedLensFlareSystem Define the JSON to parse
  127073. * @param scene Define the scene the parsed system should be instantiated in
  127074. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  127075. * @returns the parsed system
  127076. */
  127077. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  127078. /**
  127079. * Serialize the current Lens Flare System into a JSON representation.
  127080. * @returns the serialized JSON
  127081. */
  127082. serialize(): any;
  127083. }
  127084. }
  127085. declare module BABYLON {
  127086. /**
  127087. * This represents one of the lens effect in a `lensFlareSystem`.
  127088. * It controls one of the indiviual texture used in the effect.
  127089. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127090. */
  127091. export class LensFlare {
  127092. /**
  127093. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127094. */
  127095. size: number;
  127096. /**
  127097. * 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.
  127098. */
  127099. position: number;
  127100. /**
  127101. * Define the lens color.
  127102. */
  127103. color: Color3;
  127104. /**
  127105. * Define the lens texture.
  127106. */
  127107. texture: Nullable<Texture>;
  127108. /**
  127109. * Define the alpha mode to render this particular lens.
  127110. */
  127111. alphaMode: number;
  127112. private _system;
  127113. /**
  127114. * Creates a new Lens Flare.
  127115. * This represents one of the lens effect in a `lensFlareSystem`.
  127116. * It controls one of the indiviual texture used in the effect.
  127117. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127118. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  127119. * @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.
  127120. * @param color Define the lens color
  127121. * @param imgUrl Define the lens texture url
  127122. * @param system Define the `lensFlareSystem` this flare is part of
  127123. * @returns The newly created Lens Flare
  127124. */
  127125. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  127126. /**
  127127. * Instantiates a new Lens Flare.
  127128. * This represents one of the lens effect in a `lensFlareSystem`.
  127129. * It controls one of the indiviual texture used in the effect.
  127130. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127131. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  127132. * @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.
  127133. * @param color Define the lens color
  127134. * @param imgUrl Define the lens texture url
  127135. * @param system Define the `lensFlareSystem` this flare is part of
  127136. */
  127137. constructor(
  127138. /**
  127139. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127140. */
  127141. size: number,
  127142. /**
  127143. * 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.
  127144. */
  127145. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  127146. /**
  127147. * Dispose and release the lens flare with its associated resources.
  127148. */
  127149. dispose(): void;
  127150. }
  127151. }
  127152. declare module BABYLON {
  127153. interface AbstractScene {
  127154. /**
  127155. * The list of lens flare system added to the scene
  127156. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127157. */
  127158. lensFlareSystems: Array<LensFlareSystem>;
  127159. /**
  127160. * Removes the given lens flare system from this scene.
  127161. * @param toRemove The lens flare system to remove
  127162. * @returns The index of the removed lens flare system
  127163. */
  127164. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  127165. /**
  127166. * Adds the given lens flare system to this scene
  127167. * @param newLensFlareSystem The lens flare system to add
  127168. */
  127169. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  127170. /**
  127171. * Gets a lens flare system using its name
  127172. * @param name defines the name to look for
  127173. * @returns the lens flare system or null if not found
  127174. */
  127175. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  127176. /**
  127177. * Gets a lens flare system using its id
  127178. * @param id defines the id to look for
  127179. * @returns the lens flare system or null if not found
  127180. */
  127181. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  127182. }
  127183. /**
  127184. * Defines the lens flare scene component responsible to manage any lens flares
  127185. * in a given scene.
  127186. */
  127187. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  127188. /**
  127189. * The component name helpfull to identify the component in the list of scene components.
  127190. */
  127191. readonly name: string;
  127192. /**
  127193. * The scene the component belongs to.
  127194. */
  127195. scene: Scene;
  127196. /**
  127197. * Creates a new instance of the component for the given scene
  127198. * @param scene Defines the scene to register the component in
  127199. */
  127200. constructor(scene: Scene);
  127201. /**
  127202. * Registers the component in a given scene
  127203. */
  127204. register(): void;
  127205. /**
  127206. * Rebuilds the elements related to this component in case of
  127207. * context lost for instance.
  127208. */
  127209. rebuild(): void;
  127210. /**
  127211. * Adds all the elements from the container to the scene
  127212. * @param container the container holding the elements
  127213. */
  127214. addFromContainer(container: AbstractScene): void;
  127215. /**
  127216. * Removes all the elements in the container from the scene
  127217. * @param container contains the elements to remove
  127218. * @param dispose if the removed element should be disposed (default: false)
  127219. */
  127220. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127221. /**
  127222. * Serializes the component data to the specified json object
  127223. * @param serializationObject The object to serialize to
  127224. */
  127225. serialize(serializationObject: any): void;
  127226. /**
  127227. * Disposes the component and the associated ressources.
  127228. */
  127229. dispose(): void;
  127230. private _draw;
  127231. }
  127232. }
  127233. declare module BABYLON {
  127234. /** @hidden */
  127235. export var depthPixelShader: {
  127236. name: string;
  127237. shader: string;
  127238. };
  127239. }
  127240. declare module BABYLON {
  127241. /** @hidden */
  127242. export var depthVertexShader: {
  127243. name: string;
  127244. shader: string;
  127245. };
  127246. }
  127247. declare module BABYLON {
  127248. /**
  127249. * This represents a depth renderer in Babylon.
  127250. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127251. */
  127252. export class DepthRenderer {
  127253. private _scene;
  127254. private _depthMap;
  127255. private _effect;
  127256. private readonly _storeNonLinearDepth;
  127257. private readonly _clearColor;
  127258. /** Get if the depth renderer is using packed depth or not */
  127259. readonly isPacked: boolean;
  127260. private _cachedDefines;
  127261. private _camera;
  127262. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  127263. enabled: boolean;
  127264. /**
  127265. * Specifiess that the depth renderer will only be used within
  127266. * the camera it is created for.
  127267. * This can help forcing its rendering during the camera processing.
  127268. */
  127269. useOnlyInActiveCamera: boolean;
  127270. /** @hidden */
  127271. static _SceneComponentInitialization: (scene: Scene) => void;
  127272. /**
  127273. * Instantiates a depth renderer
  127274. * @param scene The scene the renderer belongs to
  127275. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127276. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127277. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127278. */
  127279. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127280. /**
  127281. * Creates the depth rendering effect and checks if the effect is ready.
  127282. * @param subMesh The submesh to be used to render the depth map of
  127283. * @param useInstances If multiple world instances should be used
  127284. * @returns if the depth renderer is ready to render the depth map
  127285. */
  127286. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127287. /**
  127288. * Gets the texture which the depth map will be written to.
  127289. * @returns The depth map texture
  127290. */
  127291. getDepthMap(): RenderTargetTexture;
  127292. /**
  127293. * Disposes of the depth renderer.
  127294. */
  127295. dispose(): void;
  127296. }
  127297. }
  127298. declare module BABYLON {
  127299. /** @hidden */
  127300. export var minmaxReduxPixelShader: {
  127301. name: string;
  127302. shader: string;
  127303. };
  127304. }
  127305. declare module BABYLON {
  127306. /**
  127307. * This class computes a min/max reduction from a texture: it means it computes the minimum
  127308. * and maximum values from all values of the texture.
  127309. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  127310. * The source values are read from the red channel of the texture.
  127311. */
  127312. export class MinMaxReducer {
  127313. /**
  127314. * Observable triggered when the computation has been performed
  127315. */
  127316. onAfterReductionPerformed: Observable<{
  127317. min: number;
  127318. max: number;
  127319. }>;
  127320. protected _camera: Camera;
  127321. protected _sourceTexture: Nullable<RenderTargetTexture>;
  127322. protected _reductionSteps: Nullable<Array<PostProcess>>;
  127323. protected _postProcessManager: PostProcessManager;
  127324. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  127325. protected _forceFullscreenViewport: boolean;
  127326. /**
  127327. * Creates a min/max reducer
  127328. * @param camera The camera to use for the post processes
  127329. */
  127330. constructor(camera: Camera);
  127331. /**
  127332. * Gets the texture used to read the values from.
  127333. */
  127334. get sourceTexture(): Nullable<RenderTargetTexture>;
  127335. /**
  127336. * Sets the source texture to read the values from.
  127337. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  127338. * because in such textures '1' value must not be taken into account to compute the maximum
  127339. * as this value is used to clear the texture.
  127340. * Note that the computation is not activated by calling this function, you must call activate() for that!
  127341. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  127342. * @param depthRedux Indicates if the texture is a depth texture or not
  127343. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  127344. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127345. */
  127346. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127347. /**
  127348. * Defines the refresh rate of the computation.
  127349. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127350. */
  127351. get refreshRate(): number;
  127352. set refreshRate(value: number);
  127353. protected _activated: boolean;
  127354. /**
  127355. * Gets the activation status of the reducer
  127356. */
  127357. get activated(): boolean;
  127358. /**
  127359. * Activates the reduction computation.
  127360. * When activated, the observers registered in onAfterReductionPerformed are
  127361. * called after the compuation is performed
  127362. */
  127363. activate(): void;
  127364. /**
  127365. * Deactivates the reduction computation.
  127366. */
  127367. deactivate(): void;
  127368. /**
  127369. * Disposes the min/max reducer
  127370. * @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.
  127371. */
  127372. dispose(disposeAll?: boolean): void;
  127373. }
  127374. }
  127375. declare module BABYLON {
  127376. /**
  127377. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  127378. */
  127379. export class DepthReducer extends MinMaxReducer {
  127380. private _depthRenderer;
  127381. private _depthRendererId;
  127382. /**
  127383. * Gets the depth renderer used for the computation.
  127384. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  127385. */
  127386. get depthRenderer(): Nullable<DepthRenderer>;
  127387. /**
  127388. * Creates a depth reducer
  127389. * @param camera The camera used to render the depth texture
  127390. */
  127391. constructor(camera: Camera);
  127392. /**
  127393. * Sets the depth renderer to use to generate the depth map
  127394. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  127395. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  127396. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127397. */
  127398. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  127399. /** @hidden */
  127400. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127401. /**
  127402. * Activates the reduction computation.
  127403. * When activated, the observers registered in onAfterReductionPerformed are
  127404. * called after the compuation is performed
  127405. */
  127406. activate(): void;
  127407. /**
  127408. * Deactivates the reduction computation.
  127409. */
  127410. deactivate(): void;
  127411. /**
  127412. * Disposes the depth reducer
  127413. * @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.
  127414. */
  127415. dispose(disposeAll?: boolean): void;
  127416. }
  127417. }
  127418. declare module BABYLON {
  127419. /**
  127420. * A CSM implementation allowing casting shadows on large scenes.
  127421. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127422. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  127423. */
  127424. export class CascadedShadowGenerator extends ShadowGenerator {
  127425. private static readonly frustumCornersNDCSpace;
  127426. /**
  127427. * Name of the CSM class
  127428. */
  127429. static CLASSNAME: string;
  127430. /**
  127431. * Defines the default number of cascades used by the CSM.
  127432. */
  127433. static readonly DEFAULT_CASCADES_COUNT: number;
  127434. /**
  127435. * Defines the minimum number of cascades used by the CSM.
  127436. */
  127437. static readonly MIN_CASCADES_COUNT: number;
  127438. /**
  127439. * Defines the maximum number of cascades used by the CSM.
  127440. */
  127441. static readonly MAX_CASCADES_COUNT: number;
  127442. protected _validateFilter(filter: number): number;
  127443. /**
  127444. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  127445. */
  127446. penumbraDarkness: number;
  127447. private _numCascades;
  127448. /**
  127449. * Gets or set the number of cascades used by the CSM.
  127450. */
  127451. get numCascades(): number;
  127452. set numCascades(value: number);
  127453. /**
  127454. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  127455. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  127456. */
  127457. stabilizeCascades: boolean;
  127458. private _freezeShadowCastersBoundingInfo;
  127459. private _freezeShadowCastersBoundingInfoObservable;
  127460. /**
  127461. * Enables or disables the shadow casters bounding info computation.
  127462. * If your shadow casters don't move, you can disable this feature.
  127463. * If it is enabled, the bounding box computation is done every frame.
  127464. */
  127465. get freezeShadowCastersBoundingInfo(): boolean;
  127466. set freezeShadowCastersBoundingInfo(freeze: boolean);
  127467. private _scbiMin;
  127468. private _scbiMax;
  127469. protected _computeShadowCastersBoundingInfo(): void;
  127470. protected _shadowCastersBoundingInfo: BoundingInfo;
  127471. /**
  127472. * Gets or sets the shadow casters bounding info.
  127473. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  127474. * so that the system won't overwrite the bounds you provide
  127475. */
  127476. get shadowCastersBoundingInfo(): BoundingInfo;
  127477. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  127478. protected _breaksAreDirty: boolean;
  127479. protected _minDistance: number;
  127480. protected _maxDistance: number;
  127481. /**
  127482. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  127483. *
  127484. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  127485. * If you don't know these values, simply leave them to their defaults and don't call this function.
  127486. * @param min minimal distance for the breaks (default to 0.)
  127487. * @param max maximal distance for the breaks (default to 1.)
  127488. */
  127489. setMinMaxDistance(min: number, max: number): void;
  127490. /** Gets the minimal distance used in the cascade break computation */
  127491. get minDistance(): number;
  127492. /** Gets the maximal distance used in the cascade break computation */
  127493. get maxDistance(): number;
  127494. /**
  127495. * Gets the class name of that object
  127496. * @returns "CascadedShadowGenerator"
  127497. */
  127498. getClassName(): string;
  127499. private _cascadeMinExtents;
  127500. private _cascadeMaxExtents;
  127501. /**
  127502. * Gets a cascade minimum extents
  127503. * @param cascadeIndex index of the cascade
  127504. * @returns the minimum cascade extents
  127505. */
  127506. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  127507. /**
  127508. * Gets a cascade maximum extents
  127509. * @param cascadeIndex index of the cascade
  127510. * @returns the maximum cascade extents
  127511. */
  127512. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  127513. private _cascades;
  127514. private _currentLayer;
  127515. private _viewSpaceFrustumsZ;
  127516. private _viewMatrices;
  127517. private _projectionMatrices;
  127518. private _transformMatrices;
  127519. private _transformMatricesAsArray;
  127520. private _frustumLengths;
  127521. private _lightSizeUVCorrection;
  127522. private _depthCorrection;
  127523. private _frustumCornersWorldSpace;
  127524. private _frustumCenter;
  127525. private _shadowCameraPos;
  127526. private _shadowMaxZ;
  127527. /**
  127528. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  127529. * It defaults to camera.maxZ
  127530. */
  127531. get shadowMaxZ(): number;
  127532. /**
  127533. * Sets the shadow max z distance.
  127534. */
  127535. set shadowMaxZ(value: number);
  127536. protected _debug: boolean;
  127537. /**
  127538. * Gets or sets the debug flag.
  127539. * When enabled, the cascades are materialized by different colors on the screen.
  127540. */
  127541. get debug(): boolean;
  127542. set debug(dbg: boolean);
  127543. private _depthClamp;
  127544. /**
  127545. * Gets or sets the depth clamping value.
  127546. *
  127547. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  127548. * to account for the shadow casters far away.
  127549. *
  127550. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  127551. */
  127552. get depthClamp(): boolean;
  127553. set depthClamp(value: boolean);
  127554. private _cascadeBlendPercentage;
  127555. /**
  127556. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  127557. * It defaults to 0.1 (10% blending).
  127558. */
  127559. get cascadeBlendPercentage(): number;
  127560. set cascadeBlendPercentage(value: number);
  127561. private _lambda;
  127562. /**
  127563. * Gets or set the lambda parameter.
  127564. * This parameter is used to split the camera frustum and create the cascades.
  127565. * 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.
  127566. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  127567. */
  127568. get lambda(): number;
  127569. set lambda(value: number);
  127570. /**
  127571. * Gets the view matrix corresponding to a given cascade
  127572. * @param cascadeNum cascade to retrieve the view matrix from
  127573. * @returns the cascade view matrix
  127574. */
  127575. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127576. /**
  127577. * Gets the projection matrix corresponding to a given cascade
  127578. * @param cascadeNum cascade to retrieve the projection matrix from
  127579. * @returns the cascade projection matrix
  127580. */
  127581. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  127582. /**
  127583. * Gets the transformation matrix corresponding to a given cascade
  127584. * @param cascadeNum cascade to retrieve the transformation matrix from
  127585. * @returns the cascade transformation matrix
  127586. */
  127587. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  127588. private _depthRenderer;
  127589. /**
  127590. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127591. *
  127592. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127593. *
  127594. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127595. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127596. * @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
  127597. */
  127598. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127599. private _depthReducer;
  127600. private _autoCalcDepthBounds;
  127601. /**
  127602. * Gets or sets the autoCalcDepthBounds property.
  127603. *
  127604. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127605. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127606. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127607. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127608. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127609. */
  127610. get autoCalcDepthBounds(): boolean;
  127611. set autoCalcDepthBounds(value: boolean);
  127612. /**
  127613. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127614. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127615. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127616. * for setting the refresh rate on the renderer yourself!
  127617. */
  127618. get autoCalcDepthBoundsRefreshRate(): number;
  127619. set autoCalcDepthBoundsRefreshRate(value: number);
  127620. /**
  127621. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127622. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127623. * you change the camera near/far planes!
  127624. */
  127625. splitFrustum(): void;
  127626. private _splitFrustum;
  127627. private _computeMatrices;
  127628. private _computeFrustumInWorldSpace;
  127629. private _computeCascadeFrustum;
  127630. /** @hidden */
  127631. static _SceneComponentInitialization: (scene: Scene) => void;
  127632. /**
  127633. * Creates a Cascaded Shadow Generator object.
  127634. * A ShadowGenerator is the required tool to use the shadows.
  127635. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127636. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127637. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127638. * @param light The directional light object generating the shadows.
  127639. * @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.
  127640. */
  127641. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127642. protected _initializeGenerator(): void;
  127643. protected _createTargetRenderTexture(): void;
  127644. protected _initializeShadowMap(): void;
  127645. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  127646. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  127647. /**
  127648. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127649. * @param defines Defines of the material we want to update
  127650. * @param lightIndex Index of the light in the enabled light list of the material
  127651. */
  127652. prepareDefines(defines: any, lightIndex: number): void;
  127653. /**
  127654. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127655. * defined in the generator but impacting the effect).
  127656. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127657. * @param effect The effect we are binfing the information for
  127658. */
  127659. bindShadowLight(lightIndex: string, effect: Effect): void;
  127660. /**
  127661. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127662. * (eq to view projection * shadow projection matrices)
  127663. * @returns The transform matrix used to create the shadow map
  127664. */
  127665. getTransformMatrix(): Matrix;
  127666. /**
  127667. * Disposes the ShadowGenerator.
  127668. * Returns nothing.
  127669. */
  127670. dispose(): void;
  127671. /**
  127672. * Serializes the shadow generator setup to a json object.
  127673. * @returns The serialized JSON object
  127674. */
  127675. serialize(): any;
  127676. /**
  127677. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127678. * @param parsedShadowGenerator The JSON object to parse
  127679. * @param scene The scene to create the shadow map for
  127680. * @returns The parsed shadow generator
  127681. */
  127682. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  127683. }
  127684. }
  127685. declare module BABYLON {
  127686. /**
  127687. * Defines the shadow generator component responsible to manage any shadow generators
  127688. * in a given scene.
  127689. */
  127690. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127691. /**
  127692. * The component name helpfull to identify the component in the list of scene components.
  127693. */
  127694. readonly name: string;
  127695. /**
  127696. * The scene the component belongs to.
  127697. */
  127698. scene: Scene;
  127699. /**
  127700. * Creates a new instance of the component for the given scene
  127701. * @param scene Defines the scene to register the component in
  127702. */
  127703. constructor(scene: Scene);
  127704. /**
  127705. * Registers the component in a given scene
  127706. */
  127707. register(): void;
  127708. /**
  127709. * Rebuilds the elements related to this component in case of
  127710. * context lost for instance.
  127711. */
  127712. rebuild(): void;
  127713. /**
  127714. * Serializes the component data to the specified json object
  127715. * @param serializationObject The object to serialize to
  127716. */
  127717. serialize(serializationObject: any): void;
  127718. /**
  127719. * Adds all the elements from the container to the scene
  127720. * @param container the container holding the elements
  127721. */
  127722. addFromContainer(container: AbstractScene): void;
  127723. /**
  127724. * Removes all the elements in the container from the scene
  127725. * @param container contains the elements to remove
  127726. * @param dispose if the removed element should be disposed (default: false)
  127727. */
  127728. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127729. /**
  127730. * Rebuilds the elements related to this component in case of
  127731. * context lost for instance.
  127732. */
  127733. dispose(): void;
  127734. private _gatherRenderTargets;
  127735. }
  127736. }
  127737. declare module BABYLON {
  127738. /**
  127739. * A point light is a light defined by an unique point in world space.
  127740. * The light is emitted in every direction from this point.
  127741. * A good example of a point light is a standard light bulb.
  127742. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127743. */
  127744. export class PointLight extends ShadowLight {
  127745. private _shadowAngle;
  127746. /**
  127747. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127748. * This specifies what angle the shadow will use to be created.
  127749. *
  127750. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127751. */
  127752. get shadowAngle(): number;
  127753. /**
  127754. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127755. * This specifies what angle the shadow will use to be created.
  127756. *
  127757. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127758. */
  127759. set shadowAngle(value: number);
  127760. /**
  127761. * Gets the direction if it has been set.
  127762. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127763. */
  127764. get direction(): Vector3;
  127765. /**
  127766. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127767. */
  127768. set direction(value: Vector3);
  127769. /**
  127770. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  127771. * A PointLight emits the light in every direction.
  127772. * It can cast shadows.
  127773. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  127774. * ```javascript
  127775. * var pointLight = new PointLight("pl", camera.position, scene);
  127776. * ```
  127777. * Documentation : https://doc.babylonjs.com/babylon101/lights
  127778. * @param name The light friendly name
  127779. * @param position The position of the point light in the scene
  127780. * @param scene The scene the lights belongs to
  127781. */
  127782. constructor(name: string, position: Vector3, scene: Scene);
  127783. /**
  127784. * Returns the string "PointLight"
  127785. * @returns the class name
  127786. */
  127787. getClassName(): string;
  127788. /**
  127789. * Returns the integer 0.
  127790. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  127791. */
  127792. getTypeID(): number;
  127793. /**
  127794. * Specifies wether or not the shadowmap should be a cube texture.
  127795. * @returns true if the shadowmap needs to be a cube texture.
  127796. */
  127797. needCube(): boolean;
  127798. /**
  127799. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  127800. * @param faceIndex The index of the face we are computed the direction to generate shadow
  127801. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  127802. */
  127803. getShadowDirection(faceIndex?: number): Vector3;
  127804. /**
  127805. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  127806. * - fov = PI / 2
  127807. * - aspect ratio : 1.0
  127808. * - z-near and far equal to the active camera minZ and maxZ.
  127809. * Returns the PointLight.
  127810. */
  127811. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  127812. protected _buildUniformLayout(): void;
  127813. /**
  127814. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  127815. * @param effect The effect to update
  127816. * @param lightIndex The index of the light in the effect to update
  127817. * @returns The point light
  127818. */
  127819. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  127820. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  127821. /**
  127822. * Prepares the list of defines specific to the light type.
  127823. * @param defines the list of defines
  127824. * @param lightIndex defines the index of the light for the effect
  127825. */
  127826. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  127827. }
  127828. }
  127829. declare module BABYLON {
  127830. /**
  127831. * Header information of HDR texture files.
  127832. */
  127833. export interface HDRInfo {
  127834. /**
  127835. * The height of the texture in pixels.
  127836. */
  127837. height: number;
  127838. /**
  127839. * The width of the texture in pixels.
  127840. */
  127841. width: number;
  127842. /**
  127843. * The index of the beginning of the data in the binary file.
  127844. */
  127845. dataPosition: number;
  127846. }
  127847. /**
  127848. * This groups tools to convert HDR texture to native colors array.
  127849. */
  127850. export class HDRTools {
  127851. private static Ldexp;
  127852. private static Rgbe2float;
  127853. private static readStringLine;
  127854. /**
  127855. * Reads header information from an RGBE texture stored in a native array.
  127856. * More information on this format are available here:
  127857. * https://en.wikipedia.org/wiki/RGBE_image_format
  127858. *
  127859. * @param uint8array The binary file stored in native array.
  127860. * @return The header information.
  127861. */
  127862. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  127863. /**
  127864. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  127865. * This RGBE texture needs to store the information as a panorama.
  127866. *
  127867. * More information on this format are available here:
  127868. * https://en.wikipedia.org/wiki/RGBE_image_format
  127869. *
  127870. * @param buffer The binary file stored in an array buffer.
  127871. * @param size The expected size of the extracted cubemap.
  127872. * @return The Cube Map information.
  127873. */
  127874. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  127875. /**
  127876. * Returns the pixels data extracted from an RGBE texture.
  127877. * This pixels will be stored left to right up to down in the R G B order in one array.
  127878. *
  127879. * More information on this format are available here:
  127880. * https://en.wikipedia.org/wiki/RGBE_image_format
  127881. *
  127882. * @param uint8array The binary file stored in an array buffer.
  127883. * @param hdrInfo The header information of the file.
  127884. * @return The pixels data in RGB right to left up to down order.
  127885. */
  127886. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  127887. private static RGBE_ReadPixels_RLE;
  127888. }
  127889. }
  127890. declare module BABYLON {
  127891. /**
  127892. * This represents a texture coming from an HDR input.
  127893. *
  127894. * The only supported format is currently panorama picture stored in RGBE format.
  127895. * Example of such files can be found on HDRLib: http://hdrlib.com/
  127896. */
  127897. export class HDRCubeTexture extends BaseTexture {
  127898. private static _facesMapping;
  127899. private _generateHarmonics;
  127900. private _noMipmap;
  127901. private _textureMatrix;
  127902. private _size;
  127903. private _onLoad;
  127904. private _onError;
  127905. /**
  127906. * The texture URL.
  127907. */
  127908. url: string;
  127909. /**
  127910. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  127911. */
  127912. coordinatesMode: number;
  127913. protected _isBlocking: boolean;
  127914. /**
  127915. * Sets wether or not the texture is blocking during loading.
  127916. */
  127917. set isBlocking(value: boolean);
  127918. /**
  127919. * Gets wether or not the texture is blocking during loading.
  127920. */
  127921. get isBlocking(): boolean;
  127922. protected _rotationY: number;
  127923. /**
  127924. * Sets texture matrix rotation angle around Y axis in radians.
  127925. */
  127926. set rotationY(value: number);
  127927. /**
  127928. * Gets texture matrix rotation angle around Y axis radians.
  127929. */
  127930. get rotationY(): number;
  127931. /**
  127932. * Gets or sets the center of the bounding box associated with the cube texture
  127933. * It must define where the camera used to render the texture was set
  127934. */
  127935. boundingBoxPosition: Vector3;
  127936. private _boundingBoxSize;
  127937. /**
  127938. * Gets or sets the size of the bounding box associated with the cube texture
  127939. * When defined, the cubemap will switch to local mode
  127940. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  127941. * @example https://www.babylonjs-playground.com/#RNASML
  127942. */
  127943. set boundingBoxSize(value: Vector3);
  127944. get boundingBoxSize(): Vector3;
  127945. /**
  127946. * Instantiates an HDRTexture from the following parameters.
  127947. *
  127948. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  127949. * @param scene The scene the texture will be used in
  127950. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  127951. * @param noMipmap Forces to not generate the mipmap if true
  127952. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  127953. * @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)
  127954. * @param reserved Reserved flag for internal use.
  127955. */
  127956. 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>);
  127957. /**
  127958. * Get the current class name of the texture useful for serialization or dynamic coding.
  127959. * @returns "HDRCubeTexture"
  127960. */
  127961. getClassName(): string;
  127962. /**
  127963. * Occurs when the file is raw .hdr file.
  127964. */
  127965. private loadTexture;
  127966. clone(): HDRCubeTexture;
  127967. delayLoad(): void;
  127968. /**
  127969. * Get the texture reflection matrix used to rotate/transform the reflection.
  127970. * @returns the reflection matrix
  127971. */
  127972. getReflectionTextureMatrix(): Matrix;
  127973. /**
  127974. * Set the texture reflection matrix used to rotate/transform the reflection.
  127975. * @param value Define the reflection matrix to set
  127976. */
  127977. setReflectionTextureMatrix(value: Matrix): void;
  127978. /**
  127979. * Parses a JSON representation of an HDR Texture in order to create the texture
  127980. * @param parsedTexture Define the JSON representation
  127981. * @param scene Define the scene the texture should be created in
  127982. * @param rootUrl Define the root url in case we need to load relative dependencies
  127983. * @returns the newly created texture after parsing
  127984. */
  127985. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  127986. serialize(): any;
  127987. }
  127988. }
  127989. declare module BABYLON {
  127990. /**
  127991. * Class used to control physics engine
  127992. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127993. */
  127994. export class PhysicsEngine implements IPhysicsEngine {
  127995. private _physicsPlugin;
  127996. /**
  127997. * Global value used to control the smallest number supported by the simulation
  127998. */
  127999. static Epsilon: number;
  128000. private _impostors;
  128001. private _joints;
  128002. private _subTimeStep;
  128003. /**
  128004. * Gets the gravity vector used by the simulation
  128005. */
  128006. gravity: Vector3;
  128007. /**
  128008. * Factory used to create the default physics plugin.
  128009. * @returns The default physics plugin
  128010. */
  128011. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  128012. /**
  128013. * Creates a new Physics Engine
  128014. * @param gravity defines the gravity vector used by the simulation
  128015. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  128016. */
  128017. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  128018. /**
  128019. * Sets the gravity vector used by the simulation
  128020. * @param gravity defines the gravity vector to use
  128021. */
  128022. setGravity(gravity: Vector3): void;
  128023. /**
  128024. * Set the time step of the physics engine.
  128025. * Default is 1/60.
  128026. * To slow it down, enter 1/600 for example.
  128027. * To speed it up, 1/30
  128028. * @param newTimeStep defines the new timestep to apply to this world.
  128029. */
  128030. setTimeStep(newTimeStep?: number): void;
  128031. /**
  128032. * Get the time step of the physics engine.
  128033. * @returns the current time step
  128034. */
  128035. getTimeStep(): number;
  128036. /**
  128037. * Set the sub time step of the physics engine.
  128038. * Default is 0 meaning there is no sub steps
  128039. * To increase physics resolution precision, set a small value (like 1 ms)
  128040. * @param subTimeStep defines the new sub timestep used for physics resolution.
  128041. */
  128042. setSubTimeStep(subTimeStep?: number): void;
  128043. /**
  128044. * Get the sub time step of the physics engine.
  128045. * @returns the current sub time step
  128046. */
  128047. getSubTimeStep(): number;
  128048. /**
  128049. * Release all resources
  128050. */
  128051. dispose(): void;
  128052. /**
  128053. * Gets the name of the current physics plugin
  128054. * @returns the name of the plugin
  128055. */
  128056. getPhysicsPluginName(): string;
  128057. /**
  128058. * Adding a new impostor for the impostor tracking.
  128059. * This will be done by the impostor itself.
  128060. * @param impostor the impostor to add
  128061. */
  128062. addImpostor(impostor: PhysicsImpostor): void;
  128063. /**
  128064. * Remove an impostor from the engine.
  128065. * This impostor and its mesh will not longer be updated by the physics engine.
  128066. * @param impostor the impostor to remove
  128067. */
  128068. removeImpostor(impostor: PhysicsImpostor): void;
  128069. /**
  128070. * Add a joint to the physics engine
  128071. * @param mainImpostor defines the main impostor to which the joint is added.
  128072. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  128073. * @param joint defines the joint that will connect both impostors.
  128074. */
  128075. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128076. /**
  128077. * Removes a joint from the simulation
  128078. * @param mainImpostor defines the impostor used with the joint
  128079. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  128080. * @param joint defines the joint to remove
  128081. */
  128082. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128083. /**
  128084. * Called by the scene. No need to call it.
  128085. * @param delta defines the timespam between frames
  128086. */
  128087. _step(delta: number): void;
  128088. /**
  128089. * Gets the current plugin used to run the simulation
  128090. * @returns current plugin
  128091. */
  128092. getPhysicsPlugin(): IPhysicsEnginePlugin;
  128093. /**
  128094. * Gets the list of physic impostors
  128095. * @returns an array of PhysicsImpostor
  128096. */
  128097. getImpostors(): Array<PhysicsImpostor>;
  128098. /**
  128099. * Gets the impostor for a physics enabled object
  128100. * @param object defines the object impersonated by the impostor
  128101. * @returns the PhysicsImpostor or null if not found
  128102. */
  128103. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  128104. /**
  128105. * Gets the impostor for a physics body object
  128106. * @param body defines physics body used by the impostor
  128107. * @returns the PhysicsImpostor or null if not found
  128108. */
  128109. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  128110. /**
  128111. * Does a raycast in the physics world
  128112. * @param from when should the ray start?
  128113. * @param to when should the ray end?
  128114. * @returns PhysicsRaycastResult
  128115. */
  128116. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128117. }
  128118. }
  128119. declare module BABYLON {
  128120. /** @hidden */
  128121. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  128122. private _useDeltaForWorldStep;
  128123. world: any;
  128124. name: string;
  128125. private _physicsMaterials;
  128126. private _fixedTimeStep;
  128127. private _cannonRaycastResult;
  128128. private _raycastResult;
  128129. private _physicsBodysToRemoveAfterStep;
  128130. BJSCANNON: any;
  128131. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  128132. setGravity(gravity: Vector3): void;
  128133. setTimeStep(timeStep: number): void;
  128134. getTimeStep(): number;
  128135. executeStep(delta: number): void;
  128136. private _removeMarkedPhysicsBodiesFromWorld;
  128137. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128138. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128139. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128140. private _processChildMeshes;
  128141. removePhysicsBody(impostor: PhysicsImpostor): void;
  128142. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128143. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128144. private _addMaterial;
  128145. private _checkWithEpsilon;
  128146. private _createShape;
  128147. private _createHeightmap;
  128148. private _minus90X;
  128149. private _plus90X;
  128150. private _tmpPosition;
  128151. private _tmpDeltaPosition;
  128152. private _tmpUnityRotation;
  128153. private _updatePhysicsBodyTransformation;
  128154. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128155. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128156. isSupported(): boolean;
  128157. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128158. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128159. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128160. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128161. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128162. getBodyMass(impostor: PhysicsImpostor): number;
  128163. getBodyFriction(impostor: PhysicsImpostor): number;
  128164. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128165. getBodyRestitution(impostor: PhysicsImpostor): number;
  128166. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128167. sleepBody(impostor: PhysicsImpostor): void;
  128168. wakeUpBody(impostor: PhysicsImpostor): void;
  128169. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  128170. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128171. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128172. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128173. getRadius(impostor: PhysicsImpostor): number;
  128174. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128175. dispose(): void;
  128176. private _extendNamespace;
  128177. /**
  128178. * Does a raycast in the physics world
  128179. * @param from when should the ray start?
  128180. * @param to when should the ray end?
  128181. * @returns PhysicsRaycastResult
  128182. */
  128183. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128184. }
  128185. }
  128186. declare module BABYLON {
  128187. /** @hidden */
  128188. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  128189. world: any;
  128190. name: string;
  128191. BJSOIMO: any;
  128192. private _raycastResult;
  128193. constructor(iterations?: number, oimoInjection?: any);
  128194. setGravity(gravity: Vector3): void;
  128195. setTimeStep(timeStep: number): void;
  128196. getTimeStep(): number;
  128197. private _tmpImpostorsArray;
  128198. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128199. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128200. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128201. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128202. private _tmpPositionVector;
  128203. removePhysicsBody(impostor: PhysicsImpostor): void;
  128204. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128205. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128206. isSupported(): boolean;
  128207. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128208. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128209. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128210. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128211. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128212. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128213. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128214. getBodyMass(impostor: PhysicsImpostor): number;
  128215. getBodyFriction(impostor: PhysicsImpostor): number;
  128216. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128217. getBodyRestitution(impostor: PhysicsImpostor): number;
  128218. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128219. sleepBody(impostor: PhysicsImpostor): void;
  128220. wakeUpBody(impostor: PhysicsImpostor): void;
  128221. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128222. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  128223. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  128224. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128225. getRadius(impostor: PhysicsImpostor): number;
  128226. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128227. dispose(): void;
  128228. /**
  128229. * Does a raycast in the physics world
  128230. * @param from when should the ray start?
  128231. * @param to when should the ray end?
  128232. * @returns PhysicsRaycastResult
  128233. */
  128234. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128235. }
  128236. }
  128237. declare module BABYLON {
  128238. /**
  128239. * Class containing static functions to help procedurally build meshes
  128240. */
  128241. export class RibbonBuilder {
  128242. /**
  128243. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128244. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128245. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128246. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128247. * * 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
  128248. * * 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
  128249. * * 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
  128250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128251. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128252. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128253. * * 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
  128254. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128255. * * 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
  128256. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128258. * @param name defines the name of the mesh
  128259. * @param options defines the options used to create the mesh
  128260. * @param scene defines the hosting scene
  128261. * @returns the ribbon mesh
  128262. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128263. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128264. */
  128265. static CreateRibbon(name: string, options: {
  128266. pathArray: Vector3[][];
  128267. closeArray?: boolean;
  128268. closePath?: boolean;
  128269. offset?: number;
  128270. updatable?: boolean;
  128271. sideOrientation?: number;
  128272. frontUVs?: Vector4;
  128273. backUVs?: Vector4;
  128274. instance?: Mesh;
  128275. invertUV?: boolean;
  128276. uvs?: Vector2[];
  128277. colors?: Color4[];
  128278. }, scene?: Nullable<Scene>): Mesh;
  128279. }
  128280. }
  128281. declare module BABYLON {
  128282. /**
  128283. * Class containing static functions to help procedurally build meshes
  128284. */
  128285. export class ShapeBuilder {
  128286. /**
  128287. * 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.
  128288. * * 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.
  128289. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128290. * * 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.
  128291. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128292. * * 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
  128293. * * 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
  128294. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128296. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128297. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128299. * @param name defines the name of the mesh
  128300. * @param options defines the options used to create the mesh
  128301. * @param scene defines the hosting scene
  128302. * @returns the extruded shape mesh
  128303. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128304. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128305. */
  128306. static ExtrudeShape(name: string, options: {
  128307. shape: Vector3[];
  128308. path: Vector3[];
  128309. scale?: number;
  128310. rotation?: number;
  128311. cap?: number;
  128312. updatable?: boolean;
  128313. sideOrientation?: number;
  128314. frontUVs?: Vector4;
  128315. backUVs?: Vector4;
  128316. instance?: Mesh;
  128317. invertUV?: boolean;
  128318. }, scene?: Nullable<Scene>): Mesh;
  128319. /**
  128320. * Creates an custom extruded shape mesh.
  128321. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128322. * * 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.
  128323. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128324. * * 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
  128325. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128326. * * 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
  128327. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128328. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128329. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128330. * * 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
  128331. * * 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
  128332. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128334. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128335. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128337. * @param name defines the name of the mesh
  128338. * @param options defines the options used to create the mesh
  128339. * @param scene defines the hosting scene
  128340. * @returns the custom extruded shape mesh
  128341. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  128342. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128343. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128344. */
  128345. static ExtrudeShapeCustom(name: string, options: {
  128346. shape: Vector3[];
  128347. path: Vector3[];
  128348. scaleFunction?: any;
  128349. rotationFunction?: any;
  128350. ribbonCloseArray?: boolean;
  128351. ribbonClosePath?: boolean;
  128352. cap?: number;
  128353. updatable?: boolean;
  128354. sideOrientation?: number;
  128355. frontUVs?: Vector4;
  128356. backUVs?: Vector4;
  128357. instance?: Mesh;
  128358. invertUV?: boolean;
  128359. }, scene?: Nullable<Scene>): Mesh;
  128360. private static _ExtrudeShapeGeneric;
  128361. }
  128362. }
  128363. declare module BABYLON {
  128364. /**
  128365. * AmmoJS Physics plugin
  128366. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  128367. * @see https://github.com/kripken/ammo.js/
  128368. */
  128369. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  128370. private _useDeltaForWorldStep;
  128371. /**
  128372. * Reference to the Ammo library
  128373. */
  128374. bjsAMMO: any;
  128375. /**
  128376. * Created ammoJS world which physics bodies are added to
  128377. */
  128378. world: any;
  128379. /**
  128380. * Name of the plugin
  128381. */
  128382. name: string;
  128383. private _timeStep;
  128384. private _fixedTimeStep;
  128385. private _maxSteps;
  128386. private _tmpQuaternion;
  128387. private _tmpAmmoTransform;
  128388. private _tmpAmmoQuaternion;
  128389. private _tmpAmmoConcreteContactResultCallback;
  128390. private _collisionConfiguration;
  128391. private _dispatcher;
  128392. private _overlappingPairCache;
  128393. private _solver;
  128394. private _softBodySolver;
  128395. private _tmpAmmoVectorA;
  128396. private _tmpAmmoVectorB;
  128397. private _tmpAmmoVectorC;
  128398. private _tmpAmmoVectorD;
  128399. private _tmpContactCallbackResult;
  128400. private _tmpAmmoVectorRCA;
  128401. private _tmpAmmoVectorRCB;
  128402. private _raycastResult;
  128403. private static readonly DISABLE_COLLISION_FLAG;
  128404. private static readonly KINEMATIC_FLAG;
  128405. private static readonly DISABLE_DEACTIVATION_FLAG;
  128406. /**
  128407. * Initializes the ammoJS plugin
  128408. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  128409. * @param ammoInjection can be used to inject your own ammo reference
  128410. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  128411. */
  128412. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  128413. /**
  128414. * Sets the gravity of the physics world (m/(s^2))
  128415. * @param gravity Gravity to set
  128416. */
  128417. setGravity(gravity: Vector3): void;
  128418. /**
  128419. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  128420. * @param timeStep timestep to use in seconds
  128421. */
  128422. setTimeStep(timeStep: number): void;
  128423. /**
  128424. * 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)
  128425. * @param fixedTimeStep fixedTimeStep to use in seconds
  128426. */
  128427. setFixedTimeStep(fixedTimeStep: number): void;
  128428. /**
  128429. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  128430. * @param maxSteps the maximum number of steps by the physics engine per frame
  128431. */
  128432. setMaxSteps(maxSteps: number): void;
  128433. /**
  128434. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  128435. * @returns the current timestep in seconds
  128436. */
  128437. getTimeStep(): number;
  128438. /**
  128439. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  128440. */
  128441. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  128442. private _isImpostorInContact;
  128443. private _isImpostorPairInContact;
  128444. private _stepSimulation;
  128445. /**
  128446. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  128447. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  128448. * After the step the babylon meshes are set to the position of the physics imposters
  128449. * @param delta amount of time to step forward
  128450. * @param impostors array of imposters to update before/after the step
  128451. */
  128452. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128453. /**
  128454. * Update babylon mesh to match physics world object
  128455. * @param impostor imposter to match
  128456. */
  128457. private _afterSoftStep;
  128458. /**
  128459. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128460. * @param impostor imposter to match
  128461. */
  128462. private _ropeStep;
  128463. /**
  128464. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128465. * @param impostor imposter to match
  128466. */
  128467. private _softbodyOrClothStep;
  128468. private _tmpVector;
  128469. private _tmpMatrix;
  128470. /**
  128471. * Applies an impulse on the imposter
  128472. * @param impostor imposter to apply impulse to
  128473. * @param force amount of force to be applied to the imposter
  128474. * @param contactPoint the location to apply the impulse on the imposter
  128475. */
  128476. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128477. /**
  128478. * Applies a force on the imposter
  128479. * @param impostor imposter to apply force
  128480. * @param force amount of force to be applied to the imposter
  128481. * @param contactPoint the location to apply the force on the imposter
  128482. */
  128483. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128484. /**
  128485. * Creates a physics body using the plugin
  128486. * @param impostor the imposter to create the physics body on
  128487. */
  128488. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128489. /**
  128490. * Removes the physics body from the imposter and disposes of the body's memory
  128491. * @param impostor imposter to remove the physics body from
  128492. */
  128493. removePhysicsBody(impostor: PhysicsImpostor): void;
  128494. /**
  128495. * Generates a joint
  128496. * @param impostorJoint the imposter joint to create the joint with
  128497. */
  128498. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128499. /**
  128500. * Removes a joint
  128501. * @param impostorJoint the imposter joint to remove the joint from
  128502. */
  128503. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128504. private _addMeshVerts;
  128505. /**
  128506. * Initialise the soft body vertices to match its object's (mesh) vertices
  128507. * Softbody vertices (nodes) are in world space and to match this
  128508. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  128509. * @param impostor to create the softbody for
  128510. */
  128511. private _softVertexData;
  128512. /**
  128513. * Create an impostor's soft body
  128514. * @param impostor to create the softbody for
  128515. */
  128516. private _createSoftbody;
  128517. /**
  128518. * Create cloth for an impostor
  128519. * @param impostor to create the softbody for
  128520. */
  128521. private _createCloth;
  128522. /**
  128523. * Create rope for an impostor
  128524. * @param impostor to create the softbody for
  128525. */
  128526. private _createRope;
  128527. /**
  128528. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  128529. * @param impostor to create the custom physics shape for
  128530. */
  128531. private _createCustom;
  128532. private _addHullVerts;
  128533. private _createShape;
  128534. /**
  128535. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  128536. * @param impostor imposter containing the physics body and babylon object
  128537. */
  128538. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128539. /**
  128540. * Sets the babylon object's position/rotation from the physics body's position/rotation
  128541. * @param impostor imposter containing the physics body and babylon object
  128542. * @param newPosition new position
  128543. * @param newRotation new rotation
  128544. */
  128545. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128546. /**
  128547. * If this plugin is supported
  128548. * @returns true if its supported
  128549. */
  128550. isSupported(): boolean;
  128551. /**
  128552. * Sets the linear velocity of the physics body
  128553. * @param impostor imposter to set the velocity on
  128554. * @param velocity velocity to set
  128555. */
  128556. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128557. /**
  128558. * Sets the angular velocity of the physics body
  128559. * @param impostor imposter to set the velocity on
  128560. * @param velocity velocity to set
  128561. */
  128562. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128563. /**
  128564. * gets the linear velocity
  128565. * @param impostor imposter to get linear velocity from
  128566. * @returns linear velocity
  128567. */
  128568. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128569. /**
  128570. * gets the angular velocity
  128571. * @param impostor imposter to get angular velocity from
  128572. * @returns angular velocity
  128573. */
  128574. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128575. /**
  128576. * Sets the mass of physics body
  128577. * @param impostor imposter to set the mass on
  128578. * @param mass mass to set
  128579. */
  128580. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128581. /**
  128582. * Gets the mass of the physics body
  128583. * @param impostor imposter to get the mass from
  128584. * @returns mass
  128585. */
  128586. getBodyMass(impostor: PhysicsImpostor): number;
  128587. /**
  128588. * Gets friction of the impostor
  128589. * @param impostor impostor to get friction from
  128590. * @returns friction value
  128591. */
  128592. getBodyFriction(impostor: PhysicsImpostor): number;
  128593. /**
  128594. * Sets friction of the impostor
  128595. * @param impostor impostor to set friction on
  128596. * @param friction friction value
  128597. */
  128598. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128599. /**
  128600. * Gets restitution of the impostor
  128601. * @param impostor impostor to get restitution from
  128602. * @returns restitution value
  128603. */
  128604. getBodyRestitution(impostor: PhysicsImpostor): number;
  128605. /**
  128606. * Sets resitution of the impostor
  128607. * @param impostor impostor to set resitution on
  128608. * @param restitution resitution value
  128609. */
  128610. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128611. /**
  128612. * Gets pressure inside the impostor
  128613. * @param impostor impostor to get pressure from
  128614. * @returns pressure value
  128615. */
  128616. getBodyPressure(impostor: PhysicsImpostor): number;
  128617. /**
  128618. * Sets pressure inside a soft body impostor
  128619. * Cloth and rope must remain 0 pressure
  128620. * @param impostor impostor to set pressure on
  128621. * @param pressure pressure value
  128622. */
  128623. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128624. /**
  128625. * Gets stiffness of the impostor
  128626. * @param impostor impostor to get stiffness from
  128627. * @returns pressure value
  128628. */
  128629. getBodyStiffness(impostor: PhysicsImpostor): number;
  128630. /**
  128631. * Sets stiffness of the impostor
  128632. * @param impostor impostor to set stiffness on
  128633. * @param stiffness stiffness value from 0 to 1
  128634. */
  128635. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128636. /**
  128637. * Gets velocityIterations of the impostor
  128638. * @param impostor impostor to get velocity iterations from
  128639. * @returns velocityIterations value
  128640. */
  128641. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128642. /**
  128643. * Sets velocityIterations of the impostor
  128644. * @param impostor impostor to set velocity iterations on
  128645. * @param velocityIterations velocityIterations value
  128646. */
  128647. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128648. /**
  128649. * Gets positionIterations of the impostor
  128650. * @param impostor impostor to get position iterations from
  128651. * @returns positionIterations value
  128652. */
  128653. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128654. /**
  128655. * Sets positionIterations of the impostor
  128656. * @param impostor impostor to set position on
  128657. * @param positionIterations positionIterations value
  128658. */
  128659. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128660. /**
  128661. * Append an anchor to a cloth object
  128662. * @param impostor is the cloth impostor to add anchor to
  128663. * @param otherImpostor is the rigid impostor to anchor to
  128664. * @param width ratio across width from 0 to 1
  128665. * @param height ratio up height from 0 to 1
  128666. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128667. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128668. */
  128669. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128670. /**
  128671. * Append an hook to a rope object
  128672. * @param impostor is the rope impostor to add hook to
  128673. * @param otherImpostor is the rigid impostor to hook to
  128674. * @param length ratio along the rope from 0 to 1
  128675. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128676. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128677. */
  128678. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128679. /**
  128680. * Sleeps the physics body and stops it from being active
  128681. * @param impostor impostor to sleep
  128682. */
  128683. sleepBody(impostor: PhysicsImpostor): void;
  128684. /**
  128685. * Activates the physics body
  128686. * @param impostor impostor to activate
  128687. */
  128688. wakeUpBody(impostor: PhysicsImpostor): void;
  128689. /**
  128690. * Updates the distance parameters of the joint
  128691. * @param joint joint to update
  128692. * @param maxDistance maximum distance of the joint
  128693. * @param minDistance minimum distance of the joint
  128694. */
  128695. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128696. /**
  128697. * Sets a motor on the joint
  128698. * @param joint joint to set motor on
  128699. * @param speed speed of the motor
  128700. * @param maxForce maximum force of the motor
  128701. * @param motorIndex index of the motor
  128702. */
  128703. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128704. /**
  128705. * Sets the motors limit
  128706. * @param joint joint to set limit on
  128707. * @param upperLimit upper limit
  128708. * @param lowerLimit lower limit
  128709. */
  128710. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128711. /**
  128712. * Syncs the position and rotation of a mesh with the impostor
  128713. * @param mesh mesh to sync
  128714. * @param impostor impostor to update the mesh with
  128715. */
  128716. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128717. /**
  128718. * Gets the radius of the impostor
  128719. * @param impostor impostor to get radius from
  128720. * @returns the radius
  128721. */
  128722. getRadius(impostor: PhysicsImpostor): number;
  128723. /**
  128724. * Gets the box size of the impostor
  128725. * @param impostor impostor to get box size from
  128726. * @param result the resulting box size
  128727. */
  128728. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128729. /**
  128730. * Disposes of the impostor
  128731. */
  128732. dispose(): void;
  128733. /**
  128734. * Does a raycast in the physics world
  128735. * @param from when should the ray start?
  128736. * @param to when should the ray end?
  128737. * @returns PhysicsRaycastResult
  128738. */
  128739. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128740. }
  128741. }
  128742. declare module BABYLON {
  128743. interface AbstractScene {
  128744. /**
  128745. * The list of reflection probes added to the scene
  128746. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128747. */
  128748. reflectionProbes: Array<ReflectionProbe>;
  128749. /**
  128750. * Removes the given reflection probe from this scene.
  128751. * @param toRemove The reflection probe to remove
  128752. * @returns The index of the removed reflection probe
  128753. */
  128754. removeReflectionProbe(toRemove: ReflectionProbe): number;
  128755. /**
  128756. * Adds the given reflection probe to this scene.
  128757. * @param newReflectionProbe The reflection probe to add
  128758. */
  128759. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  128760. }
  128761. /**
  128762. * Class used to generate realtime reflection / refraction cube textures
  128763. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128764. */
  128765. export class ReflectionProbe {
  128766. /** defines the name of the probe */
  128767. name: string;
  128768. private _scene;
  128769. private _renderTargetTexture;
  128770. private _projectionMatrix;
  128771. private _viewMatrix;
  128772. private _target;
  128773. private _add;
  128774. private _attachedMesh;
  128775. private _invertYAxis;
  128776. /** Gets or sets probe position (center of the cube map) */
  128777. position: Vector3;
  128778. /**
  128779. * Creates a new reflection probe
  128780. * @param name defines the name of the probe
  128781. * @param size defines the texture resolution (for each face)
  128782. * @param scene defines the hosting scene
  128783. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128784. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128785. */
  128786. constructor(
  128787. /** defines the name of the probe */
  128788. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  128789. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128790. get samples(): number;
  128791. set samples(value: number);
  128792. /** Gets or sets the refresh rate to use (on every frame by default) */
  128793. get refreshRate(): number;
  128794. set refreshRate(value: number);
  128795. /**
  128796. * Gets the hosting scene
  128797. * @returns a Scene
  128798. */
  128799. getScene(): Scene;
  128800. /** Gets the internal CubeTexture used to render to */
  128801. get cubeTexture(): RenderTargetTexture;
  128802. /** Gets the list of meshes to render */
  128803. get renderList(): Nullable<AbstractMesh[]>;
  128804. /**
  128805. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128806. * @param mesh defines the mesh to attach to
  128807. */
  128808. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  128809. /**
  128810. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128811. * @param renderingGroupId The rendering group id corresponding to its index
  128812. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128813. */
  128814. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  128815. /**
  128816. * Clean all associated resources
  128817. */
  128818. dispose(): void;
  128819. /**
  128820. * Converts the reflection probe information to a readable string for debug purpose.
  128821. * @param fullDetails Supports for multiple levels of logging within scene loading
  128822. * @returns the human readable reflection probe info
  128823. */
  128824. toString(fullDetails?: boolean): string;
  128825. /**
  128826. * Get the class name of the relfection probe.
  128827. * @returns "ReflectionProbe"
  128828. */
  128829. getClassName(): string;
  128830. /**
  128831. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128832. * @returns The JSON representation of the texture
  128833. */
  128834. serialize(): any;
  128835. /**
  128836. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  128837. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  128838. * @param scene Define the scene the parsed reflection probe should be instantiated in
  128839. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  128840. * @returns The parsed reflection probe if successful
  128841. */
  128842. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  128843. }
  128844. }
  128845. declare module BABYLON {
  128846. /** @hidden */
  128847. export var _BabylonLoaderRegistered: boolean;
  128848. /**
  128849. * Helps setting up some configuration for the babylon file loader.
  128850. */
  128851. export class BabylonFileLoaderConfiguration {
  128852. /**
  128853. * The loader does not allow injecting custom physix engine into the plugins.
  128854. * Unfortunately in ES6, we need to manually inject them into the plugin.
  128855. * So you could set this variable to your engine import to make it work.
  128856. */
  128857. static LoaderInjectedPhysicsEngine: any;
  128858. }
  128859. }
  128860. declare module BABYLON {
  128861. /**
  128862. * The Physically based simple base material of BJS.
  128863. *
  128864. * This enables better naming and convention enforcements on top of the pbrMaterial.
  128865. * It is used as the base class for both the specGloss and metalRough conventions.
  128866. */
  128867. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  128868. /**
  128869. * Number of Simultaneous lights allowed on the material.
  128870. */
  128871. maxSimultaneousLights: number;
  128872. /**
  128873. * If sets to true, disables all the lights affecting the material.
  128874. */
  128875. disableLighting: boolean;
  128876. /**
  128877. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  128878. */
  128879. environmentTexture: BaseTexture;
  128880. /**
  128881. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128882. */
  128883. invertNormalMapX: boolean;
  128884. /**
  128885. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128886. */
  128887. invertNormalMapY: boolean;
  128888. /**
  128889. * Normal map used in the model.
  128890. */
  128891. normalTexture: BaseTexture;
  128892. /**
  128893. * Emissivie color used to self-illuminate the model.
  128894. */
  128895. emissiveColor: Color3;
  128896. /**
  128897. * Emissivie texture used to self-illuminate the model.
  128898. */
  128899. emissiveTexture: BaseTexture;
  128900. /**
  128901. * Occlusion Channel Strenght.
  128902. */
  128903. occlusionStrength: number;
  128904. /**
  128905. * Occlusion Texture of the material (adding extra occlusion effects).
  128906. */
  128907. occlusionTexture: BaseTexture;
  128908. /**
  128909. * Defines the alpha limits in alpha test mode.
  128910. */
  128911. alphaCutOff: number;
  128912. /**
  128913. * Gets the current double sided mode.
  128914. */
  128915. get doubleSided(): boolean;
  128916. /**
  128917. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128918. */
  128919. set doubleSided(value: boolean);
  128920. /**
  128921. * Stores the pre-calculated light information of a mesh in a texture.
  128922. */
  128923. lightmapTexture: BaseTexture;
  128924. /**
  128925. * If true, the light map contains occlusion information instead of lighting info.
  128926. */
  128927. useLightmapAsShadowmap: boolean;
  128928. /**
  128929. * Instantiates a new PBRMaterial instance.
  128930. *
  128931. * @param name The material name
  128932. * @param scene The scene the material will be use in.
  128933. */
  128934. constructor(name: string, scene: Scene);
  128935. getClassName(): string;
  128936. }
  128937. }
  128938. declare module BABYLON {
  128939. /**
  128940. * The PBR material of BJS following the metal roughness convention.
  128941. *
  128942. * This fits to the PBR convention in the GLTF definition:
  128943. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  128944. */
  128945. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  128946. /**
  128947. * The base color has two different interpretations depending on the value of metalness.
  128948. * When the material is a metal, the base color is the specific measured reflectance value
  128949. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  128950. * of the material.
  128951. */
  128952. baseColor: Color3;
  128953. /**
  128954. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  128955. * well as opacity information in the alpha channel.
  128956. */
  128957. baseTexture: BaseTexture;
  128958. /**
  128959. * Specifies the metallic scalar value of the material.
  128960. * Can also be used to scale the metalness values of the metallic texture.
  128961. */
  128962. metallic: number;
  128963. /**
  128964. * Specifies the roughness scalar value of the material.
  128965. * Can also be used to scale the roughness values of the metallic texture.
  128966. */
  128967. roughness: number;
  128968. /**
  128969. * Texture containing both the metallic value in the B channel and the
  128970. * roughness value in the G channel to keep better precision.
  128971. */
  128972. metallicRoughnessTexture: BaseTexture;
  128973. /**
  128974. * Instantiates a new PBRMetalRoughnessMaterial instance.
  128975. *
  128976. * @param name The material name
  128977. * @param scene The scene the material will be use in.
  128978. */
  128979. constructor(name: string, scene: Scene);
  128980. /**
  128981. * Return the currrent class name of the material.
  128982. */
  128983. getClassName(): string;
  128984. /**
  128985. * Makes a duplicate of the current material.
  128986. * @param name - name to use for the new material.
  128987. */
  128988. clone(name: string): PBRMetallicRoughnessMaterial;
  128989. /**
  128990. * Serialize the material to a parsable JSON object.
  128991. */
  128992. serialize(): any;
  128993. /**
  128994. * Parses a JSON object correponding to the serialize function.
  128995. */
  128996. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  128997. }
  128998. }
  128999. declare module BABYLON {
  129000. /**
  129001. * The PBR material of BJS following the specular glossiness convention.
  129002. *
  129003. * This fits to the PBR convention in the GLTF definition:
  129004. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  129005. */
  129006. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  129007. /**
  129008. * Specifies the diffuse color of the material.
  129009. */
  129010. diffuseColor: Color3;
  129011. /**
  129012. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  129013. * channel.
  129014. */
  129015. diffuseTexture: BaseTexture;
  129016. /**
  129017. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  129018. */
  129019. specularColor: Color3;
  129020. /**
  129021. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  129022. */
  129023. glossiness: number;
  129024. /**
  129025. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  129026. */
  129027. specularGlossinessTexture: BaseTexture;
  129028. /**
  129029. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  129030. *
  129031. * @param name The material name
  129032. * @param scene The scene the material will be use in.
  129033. */
  129034. constructor(name: string, scene: Scene);
  129035. /**
  129036. * Return the currrent class name of the material.
  129037. */
  129038. getClassName(): string;
  129039. /**
  129040. * Makes a duplicate of the current material.
  129041. * @param name - name to use for the new material.
  129042. */
  129043. clone(name: string): PBRSpecularGlossinessMaterial;
  129044. /**
  129045. * Serialize the material to a parsable JSON object.
  129046. */
  129047. serialize(): any;
  129048. /**
  129049. * Parses a JSON object correponding to the serialize function.
  129050. */
  129051. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  129052. }
  129053. }
  129054. declare module BABYLON {
  129055. /**
  129056. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  129057. * It can help converting any input color in a desired output one. This can then be used to create effects
  129058. * from sepia, black and white to sixties or futuristic rendering...
  129059. *
  129060. * The only supported format is currently 3dl.
  129061. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  129062. */
  129063. export class ColorGradingTexture extends BaseTexture {
  129064. /**
  129065. * The current texture matrix. (will always be identity in color grading texture)
  129066. */
  129067. private _textureMatrix;
  129068. /**
  129069. * The texture URL.
  129070. */
  129071. url: string;
  129072. /**
  129073. * Empty line regex stored for GC.
  129074. */
  129075. private static _noneEmptyLineRegex;
  129076. private _engine;
  129077. /**
  129078. * Instantiates a ColorGradingTexture from the following parameters.
  129079. *
  129080. * @param url The location of the color gradind data (currently only supporting 3dl)
  129081. * @param scene The scene the texture will be used in
  129082. */
  129083. constructor(url: string, scene: Scene);
  129084. /**
  129085. * Returns the texture matrix used in most of the material.
  129086. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  129087. */
  129088. getTextureMatrix(): Matrix;
  129089. /**
  129090. * Occurs when the file being loaded is a .3dl LUT file.
  129091. */
  129092. private load3dlTexture;
  129093. /**
  129094. * Starts the loading process of the texture.
  129095. */
  129096. private loadTexture;
  129097. /**
  129098. * Clones the color gradind texture.
  129099. */
  129100. clone(): ColorGradingTexture;
  129101. /**
  129102. * Called during delayed load for textures.
  129103. */
  129104. delayLoad(): void;
  129105. /**
  129106. * Parses a color grading texture serialized by Babylon.
  129107. * @param parsedTexture The texture information being parsedTexture
  129108. * @param scene The scene to load the texture in
  129109. * @param rootUrl The root url of the data assets to load
  129110. * @return A color gradind texture
  129111. */
  129112. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  129113. /**
  129114. * Serializes the LUT texture to json format.
  129115. */
  129116. serialize(): any;
  129117. }
  129118. }
  129119. declare module BABYLON {
  129120. /**
  129121. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  129122. */
  129123. export class EquiRectangularCubeTexture extends BaseTexture {
  129124. /** The six faces of the cube. */
  129125. private static _FacesMapping;
  129126. private _noMipmap;
  129127. private _onLoad;
  129128. private _onError;
  129129. /** The size of the cubemap. */
  129130. private _size;
  129131. /** The buffer of the image. */
  129132. private _buffer;
  129133. /** The width of the input image. */
  129134. private _width;
  129135. /** The height of the input image. */
  129136. private _height;
  129137. /** The URL to the image. */
  129138. url: string;
  129139. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  129140. coordinatesMode: number;
  129141. /**
  129142. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  129143. * @param url The location of the image
  129144. * @param scene The scene the texture will be used in
  129145. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129146. * @param noMipmap Forces to not generate the mipmap if true
  129147. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129148. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129149. * @param onLoad — defines a callback called when texture is loaded
  129150. * @param onError — defines a callback called if there is an error
  129151. */
  129152. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  129153. /**
  129154. * Load the image data, by putting the image on a canvas and extracting its buffer.
  129155. */
  129156. private loadImage;
  129157. /**
  129158. * Convert the image buffer into a cubemap and create a CubeTexture.
  129159. */
  129160. private loadTexture;
  129161. /**
  129162. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  129163. * @param buffer The ArrayBuffer that should be converted.
  129164. * @returns The buffer as Float32Array.
  129165. */
  129166. private getFloat32ArrayFromArrayBuffer;
  129167. /**
  129168. * Get the current class name of the texture useful for serialization or dynamic coding.
  129169. * @returns "EquiRectangularCubeTexture"
  129170. */
  129171. getClassName(): string;
  129172. /**
  129173. * Create a clone of the current EquiRectangularCubeTexture and return it.
  129174. * @returns A clone of the current EquiRectangularCubeTexture.
  129175. */
  129176. clone(): EquiRectangularCubeTexture;
  129177. }
  129178. }
  129179. declare module BABYLON {
  129180. /**
  129181. * Based on jsTGALoader - Javascript loader for TGA file
  129182. * By Vincent Thibault
  129183. * @see http://blog.robrowser.com/javascript-tga-loader.html
  129184. */
  129185. export class TGATools {
  129186. private static _TYPE_INDEXED;
  129187. private static _TYPE_RGB;
  129188. private static _TYPE_GREY;
  129189. private static _TYPE_RLE_INDEXED;
  129190. private static _TYPE_RLE_RGB;
  129191. private static _TYPE_RLE_GREY;
  129192. private static _ORIGIN_MASK;
  129193. private static _ORIGIN_SHIFT;
  129194. private static _ORIGIN_BL;
  129195. private static _ORIGIN_BR;
  129196. private static _ORIGIN_UL;
  129197. private static _ORIGIN_UR;
  129198. /**
  129199. * Gets the header of a TGA file
  129200. * @param data defines the TGA data
  129201. * @returns the header
  129202. */
  129203. static GetTGAHeader(data: Uint8Array): any;
  129204. /**
  129205. * Uploads TGA content to a Babylon Texture
  129206. * @hidden
  129207. */
  129208. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  129209. /** @hidden */
  129210. 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;
  129211. /** @hidden */
  129212. 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;
  129213. /** @hidden */
  129214. 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;
  129215. /** @hidden */
  129216. 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;
  129217. /** @hidden */
  129218. 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;
  129219. /** @hidden */
  129220. 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;
  129221. }
  129222. }
  129223. declare module BABYLON {
  129224. /**
  129225. * Implementation of the TGA Texture Loader.
  129226. * @hidden
  129227. */
  129228. export class _TGATextureLoader implements IInternalTextureLoader {
  129229. /**
  129230. * Defines wether the loader supports cascade loading the different faces.
  129231. */
  129232. readonly supportCascades: boolean;
  129233. /**
  129234. * This returns if the loader support the current file information.
  129235. * @param extension defines the file extension of the file being loaded
  129236. * @returns true if the loader can load the specified file
  129237. */
  129238. canLoad(extension: string): boolean;
  129239. /**
  129240. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129241. * @param data contains the texture data
  129242. * @param texture defines the BabylonJS internal texture
  129243. * @param createPolynomials will be true if polynomials have been requested
  129244. * @param onLoad defines the callback to trigger once the texture is ready
  129245. * @param onError defines the callback to trigger in case of error
  129246. */
  129247. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129248. /**
  129249. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129250. * @param data contains the texture data
  129251. * @param texture defines the BabylonJS internal texture
  129252. * @param callback defines the method to call once ready to upload
  129253. */
  129254. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129255. }
  129256. }
  129257. declare module BABYLON {
  129258. /**
  129259. * Info about the .basis files
  129260. */
  129261. class BasisFileInfo {
  129262. /**
  129263. * If the file has alpha
  129264. */
  129265. hasAlpha: boolean;
  129266. /**
  129267. * Info about each image of the basis file
  129268. */
  129269. images: Array<{
  129270. levels: Array<{
  129271. width: number;
  129272. height: number;
  129273. transcodedPixels: ArrayBufferView;
  129274. }>;
  129275. }>;
  129276. }
  129277. /**
  129278. * Result of transcoding a basis file
  129279. */
  129280. class TranscodeResult {
  129281. /**
  129282. * Info about the .basis file
  129283. */
  129284. fileInfo: BasisFileInfo;
  129285. /**
  129286. * Format to use when loading the file
  129287. */
  129288. format: number;
  129289. }
  129290. /**
  129291. * Configuration options for the Basis transcoder
  129292. */
  129293. export class BasisTranscodeConfiguration {
  129294. /**
  129295. * Supported compression formats used to determine the supported output format of the transcoder
  129296. */
  129297. supportedCompressionFormats?: {
  129298. /**
  129299. * etc1 compression format
  129300. */
  129301. etc1?: boolean;
  129302. /**
  129303. * s3tc compression format
  129304. */
  129305. s3tc?: boolean;
  129306. /**
  129307. * pvrtc compression format
  129308. */
  129309. pvrtc?: boolean;
  129310. /**
  129311. * etc2 compression format
  129312. */
  129313. etc2?: boolean;
  129314. };
  129315. /**
  129316. * If mipmap levels should be loaded for transcoded images (Default: true)
  129317. */
  129318. loadMipmapLevels?: boolean;
  129319. /**
  129320. * Index of a single image to load (Default: all images)
  129321. */
  129322. loadSingleImage?: number;
  129323. }
  129324. /**
  129325. * Used to load .Basis files
  129326. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  129327. */
  129328. export class BasisTools {
  129329. private static _IgnoreSupportedFormats;
  129330. /**
  129331. * URL to use when loading the basis transcoder
  129332. */
  129333. static JSModuleURL: string;
  129334. /**
  129335. * URL to use when loading the wasm module for the transcoder
  129336. */
  129337. static WasmModuleURL: string;
  129338. /**
  129339. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  129340. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  129341. * @returns internal format corresponding to the Basis format
  129342. */
  129343. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  129344. private static _WorkerPromise;
  129345. private static _Worker;
  129346. private static _actionId;
  129347. private static _CreateWorkerAsync;
  129348. /**
  129349. * Transcodes a loaded image file to compressed pixel data
  129350. * @param data image data to transcode
  129351. * @param config configuration options for the transcoding
  129352. * @returns a promise resulting in the transcoded image
  129353. */
  129354. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  129355. /**
  129356. * Loads a texture from the transcode result
  129357. * @param texture texture load to
  129358. * @param transcodeResult the result of transcoding the basis file to load from
  129359. */
  129360. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  129361. }
  129362. }
  129363. declare module BABYLON {
  129364. /**
  129365. * Loader for .basis file format
  129366. */
  129367. export class _BasisTextureLoader implements IInternalTextureLoader {
  129368. /**
  129369. * Defines whether the loader supports cascade loading the different faces.
  129370. */
  129371. readonly supportCascades: boolean;
  129372. /**
  129373. * This returns if the loader support the current file information.
  129374. * @param extension defines the file extension of the file being loaded
  129375. * @returns true if the loader can load the specified file
  129376. */
  129377. canLoad(extension: string): boolean;
  129378. /**
  129379. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129380. * @param data contains the texture data
  129381. * @param texture defines the BabylonJS internal texture
  129382. * @param createPolynomials will be true if polynomials have been requested
  129383. * @param onLoad defines the callback to trigger once the texture is ready
  129384. * @param onError defines the callback to trigger in case of error
  129385. */
  129386. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129387. /**
  129388. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129389. * @param data contains the texture data
  129390. * @param texture defines the BabylonJS internal texture
  129391. * @param callback defines the method to call once ready to upload
  129392. */
  129393. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129394. }
  129395. }
  129396. declare module BABYLON {
  129397. /**
  129398. * 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.
  129399. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129400. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129401. */
  129402. export class CustomProceduralTexture extends ProceduralTexture {
  129403. private _animate;
  129404. private _time;
  129405. private _config;
  129406. private _texturePath;
  129407. /**
  129408. * Instantiates a new Custom Procedural Texture.
  129409. * 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.
  129410. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129411. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129412. * @param name Define the name of the texture
  129413. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  129414. * @param size Define the size of the texture to create
  129415. * @param scene Define the scene the texture belongs to
  129416. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  129417. * @param generateMipMaps Define if the texture should creates mip maps or not
  129418. */
  129419. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129420. private _loadJson;
  129421. /**
  129422. * Is the texture ready to be used ? (rendered at least once)
  129423. * @returns true if ready, otherwise, false.
  129424. */
  129425. isReady(): boolean;
  129426. /**
  129427. * Render the texture to its associated render target.
  129428. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  129429. */
  129430. render(useCameraPostProcess?: boolean): void;
  129431. /**
  129432. * Update the list of dependant textures samplers in the shader.
  129433. */
  129434. updateTextures(): void;
  129435. /**
  129436. * Update the uniform values of the procedural texture in the shader.
  129437. */
  129438. updateShaderUniforms(): void;
  129439. /**
  129440. * Define if the texture animates or not.
  129441. */
  129442. get animate(): boolean;
  129443. set animate(value: boolean);
  129444. }
  129445. }
  129446. declare module BABYLON {
  129447. /** @hidden */
  129448. export var noisePixelShader: {
  129449. name: string;
  129450. shader: string;
  129451. };
  129452. }
  129453. declare module BABYLON {
  129454. /**
  129455. * Class used to generate noise procedural textures
  129456. */
  129457. export class NoiseProceduralTexture extends ProceduralTexture {
  129458. private _time;
  129459. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  129460. brightness: number;
  129461. /** Defines the number of octaves to process */
  129462. octaves: number;
  129463. /** Defines the level of persistence (0.8 by default) */
  129464. persistence: number;
  129465. /** Gets or sets animation speed factor (default is 1) */
  129466. animationSpeedFactor: number;
  129467. /**
  129468. * Creates a new NoiseProceduralTexture
  129469. * @param name defines the name fo the texture
  129470. * @param size defines the size of the texture (default is 256)
  129471. * @param scene defines the hosting scene
  129472. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  129473. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  129474. */
  129475. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129476. private _updateShaderUniforms;
  129477. protected _getDefines(): string;
  129478. /** Generate the current state of the procedural texture */
  129479. render(useCameraPostProcess?: boolean): void;
  129480. /**
  129481. * Serializes this noise procedural texture
  129482. * @returns a serialized noise procedural texture object
  129483. */
  129484. serialize(): any;
  129485. /**
  129486. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  129487. * @param parsedTexture defines parsed texture data
  129488. * @param scene defines the current scene
  129489. * @param rootUrl defines the root URL containing noise procedural texture information
  129490. * @returns a parsed NoiseProceduralTexture
  129491. */
  129492. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  129493. }
  129494. }
  129495. declare module BABYLON {
  129496. /**
  129497. * Raw cube texture where the raw buffers are passed in
  129498. */
  129499. export class RawCubeTexture extends CubeTexture {
  129500. /**
  129501. * Creates a cube texture where the raw buffers are passed in.
  129502. * @param scene defines the scene the texture is attached to
  129503. * @param data defines the array of data to use to create each face
  129504. * @param size defines the size of the textures
  129505. * @param format defines the format of the data
  129506. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129507. * @param generateMipMaps defines if the engine should generate the mip levels
  129508. * @param invertY defines if data must be stored with Y axis inverted
  129509. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129510. * @param compression defines the compression used (null by default)
  129511. */
  129512. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  129513. /**
  129514. * Updates the raw cube texture.
  129515. * @param data defines the data to store
  129516. * @param format defines the data format
  129517. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129518. * @param invertY defines if data must be stored with Y axis inverted
  129519. * @param compression defines the compression used (null by default)
  129520. * @param level defines which level of the texture to update
  129521. */
  129522. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  129523. /**
  129524. * Updates a raw cube texture with RGBD encoded data.
  129525. * @param data defines the array of data [mipmap][face] to use to create each face
  129526. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  129527. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129528. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129529. * @returns a promsie that resolves when the operation is complete
  129530. */
  129531. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  129532. /**
  129533. * Clones the raw cube texture.
  129534. * @return a new cube texture
  129535. */
  129536. clone(): CubeTexture;
  129537. /** @hidden */
  129538. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129539. }
  129540. }
  129541. declare module BABYLON {
  129542. /**
  129543. * Class used to store 3D textures containing user data
  129544. */
  129545. export class RawTexture3D extends Texture {
  129546. /** Gets or sets the texture format to use */
  129547. format: number;
  129548. private _engine;
  129549. /**
  129550. * Create a new RawTexture3D
  129551. * @param data defines the data of the texture
  129552. * @param width defines the width of the texture
  129553. * @param height defines the height of the texture
  129554. * @param depth defines the depth of the texture
  129555. * @param format defines the texture format to use
  129556. * @param scene defines the hosting scene
  129557. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129558. * @param invertY defines if texture must be stored with Y axis inverted
  129559. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129560. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129561. */
  129562. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129563. /** Gets or sets the texture format to use */
  129564. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129565. /**
  129566. * Update the texture with new data
  129567. * @param data defines the data to store in the texture
  129568. */
  129569. update(data: ArrayBufferView): void;
  129570. }
  129571. }
  129572. declare module BABYLON {
  129573. /**
  129574. * Class used to store 2D array textures containing user data
  129575. */
  129576. export class RawTexture2DArray extends Texture {
  129577. /** Gets or sets the texture format to use */
  129578. format: number;
  129579. private _engine;
  129580. /**
  129581. * Create a new RawTexture2DArray
  129582. * @param data defines the data of the texture
  129583. * @param width defines the width of the texture
  129584. * @param height defines the height of the texture
  129585. * @param depth defines the number of layers of the texture
  129586. * @param format defines the texture format to use
  129587. * @param scene defines the hosting scene
  129588. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129589. * @param invertY defines if texture must be stored with Y axis inverted
  129590. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129591. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129592. */
  129593. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129594. /** Gets or sets the texture format to use */
  129595. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129596. /**
  129597. * Update the texture with new data
  129598. * @param data defines the data to store in the texture
  129599. */
  129600. update(data: ArrayBufferView): void;
  129601. }
  129602. }
  129603. declare module BABYLON {
  129604. /**
  129605. * Creates a refraction texture used by refraction channel of the standard material.
  129606. * It is like a mirror but to see through a material.
  129607. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129608. */
  129609. export class RefractionTexture extends RenderTargetTexture {
  129610. /**
  129611. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129612. * 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.
  129613. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129614. */
  129615. refractionPlane: Plane;
  129616. /**
  129617. * Define how deep under the surface we should see.
  129618. */
  129619. depth: number;
  129620. /**
  129621. * Creates a refraction texture used by refraction channel of the standard material.
  129622. * It is like a mirror but to see through a material.
  129623. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129624. * @param name Define the texture name
  129625. * @param size Define the size of the underlying texture
  129626. * @param scene Define the scene the refraction belongs to
  129627. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129628. */
  129629. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129630. /**
  129631. * Clone the refraction texture.
  129632. * @returns the cloned texture
  129633. */
  129634. clone(): RefractionTexture;
  129635. /**
  129636. * Serialize the texture to a JSON representation you could use in Parse later on
  129637. * @returns the serialized JSON representation
  129638. */
  129639. serialize(): any;
  129640. }
  129641. }
  129642. declare module BABYLON {
  129643. /**
  129644. * Defines the options related to the creation of an HtmlElementTexture
  129645. */
  129646. export interface IHtmlElementTextureOptions {
  129647. /**
  129648. * Defines wether mip maps should be created or not.
  129649. */
  129650. generateMipMaps?: boolean;
  129651. /**
  129652. * Defines the sampling mode of the texture.
  129653. */
  129654. samplingMode?: number;
  129655. /**
  129656. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129657. */
  129658. engine: Nullable<ThinEngine>;
  129659. /**
  129660. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129661. */
  129662. scene: Nullable<Scene>;
  129663. }
  129664. /**
  129665. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129666. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129667. * is automatically managed.
  129668. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129669. * in your application.
  129670. *
  129671. * As the update is not automatic, you need to call them manually.
  129672. */
  129673. export class HtmlElementTexture extends BaseTexture {
  129674. /**
  129675. * The texture URL.
  129676. */
  129677. element: HTMLVideoElement | HTMLCanvasElement;
  129678. private static readonly DefaultOptions;
  129679. private _textureMatrix;
  129680. private _engine;
  129681. private _isVideo;
  129682. private _generateMipMaps;
  129683. private _samplingMode;
  129684. /**
  129685. * Instantiates a HtmlElementTexture from the following parameters.
  129686. *
  129687. * @param name Defines the name of the texture
  129688. * @param element Defines the video or canvas the texture is filled with
  129689. * @param options Defines the other none mandatory texture creation options
  129690. */
  129691. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129692. private _createInternalTexture;
  129693. /**
  129694. * Returns the texture matrix used in most of the material.
  129695. */
  129696. getTextureMatrix(): Matrix;
  129697. /**
  129698. * Updates the content of the texture.
  129699. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129700. */
  129701. update(invertY?: Nullable<boolean>): void;
  129702. }
  129703. }
  129704. declare module BABYLON {
  129705. /**
  129706. * Defines the basic options interface of a TexturePacker Frame
  129707. */
  129708. export interface ITexturePackerFrame {
  129709. /**
  129710. * The frame ID
  129711. */
  129712. id: number;
  129713. /**
  129714. * The frames Scale
  129715. */
  129716. scale: Vector2;
  129717. /**
  129718. * The Frames offset
  129719. */
  129720. offset: Vector2;
  129721. }
  129722. /**
  129723. * This is a support class for frame Data on texture packer sets.
  129724. */
  129725. export class TexturePackerFrame implements ITexturePackerFrame {
  129726. /**
  129727. * The frame ID
  129728. */
  129729. id: number;
  129730. /**
  129731. * The frames Scale
  129732. */
  129733. scale: Vector2;
  129734. /**
  129735. * The Frames offset
  129736. */
  129737. offset: Vector2;
  129738. /**
  129739. * Initializes a texture package frame.
  129740. * @param id The numerical frame identifier
  129741. * @param scale Scalar Vector2 for UV frame
  129742. * @param offset Vector2 for the frame position in UV units.
  129743. * @returns TexturePackerFrame
  129744. */
  129745. constructor(id: number, scale: Vector2, offset: Vector2);
  129746. }
  129747. }
  129748. declare module BABYLON {
  129749. /**
  129750. * Defines the basic options interface of a TexturePacker
  129751. */
  129752. export interface ITexturePackerOptions {
  129753. /**
  129754. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  129755. */
  129756. map?: string[];
  129757. /**
  129758. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129759. */
  129760. uvsIn?: string;
  129761. /**
  129762. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129763. */
  129764. uvsOut?: string;
  129765. /**
  129766. * number representing the layout style. Defaults to LAYOUT_STRIP
  129767. */
  129768. layout?: number;
  129769. /**
  129770. * number of columns if using custom column count layout(2). This defaults to 4.
  129771. */
  129772. colnum?: number;
  129773. /**
  129774. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  129775. */
  129776. updateInputMeshes?: boolean;
  129777. /**
  129778. * boolean flag to dispose all the source textures. Defaults to true.
  129779. */
  129780. disposeSources?: boolean;
  129781. /**
  129782. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  129783. */
  129784. fillBlanks?: boolean;
  129785. /**
  129786. * string value representing the context fill style color. Defaults to 'black'.
  129787. */
  129788. customFillColor?: string;
  129789. /**
  129790. * Width and Height Value of each Frame in the TexturePacker Sets
  129791. */
  129792. frameSize?: number;
  129793. /**
  129794. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  129795. */
  129796. paddingRatio?: number;
  129797. /**
  129798. * Number that declares the fill method for the padding gutter.
  129799. */
  129800. paddingMode?: number;
  129801. /**
  129802. * If in SUBUV_COLOR padding mode what color to use.
  129803. */
  129804. paddingColor?: Color3 | Color4;
  129805. }
  129806. /**
  129807. * Defines the basic interface of a TexturePacker JSON File
  129808. */
  129809. export interface ITexturePackerJSON {
  129810. /**
  129811. * The frame ID
  129812. */
  129813. name: string;
  129814. /**
  129815. * The base64 channel data
  129816. */
  129817. sets: any;
  129818. /**
  129819. * The options of the Packer
  129820. */
  129821. options: ITexturePackerOptions;
  129822. /**
  129823. * The frame data of the Packer
  129824. */
  129825. frames: Array<number>;
  129826. }
  129827. /**
  129828. * This is a support class that generates a series of packed texture sets.
  129829. * @see https://doc.babylonjs.com/babylon101/materials
  129830. */
  129831. export class TexturePacker {
  129832. /** Packer Layout Constant 0 */
  129833. static readonly LAYOUT_STRIP: number;
  129834. /** Packer Layout Constant 1 */
  129835. static readonly LAYOUT_POWER2: number;
  129836. /** Packer Layout Constant 2 */
  129837. static readonly LAYOUT_COLNUM: number;
  129838. /** Packer Layout Constant 0 */
  129839. static readonly SUBUV_WRAP: number;
  129840. /** Packer Layout Constant 1 */
  129841. static readonly SUBUV_EXTEND: number;
  129842. /** Packer Layout Constant 2 */
  129843. static readonly SUBUV_COLOR: number;
  129844. /** The Name of the Texture Package */
  129845. name: string;
  129846. /** The scene scope of the TexturePacker */
  129847. scene: Scene;
  129848. /** The Meshes to target */
  129849. meshes: AbstractMesh[];
  129850. /** Arguments passed with the Constructor */
  129851. options: ITexturePackerOptions;
  129852. /** The promise that is started upon initialization */
  129853. promise: Nullable<Promise<TexturePacker | string>>;
  129854. /** The Container object for the channel sets that are generated */
  129855. sets: object;
  129856. /** The Container array for the frames that are generated */
  129857. frames: TexturePackerFrame[];
  129858. /** The expected number of textures the system is parsing. */
  129859. private _expecting;
  129860. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  129861. private _paddingValue;
  129862. /**
  129863. * Initializes a texture package series from an array of meshes or a single mesh.
  129864. * @param name The name of the package
  129865. * @param meshes The target meshes to compose the package from
  129866. * @param options The arguments that texture packer should follow while building.
  129867. * @param scene The scene which the textures are scoped to.
  129868. * @returns TexturePacker
  129869. */
  129870. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  129871. /**
  129872. * Starts the package process
  129873. * @param resolve The promises resolution function
  129874. * @returns TexturePacker
  129875. */
  129876. private _createFrames;
  129877. /**
  129878. * Calculates the Size of the Channel Sets
  129879. * @returns Vector2
  129880. */
  129881. private _calculateSize;
  129882. /**
  129883. * Calculates the UV data for the frames.
  129884. * @param baseSize the base frameSize
  129885. * @param padding the base frame padding
  129886. * @param dtSize size of the Dynamic Texture for that channel
  129887. * @param dtUnits is 1/dtSize
  129888. * @param update flag to update the input meshes
  129889. */
  129890. private _calculateMeshUVFrames;
  129891. /**
  129892. * Calculates the frames Offset.
  129893. * @param index of the frame
  129894. * @returns Vector2
  129895. */
  129896. private _getFrameOffset;
  129897. /**
  129898. * Updates a Mesh to the frame data
  129899. * @param mesh that is the target
  129900. * @param frameID or the frame index
  129901. */
  129902. private _updateMeshUV;
  129903. /**
  129904. * Updates a Meshes materials to use the texture packer channels
  129905. * @param m is the mesh to target
  129906. * @param force all channels on the packer to be set.
  129907. */
  129908. private _updateTextureReferences;
  129909. /**
  129910. * Public method to set a Mesh to a frame
  129911. * @param m that is the target
  129912. * @param frameID or the frame index
  129913. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  129914. */
  129915. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  129916. /**
  129917. * Starts the async promise to compile the texture packer.
  129918. * @returns Promise<void>
  129919. */
  129920. processAsync(): Promise<void>;
  129921. /**
  129922. * Disposes all textures associated with this packer
  129923. */
  129924. dispose(): void;
  129925. /**
  129926. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  129927. * @param imageType is the image type to use.
  129928. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  129929. */
  129930. download(imageType?: string, quality?: number): void;
  129931. /**
  129932. * Public method to load a texturePacker JSON file.
  129933. * @param data of the JSON file in string format.
  129934. */
  129935. updateFromJSON(data: string): void;
  129936. }
  129937. }
  129938. declare module BABYLON {
  129939. /**
  129940. * Enum used to define the target of a block
  129941. */
  129942. export enum NodeMaterialBlockTargets {
  129943. /** Vertex shader */
  129944. Vertex = 1,
  129945. /** Fragment shader */
  129946. Fragment = 2,
  129947. /** Neutral */
  129948. Neutral = 4,
  129949. /** Vertex and Fragment */
  129950. VertexAndFragment = 3
  129951. }
  129952. }
  129953. declare module BABYLON {
  129954. /**
  129955. * Defines the kind of connection point for node based material
  129956. */
  129957. export enum NodeMaterialBlockConnectionPointTypes {
  129958. /** Float */
  129959. Float = 1,
  129960. /** Int */
  129961. Int = 2,
  129962. /** Vector2 */
  129963. Vector2 = 4,
  129964. /** Vector3 */
  129965. Vector3 = 8,
  129966. /** Vector4 */
  129967. Vector4 = 16,
  129968. /** Color3 */
  129969. Color3 = 32,
  129970. /** Color4 */
  129971. Color4 = 64,
  129972. /** Matrix */
  129973. Matrix = 128,
  129974. /** Detect type based on connection */
  129975. AutoDetect = 1024,
  129976. /** Output type that will be defined by input type */
  129977. BasedOnInput = 2048
  129978. }
  129979. }
  129980. declare module BABYLON {
  129981. /**
  129982. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  129983. */
  129984. export enum NodeMaterialBlockConnectionPointMode {
  129985. /** Value is an uniform */
  129986. Uniform = 0,
  129987. /** Value is a mesh attribute */
  129988. Attribute = 1,
  129989. /** Value is a varying between vertex and fragment shaders */
  129990. Varying = 2,
  129991. /** Mode is undefined */
  129992. Undefined = 3
  129993. }
  129994. }
  129995. declare module BABYLON {
  129996. /**
  129997. * Enum used to define system values e.g. values automatically provided by the system
  129998. */
  129999. export enum NodeMaterialSystemValues {
  130000. /** World */
  130001. World = 1,
  130002. /** View */
  130003. View = 2,
  130004. /** Projection */
  130005. Projection = 3,
  130006. /** ViewProjection */
  130007. ViewProjection = 4,
  130008. /** WorldView */
  130009. WorldView = 5,
  130010. /** WorldViewProjection */
  130011. WorldViewProjection = 6,
  130012. /** CameraPosition */
  130013. CameraPosition = 7,
  130014. /** Fog Color */
  130015. FogColor = 8,
  130016. /** Delta time */
  130017. DeltaTime = 9
  130018. }
  130019. }
  130020. declare module BABYLON {
  130021. /**
  130022. * Root class for all node material optimizers
  130023. */
  130024. export class NodeMaterialOptimizer {
  130025. /**
  130026. * Function used to optimize a NodeMaterial graph
  130027. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  130028. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  130029. */
  130030. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  130031. }
  130032. }
  130033. declare module BABYLON {
  130034. /**
  130035. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  130036. */
  130037. export class TransformBlock extends NodeMaterialBlock {
  130038. /**
  130039. * Defines the value to use to complement W value to transform it to a Vector4
  130040. */
  130041. complementW: number;
  130042. /**
  130043. * Defines the value to use to complement z value to transform it to a Vector4
  130044. */
  130045. complementZ: number;
  130046. /**
  130047. * Creates a new TransformBlock
  130048. * @param name defines the block name
  130049. */
  130050. constructor(name: string);
  130051. /**
  130052. * Gets the current class name
  130053. * @returns the class name
  130054. */
  130055. getClassName(): string;
  130056. /**
  130057. * Gets the vector input
  130058. */
  130059. get vector(): NodeMaterialConnectionPoint;
  130060. /**
  130061. * Gets the output component
  130062. */
  130063. get output(): NodeMaterialConnectionPoint;
  130064. /**
  130065. * Gets the xyz output component
  130066. */
  130067. get xyz(): NodeMaterialConnectionPoint;
  130068. /**
  130069. * Gets the matrix transform input
  130070. */
  130071. get transform(): NodeMaterialConnectionPoint;
  130072. protected _buildBlock(state: NodeMaterialBuildState): this;
  130073. serialize(): any;
  130074. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130075. protected _dumpPropertiesCode(): string;
  130076. }
  130077. }
  130078. declare module BABYLON {
  130079. /**
  130080. * Block used to output the vertex position
  130081. */
  130082. export class VertexOutputBlock extends NodeMaterialBlock {
  130083. /**
  130084. * Creates a new VertexOutputBlock
  130085. * @param name defines the block name
  130086. */
  130087. constructor(name: string);
  130088. /**
  130089. * Gets the current class name
  130090. * @returns the class name
  130091. */
  130092. getClassName(): string;
  130093. /**
  130094. * Gets the vector input component
  130095. */
  130096. get vector(): NodeMaterialConnectionPoint;
  130097. protected _buildBlock(state: NodeMaterialBuildState): this;
  130098. }
  130099. }
  130100. declare module BABYLON {
  130101. /**
  130102. * Block used to output the final color
  130103. */
  130104. export class FragmentOutputBlock extends NodeMaterialBlock {
  130105. /**
  130106. * Create a new FragmentOutputBlock
  130107. * @param name defines the block name
  130108. */
  130109. constructor(name: string);
  130110. /**
  130111. * Gets the current class name
  130112. * @returns the class name
  130113. */
  130114. getClassName(): string;
  130115. /**
  130116. * Gets the rgba input component
  130117. */
  130118. get rgba(): NodeMaterialConnectionPoint;
  130119. /**
  130120. * Gets the rgb input component
  130121. */
  130122. get rgb(): NodeMaterialConnectionPoint;
  130123. /**
  130124. * Gets the a input component
  130125. */
  130126. get a(): NodeMaterialConnectionPoint;
  130127. protected _buildBlock(state: NodeMaterialBuildState): this;
  130128. }
  130129. }
  130130. declare module BABYLON {
  130131. /**
  130132. * Block used to read a reflection texture from a sampler
  130133. */
  130134. export class ReflectionTextureBlock extends NodeMaterialBlock {
  130135. private _define3DName;
  130136. private _defineCubicName;
  130137. private _defineExplicitName;
  130138. private _defineProjectionName;
  130139. private _defineLocalCubicName;
  130140. private _defineSphericalName;
  130141. private _definePlanarName;
  130142. private _defineEquirectangularName;
  130143. private _defineMirroredEquirectangularFixedName;
  130144. private _defineEquirectangularFixedName;
  130145. private _defineSkyboxName;
  130146. private _cubeSamplerName;
  130147. private _2DSamplerName;
  130148. private _positionUVWName;
  130149. private _directionWName;
  130150. private _reflectionCoordsName;
  130151. private _reflection2DCoordsName;
  130152. private _reflectionColorName;
  130153. private _reflectionMatrixName;
  130154. /**
  130155. * Gets or sets the texture associated with the node
  130156. */
  130157. texture: Nullable<BaseTexture>;
  130158. /**
  130159. * Create a new TextureBlock
  130160. * @param name defines the block name
  130161. */
  130162. constructor(name: string);
  130163. /**
  130164. * Gets the current class name
  130165. * @returns the class name
  130166. */
  130167. getClassName(): string;
  130168. /**
  130169. * Gets the world position input component
  130170. */
  130171. get position(): NodeMaterialConnectionPoint;
  130172. /**
  130173. * Gets the world position input component
  130174. */
  130175. get worldPosition(): NodeMaterialConnectionPoint;
  130176. /**
  130177. * Gets the world normal input component
  130178. */
  130179. get worldNormal(): NodeMaterialConnectionPoint;
  130180. /**
  130181. * Gets the world input component
  130182. */
  130183. get world(): NodeMaterialConnectionPoint;
  130184. /**
  130185. * Gets the camera (or eye) position component
  130186. */
  130187. get cameraPosition(): NodeMaterialConnectionPoint;
  130188. /**
  130189. * Gets the view input component
  130190. */
  130191. get view(): NodeMaterialConnectionPoint;
  130192. /**
  130193. * Gets the rgb output component
  130194. */
  130195. get rgb(): NodeMaterialConnectionPoint;
  130196. /**
  130197. * Gets the r output component
  130198. */
  130199. get r(): NodeMaterialConnectionPoint;
  130200. /**
  130201. * Gets the g output component
  130202. */
  130203. get g(): NodeMaterialConnectionPoint;
  130204. /**
  130205. * Gets the b output component
  130206. */
  130207. get b(): NodeMaterialConnectionPoint;
  130208. autoConfigure(material: NodeMaterial): void;
  130209. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130210. isReady(): boolean;
  130211. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130212. private _injectVertexCode;
  130213. private _writeOutput;
  130214. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130215. protected _dumpPropertiesCode(): string;
  130216. serialize(): any;
  130217. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130218. }
  130219. }
  130220. declare module BABYLON {
  130221. /**
  130222. * Interface used to configure the node material editor
  130223. */
  130224. export interface INodeMaterialEditorOptions {
  130225. /** Define the URl to load node editor script */
  130226. editorURL?: string;
  130227. }
  130228. /** @hidden */
  130229. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  130230. NORMAL: boolean;
  130231. TANGENT: boolean;
  130232. UV1: boolean;
  130233. /** BONES */
  130234. NUM_BONE_INFLUENCERS: number;
  130235. BonesPerMesh: number;
  130236. BONETEXTURE: boolean;
  130237. /** MORPH TARGETS */
  130238. MORPHTARGETS: boolean;
  130239. MORPHTARGETS_NORMAL: boolean;
  130240. MORPHTARGETS_TANGENT: boolean;
  130241. MORPHTARGETS_UV: boolean;
  130242. NUM_MORPH_INFLUENCERS: number;
  130243. /** IMAGE PROCESSING */
  130244. IMAGEPROCESSING: boolean;
  130245. VIGNETTE: boolean;
  130246. VIGNETTEBLENDMODEMULTIPLY: boolean;
  130247. VIGNETTEBLENDMODEOPAQUE: boolean;
  130248. TONEMAPPING: boolean;
  130249. TONEMAPPING_ACES: boolean;
  130250. CONTRAST: boolean;
  130251. EXPOSURE: boolean;
  130252. COLORCURVES: boolean;
  130253. COLORGRADING: boolean;
  130254. COLORGRADING3D: boolean;
  130255. SAMPLER3DGREENDEPTH: boolean;
  130256. SAMPLER3DBGRMAP: boolean;
  130257. IMAGEPROCESSINGPOSTPROCESS: boolean;
  130258. /** MISC. */
  130259. BUMPDIRECTUV: number;
  130260. constructor();
  130261. setValue(name: string, value: boolean): void;
  130262. }
  130263. /**
  130264. * Class used to configure NodeMaterial
  130265. */
  130266. export interface INodeMaterialOptions {
  130267. /**
  130268. * Defines if blocks should emit comments
  130269. */
  130270. emitComments: boolean;
  130271. }
  130272. /**
  130273. * Class used to create a node based material built by assembling shader blocks
  130274. */
  130275. export class NodeMaterial extends PushMaterial {
  130276. private static _BuildIdGenerator;
  130277. private _options;
  130278. private _vertexCompilationState;
  130279. private _fragmentCompilationState;
  130280. private _sharedData;
  130281. private _buildId;
  130282. private _buildWasSuccessful;
  130283. private _cachedWorldViewMatrix;
  130284. private _cachedWorldViewProjectionMatrix;
  130285. private _optimizers;
  130286. private _animationFrame;
  130287. /** Define the Url to load node editor script */
  130288. static EditorURL: string;
  130289. /** Define the Url to load snippets */
  130290. static SnippetUrl: string;
  130291. private BJSNODEMATERIALEDITOR;
  130292. /** Get the inspector from bundle or global */
  130293. private _getGlobalNodeMaterialEditor;
  130294. /**
  130295. * Gets or sets data used by visual editor
  130296. * @see https://nme.babylonjs.com
  130297. */
  130298. editorData: any;
  130299. /**
  130300. * 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)
  130301. */
  130302. ignoreAlpha: boolean;
  130303. /**
  130304. * Defines the maximum number of lights that can be used in the material
  130305. */
  130306. maxSimultaneousLights: number;
  130307. /**
  130308. * Observable raised when the material is built
  130309. */
  130310. onBuildObservable: Observable<NodeMaterial>;
  130311. /**
  130312. * Gets or sets the root nodes of the material vertex shader
  130313. */
  130314. _vertexOutputNodes: NodeMaterialBlock[];
  130315. /**
  130316. * Gets or sets the root nodes of the material fragment (pixel) shader
  130317. */
  130318. _fragmentOutputNodes: NodeMaterialBlock[];
  130319. /** Gets or sets options to control the node material overall behavior */
  130320. get options(): INodeMaterialOptions;
  130321. set options(options: INodeMaterialOptions);
  130322. /**
  130323. * Default configuration related to image processing available in the standard Material.
  130324. */
  130325. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130326. /**
  130327. * Gets the image processing configuration used either in this material.
  130328. */
  130329. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130330. /**
  130331. * Sets the Default image processing configuration used either in the this material.
  130332. *
  130333. * If sets to null, the scene one is in use.
  130334. */
  130335. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  130336. /**
  130337. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  130338. */
  130339. attachedBlocks: NodeMaterialBlock[];
  130340. /**
  130341. * Create a new node based material
  130342. * @param name defines the material name
  130343. * @param scene defines the hosting scene
  130344. * @param options defines creation option
  130345. */
  130346. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  130347. /**
  130348. * Gets the current class name of the material e.g. "NodeMaterial"
  130349. * @returns the class name
  130350. */
  130351. getClassName(): string;
  130352. /**
  130353. * Keep track of the image processing observer to allow dispose and replace.
  130354. */
  130355. private _imageProcessingObserver;
  130356. /**
  130357. * Attaches a new image processing configuration to the Standard Material.
  130358. * @param configuration
  130359. */
  130360. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130361. /**
  130362. * Get a block by its name
  130363. * @param name defines the name of the block to retrieve
  130364. * @returns the required block or null if not found
  130365. */
  130366. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  130367. /**
  130368. * Get a block by its name
  130369. * @param predicate defines the predicate used to find the good candidate
  130370. * @returns the required block or null if not found
  130371. */
  130372. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  130373. /**
  130374. * Get an input block by its name
  130375. * @param predicate defines the predicate used to find the good candidate
  130376. * @returns the required input block or null if not found
  130377. */
  130378. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  130379. /**
  130380. * Gets the list of input blocks attached to this material
  130381. * @returns an array of InputBlocks
  130382. */
  130383. getInputBlocks(): InputBlock[];
  130384. /**
  130385. * Adds a new optimizer to the list of optimizers
  130386. * @param optimizer defines the optimizers to add
  130387. * @returns the current material
  130388. */
  130389. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130390. /**
  130391. * Remove an optimizer from the list of optimizers
  130392. * @param optimizer defines the optimizers to remove
  130393. * @returns the current material
  130394. */
  130395. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130396. /**
  130397. * Add a new block to the list of output nodes
  130398. * @param node defines the node to add
  130399. * @returns the current material
  130400. */
  130401. addOutputNode(node: NodeMaterialBlock): this;
  130402. /**
  130403. * Remove a block from the list of root nodes
  130404. * @param node defines the node to remove
  130405. * @returns the current material
  130406. */
  130407. removeOutputNode(node: NodeMaterialBlock): this;
  130408. private _addVertexOutputNode;
  130409. private _removeVertexOutputNode;
  130410. private _addFragmentOutputNode;
  130411. private _removeFragmentOutputNode;
  130412. /**
  130413. * Specifies if the material will require alpha blending
  130414. * @returns a boolean specifying if alpha blending is needed
  130415. */
  130416. needAlphaBlending(): boolean;
  130417. /**
  130418. * Specifies if this material should be rendered in alpha test mode
  130419. * @returns a boolean specifying if an alpha test is needed.
  130420. */
  130421. needAlphaTesting(): boolean;
  130422. private _initializeBlock;
  130423. private _resetDualBlocks;
  130424. /**
  130425. * Remove a block from the current node material
  130426. * @param block defines the block to remove
  130427. */
  130428. removeBlock(block: NodeMaterialBlock): void;
  130429. /**
  130430. * Build the material and generates the inner effect
  130431. * @param verbose defines if the build should log activity
  130432. */
  130433. build(verbose?: boolean): void;
  130434. /**
  130435. * Runs an otpimization phase to try to improve the shader code
  130436. */
  130437. optimize(): void;
  130438. private _prepareDefinesForAttributes;
  130439. /**
  130440. * Get if the submesh is ready to be used and all its information available.
  130441. * Child classes can use it to update shaders
  130442. * @param mesh defines the mesh to check
  130443. * @param subMesh defines which submesh to check
  130444. * @param useInstances specifies that instances should be used
  130445. * @returns a boolean indicating that the submesh is ready or not
  130446. */
  130447. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130448. /**
  130449. * Get a string representing the shaders built by the current node graph
  130450. */
  130451. get compiledShaders(): string;
  130452. /**
  130453. * Binds the world matrix to the material
  130454. * @param world defines the world transformation matrix
  130455. */
  130456. bindOnlyWorldMatrix(world: Matrix): void;
  130457. /**
  130458. * Binds the submesh to this material by preparing the effect and shader to draw
  130459. * @param world defines the world transformation matrix
  130460. * @param mesh defines the mesh containing the submesh
  130461. * @param subMesh defines the submesh to bind the material to
  130462. */
  130463. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130464. /**
  130465. * Gets the active textures from the material
  130466. * @returns an array of textures
  130467. */
  130468. getActiveTextures(): BaseTexture[];
  130469. /**
  130470. * Gets the list of texture blocks
  130471. * @returns an array of texture blocks
  130472. */
  130473. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  130474. /**
  130475. * Specifies if the material uses a texture
  130476. * @param texture defines the texture to check against the material
  130477. * @returns a boolean specifying if the material uses the texture
  130478. */
  130479. hasTexture(texture: BaseTexture): boolean;
  130480. /**
  130481. * Disposes the material
  130482. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  130483. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  130484. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  130485. */
  130486. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  130487. /** Creates the node editor window. */
  130488. private _createNodeEditor;
  130489. /**
  130490. * Launch the node material editor
  130491. * @param config Define the configuration of the editor
  130492. * @return a promise fulfilled when the node editor is visible
  130493. */
  130494. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  130495. /**
  130496. * Clear the current material
  130497. */
  130498. clear(): void;
  130499. /**
  130500. * Clear the current material and set it to a default state
  130501. */
  130502. setToDefault(): void;
  130503. /**
  130504. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  130505. * @param url defines the url to load from
  130506. * @returns a promise that will fullfil when the material is fully loaded
  130507. */
  130508. loadAsync(url: string): Promise<void>;
  130509. private _gatherBlocks;
  130510. /**
  130511. * Generate a string containing the code declaration required to create an equivalent of this material
  130512. * @returns a string
  130513. */
  130514. generateCode(): string;
  130515. /**
  130516. * Serializes this material in a JSON representation
  130517. * @returns the serialized material object
  130518. */
  130519. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  130520. private _restoreConnections;
  130521. /**
  130522. * Clear the current graph and load a new one from a serialization object
  130523. * @param source defines the JSON representation of the material
  130524. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130525. */
  130526. loadFromSerialization(source: any, rootUrl?: string): void;
  130527. /**
  130528. * Creates a node material from parsed material data
  130529. * @param source defines the JSON representation of the material
  130530. * @param scene defines the hosting scene
  130531. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130532. * @returns a new node material
  130533. */
  130534. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  130535. /**
  130536. * Creates a node material from a snippet saved in a remote file
  130537. * @param name defines the name of the material to create
  130538. * @param url defines the url to load from
  130539. * @param scene defines the hosting scene
  130540. * @returns a promise that will resolve to the new node material
  130541. */
  130542. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  130543. /**
  130544. * Creates a node material from a snippet saved by the node material editor
  130545. * @param snippetId defines the snippet to load
  130546. * @param scene defines the hosting scene
  130547. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130548. * @returns a promise that will resolve to the new node material
  130549. */
  130550. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  130551. /**
  130552. * Creates a new node material set to default basic configuration
  130553. * @param name defines the name of the material
  130554. * @param scene defines the hosting scene
  130555. * @returns a new NodeMaterial
  130556. */
  130557. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  130558. }
  130559. }
  130560. declare module BABYLON {
  130561. /**
  130562. * Block used to read a texture from a sampler
  130563. */
  130564. export class TextureBlock extends NodeMaterialBlock {
  130565. private _defineName;
  130566. private _linearDefineName;
  130567. private _tempTextureRead;
  130568. private _samplerName;
  130569. private _transformedUVName;
  130570. private _textureTransformName;
  130571. private _textureInfoName;
  130572. private _mainUVName;
  130573. private _mainUVDefineName;
  130574. /**
  130575. * Gets or sets the texture associated with the node
  130576. */
  130577. texture: Nullable<Texture>;
  130578. /**
  130579. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  130580. */
  130581. convertToGammaSpace: boolean;
  130582. /**
  130583. * Create a new TextureBlock
  130584. * @param name defines the block name
  130585. */
  130586. constructor(name: string);
  130587. /**
  130588. * Gets the current class name
  130589. * @returns the class name
  130590. */
  130591. getClassName(): string;
  130592. /**
  130593. * Gets the uv input component
  130594. */
  130595. get uv(): NodeMaterialConnectionPoint;
  130596. /**
  130597. * Gets the rgba output component
  130598. */
  130599. get rgba(): NodeMaterialConnectionPoint;
  130600. /**
  130601. * Gets the rgb output component
  130602. */
  130603. get rgb(): NodeMaterialConnectionPoint;
  130604. /**
  130605. * Gets the r output component
  130606. */
  130607. get r(): NodeMaterialConnectionPoint;
  130608. /**
  130609. * Gets the g output component
  130610. */
  130611. get g(): NodeMaterialConnectionPoint;
  130612. /**
  130613. * Gets the b output component
  130614. */
  130615. get b(): NodeMaterialConnectionPoint;
  130616. /**
  130617. * Gets the a output component
  130618. */
  130619. get a(): NodeMaterialConnectionPoint;
  130620. get target(): NodeMaterialBlockTargets;
  130621. autoConfigure(material: NodeMaterial): void;
  130622. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130623. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130624. isReady(): boolean;
  130625. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130626. private get _isMixed();
  130627. private _injectVertexCode;
  130628. private _writeTextureRead;
  130629. private _writeOutput;
  130630. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130631. protected _dumpPropertiesCode(): string;
  130632. serialize(): any;
  130633. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130634. }
  130635. }
  130636. declare module BABYLON {
  130637. /**
  130638. * Class used to store shared data between 2 NodeMaterialBuildState
  130639. */
  130640. export class NodeMaterialBuildStateSharedData {
  130641. /**
  130642. * Gets the list of emitted varyings
  130643. */
  130644. temps: string[];
  130645. /**
  130646. * Gets the list of emitted varyings
  130647. */
  130648. varyings: string[];
  130649. /**
  130650. * Gets the varying declaration string
  130651. */
  130652. varyingDeclaration: string;
  130653. /**
  130654. * Input blocks
  130655. */
  130656. inputBlocks: InputBlock[];
  130657. /**
  130658. * Input blocks
  130659. */
  130660. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  130661. /**
  130662. * Bindable blocks (Blocks that need to set data to the effect)
  130663. */
  130664. bindableBlocks: NodeMaterialBlock[];
  130665. /**
  130666. * List of blocks that can provide a compilation fallback
  130667. */
  130668. blocksWithFallbacks: NodeMaterialBlock[];
  130669. /**
  130670. * List of blocks that can provide a define update
  130671. */
  130672. blocksWithDefines: NodeMaterialBlock[];
  130673. /**
  130674. * List of blocks that can provide a repeatable content
  130675. */
  130676. repeatableContentBlocks: NodeMaterialBlock[];
  130677. /**
  130678. * List of blocks that can provide a dynamic list of uniforms
  130679. */
  130680. dynamicUniformBlocks: NodeMaterialBlock[];
  130681. /**
  130682. * List of blocks that can block the isReady function for the material
  130683. */
  130684. blockingBlocks: NodeMaterialBlock[];
  130685. /**
  130686. * Gets the list of animated inputs
  130687. */
  130688. animatedInputs: InputBlock[];
  130689. /**
  130690. * Build Id used to avoid multiple recompilations
  130691. */
  130692. buildId: number;
  130693. /** List of emitted variables */
  130694. variableNames: {
  130695. [key: string]: number;
  130696. };
  130697. /** List of emitted defines */
  130698. defineNames: {
  130699. [key: string]: number;
  130700. };
  130701. /** Should emit comments? */
  130702. emitComments: boolean;
  130703. /** Emit build activity */
  130704. verbose: boolean;
  130705. /** Gets or sets the hosting scene */
  130706. scene: Scene;
  130707. /**
  130708. * Gets the compilation hints emitted at compilation time
  130709. */
  130710. hints: {
  130711. needWorldViewMatrix: boolean;
  130712. needWorldViewProjectionMatrix: boolean;
  130713. needAlphaBlending: boolean;
  130714. needAlphaTesting: boolean;
  130715. };
  130716. /**
  130717. * List of compilation checks
  130718. */
  130719. checks: {
  130720. emitVertex: boolean;
  130721. emitFragment: boolean;
  130722. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  130723. };
  130724. /** Creates a new shared data */
  130725. constructor();
  130726. /**
  130727. * Emits console errors and exceptions if there is a failing check
  130728. */
  130729. emitErrors(): void;
  130730. }
  130731. }
  130732. declare module BABYLON {
  130733. /**
  130734. * Class used to store node based material build state
  130735. */
  130736. export class NodeMaterialBuildState {
  130737. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  130738. supportUniformBuffers: boolean;
  130739. /**
  130740. * Gets the list of emitted attributes
  130741. */
  130742. attributes: string[];
  130743. /**
  130744. * Gets the list of emitted uniforms
  130745. */
  130746. uniforms: string[];
  130747. /**
  130748. * Gets the list of emitted constants
  130749. */
  130750. constants: string[];
  130751. /**
  130752. * Gets the list of emitted samplers
  130753. */
  130754. samplers: string[];
  130755. /**
  130756. * Gets the list of emitted functions
  130757. */
  130758. functions: {
  130759. [key: string]: string;
  130760. };
  130761. /**
  130762. * Gets the list of emitted extensions
  130763. */
  130764. extensions: {
  130765. [key: string]: string;
  130766. };
  130767. /**
  130768. * Gets the target of the compilation state
  130769. */
  130770. target: NodeMaterialBlockTargets;
  130771. /**
  130772. * Gets the list of emitted counters
  130773. */
  130774. counters: {
  130775. [key: string]: number;
  130776. };
  130777. /**
  130778. * Shared data between multiple NodeMaterialBuildState instances
  130779. */
  130780. sharedData: NodeMaterialBuildStateSharedData;
  130781. /** @hidden */
  130782. _vertexState: NodeMaterialBuildState;
  130783. /** @hidden */
  130784. _attributeDeclaration: string;
  130785. /** @hidden */
  130786. _uniformDeclaration: string;
  130787. /** @hidden */
  130788. _constantDeclaration: string;
  130789. /** @hidden */
  130790. _samplerDeclaration: string;
  130791. /** @hidden */
  130792. _varyingTransfer: string;
  130793. private _repeatableContentAnchorIndex;
  130794. /** @hidden */
  130795. _builtCompilationString: string;
  130796. /**
  130797. * Gets the emitted compilation strings
  130798. */
  130799. compilationString: string;
  130800. /**
  130801. * Finalize the compilation strings
  130802. * @param state defines the current compilation state
  130803. */
  130804. finalize(state: NodeMaterialBuildState): void;
  130805. /** @hidden */
  130806. get _repeatableContentAnchor(): string;
  130807. /** @hidden */
  130808. _getFreeVariableName(prefix: string): string;
  130809. /** @hidden */
  130810. _getFreeDefineName(prefix: string): string;
  130811. /** @hidden */
  130812. _excludeVariableName(name: string): void;
  130813. /** @hidden */
  130814. _emit2DSampler(name: string): void;
  130815. /** @hidden */
  130816. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  130817. /** @hidden */
  130818. _emitExtension(name: string, extension: string): void;
  130819. /** @hidden */
  130820. _emitFunction(name: string, code: string, comments: string): void;
  130821. /** @hidden */
  130822. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  130823. replaceStrings?: {
  130824. search: RegExp;
  130825. replace: string;
  130826. }[];
  130827. repeatKey?: string;
  130828. }): string;
  130829. /** @hidden */
  130830. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  130831. repeatKey?: string;
  130832. removeAttributes?: boolean;
  130833. removeUniforms?: boolean;
  130834. removeVaryings?: boolean;
  130835. removeIfDef?: boolean;
  130836. replaceStrings?: {
  130837. search: RegExp;
  130838. replace: string;
  130839. }[];
  130840. }, storeKey?: string): void;
  130841. /** @hidden */
  130842. _registerTempVariable(name: string): boolean;
  130843. /** @hidden */
  130844. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  130845. /** @hidden */
  130846. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  130847. /** @hidden */
  130848. _emitFloat(value: number): string;
  130849. }
  130850. }
  130851. declare module BABYLON {
  130852. /**
  130853. * Defines a block that can be used inside a node based material
  130854. */
  130855. export class NodeMaterialBlock {
  130856. private _buildId;
  130857. private _buildTarget;
  130858. private _target;
  130859. private _isFinalMerger;
  130860. private _isInput;
  130861. protected _isUnique: boolean;
  130862. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  130863. inputsAreExclusive: boolean;
  130864. /** @hidden */
  130865. _codeVariableName: string;
  130866. /** @hidden */
  130867. _inputs: NodeMaterialConnectionPoint[];
  130868. /** @hidden */
  130869. _outputs: NodeMaterialConnectionPoint[];
  130870. /** @hidden */
  130871. _preparationId: number;
  130872. /**
  130873. * Gets or sets the name of the block
  130874. */
  130875. name: string;
  130876. /**
  130877. * Gets or sets the unique id of the node
  130878. */
  130879. uniqueId: number;
  130880. /**
  130881. * Gets or sets the comments associated with this block
  130882. */
  130883. comments: string;
  130884. /**
  130885. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  130886. */
  130887. get isUnique(): boolean;
  130888. /**
  130889. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  130890. */
  130891. get isFinalMerger(): boolean;
  130892. /**
  130893. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  130894. */
  130895. get isInput(): boolean;
  130896. /**
  130897. * Gets or sets the build Id
  130898. */
  130899. get buildId(): number;
  130900. set buildId(value: number);
  130901. /**
  130902. * Gets or sets the target of the block
  130903. */
  130904. get target(): NodeMaterialBlockTargets;
  130905. set target(value: NodeMaterialBlockTargets);
  130906. /**
  130907. * Gets the list of input points
  130908. */
  130909. get inputs(): NodeMaterialConnectionPoint[];
  130910. /** Gets the list of output points */
  130911. get outputs(): NodeMaterialConnectionPoint[];
  130912. /**
  130913. * Find an input by its name
  130914. * @param name defines the name of the input to look for
  130915. * @returns the input or null if not found
  130916. */
  130917. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130918. /**
  130919. * Find an output by its name
  130920. * @param name defines the name of the outputto look for
  130921. * @returns the output or null if not found
  130922. */
  130923. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130924. /**
  130925. * Creates a new NodeMaterialBlock
  130926. * @param name defines the block name
  130927. * @param target defines the target of that block (Vertex by default)
  130928. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  130929. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  130930. */
  130931. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  130932. /**
  130933. * Initialize the block and prepare the context for build
  130934. * @param state defines the state that will be used for the build
  130935. */
  130936. initialize(state: NodeMaterialBuildState): void;
  130937. /**
  130938. * Bind data to effect. Will only be called for blocks with isBindable === true
  130939. * @param effect defines the effect to bind data to
  130940. * @param nodeMaterial defines the hosting NodeMaterial
  130941. * @param mesh defines the mesh that will be rendered
  130942. */
  130943. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130944. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  130945. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  130946. protected _writeFloat(value: number): string;
  130947. /**
  130948. * Gets the current class name e.g. "NodeMaterialBlock"
  130949. * @returns the class name
  130950. */
  130951. getClassName(): string;
  130952. /**
  130953. * Register a new input. Must be called inside a block constructor
  130954. * @param name defines the connection point name
  130955. * @param type defines the connection point type
  130956. * @param isOptional defines a boolean indicating that this input can be omitted
  130957. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130958. * @returns the current block
  130959. */
  130960. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  130961. /**
  130962. * Register a new output. Must be called inside a block constructor
  130963. * @param name defines the connection point name
  130964. * @param type defines the connection point type
  130965. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130966. * @returns the current block
  130967. */
  130968. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  130969. /**
  130970. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  130971. * @param forOutput defines an optional connection point to check compatibility with
  130972. * @returns the first available input or null
  130973. */
  130974. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  130975. /**
  130976. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  130977. * @param forBlock defines an optional block to check compatibility with
  130978. * @returns the first available input or null
  130979. */
  130980. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  130981. /**
  130982. * Gets the sibling of the given output
  130983. * @param current defines the current output
  130984. * @returns the next output in the list or null
  130985. */
  130986. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  130987. /**
  130988. * Connect current block with another block
  130989. * @param other defines the block to connect with
  130990. * @param options define the various options to help pick the right connections
  130991. * @returns the current block
  130992. */
  130993. connectTo(other: NodeMaterialBlock, options?: {
  130994. input?: string;
  130995. output?: string;
  130996. outputSwizzle?: string;
  130997. }): this | undefined;
  130998. protected _buildBlock(state: NodeMaterialBuildState): void;
  130999. /**
  131000. * Add uniforms, samplers and uniform buffers at compilation time
  131001. * @param state defines the state to update
  131002. * @param nodeMaterial defines the node material requesting the update
  131003. * @param defines defines the material defines to update
  131004. * @param uniformBuffers defines the list of uniform buffer names
  131005. */
  131006. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131007. /**
  131008. * Add potential fallbacks if shader compilation fails
  131009. * @param mesh defines the mesh to be rendered
  131010. * @param fallbacks defines the current prioritized list of fallbacks
  131011. */
  131012. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131013. /**
  131014. * Initialize defines for shader compilation
  131015. * @param mesh defines the mesh to be rendered
  131016. * @param nodeMaterial defines the node material requesting the update
  131017. * @param defines defines the material defines to update
  131018. * @param useInstances specifies that instances should be used
  131019. */
  131020. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131021. /**
  131022. * Update defines for shader compilation
  131023. * @param mesh defines the mesh to be rendered
  131024. * @param nodeMaterial defines the node material requesting the update
  131025. * @param defines defines the material defines to update
  131026. * @param useInstances specifies that instances should be used
  131027. */
  131028. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131029. /**
  131030. * Lets the block try to connect some inputs automatically
  131031. * @param material defines the hosting NodeMaterial
  131032. */
  131033. autoConfigure(material: NodeMaterial): void;
  131034. /**
  131035. * Function called when a block is declared as repeatable content generator
  131036. * @param vertexShaderState defines the current compilation state for the vertex shader
  131037. * @param fragmentShaderState defines the current compilation state for the fragment shader
  131038. * @param mesh defines the mesh to be rendered
  131039. * @param defines defines the material defines to update
  131040. */
  131041. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131042. /**
  131043. * Checks if the block is ready
  131044. * @param mesh defines the mesh to be rendered
  131045. * @param nodeMaterial defines the node material requesting the update
  131046. * @param defines defines the material defines to update
  131047. * @param useInstances specifies that instances should be used
  131048. * @returns true if the block is ready
  131049. */
  131050. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  131051. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  131052. private _processBuild;
  131053. /**
  131054. * Compile the current node and generate the shader code
  131055. * @param state defines the current compilation state (uniforms, samplers, current string)
  131056. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  131057. * @returns true if already built
  131058. */
  131059. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  131060. protected _inputRename(name: string): string;
  131061. protected _outputRename(name: string): string;
  131062. protected _dumpPropertiesCode(): string;
  131063. /** @hidden */
  131064. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  131065. /** @hidden */
  131066. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  131067. /**
  131068. * Clone the current block to a new identical block
  131069. * @param scene defines the hosting scene
  131070. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131071. * @returns a copy of the current block
  131072. */
  131073. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  131074. /**
  131075. * Serializes this block in a JSON representation
  131076. * @returns the serialized block object
  131077. */
  131078. serialize(): any;
  131079. /** @hidden */
  131080. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131081. /**
  131082. * Release resources
  131083. */
  131084. dispose(): void;
  131085. }
  131086. }
  131087. declare module BABYLON {
  131088. /**
  131089. * Enum defining the type of animations supported by InputBlock
  131090. */
  131091. export enum AnimatedInputBlockTypes {
  131092. /** No animation */
  131093. None = 0,
  131094. /** Time based animation. Will only work for floats */
  131095. Time = 1
  131096. }
  131097. }
  131098. declare module BABYLON {
  131099. /**
  131100. * Block used to expose an input value
  131101. */
  131102. export class InputBlock extends NodeMaterialBlock {
  131103. private _mode;
  131104. private _associatedVariableName;
  131105. private _storedValue;
  131106. private _valueCallback;
  131107. private _type;
  131108. private _animationType;
  131109. /** Gets or set a value used to limit the range of float values */
  131110. min: number;
  131111. /** Gets or set a value used to limit the range of float values */
  131112. max: number;
  131113. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  131114. isBoolean: boolean;
  131115. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  131116. matrixMode: number;
  131117. /** @hidden */
  131118. _systemValue: Nullable<NodeMaterialSystemValues>;
  131119. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  131120. visibleInInspector: boolean;
  131121. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  131122. isConstant: boolean;
  131123. /** Gets or sets the group to use to display this block in the Inspector */
  131124. groupInInspector: string;
  131125. /** Gets an observable raised when the value is changed */
  131126. onValueChangedObservable: Observable<InputBlock>;
  131127. /**
  131128. * Gets or sets the connection point type (default is float)
  131129. */
  131130. get type(): NodeMaterialBlockConnectionPointTypes;
  131131. /**
  131132. * Creates a new InputBlock
  131133. * @param name defines the block name
  131134. * @param target defines the target of that block (Vertex by default)
  131135. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  131136. */
  131137. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  131138. /**
  131139. * Gets the output component
  131140. */
  131141. get output(): NodeMaterialConnectionPoint;
  131142. /**
  131143. * Set the source of this connection point to a vertex attribute
  131144. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  131145. * @returns the current connection point
  131146. */
  131147. setAsAttribute(attributeName?: string): InputBlock;
  131148. /**
  131149. * Set the source of this connection point to a system value
  131150. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  131151. * @returns the current connection point
  131152. */
  131153. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  131154. /**
  131155. * Gets or sets the value of that point.
  131156. * Please note that this value will be ignored if valueCallback is defined
  131157. */
  131158. get value(): any;
  131159. set value(value: any);
  131160. /**
  131161. * Gets or sets a callback used to get the value of that point.
  131162. * Please note that setting this value will force the connection point to ignore the value property
  131163. */
  131164. get valueCallback(): () => any;
  131165. set valueCallback(value: () => any);
  131166. /**
  131167. * Gets or sets the associated variable name in the shader
  131168. */
  131169. get associatedVariableName(): string;
  131170. set associatedVariableName(value: string);
  131171. /** Gets or sets the type of animation applied to the input */
  131172. get animationType(): AnimatedInputBlockTypes;
  131173. set animationType(value: AnimatedInputBlockTypes);
  131174. /**
  131175. * Gets a boolean indicating that this connection point not defined yet
  131176. */
  131177. get isUndefined(): boolean;
  131178. /**
  131179. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  131180. * In this case the connection point name must be the name of the uniform to use.
  131181. * Can only be set on inputs
  131182. */
  131183. get isUniform(): boolean;
  131184. set isUniform(value: boolean);
  131185. /**
  131186. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  131187. * In this case the connection point name must be the name of the attribute to use
  131188. * Can only be set on inputs
  131189. */
  131190. get isAttribute(): boolean;
  131191. set isAttribute(value: boolean);
  131192. /**
  131193. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  131194. * Can only be set on exit points
  131195. */
  131196. get isVarying(): boolean;
  131197. set isVarying(value: boolean);
  131198. /**
  131199. * Gets a boolean indicating that the current connection point is a system value
  131200. */
  131201. get isSystemValue(): boolean;
  131202. /**
  131203. * Gets or sets the current well known value or null if not defined as a system value
  131204. */
  131205. get systemValue(): Nullable<NodeMaterialSystemValues>;
  131206. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  131207. /**
  131208. * Gets the current class name
  131209. * @returns the class name
  131210. */
  131211. getClassName(): string;
  131212. /**
  131213. * Animate the input if animationType !== None
  131214. * @param scene defines the rendering scene
  131215. */
  131216. animate(scene: Scene): void;
  131217. private _emitDefine;
  131218. initialize(state: NodeMaterialBuildState): void;
  131219. /**
  131220. * Set the input block to its default value (based on its type)
  131221. */
  131222. setDefaultValue(): void;
  131223. private _emitConstant;
  131224. private _emit;
  131225. /** @hidden */
  131226. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  131227. /** @hidden */
  131228. _transmit(effect: Effect, scene: Scene): void;
  131229. protected _buildBlock(state: NodeMaterialBuildState): void;
  131230. protected _dumpPropertiesCode(): string;
  131231. dispose(): void;
  131232. serialize(): any;
  131233. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131234. }
  131235. }
  131236. declare module BABYLON {
  131237. /**
  131238. * Enum used to define the compatibility state between two connection points
  131239. */
  131240. export enum NodeMaterialConnectionPointCompatibilityStates {
  131241. /** Points are compatibles */
  131242. Compatible = 0,
  131243. /** Points are incompatible because of their types */
  131244. TypeIncompatible = 1,
  131245. /** Points are incompatible because of their targets (vertex vs fragment) */
  131246. TargetIncompatible = 2
  131247. }
  131248. /**
  131249. * Defines the direction of a connection point
  131250. */
  131251. export enum NodeMaterialConnectionPointDirection {
  131252. /** Input */
  131253. Input = 0,
  131254. /** Output */
  131255. Output = 1
  131256. }
  131257. /**
  131258. * Defines a connection point for a block
  131259. */
  131260. export class NodeMaterialConnectionPoint {
  131261. /** @hidden */
  131262. _ownerBlock: NodeMaterialBlock;
  131263. /** @hidden */
  131264. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  131265. private _endpoints;
  131266. private _associatedVariableName;
  131267. private _direction;
  131268. /** @hidden */
  131269. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131270. /** @hidden */
  131271. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131272. private _type;
  131273. /** @hidden */
  131274. _enforceAssociatedVariableName: boolean;
  131275. /** Gets the direction of the point */
  131276. get direction(): NodeMaterialConnectionPointDirection;
  131277. /**
  131278. * Gets or sets the additional types supported by this connection point
  131279. */
  131280. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131281. /**
  131282. * Gets or sets the additional types excluded by this connection point
  131283. */
  131284. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131285. /**
  131286. * Observable triggered when this point is connected
  131287. */
  131288. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  131289. /**
  131290. * Gets or sets the associated variable name in the shader
  131291. */
  131292. get associatedVariableName(): string;
  131293. set associatedVariableName(value: string);
  131294. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  131295. get innerType(): NodeMaterialBlockConnectionPointTypes;
  131296. /**
  131297. * Gets or sets the connection point type (default is float)
  131298. */
  131299. get type(): NodeMaterialBlockConnectionPointTypes;
  131300. set type(value: NodeMaterialBlockConnectionPointTypes);
  131301. /**
  131302. * Gets or sets the connection point name
  131303. */
  131304. name: string;
  131305. /**
  131306. * Gets or sets a boolean indicating that this connection point can be omitted
  131307. */
  131308. isOptional: boolean;
  131309. /**
  131310. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  131311. */
  131312. define: string;
  131313. /** @hidden */
  131314. _prioritizeVertex: boolean;
  131315. private _target;
  131316. /** Gets or sets the target of that connection point */
  131317. get target(): NodeMaterialBlockTargets;
  131318. set target(value: NodeMaterialBlockTargets);
  131319. /**
  131320. * Gets a boolean indicating that the current point is connected
  131321. */
  131322. get isConnected(): boolean;
  131323. /**
  131324. * Gets a boolean indicating that the current point is connected to an input block
  131325. */
  131326. get isConnectedToInputBlock(): boolean;
  131327. /**
  131328. * Gets a the connected input block (if any)
  131329. */
  131330. get connectInputBlock(): Nullable<InputBlock>;
  131331. /** Get the other side of the connection (if any) */
  131332. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  131333. /** Get the block that owns this connection point */
  131334. get ownerBlock(): NodeMaterialBlock;
  131335. /** Get the block connected on the other side of this connection (if any) */
  131336. get sourceBlock(): Nullable<NodeMaterialBlock>;
  131337. /** Get the block connected on the endpoints of this connection (if any) */
  131338. get connectedBlocks(): Array<NodeMaterialBlock>;
  131339. /** Gets the list of connected endpoints */
  131340. get endpoints(): NodeMaterialConnectionPoint[];
  131341. /** Gets a boolean indicating if that output point is connected to at least one input */
  131342. get hasEndpoints(): boolean;
  131343. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  131344. get isConnectedInVertexShader(): boolean;
  131345. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  131346. get isConnectedInFragmentShader(): boolean;
  131347. /**
  131348. * Creates a new connection point
  131349. * @param name defines the connection point name
  131350. * @param ownerBlock defines the block hosting this connection point
  131351. * @param direction defines the direction of the connection point
  131352. */
  131353. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  131354. /**
  131355. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  131356. * @returns the class name
  131357. */
  131358. getClassName(): string;
  131359. /**
  131360. * Gets a boolean indicating if the current point can be connected to another point
  131361. * @param connectionPoint defines the other connection point
  131362. * @returns a boolean
  131363. */
  131364. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  131365. /**
  131366. * Gets a number indicating if the current point can be connected to another point
  131367. * @param connectionPoint defines the other connection point
  131368. * @returns a number defining the compatibility state
  131369. */
  131370. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  131371. /**
  131372. * Connect this point to another connection point
  131373. * @param connectionPoint defines the other connection point
  131374. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  131375. * @returns the current connection point
  131376. */
  131377. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  131378. /**
  131379. * Disconnect this point from one of his endpoint
  131380. * @param endpoint defines the other connection point
  131381. * @returns the current connection point
  131382. */
  131383. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  131384. /**
  131385. * Serializes this point in a JSON representation
  131386. * @returns the serialized point object
  131387. */
  131388. serialize(): any;
  131389. /**
  131390. * Release resources
  131391. */
  131392. dispose(): void;
  131393. }
  131394. }
  131395. declare module BABYLON {
  131396. /**
  131397. * Block used to add support for vertex skinning (bones)
  131398. */
  131399. export class BonesBlock extends NodeMaterialBlock {
  131400. /**
  131401. * Creates a new BonesBlock
  131402. * @param name defines the block name
  131403. */
  131404. constructor(name: string);
  131405. /**
  131406. * Initialize the block and prepare the context for build
  131407. * @param state defines the state that will be used for the build
  131408. */
  131409. initialize(state: NodeMaterialBuildState): void;
  131410. /**
  131411. * Gets the current class name
  131412. * @returns the class name
  131413. */
  131414. getClassName(): string;
  131415. /**
  131416. * Gets the matrix indices input component
  131417. */
  131418. get matricesIndices(): NodeMaterialConnectionPoint;
  131419. /**
  131420. * Gets the matrix weights input component
  131421. */
  131422. get matricesWeights(): NodeMaterialConnectionPoint;
  131423. /**
  131424. * Gets the extra matrix indices input component
  131425. */
  131426. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  131427. /**
  131428. * Gets the extra matrix weights input component
  131429. */
  131430. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  131431. /**
  131432. * Gets the world input component
  131433. */
  131434. get world(): NodeMaterialConnectionPoint;
  131435. /**
  131436. * Gets the output component
  131437. */
  131438. get output(): NodeMaterialConnectionPoint;
  131439. autoConfigure(material: NodeMaterial): void;
  131440. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131441. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131442. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131443. protected _buildBlock(state: NodeMaterialBuildState): this;
  131444. }
  131445. }
  131446. declare module BABYLON {
  131447. /**
  131448. * Block used to add support for instances
  131449. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  131450. */
  131451. export class InstancesBlock extends NodeMaterialBlock {
  131452. /**
  131453. * Creates a new InstancesBlock
  131454. * @param name defines the block name
  131455. */
  131456. constructor(name: string);
  131457. /**
  131458. * Gets the current class name
  131459. * @returns the class name
  131460. */
  131461. getClassName(): string;
  131462. /**
  131463. * Gets the first world row input component
  131464. */
  131465. get world0(): NodeMaterialConnectionPoint;
  131466. /**
  131467. * Gets the second world row input component
  131468. */
  131469. get world1(): NodeMaterialConnectionPoint;
  131470. /**
  131471. * Gets the third world row input component
  131472. */
  131473. get world2(): NodeMaterialConnectionPoint;
  131474. /**
  131475. * Gets the forth world row input component
  131476. */
  131477. get world3(): NodeMaterialConnectionPoint;
  131478. /**
  131479. * Gets the world input component
  131480. */
  131481. get world(): NodeMaterialConnectionPoint;
  131482. /**
  131483. * Gets the output component
  131484. */
  131485. get output(): NodeMaterialConnectionPoint;
  131486. /**
  131487. * Gets the isntanceID component
  131488. */
  131489. get instanceID(): NodeMaterialConnectionPoint;
  131490. autoConfigure(material: NodeMaterial): void;
  131491. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131492. protected _buildBlock(state: NodeMaterialBuildState): this;
  131493. }
  131494. }
  131495. declare module BABYLON {
  131496. /**
  131497. * Block used to add morph targets support to vertex shader
  131498. */
  131499. export class MorphTargetsBlock extends NodeMaterialBlock {
  131500. private _repeatableContentAnchor;
  131501. /**
  131502. * Create a new MorphTargetsBlock
  131503. * @param name defines the block name
  131504. */
  131505. constructor(name: string);
  131506. /**
  131507. * Gets the current class name
  131508. * @returns the class name
  131509. */
  131510. getClassName(): string;
  131511. /**
  131512. * Gets the position input component
  131513. */
  131514. get position(): NodeMaterialConnectionPoint;
  131515. /**
  131516. * Gets the normal input component
  131517. */
  131518. get normal(): NodeMaterialConnectionPoint;
  131519. /**
  131520. * Gets the tangent input component
  131521. */
  131522. get tangent(): NodeMaterialConnectionPoint;
  131523. /**
  131524. * Gets the tangent input component
  131525. */
  131526. get uv(): NodeMaterialConnectionPoint;
  131527. /**
  131528. * Gets the position output component
  131529. */
  131530. get positionOutput(): NodeMaterialConnectionPoint;
  131531. /**
  131532. * Gets the normal output component
  131533. */
  131534. get normalOutput(): NodeMaterialConnectionPoint;
  131535. /**
  131536. * Gets the tangent output component
  131537. */
  131538. get tangentOutput(): NodeMaterialConnectionPoint;
  131539. /**
  131540. * Gets the tangent output component
  131541. */
  131542. get uvOutput(): NodeMaterialConnectionPoint;
  131543. initialize(state: NodeMaterialBuildState): void;
  131544. autoConfigure(material: NodeMaterial): void;
  131545. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131546. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131547. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131548. protected _buildBlock(state: NodeMaterialBuildState): this;
  131549. }
  131550. }
  131551. declare module BABYLON {
  131552. /**
  131553. * Block used to get data information from a light
  131554. */
  131555. export class LightInformationBlock extends NodeMaterialBlock {
  131556. private _lightDataUniformName;
  131557. private _lightColorUniformName;
  131558. private _lightTypeDefineName;
  131559. /**
  131560. * Gets or sets the light associated with this block
  131561. */
  131562. light: Nullable<Light>;
  131563. /**
  131564. * Creates a new LightInformationBlock
  131565. * @param name defines the block name
  131566. */
  131567. constructor(name: string);
  131568. /**
  131569. * Gets the current class name
  131570. * @returns the class name
  131571. */
  131572. getClassName(): string;
  131573. /**
  131574. * Gets the world position input component
  131575. */
  131576. get worldPosition(): NodeMaterialConnectionPoint;
  131577. /**
  131578. * Gets the direction output component
  131579. */
  131580. get direction(): NodeMaterialConnectionPoint;
  131581. /**
  131582. * Gets the direction output component
  131583. */
  131584. get color(): NodeMaterialConnectionPoint;
  131585. /**
  131586. * Gets the direction output component
  131587. */
  131588. get intensity(): NodeMaterialConnectionPoint;
  131589. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131590. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131591. protected _buildBlock(state: NodeMaterialBuildState): this;
  131592. serialize(): any;
  131593. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131594. }
  131595. }
  131596. declare module BABYLON {
  131597. /**
  131598. * Block used to add image processing support to fragment shader
  131599. */
  131600. export class ImageProcessingBlock extends NodeMaterialBlock {
  131601. /**
  131602. * Create a new ImageProcessingBlock
  131603. * @param name defines the block name
  131604. */
  131605. constructor(name: string);
  131606. /**
  131607. * Gets the current class name
  131608. * @returns the class name
  131609. */
  131610. getClassName(): string;
  131611. /**
  131612. * Gets the color input component
  131613. */
  131614. get color(): NodeMaterialConnectionPoint;
  131615. /**
  131616. * Gets the output component
  131617. */
  131618. get output(): NodeMaterialConnectionPoint;
  131619. /**
  131620. * Initialize the block and prepare the context for build
  131621. * @param state defines the state that will be used for the build
  131622. */
  131623. initialize(state: NodeMaterialBuildState): void;
  131624. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  131625. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131626. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131627. protected _buildBlock(state: NodeMaterialBuildState): this;
  131628. }
  131629. }
  131630. declare module BABYLON {
  131631. /**
  131632. * Block used to pertub normals based on a normal map
  131633. */
  131634. export class PerturbNormalBlock extends NodeMaterialBlock {
  131635. private _tangentSpaceParameterName;
  131636. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  131637. invertX: boolean;
  131638. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  131639. invertY: boolean;
  131640. /**
  131641. * Create a new PerturbNormalBlock
  131642. * @param name defines the block name
  131643. */
  131644. constructor(name: string);
  131645. /**
  131646. * Gets the current class name
  131647. * @returns the class name
  131648. */
  131649. getClassName(): string;
  131650. /**
  131651. * Gets the world position input component
  131652. */
  131653. get worldPosition(): NodeMaterialConnectionPoint;
  131654. /**
  131655. * Gets the world normal input component
  131656. */
  131657. get worldNormal(): NodeMaterialConnectionPoint;
  131658. /**
  131659. * Gets the world tangent input component
  131660. */
  131661. get worldTangent(): NodeMaterialConnectionPoint;
  131662. /**
  131663. * Gets the uv input component
  131664. */
  131665. get uv(): NodeMaterialConnectionPoint;
  131666. /**
  131667. * Gets the normal map color input component
  131668. */
  131669. get normalMapColor(): NodeMaterialConnectionPoint;
  131670. /**
  131671. * Gets the strength input component
  131672. */
  131673. get strength(): NodeMaterialConnectionPoint;
  131674. /**
  131675. * Gets the output component
  131676. */
  131677. get output(): NodeMaterialConnectionPoint;
  131678. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131679. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131680. autoConfigure(material: NodeMaterial): void;
  131681. protected _buildBlock(state: NodeMaterialBuildState): this;
  131682. protected _dumpPropertiesCode(): string;
  131683. serialize(): any;
  131684. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131685. }
  131686. }
  131687. declare module BABYLON {
  131688. /**
  131689. * Block used to discard a pixel if a value is smaller than a cutoff
  131690. */
  131691. export class DiscardBlock extends NodeMaterialBlock {
  131692. /**
  131693. * Create a new DiscardBlock
  131694. * @param name defines the block name
  131695. */
  131696. constructor(name: string);
  131697. /**
  131698. * Gets the current class name
  131699. * @returns the class name
  131700. */
  131701. getClassName(): string;
  131702. /**
  131703. * Gets the color input component
  131704. */
  131705. get value(): NodeMaterialConnectionPoint;
  131706. /**
  131707. * Gets the cutoff input component
  131708. */
  131709. get cutoff(): NodeMaterialConnectionPoint;
  131710. protected _buildBlock(state: NodeMaterialBuildState): this;
  131711. }
  131712. }
  131713. declare module BABYLON {
  131714. /**
  131715. * Block used to test if the fragment shader is front facing
  131716. */
  131717. export class FrontFacingBlock extends NodeMaterialBlock {
  131718. /**
  131719. * Creates a new FrontFacingBlock
  131720. * @param name defines the block name
  131721. */
  131722. constructor(name: string);
  131723. /**
  131724. * Gets the current class name
  131725. * @returns the class name
  131726. */
  131727. getClassName(): string;
  131728. /**
  131729. * Gets the output component
  131730. */
  131731. get output(): NodeMaterialConnectionPoint;
  131732. protected _buildBlock(state: NodeMaterialBuildState): this;
  131733. }
  131734. }
  131735. declare module BABYLON {
  131736. /**
  131737. * Block used to get the derivative value on x and y of a given input
  131738. */
  131739. export class DerivativeBlock extends NodeMaterialBlock {
  131740. /**
  131741. * Create a new DerivativeBlock
  131742. * @param name defines the block name
  131743. */
  131744. constructor(name: string);
  131745. /**
  131746. * Gets the current class name
  131747. * @returns the class name
  131748. */
  131749. getClassName(): string;
  131750. /**
  131751. * Gets the input component
  131752. */
  131753. get input(): NodeMaterialConnectionPoint;
  131754. /**
  131755. * Gets the derivative output on x
  131756. */
  131757. get dx(): NodeMaterialConnectionPoint;
  131758. /**
  131759. * Gets the derivative output on y
  131760. */
  131761. get dy(): NodeMaterialConnectionPoint;
  131762. protected _buildBlock(state: NodeMaterialBuildState): this;
  131763. }
  131764. }
  131765. declare module BABYLON {
  131766. /**
  131767. * Block used to add support for scene fog
  131768. */
  131769. export class FogBlock extends NodeMaterialBlock {
  131770. private _fogDistanceName;
  131771. private _fogParameters;
  131772. /**
  131773. * Create a new FogBlock
  131774. * @param name defines the block name
  131775. */
  131776. constructor(name: string);
  131777. /**
  131778. * Gets the current class name
  131779. * @returns the class name
  131780. */
  131781. getClassName(): string;
  131782. /**
  131783. * Gets the world position input component
  131784. */
  131785. get worldPosition(): NodeMaterialConnectionPoint;
  131786. /**
  131787. * Gets the view input component
  131788. */
  131789. get view(): NodeMaterialConnectionPoint;
  131790. /**
  131791. * Gets the color input component
  131792. */
  131793. get input(): NodeMaterialConnectionPoint;
  131794. /**
  131795. * Gets the fog color input component
  131796. */
  131797. get fogColor(): NodeMaterialConnectionPoint;
  131798. /**
  131799. * Gets the output component
  131800. */
  131801. get output(): NodeMaterialConnectionPoint;
  131802. autoConfigure(material: NodeMaterial): void;
  131803. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131804. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131805. protected _buildBlock(state: NodeMaterialBuildState): this;
  131806. }
  131807. }
  131808. declare module BABYLON {
  131809. /**
  131810. * Block used to add light in the fragment shader
  131811. */
  131812. export class LightBlock extends NodeMaterialBlock {
  131813. private _lightId;
  131814. /**
  131815. * Gets or sets the light associated with this block
  131816. */
  131817. light: Nullable<Light>;
  131818. /**
  131819. * Create a new LightBlock
  131820. * @param name defines the block name
  131821. */
  131822. constructor(name: string);
  131823. /**
  131824. * Gets the current class name
  131825. * @returns the class name
  131826. */
  131827. getClassName(): string;
  131828. /**
  131829. * Gets the world position input component
  131830. */
  131831. get worldPosition(): NodeMaterialConnectionPoint;
  131832. /**
  131833. * Gets the world normal input component
  131834. */
  131835. get worldNormal(): NodeMaterialConnectionPoint;
  131836. /**
  131837. * Gets the camera (or eye) position component
  131838. */
  131839. get cameraPosition(): NodeMaterialConnectionPoint;
  131840. /**
  131841. * Gets the glossiness component
  131842. */
  131843. get glossiness(): NodeMaterialConnectionPoint;
  131844. /**
  131845. * Gets the glossinness power component
  131846. */
  131847. get glossPower(): NodeMaterialConnectionPoint;
  131848. /**
  131849. * Gets the diffuse color component
  131850. */
  131851. get diffuseColor(): NodeMaterialConnectionPoint;
  131852. /**
  131853. * Gets the specular color component
  131854. */
  131855. get specularColor(): NodeMaterialConnectionPoint;
  131856. /**
  131857. * Gets the diffuse output component
  131858. */
  131859. get diffuseOutput(): NodeMaterialConnectionPoint;
  131860. /**
  131861. * Gets the specular output component
  131862. */
  131863. get specularOutput(): NodeMaterialConnectionPoint;
  131864. /**
  131865. * Gets the shadow output component
  131866. */
  131867. get shadow(): NodeMaterialConnectionPoint;
  131868. autoConfigure(material: NodeMaterial): void;
  131869. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131870. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131871. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131872. private _injectVertexCode;
  131873. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131874. serialize(): any;
  131875. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131876. }
  131877. }
  131878. declare module BABYLON {
  131879. /**
  131880. * Block used to multiply 2 values
  131881. */
  131882. export class MultiplyBlock extends NodeMaterialBlock {
  131883. /**
  131884. * Creates a new MultiplyBlock
  131885. * @param name defines the block name
  131886. */
  131887. constructor(name: string);
  131888. /**
  131889. * Gets the current class name
  131890. * @returns the class name
  131891. */
  131892. getClassName(): string;
  131893. /**
  131894. * Gets the left operand input component
  131895. */
  131896. get left(): NodeMaterialConnectionPoint;
  131897. /**
  131898. * Gets the right operand input component
  131899. */
  131900. get right(): NodeMaterialConnectionPoint;
  131901. /**
  131902. * Gets the output component
  131903. */
  131904. get output(): NodeMaterialConnectionPoint;
  131905. protected _buildBlock(state: NodeMaterialBuildState): this;
  131906. }
  131907. }
  131908. declare module BABYLON {
  131909. /**
  131910. * Block used to add 2 vectors
  131911. */
  131912. export class AddBlock extends NodeMaterialBlock {
  131913. /**
  131914. * Creates a new AddBlock
  131915. * @param name defines the block name
  131916. */
  131917. constructor(name: string);
  131918. /**
  131919. * Gets the current class name
  131920. * @returns the class name
  131921. */
  131922. getClassName(): string;
  131923. /**
  131924. * Gets the left operand input component
  131925. */
  131926. get left(): NodeMaterialConnectionPoint;
  131927. /**
  131928. * Gets the right operand input component
  131929. */
  131930. get right(): NodeMaterialConnectionPoint;
  131931. /**
  131932. * Gets the output component
  131933. */
  131934. get output(): NodeMaterialConnectionPoint;
  131935. protected _buildBlock(state: NodeMaterialBuildState): this;
  131936. }
  131937. }
  131938. declare module BABYLON {
  131939. /**
  131940. * Block used to scale a vector by a float
  131941. */
  131942. export class ScaleBlock extends NodeMaterialBlock {
  131943. /**
  131944. * Creates a new ScaleBlock
  131945. * @param name defines the block name
  131946. */
  131947. constructor(name: string);
  131948. /**
  131949. * Gets the current class name
  131950. * @returns the class name
  131951. */
  131952. getClassName(): string;
  131953. /**
  131954. * Gets the input component
  131955. */
  131956. get input(): NodeMaterialConnectionPoint;
  131957. /**
  131958. * Gets the factor input component
  131959. */
  131960. get factor(): NodeMaterialConnectionPoint;
  131961. /**
  131962. * Gets the output component
  131963. */
  131964. get output(): NodeMaterialConnectionPoint;
  131965. protected _buildBlock(state: NodeMaterialBuildState): this;
  131966. }
  131967. }
  131968. declare module BABYLON {
  131969. /**
  131970. * Block used to clamp a float
  131971. */
  131972. export class ClampBlock extends NodeMaterialBlock {
  131973. /** Gets or sets the minimum range */
  131974. minimum: number;
  131975. /** Gets or sets the maximum range */
  131976. maximum: number;
  131977. /**
  131978. * Creates a new ClampBlock
  131979. * @param name defines the block name
  131980. */
  131981. constructor(name: string);
  131982. /**
  131983. * Gets the current class name
  131984. * @returns the class name
  131985. */
  131986. getClassName(): string;
  131987. /**
  131988. * Gets the value input component
  131989. */
  131990. get value(): NodeMaterialConnectionPoint;
  131991. /**
  131992. * Gets the output component
  131993. */
  131994. get output(): NodeMaterialConnectionPoint;
  131995. protected _buildBlock(state: NodeMaterialBuildState): this;
  131996. protected _dumpPropertiesCode(): string;
  131997. serialize(): any;
  131998. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131999. }
  132000. }
  132001. declare module BABYLON {
  132002. /**
  132003. * Block used to apply a cross product between 2 vectors
  132004. */
  132005. export class CrossBlock extends NodeMaterialBlock {
  132006. /**
  132007. * Creates a new CrossBlock
  132008. * @param name defines the block name
  132009. */
  132010. constructor(name: string);
  132011. /**
  132012. * Gets the current class name
  132013. * @returns the class name
  132014. */
  132015. getClassName(): string;
  132016. /**
  132017. * Gets the left operand input component
  132018. */
  132019. get left(): NodeMaterialConnectionPoint;
  132020. /**
  132021. * Gets the right operand input component
  132022. */
  132023. get right(): NodeMaterialConnectionPoint;
  132024. /**
  132025. * Gets the output component
  132026. */
  132027. get output(): NodeMaterialConnectionPoint;
  132028. protected _buildBlock(state: NodeMaterialBuildState): this;
  132029. }
  132030. }
  132031. declare module BABYLON {
  132032. /**
  132033. * Block used to apply a dot product between 2 vectors
  132034. */
  132035. export class DotBlock extends NodeMaterialBlock {
  132036. /**
  132037. * Creates a new DotBlock
  132038. * @param name defines the block name
  132039. */
  132040. constructor(name: string);
  132041. /**
  132042. * Gets the current class name
  132043. * @returns the class name
  132044. */
  132045. getClassName(): string;
  132046. /**
  132047. * Gets the left operand input component
  132048. */
  132049. get left(): NodeMaterialConnectionPoint;
  132050. /**
  132051. * Gets the right operand input component
  132052. */
  132053. get right(): NodeMaterialConnectionPoint;
  132054. /**
  132055. * Gets the output component
  132056. */
  132057. get output(): NodeMaterialConnectionPoint;
  132058. protected _buildBlock(state: NodeMaterialBuildState): this;
  132059. }
  132060. }
  132061. declare module BABYLON {
  132062. /**
  132063. * Block used to remap a float from a range to a new one
  132064. */
  132065. export class RemapBlock extends NodeMaterialBlock {
  132066. /**
  132067. * Gets or sets the source range
  132068. */
  132069. sourceRange: Vector2;
  132070. /**
  132071. * Gets or sets the target range
  132072. */
  132073. targetRange: Vector2;
  132074. /**
  132075. * Creates a new RemapBlock
  132076. * @param name defines the block name
  132077. */
  132078. constructor(name: string);
  132079. /**
  132080. * Gets the current class name
  132081. * @returns the class name
  132082. */
  132083. getClassName(): string;
  132084. /**
  132085. * Gets the input component
  132086. */
  132087. get input(): NodeMaterialConnectionPoint;
  132088. /**
  132089. * Gets the source min input component
  132090. */
  132091. get sourceMin(): NodeMaterialConnectionPoint;
  132092. /**
  132093. * Gets the source max input component
  132094. */
  132095. get sourceMax(): NodeMaterialConnectionPoint;
  132096. /**
  132097. * Gets the target min input component
  132098. */
  132099. get targetMin(): NodeMaterialConnectionPoint;
  132100. /**
  132101. * Gets the target max input component
  132102. */
  132103. get targetMax(): NodeMaterialConnectionPoint;
  132104. /**
  132105. * Gets the output component
  132106. */
  132107. get output(): NodeMaterialConnectionPoint;
  132108. protected _buildBlock(state: NodeMaterialBuildState): this;
  132109. protected _dumpPropertiesCode(): string;
  132110. serialize(): any;
  132111. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132112. }
  132113. }
  132114. declare module BABYLON {
  132115. /**
  132116. * Block used to normalize a vector
  132117. */
  132118. export class NormalizeBlock extends NodeMaterialBlock {
  132119. /**
  132120. * Creates a new NormalizeBlock
  132121. * @param name defines the block name
  132122. */
  132123. constructor(name: string);
  132124. /**
  132125. * Gets the current class name
  132126. * @returns the class name
  132127. */
  132128. getClassName(): string;
  132129. /**
  132130. * Gets the input component
  132131. */
  132132. get input(): NodeMaterialConnectionPoint;
  132133. /**
  132134. * Gets the output component
  132135. */
  132136. get output(): NodeMaterialConnectionPoint;
  132137. protected _buildBlock(state: NodeMaterialBuildState): this;
  132138. }
  132139. }
  132140. declare module BABYLON {
  132141. /**
  132142. * Operations supported by the Trigonometry block
  132143. */
  132144. export enum TrigonometryBlockOperations {
  132145. /** Cos */
  132146. Cos = 0,
  132147. /** Sin */
  132148. Sin = 1,
  132149. /** Abs */
  132150. Abs = 2,
  132151. /** Exp */
  132152. Exp = 3,
  132153. /** Exp2 */
  132154. Exp2 = 4,
  132155. /** Round */
  132156. Round = 5,
  132157. /** Floor */
  132158. Floor = 6,
  132159. /** Ceiling */
  132160. Ceiling = 7,
  132161. /** Square root */
  132162. Sqrt = 8,
  132163. /** Log */
  132164. Log = 9,
  132165. /** Tangent */
  132166. Tan = 10,
  132167. /** Arc tangent */
  132168. ArcTan = 11,
  132169. /** Arc cosinus */
  132170. ArcCos = 12,
  132171. /** Arc sinus */
  132172. ArcSin = 13,
  132173. /** Fraction */
  132174. Fract = 14,
  132175. /** Sign */
  132176. Sign = 15,
  132177. /** To radians (from degrees) */
  132178. Radians = 16,
  132179. /** To degrees (from radians) */
  132180. Degrees = 17
  132181. }
  132182. /**
  132183. * Block used to apply trigonometry operation to floats
  132184. */
  132185. export class TrigonometryBlock extends NodeMaterialBlock {
  132186. /**
  132187. * Gets or sets the operation applied by the block
  132188. */
  132189. operation: TrigonometryBlockOperations;
  132190. /**
  132191. * Creates a new TrigonometryBlock
  132192. * @param name defines the block name
  132193. */
  132194. constructor(name: string);
  132195. /**
  132196. * Gets the current class name
  132197. * @returns the class name
  132198. */
  132199. getClassName(): string;
  132200. /**
  132201. * Gets the input component
  132202. */
  132203. get input(): NodeMaterialConnectionPoint;
  132204. /**
  132205. * Gets the output component
  132206. */
  132207. get output(): NodeMaterialConnectionPoint;
  132208. protected _buildBlock(state: NodeMaterialBuildState): this;
  132209. serialize(): any;
  132210. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132211. protected _dumpPropertiesCode(): string;
  132212. }
  132213. }
  132214. declare module BABYLON {
  132215. /**
  132216. * Block used to create a Color3/4 out of individual inputs (one for each component)
  132217. */
  132218. export class ColorMergerBlock extends NodeMaterialBlock {
  132219. /**
  132220. * Create a new ColorMergerBlock
  132221. * @param name defines the block name
  132222. */
  132223. constructor(name: string);
  132224. /**
  132225. * Gets the current class name
  132226. * @returns the class name
  132227. */
  132228. getClassName(): string;
  132229. /**
  132230. * Gets the rgb component (input)
  132231. */
  132232. get rgbIn(): NodeMaterialConnectionPoint;
  132233. /**
  132234. * Gets the r component (input)
  132235. */
  132236. get r(): NodeMaterialConnectionPoint;
  132237. /**
  132238. * Gets the g component (input)
  132239. */
  132240. get g(): NodeMaterialConnectionPoint;
  132241. /**
  132242. * Gets the b component (input)
  132243. */
  132244. get b(): NodeMaterialConnectionPoint;
  132245. /**
  132246. * Gets the a component (input)
  132247. */
  132248. get a(): NodeMaterialConnectionPoint;
  132249. /**
  132250. * Gets the rgba component (output)
  132251. */
  132252. get rgba(): NodeMaterialConnectionPoint;
  132253. /**
  132254. * Gets the rgb component (output)
  132255. */
  132256. get rgbOut(): NodeMaterialConnectionPoint;
  132257. /**
  132258. * Gets the rgb component (output)
  132259. * @deprecated Please use rgbOut instead.
  132260. */
  132261. get rgb(): NodeMaterialConnectionPoint;
  132262. protected _buildBlock(state: NodeMaterialBuildState): this;
  132263. }
  132264. }
  132265. declare module BABYLON {
  132266. /**
  132267. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  132268. */
  132269. export class VectorMergerBlock extends NodeMaterialBlock {
  132270. /**
  132271. * Create a new VectorMergerBlock
  132272. * @param name defines the block name
  132273. */
  132274. constructor(name: string);
  132275. /**
  132276. * Gets the current class name
  132277. * @returns the class name
  132278. */
  132279. getClassName(): string;
  132280. /**
  132281. * Gets the xyz component (input)
  132282. */
  132283. get xyzIn(): NodeMaterialConnectionPoint;
  132284. /**
  132285. * Gets the xy component (input)
  132286. */
  132287. get xyIn(): NodeMaterialConnectionPoint;
  132288. /**
  132289. * Gets the x component (input)
  132290. */
  132291. get x(): NodeMaterialConnectionPoint;
  132292. /**
  132293. * Gets the y component (input)
  132294. */
  132295. get y(): NodeMaterialConnectionPoint;
  132296. /**
  132297. * Gets the z component (input)
  132298. */
  132299. get z(): NodeMaterialConnectionPoint;
  132300. /**
  132301. * Gets the w component (input)
  132302. */
  132303. get w(): NodeMaterialConnectionPoint;
  132304. /**
  132305. * Gets the xyzw component (output)
  132306. */
  132307. get xyzw(): NodeMaterialConnectionPoint;
  132308. /**
  132309. * Gets the xyz component (output)
  132310. */
  132311. get xyzOut(): NodeMaterialConnectionPoint;
  132312. /**
  132313. * Gets the xy component (output)
  132314. */
  132315. get xyOut(): NodeMaterialConnectionPoint;
  132316. /**
  132317. * Gets the xy component (output)
  132318. * @deprecated Please use xyOut instead.
  132319. */
  132320. get xy(): NodeMaterialConnectionPoint;
  132321. /**
  132322. * Gets the xyz component (output)
  132323. * @deprecated Please use xyzOut instead.
  132324. */
  132325. get xyz(): NodeMaterialConnectionPoint;
  132326. protected _buildBlock(state: NodeMaterialBuildState): this;
  132327. }
  132328. }
  132329. declare module BABYLON {
  132330. /**
  132331. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  132332. */
  132333. export class ColorSplitterBlock extends NodeMaterialBlock {
  132334. /**
  132335. * Create a new ColorSplitterBlock
  132336. * @param name defines the block name
  132337. */
  132338. constructor(name: string);
  132339. /**
  132340. * Gets the current class name
  132341. * @returns the class name
  132342. */
  132343. getClassName(): string;
  132344. /**
  132345. * Gets the rgba component (input)
  132346. */
  132347. get rgba(): NodeMaterialConnectionPoint;
  132348. /**
  132349. * Gets the rgb component (input)
  132350. */
  132351. get rgbIn(): NodeMaterialConnectionPoint;
  132352. /**
  132353. * Gets the rgb component (output)
  132354. */
  132355. get rgbOut(): NodeMaterialConnectionPoint;
  132356. /**
  132357. * Gets the r component (output)
  132358. */
  132359. get r(): NodeMaterialConnectionPoint;
  132360. /**
  132361. * Gets the g component (output)
  132362. */
  132363. get g(): NodeMaterialConnectionPoint;
  132364. /**
  132365. * Gets the b component (output)
  132366. */
  132367. get b(): NodeMaterialConnectionPoint;
  132368. /**
  132369. * Gets the a component (output)
  132370. */
  132371. get a(): NodeMaterialConnectionPoint;
  132372. protected _inputRename(name: string): string;
  132373. protected _outputRename(name: string): string;
  132374. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132375. }
  132376. }
  132377. declare module BABYLON {
  132378. /**
  132379. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  132380. */
  132381. export class VectorSplitterBlock extends NodeMaterialBlock {
  132382. /**
  132383. * Create a new VectorSplitterBlock
  132384. * @param name defines the block name
  132385. */
  132386. constructor(name: string);
  132387. /**
  132388. * Gets the current class name
  132389. * @returns the class name
  132390. */
  132391. getClassName(): string;
  132392. /**
  132393. * Gets the xyzw component (input)
  132394. */
  132395. get xyzw(): NodeMaterialConnectionPoint;
  132396. /**
  132397. * Gets the xyz component (input)
  132398. */
  132399. get xyzIn(): NodeMaterialConnectionPoint;
  132400. /**
  132401. * Gets the xy component (input)
  132402. */
  132403. get xyIn(): NodeMaterialConnectionPoint;
  132404. /**
  132405. * Gets the xyz component (output)
  132406. */
  132407. get xyzOut(): NodeMaterialConnectionPoint;
  132408. /**
  132409. * Gets the xy component (output)
  132410. */
  132411. get xyOut(): NodeMaterialConnectionPoint;
  132412. /**
  132413. * Gets the x component (output)
  132414. */
  132415. get x(): NodeMaterialConnectionPoint;
  132416. /**
  132417. * Gets the y component (output)
  132418. */
  132419. get y(): NodeMaterialConnectionPoint;
  132420. /**
  132421. * Gets the z component (output)
  132422. */
  132423. get z(): NodeMaterialConnectionPoint;
  132424. /**
  132425. * Gets the w component (output)
  132426. */
  132427. get w(): NodeMaterialConnectionPoint;
  132428. protected _inputRename(name: string): string;
  132429. protected _outputRename(name: string): string;
  132430. protected _buildBlock(state: NodeMaterialBuildState): this;
  132431. }
  132432. }
  132433. declare module BABYLON {
  132434. /**
  132435. * Block used to lerp between 2 values
  132436. */
  132437. export class LerpBlock extends NodeMaterialBlock {
  132438. /**
  132439. * Creates a new LerpBlock
  132440. * @param name defines the block name
  132441. */
  132442. constructor(name: string);
  132443. /**
  132444. * Gets the current class name
  132445. * @returns the class name
  132446. */
  132447. getClassName(): string;
  132448. /**
  132449. * Gets the left operand input component
  132450. */
  132451. get left(): NodeMaterialConnectionPoint;
  132452. /**
  132453. * Gets the right operand input component
  132454. */
  132455. get right(): NodeMaterialConnectionPoint;
  132456. /**
  132457. * Gets the gradient operand input component
  132458. */
  132459. get gradient(): NodeMaterialConnectionPoint;
  132460. /**
  132461. * Gets the output component
  132462. */
  132463. get output(): NodeMaterialConnectionPoint;
  132464. protected _buildBlock(state: NodeMaterialBuildState): this;
  132465. }
  132466. }
  132467. declare module BABYLON {
  132468. /**
  132469. * Block used to divide 2 vectors
  132470. */
  132471. export class DivideBlock extends NodeMaterialBlock {
  132472. /**
  132473. * Creates a new DivideBlock
  132474. * @param name defines the block name
  132475. */
  132476. constructor(name: string);
  132477. /**
  132478. * Gets the current class name
  132479. * @returns the class name
  132480. */
  132481. getClassName(): string;
  132482. /**
  132483. * Gets the left operand input component
  132484. */
  132485. get left(): NodeMaterialConnectionPoint;
  132486. /**
  132487. * Gets the right operand input component
  132488. */
  132489. get right(): NodeMaterialConnectionPoint;
  132490. /**
  132491. * Gets the output component
  132492. */
  132493. get output(): NodeMaterialConnectionPoint;
  132494. protected _buildBlock(state: NodeMaterialBuildState): this;
  132495. }
  132496. }
  132497. declare module BABYLON {
  132498. /**
  132499. * Block used to subtract 2 vectors
  132500. */
  132501. export class SubtractBlock extends NodeMaterialBlock {
  132502. /**
  132503. * Creates a new SubtractBlock
  132504. * @param name defines the block name
  132505. */
  132506. constructor(name: string);
  132507. /**
  132508. * Gets the current class name
  132509. * @returns the class name
  132510. */
  132511. getClassName(): string;
  132512. /**
  132513. * Gets the left operand input component
  132514. */
  132515. get left(): NodeMaterialConnectionPoint;
  132516. /**
  132517. * Gets the right operand input component
  132518. */
  132519. get right(): NodeMaterialConnectionPoint;
  132520. /**
  132521. * Gets the output component
  132522. */
  132523. get output(): NodeMaterialConnectionPoint;
  132524. protected _buildBlock(state: NodeMaterialBuildState): this;
  132525. }
  132526. }
  132527. declare module BABYLON {
  132528. /**
  132529. * Block used to step a value
  132530. */
  132531. export class StepBlock extends NodeMaterialBlock {
  132532. /**
  132533. * Creates a new StepBlock
  132534. * @param name defines the block name
  132535. */
  132536. constructor(name: string);
  132537. /**
  132538. * Gets the current class name
  132539. * @returns the class name
  132540. */
  132541. getClassName(): string;
  132542. /**
  132543. * Gets the value operand input component
  132544. */
  132545. get value(): NodeMaterialConnectionPoint;
  132546. /**
  132547. * Gets the edge operand input component
  132548. */
  132549. get edge(): NodeMaterialConnectionPoint;
  132550. /**
  132551. * Gets the output component
  132552. */
  132553. get output(): NodeMaterialConnectionPoint;
  132554. protected _buildBlock(state: NodeMaterialBuildState): this;
  132555. }
  132556. }
  132557. declare module BABYLON {
  132558. /**
  132559. * Block used to get the opposite (1 - x) of a value
  132560. */
  132561. export class OneMinusBlock extends NodeMaterialBlock {
  132562. /**
  132563. * Creates a new OneMinusBlock
  132564. * @param name defines the block name
  132565. */
  132566. constructor(name: string);
  132567. /**
  132568. * Gets the current class name
  132569. * @returns the class name
  132570. */
  132571. getClassName(): string;
  132572. /**
  132573. * Gets the input component
  132574. */
  132575. get input(): NodeMaterialConnectionPoint;
  132576. /**
  132577. * Gets the output component
  132578. */
  132579. get output(): NodeMaterialConnectionPoint;
  132580. protected _buildBlock(state: NodeMaterialBuildState): this;
  132581. }
  132582. }
  132583. declare module BABYLON {
  132584. /**
  132585. * Block used to get the view direction
  132586. */
  132587. export class ViewDirectionBlock extends NodeMaterialBlock {
  132588. /**
  132589. * Creates a new ViewDirectionBlock
  132590. * @param name defines the block name
  132591. */
  132592. constructor(name: string);
  132593. /**
  132594. * Gets the current class name
  132595. * @returns the class name
  132596. */
  132597. getClassName(): string;
  132598. /**
  132599. * Gets the world position component
  132600. */
  132601. get worldPosition(): NodeMaterialConnectionPoint;
  132602. /**
  132603. * Gets the camera position component
  132604. */
  132605. get cameraPosition(): NodeMaterialConnectionPoint;
  132606. /**
  132607. * Gets the output component
  132608. */
  132609. get output(): NodeMaterialConnectionPoint;
  132610. autoConfigure(material: NodeMaterial): void;
  132611. protected _buildBlock(state: NodeMaterialBuildState): this;
  132612. }
  132613. }
  132614. declare module BABYLON {
  132615. /**
  132616. * Block used to compute fresnel value
  132617. */
  132618. export class FresnelBlock extends NodeMaterialBlock {
  132619. /**
  132620. * Create a new FresnelBlock
  132621. * @param name defines the block name
  132622. */
  132623. constructor(name: string);
  132624. /**
  132625. * Gets the current class name
  132626. * @returns the class name
  132627. */
  132628. getClassName(): string;
  132629. /**
  132630. * Gets the world normal input component
  132631. */
  132632. get worldNormal(): NodeMaterialConnectionPoint;
  132633. /**
  132634. * Gets the view direction input component
  132635. */
  132636. get viewDirection(): NodeMaterialConnectionPoint;
  132637. /**
  132638. * Gets the bias input component
  132639. */
  132640. get bias(): NodeMaterialConnectionPoint;
  132641. /**
  132642. * Gets the camera (or eye) position component
  132643. */
  132644. get power(): NodeMaterialConnectionPoint;
  132645. /**
  132646. * Gets the fresnel output component
  132647. */
  132648. get fresnel(): NodeMaterialConnectionPoint;
  132649. autoConfigure(material: NodeMaterial): void;
  132650. protected _buildBlock(state: NodeMaterialBuildState): this;
  132651. }
  132652. }
  132653. declare module BABYLON {
  132654. /**
  132655. * Block used to get the max of 2 values
  132656. */
  132657. export class MaxBlock extends NodeMaterialBlock {
  132658. /**
  132659. * Creates a new MaxBlock
  132660. * @param name defines the block name
  132661. */
  132662. constructor(name: string);
  132663. /**
  132664. * Gets the current class name
  132665. * @returns the class name
  132666. */
  132667. getClassName(): string;
  132668. /**
  132669. * Gets the left operand input component
  132670. */
  132671. get left(): NodeMaterialConnectionPoint;
  132672. /**
  132673. * Gets the right operand input component
  132674. */
  132675. get right(): NodeMaterialConnectionPoint;
  132676. /**
  132677. * Gets the output component
  132678. */
  132679. get output(): NodeMaterialConnectionPoint;
  132680. protected _buildBlock(state: NodeMaterialBuildState): this;
  132681. }
  132682. }
  132683. declare module BABYLON {
  132684. /**
  132685. * Block used to get the min of 2 values
  132686. */
  132687. export class MinBlock extends NodeMaterialBlock {
  132688. /**
  132689. * Creates a new MinBlock
  132690. * @param name defines the block name
  132691. */
  132692. constructor(name: string);
  132693. /**
  132694. * Gets the current class name
  132695. * @returns the class name
  132696. */
  132697. getClassName(): string;
  132698. /**
  132699. * Gets the left operand input component
  132700. */
  132701. get left(): NodeMaterialConnectionPoint;
  132702. /**
  132703. * Gets the right operand input component
  132704. */
  132705. get right(): NodeMaterialConnectionPoint;
  132706. /**
  132707. * Gets the output component
  132708. */
  132709. get output(): NodeMaterialConnectionPoint;
  132710. protected _buildBlock(state: NodeMaterialBuildState): this;
  132711. }
  132712. }
  132713. declare module BABYLON {
  132714. /**
  132715. * Block used to get the distance between 2 values
  132716. */
  132717. export class DistanceBlock extends NodeMaterialBlock {
  132718. /**
  132719. * Creates a new DistanceBlock
  132720. * @param name defines the block name
  132721. */
  132722. constructor(name: string);
  132723. /**
  132724. * Gets the current class name
  132725. * @returns the class name
  132726. */
  132727. getClassName(): string;
  132728. /**
  132729. * Gets the left operand input component
  132730. */
  132731. get left(): NodeMaterialConnectionPoint;
  132732. /**
  132733. * Gets the right operand input component
  132734. */
  132735. get right(): NodeMaterialConnectionPoint;
  132736. /**
  132737. * Gets the output component
  132738. */
  132739. get output(): NodeMaterialConnectionPoint;
  132740. protected _buildBlock(state: NodeMaterialBuildState): this;
  132741. }
  132742. }
  132743. declare module BABYLON {
  132744. /**
  132745. * Block used to get the length of a vector
  132746. */
  132747. export class LengthBlock extends NodeMaterialBlock {
  132748. /**
  132749. * Creates a new LengthBlock
  132750. * @param name defines the block name
  132751. */
  132752. constructor(name: string);
  132753. /**
  132754. * Gets the current class name
  132755. * @returns the class name
  132756. */
  132757. getClassName(): string;
  132758. /**
  132759. * Gets the value input component
  132760. */
  132761. get value(): NodeMaterialConnectionPoint;
  132762. /**
  132763. * Gets the output component
  132764. */
  132765. get output(): NodeMaterialConnectionPoint;
  132766. protected _buildBlock(state: NodeMaterialBuildState): this;
  132767. }
  132768. }
  132769. declare module BABYLON {
  132770. /**
  132771. * Block used to get negative version of a value (i.e. x * -1)
  132772. */
  132773. export class NegateBlock extends NodeMaterialBlock {
  132774. /**
  132775. * Creates a new NegateBlock
  132776. * @param name defines the block name
  132777. */
  132778. constructor(name: string);
  132779. /**
  132780. * Gets the current class name
  132781. * @returns the class name
  132782. */
  132783. getClassName(): string;
  132784. /**
  132785. * Gets the value input component
  132786. */
  132787. get value(): NodeMaterialConnectionPoint;
  132788. /**
  132789. * Gets the output component
  132790. */
  132791. get output(): NodeMaterialConnectionPoint;
  132792. protected _buildBlock(state: NodeMaterialBuildState): this;
  132793. }
  132794. }
  132795. declare module BABYLON {
  132796. /**
  132797. * Block used to get the value of the first parameter raised to the power of the second
  132798. */
  132799. export class PowBlock extends NodeMaterialBlock {
  132800. /**
  132801. * Creates a new PowBlock
  132802. * @param name defines the block name
  132803. */
  132804. constructor(name: string);
  132805. /**
  132806. * Gets the current class name
  132807. * @returns the class name
  132808. */
  132809. getClassName(): string;
  132810. /**
  132811. * Gets the value operand input component
  132812. */
  132813. get value(): NodeMaterialConnectionPoint;
  132814. /**
  132815. * Gets the power operand input component
  132816. */
  132817. get power(): NodeMaterialConnectionPoint;
  132818. /**
  132819. * Gets the output component
  132820. */
  132821. get output(): NodeMaterialConnectionPoint;
  132822. protected _buildBlock(state: NodeMaterialBuildState): this;
  132823. }
  132824. }
  132825. declare module BABYLON {
  132826. /**
  132827. * Block used to get a random number
  132828. */
  132829. export class RandomNumberBlock extends NodeMaterialBlock {
  132830. /**
  132831. * Creates a new RandomNumberBlock
  132832. * @param name defines the block name
  132833. */
  132834. constructor(name: string);
  132835. /**
  132836. * Gets the current class name
  132837. * @returns the class name
  132838. */
  132839. getClassName(): string;
  132840. /**
  132841. * Gets the seed input component
  132842. */
  132843. get seed(): NodeMaterialConnectionPoint;
  132844. /**
  132845. * Gets the output component
  132846. */
  132847. get output(): NodeMaterialConnectionPoint;
  132848. protected _buildBlock(state: NodeMaterialBuildState): this;
  132849. }
  132850. }
  132851. declare module BABYLON {
  132852. /**
  132853. * Block used to compute arc tangent of 2 values
  132854. */
  132855. export class ArcTan2Block extends NodeMaterialBlock {
  132856. /**
  132857. * Creates a new ArcTan2Block
  132858. * @param name defines the block name
  132859. */
  132860. constructor(name: string);
  132861. /**
  132862. * Gets the current class name
  132863. * @returns the class name
  132864. */
  132865. getClassName(): string;
  132866. /**
  132867. * Gets the x operand input component
  132868. */
  132869. get x(): NodeMaterialConnectionPoint;
  132870. /**
  132871. * Gets the y operand input component
  132872. */
  132873. get y(): 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 smooth step a value
  132884. */
  132885. export class SmoothStepBlock extends NodeMaterialBlock {
  132886. /**
  132887. * Creates a new SmoothStepBlock
  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 value operand input component
  132898. */
  132899. get value(): NodeMaterialConnectionPoint;
  132900. /**
  132901. * Gets the first edge operand input component
  132902. */
  132903. get edge0(): NodeMaterialConnectionPoint;
  132904. /**
  132905. * Gets the second edge operand input component
  132906. */
  132907. get edge1(): NodeMaterialConnectionPoint;
  132908. /**
  132909. * Gets the output component
  132910. */
  132911. get output(): NodeMaterialConnectionPoint;
  132912. protected _buildBlock(state: NodeMaterialBuildState): this;
  132913. }
  132914. }
  132915. declare module BABYLON {
  132916. /**
  132917. * Block used to get the reciprocal (1 / x) of a value
  132918. */
  132919. export class ReciprocalBlock extends NodeMaterialBlock {
  132920. /**
  132921. * Creates a new ReciprocalBlock
  132922. * @param name defines the block name
  132923. */
  132924. constructor(name: string);
  132925. /**
  132926. * Gets the current class name
  132927. * @returns the class name
  132928. */
  132929. getClassName(): string;
  132930. /**
  132931. * Gets the input component
  132932. */
  132933. get input(): NodeMaterialConnectionPoint;
  132934. /**
  132935. * Gets the output component
  132936. */
  132937. get output(): NodeMaterialConnectionPoint;
  132938. protected _buildBlock(state: NodeMaterialBuildState): this;
  132939. }
  132940. }
  132941. declare module BABYLON {
  132942. /**
  132943. * Block used to replace a color by another one
  132944. */
  132945. export class ReplaceColorBlock extends NodeMaterialBlock {
  132946. /**
  132947. * Creates a new ReplaceColorBlock
  132948. * @param name defines the block name
  132949. */
  132950. constructor(name: string);
  132951. /**
  132952. * Gets the current class name
  132953. * @returns the class name
  132954. */
  132955. getClassName(): string;
  132956. /**
  132957. * Gets the value input component
  132958. */
  132959. get value(): NodeMaterialConnectionPoint;
  132960. /**
  132961. * Gets the reference input component
  132962. */
  132963. get reference(): NodeMaterialConnectionPoint;
  132964. /**
  132965. * Gets the distance input component
  132966. */
  132967. get distance(): NodeMaterialConnectionPoint;
  132968. /**
  132969. * Gets the replacement input component
  132970. */
  132971. get replacement(): NodeMaterialConnectionPoint;
  132972. /**
  132973. * Gets the output component
  132974. */
  132975. get output(): NodeMaterialConnectionPoint;
  132976. protected _buildBlock(state: NodeMaterialBuildState): this;
  132977. }
  132978. }
  132979. declare module BABYLON {
  132980. /**
  132981. * Block used to posterize a value
  132982. * @see https://en.wikipedia.org/wiki/Posterization
  132983. */
  132984. export class PosterizeBlock extends NodeMaterialBlock {
  132985. /**
  132986. * Creates a new PosterizeBlock
  132987. * @param name defines the block name
  132988. */
  132989. constructor(name: string);
  132990. /**
  132991. * Gets the current class name
  132992. * @returns the class name
  132993. */
  132994. getClassName(): string;
  132995. /**
  132996. * Gets the value input component
  132997. */
  132998. get value(): NodeMaterialConnectionPoint;
  132999. /**
  133000. * Gets the steps input component
  133001. */
  133002. get steps(): NodeMaterialConnectionPoint;
  133003. /**
  133004. * Gets the output component
  133005. */
  133006. get output(): NodeMaterialConnectionPoint;
  133007. protected _buildBlock(state: NodeMaterialBuildState): this;
  133008. }
  133009. }
  133010. declare module BABYLON {
  133011. /**
  133012. * Operations supported by the Wave block
  133013. */
  133014. export enum WaveBlockKind {
  133015. /** SawTooth */
  133016. SawTooth = 0,
  133017. /** Square */
  133018. Square = 1,
  133019. /** Triangle */
  133020. Triangle = 2
  133021. }
  133022. /**
  133023. * Block used to apply wave operation to floats
  133024. */
  133025. export class WaveBlock extends NodeMaterialBlock {
  133026. /**
  133027. * Gets or sets the kibnd of wave to be applied by the block
  133028. */
  133029. kind: WaveBlockKind;
  133030. /**
  133031. * Creates a new WaveBlock
  133032. * @param name defines the block name
  133033. */
  133034. constructor(name: string);
  133035. /**
  133036. * Gets the current class name
  133037. * @returns the class name
  133038. */
  133039. getClassName(): string;
  133040. /**
  133041. * Gets the input component
  133042. */
  133043. get input(): NodeMaterialConnectionPoint;
  133044. /**
  133045. * Gets the output component
  133046. */
  133047. get output(): NodeMaterialConnectionPoint;
  133048. protected _buildBlock(state: NodeMaterialBuildState): this;
  133049. serialize(): any;
  133050. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133051. }
  133052. }
  133053. declare module BABYLON {
  133054. /**
  133055. * Class used to store a color step for the GradientBlock
  133056. */
  133057. export class GradientBlockColorStep {
  133058. /**
  133059. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133060. */
  133061. step: number;
  133062. /**
  133063. * Gets or sets the color associated with this step
  133064. */
  133065. color: Color3;
  133066. /**
  133067. * Creates a new GradientBlockColorStep
  133068. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  133069. * @param color defines the color associated with this step
  133070. */
  133071. constructor(
  133072. /**
  133073. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133074. */
  133075. step: number,
  133076. /**
  133077. * Gets or sets the color associated with this step
  133078. */
  133079. color: Color3);
  133080. }
  133081. /**
  133082. * Block used to return a color from a gradient based on an input value between 0 and 1
  133083. */
  133084. export class GradientBlock extends NodeMaterialBlock {
  133085. /**
  133086. * Gets or sets the list of color steps
  133087. */
  133088. colorSteps: GradientBlockColorStep[];
  133089. /**
  133090. * Creates a new GradientBlock
  133091. * @param name defines the block name
  133092. */
  133093. constructor(name: string);
  133094. /**
  133095. * Gets the current class name
  133096. * @returns the class name
  133097. */
  133098. getClassName(): string;
  133099. /**
  133100. * Gets the gradient input component
  133101. */
  133102. get gradient(): NodeMaterialConnectionPoint;
  133103. /**
  133104. * Gets the output component
  133105. */
  133106. get output(): NodeMaterialConnectionPoint;
  133107. private _writeColorConstant;
  133108. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133109. serialize(): any;
  133110. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133111. protected _dumpPropertiesCode(): string;
  133112. }
  133113. }
  133114. declare module BABYLON {
  133115. /**
  133116. * Block used to normalize lerp between 2 values
  133117. */
  133118. export class NLerpBlock extends NodeMaterialBlock {
  133119. /**
  133120. * Creates a new NLerpBlock
  133121. * @param name defines the block name
  133122. */
  133123. constructor(name: string);
  133124. /**
  133125. * Gets the current class name
  133126. * @returns the class name
  133127. */
  133128. getClassName(): string;
  133129. /**
  133130. * Gets the left operand input component
  133131. */
  133132. get left(): NodeMaterialConnectionPoint;
  133133. /**
  133134. * Gets the right operand input component
  133135. */
  133136. get right(): NodeMaterialConnectionPoint;
  133137. /**
  133138. * Gets the gradient operand input component
  133139. */
  133140. get gradient(): NodeMaterialConnectionPoint;
  133141. /**
  133142. * Gets the output component
  133143. */
  133144. get output(): NodeMaterialConnectionPoint;
  133145. protected _buildBlock(state: NodeMaterialBuildState): this;
  133146. }
  133147. }
  133148. declare module BABYLON {
  133149. /**
  133150. * block used to Generate a Worley Noise 3D Noise Pattern
  133151. */
  133152. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  133153. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133154. manhattanDistance: boolean;
  133155. /**
  133156. * Creates a new WorleyNoise3DBlock
  133157. * @param name defines the block name
  133158. */
  133159. constructor(name: string);
  133160. /**
  133161. * Gets the current class name
  133162. * @returns the class name
  133163. */
  133164. getClassName(): string;
  133165. /**
  133166. * Gets the seed input component
  133167. */
  133168. get seed(): NodeMaterialConnectionPoint;
  133169. /**
  133170. * Gets the jitter input component
  133171. */
  133172. get jitter(): NodeMaterialConnectionPoint;
  133173. /**
  133174. * Gets the output component
  133175. */
  133176. get output(): NodeMaterialConnectionPoint;
  133177. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133178. /**
  133179. * Exposes the properties to the UI?
  133180. */
  133181. protected _dumpPropertiesCode(): string;
  133182. /**
  133183. * Exposes the properties to the Seralize?
  133184. */
  133185. serialize(): any;
  133186. /**
  133187. * Exposes the properties to the deseralize?
  133188. */
  133189. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133190. }
  133191. }
  133192. declare module BABYLON {
  133193. /**
  133194. * block used to Generate a Simplex Perlin 3d Noise Pattern
  133195. */
  133196. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  133197. /**
  133198. * Creates a new SimplexPerlin3DBlock
  133199. * @param name defines the block name
  133200. */
  133201. constructor(name: string);
  133202. /**
  133203. * Gets the current class name
  133204. * @returns the class name
  133205. */
  133206. getClassName(): string;
  133207. /**
  133208. * Gets the seed operand input component
  133209. */
  133210. get seed(): NodeMaterialConnectionPoint;
  133211. /**
  133212. * Gets the output component
  133213. */
  133214. get output(): NodeMaterialConnectionPoint;
  133215. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133216. }
  133217. }
  133218. declare module BABYLON {
  133219. /**
  133220. * Block used to blend normals
  133221. */
  133222. export class NormalBlendBlock extends NodeMaterialBlock {
  133223. /**
  133224. * Creates a new NormalBlendBlock
  133225. * @param name defines the block name
  133226. */
  133227. constructor(name: string);
  133228. /**
  133229. * Gets the current class name
  133230. * @returns the class name
  133231. */
  133232. getClassName(): string;
  133233. /**
  133234. * Gets the first input component
  133235. */
  133236. get normalMap0(): NodeMaterialConnectionPoint;
  133237. /**
  133238. * Gets the second input component
  133239. */
  133240. get normalMap1(): NodeMaterialConnectionPoint;
  133241. /**
  133242. * Gets the output component
  133243. */
  133244. get output(): NodeMaterialConnectionPoint;
  133245. protected _buildBlock(state: NodeMaterialBuildState): this;
  133246. }
  133247. }
  133248. declare module BABYLON {
  133249. /**
  133250. * Block used to rotate a 2d vector by a given angle
  133251. */
  133252. export class Rotate2dBlock extends NodeMaterialBlock {
  133253. /**
  133254. * Creates a new Rotate2dBlock
  133255. * @param name defines the block name
  133256. */
  133257. constructor(name: string);
  133258. /**
  133259. * Gets the current class name
  133260. * @returns the class name
  133261. */
  133262. getClassName(): string;
  133263. /**
  133264. * Gets the input vector
  133265. */
  133266. get input(): NodeMaterialConnectionPoint;
  133267. /**
  133268. * Gets the input angle
  133269. */
  133270. get angle(): NodeMaterialConnectionPoint;
  133271. /**
  133272. * Gets the output component
  133273. */
  133274. get output(): NodeMaterialConnectionPoint;
  133275. autoConfigure(material: NodeMaterial): void;
  133276. protected _buildBlock(state: NodeMaterialBuildState): this;
  133277. }
  133278. }
  133279. declare module BABYLON {
  133280. /**
  133281. * Block used to get the reflected vector from a direction and a normal
  133282. */
  133283. export class ReflectBlock extends NodeMaterialBlock {
  133284. /**
  133285. * Creates a new ReflectBlock
  133286. * @param name defines the block name
  133287. */
  133288. constructor(name: string);
  133289. /**
  133290. * Gets the current class name
  133291. * @returns the class name
  133292. */
  133293. getClassName(): string;
  133294. /**
  133295. * Gets the incident component
  133296. */
  133297. get incident(): NodeMaterialConnectionPoint;
  133298. /**
  133299. * Gets the normal component
  133300. */
  133301. get normal(): NodeMaterialConnectionPoint;
  133302. /**
  133303. * Gets the output component
  133304. */
  133305. get output(): NodeMaterialConnectionPoint;
  133306. protected _buildBlock(state: NodeMaterialBuildState): this;
  133307. }
  133308. }
  133309. declare module BABYLON {
  133310. /**
  133311. * Block used to get the refracted vector from a direction and a normal
  133312. */
  133313. export class RefractBlock extends NodeMaterialBlock {
  133314. /**
  133315. * Creates a new RefractBlock
  133316. * @param name defines the block name
  133317. */
  133318. constructor(name: string);
  133319. /**
  133320. * Gets the current class name
  133321. * @returns the class name
  133322. */
  133323. getClassName(): string;
  133324. /**
  133325. * Gets the incident component
  133326. */
  133327. get incident(): NodeMaterialConnectionPoint;
  133328. /**
  133329. * Gets the normal component
  133330. */
  133331. get normal(): NodeMaterialConnectionPoint;
  133332. /**
  133333. * Gets the index of refraction component
  133334. */
  133335. get ior(): NodeMaterialConnectionPoint;
  133336. /**
  133337. * Gets the output component
  133338. */
  133339. get output(): NodeMaterialConnectionPoint;
  133340. protected _buildBlock(state: NodeMaterialBuildState): this;
  133341. }
  133342. }
  133343. declare module BABYLON {
  133344. /**
  133345. * Block used to desaturate a color
  133346. */
  133347. export class DesaturateBlock extends NodeMaterialBlock {
  133348. /**
  133349. * Creates a new DesaturateBlock
  133350. * @param name defines the block name
  133351. */
  133352. constructor(name: string);
  133353. /**
  133354. * Gets the current class name
  133355. * @returns the class name
  133356. */
  133357. getClassName(): string;
  133358. /**
  133359. * Gets the color operand input component
  133360. */
  133361. get color(): NodeMaterialConnectionPoint;
  133362. /**
  133363. * Gets the level operand input component
  133364. */
  133365. get level(): NodeMaterialConnectionPoint;
  133366. /**
  133367. * Gets the output component
  133368. */
  133369. get output(): NodeMaterialConnectionPoint;
  133370. protected _buildBlock(state: NodeMaterialBuildState): this;
  133371. }
  133372. }
  133373. declare module BABYLON {
  133374. /**
  133375. * Effect Render Options
  133376. */
  133377. export interface IEffectRendererOptions {
  133378. /**
  133379. * Defines the vertices positions.
  133380. */
  133381. positions?: number[];
  133382. /**
  133383. * Defines the indices.
  133384. */
  133385. indices?: number[];
  133386. }
  133387. /**
  133388. * Helper class to render one or more effects
  133389. */
  133390. export class EffectRenderer {
  133391. private engine;
  133392. private static _DefaultOptions;
  133393. private _vertexBuffers;
  133394. private _indexBuffer;
  133395. private _ringBufferIndex;
  133396. private _ringScreenBuffer;
  133397. private _fullscreenViewport;
  133398. private _getNextFrameBuffer;
  133399. /**
  133400. * Creates an effect renderer
  133401. * @param engine the engine to use for rendering
  133402. * @param options defines the options of the effect renderer
  133403. */
  133404. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  133405. /**
  133406. * Sets the current viewport in normalized coordinates 0-1
  133407. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  133408. */
  133409. setViewport(viewport?: Viewport): void;
  133410. /**
  133411. * Binds the embedded attributes buffer to the effect.
  133412. * @param effect Defines the effect to bind the attributes for
  133413. */
  133414. bindBuffers(effect: Effect): void;
  133415. /**
  133416. * Sets the current effect wrapper to use during draw.
  133417. * The effect needs to be ready before calling this api.
  133418. * This also sets the default full screen position attribute.
  133419. * @param effectWrapper Defines the effect to draw with
  133420. */
  133421. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  133422. /**
  133423. * Draws a full screen quad.
  133424. */
  133425. draw(): void;
  133426. /**
  133427. * renders one or more effects to a specified texture
  133428. * @param effectWrappers list of effects to renderer
  133429. * @param outputTexture texture to draw to, if null it will render to the screen
  133430. */
  133431. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  133432. /**
  133433. * Disposes of the effect renderer
  133434. */
  133435. dispose(): void;
  133436. }
  133437. /**
  133438. * Options to create an EffectWrapper
  133439. */
  133440. interface EffectWrapperCreationOptions {
  133441. /**
  133442. * Engine to use to create the effect
  133443. */
  133444. engine: ThinEngine;
  133445. /**
  133446. * Fragment shader for the effect
  133447. */
  133448. fragmentShader: string;
  133449. /**
  133450. * Vertex shader for the effect
  133451. */
  133452. vertexShader?: string;
  133453. /**
  133454. * Attributes to use in the shader
  133455. */
  133456. attributeNames?: Array<string>;
  133457. /**
  133458. * Uniforms to use in the shader
  133459. */
  133460. uniformNames?: Array<string>;
  133461. /**
  133462. * Texture sampler names to use in the shader
  133463. */
  133464. samplerNames?: Array<string>;
  133465. /**
  133466. * The friendly name of the effect displayed in Spector.
  133467. */
  133468. name?: string;
  133469. }
  133470. /**
  133471. * Wraps an effect to be used for rendering
  133472. */
  133473. export class EffectWrapper {
  133474. /**
  133475. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  133476. */
  133477. onApplyObservable: Observable<{}>;
  133478. /**
  133479. * The underlying effect
  133480. */
  133481. effect: Effect;
  133482. /**
  133483. * Creates an effect to be renderer
  133484. * @param creationOptions options to create the effect
  133485. */
  133486. constructor(creationOptions: EffectWrapperCreationOptions);
  133487. /**
  133488. * Disposes of the effect wrapper
  133489. */
  133490. dispose(): void;
  133491. }
  133492. }
  133493. declare module BABYLON {
  133494. /**
  133495. * Helper class to push actions to a pool of workers.
  133496. */
  133497. export class WorkerPool implements IDisposable {
  133498. private _workerInfos;
  133499. private _pendingActions;
  133500. /**
  133501. * Constructor
  133502. * @param workers Array of workers to use for actions
  133503. */
  133504. constructor(workers: Array<Worker>);
  133505. /**
  133506. * Terminates all workers and clears any pending actions.
  133507. */
  133508. dispose(): void;
  133509. /**
  133510. * Pushes an action to the worker pool. If all the workers are active, the action will be
  133511. * pended until a worker has completed its action.
  133512. * @param action The action to perform. Call onComplete when the action is complete.
  133513. */
  133514. push(action: (worker: Worker, onComplete: () => void) => void): void;
  133515. private _execute;
  133516. }
  133517. }
  133518. declare module BABYLON {
  133519. /**
  133520. * Configuration for Draco compression
  133521. */
  133522. export interface IDracoCompressionConfiguration {
  133523. /**
  133524. * Configuration for the decoder.
  133525. */
  133526. decoder: {
  133527. /**
  133528. * The url to the WebAssembly module.
  133529. */
  133530. wasmUrl?: string;
  133531. /**
  133532. * The url to the WebAssembly binary.
  133533. */
  133534. wasmBinaryUrl?: string;
  133535. /**
  133536. * The url to the fallback JavaScript module.
  133537. */
  133538. fallbackUrl?: string;
  133539. };
  133540. }
  133541. /**
  133542. * Draco compression (https://google.github.io/draco/)
  133543. *
  133544. * This class wraps the Draco module.
  133545. *
  133546. * **Encoder**
  133547. *
  133548. * The encoder is not currently implemented.
  133549. *
  133550. * **Decoder**
  133551. *
  133552. * 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.
  133553. *
  133554. * To update the configuration, use the following code:
  133555. * ```javascript
  133556. * DracoCompression.Configuration = {
  133557. * decoder: {
  133558. * wasmUrl: "<url to the WebAssembly library>",
  133559. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  133560. * fallbackUrl: "<url to the fallback JavaScript library>",
  133561. * }
  133562. * };
  133563. * ```
  133564. *
  133565. * 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.
  133566. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  133567. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  133568. *
  133569. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  133570. * ```javascript
  133571. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  133572. * ```
  133573. *
  133574. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  133575. */
  133576. export class DracoCompression implements IDisposable {
  133577. private _workerPoolPromise?;
  133578. private _decoderModulePromise?;
  133579. /**
  133580. * The configuration. Defaults to the following urls:
  133581. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  133582. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  133583. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  133584. */
  133585. static Configuration: IDracoCompressionConfiguration;
  133586. /**
  133587. * Returns true if the decoder configuration is available.
  133588. */
  133589. static get DecoderAvailable(): boolean;
  133590. /**
  133591. * Default number of workers to create when creating the draco compression object.
  133592. */
  133593. static DefaultNumWorkers: number;
  133594. private static GetDefaultNumWorkers;
  133595. private static _Default;
  133596. /**
  133597. * Default instance for the draco compression object.
  133598. */
  133599. static get Default(): DracoCompression;
  133600. /**
  133601. * Constructor
  133602. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  133603. */
  133604. constructor(numWorkers?: number);
  133605. /**
  133606. * Stop all async operations and release resources.
  133607. */
  133608. dispose(): void;
  133609. /**
  133610. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  133611. * @returns a promise that resolves when ready
  133612. */
  133613. whenReadyAsync(): Promise<void>;
  133614. /**
  133615. * Decode Draco compressed mesh data to vertex data.
  133616. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  133617. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  133618. * @returns A promise that resolves with the decoded vertex data
  133619. */
  133620. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  133621. [kind: string]: number;
  133622. }): Promise<VertexData>;
  133623. }
  133624. }
  133625. declare module BABYLON {
  133626. /**
  133627. * Class for building Constructive Solid Geometry
  133628. */
  133629. export class CSG {
  133630. private polygons;
  133631. /**
  133632. * The world matrix
  133633. */
  133634. matrix: Matrix;
  133635. /**
  133636. * Stores the position
  133637. */
  133638. position: Vector3;
  133639. /**
  133640. * Stores the rotation
  133641. */
  133642. rotation: Vector3;
  133643. /**
  133644. * Stores the rotation quaternion
  133645. */
  133646. rotationQuaternion: Nullable<Quaternion>;
  133647. /**
  133648. * Stores the scaling vector
  133649. */
  133650. scaling: Vector3;
  133651. /**
  133652. * Convert the Mesh to CSG
  133653. * @param mesh The Mesh to convert to CSG
  133654. * @returns A new CSG from the Mesh
  133655. */
  133656. static FromMesh(mesh: Mesh): CSG;
  133657. /**
  133658. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  133659. * @param polygons Polygons used to construct a CSG solid
  133660. */
  133661. private static FromPolygons;
  133662. /**
  133663. * Clones, or makes a deep copy, of the CSG
  133664. * @returns A new CSG
  133665. */
  133666. clone(): CSG;
  133667. /**
  133668. * Unions this CSG with another CSG
  133669. * @param csg The CSG to union against this CSG
  133670. * @returns The unioned CSG
  133671. */
  133672. union(csg: CSG): CSG;
  133673. /**
  133674. * Unions this CSG with another CSG in place
  133675. * @param csg The CSG to union against this CSG
  133676. */
  133677. unionInPlace(csg: CSG): void;
  133678. /**
  133679. * Subtracts this CSG with another CSG
  133680. * @param csg The CSG to subtract against this CSG
  133681. * @returns A new CSG
  133682. */
  133683. subtract(csg: CSG): CSG;
  133684. /**
  133685. * Subtracts this CSG with another CSG in place
  133686. * @param csg The CSG to subtact against this CSG
  133687. */
  133688. subtractInPlace(csg: CSG): void;
  133689. /**
  133690. * Intersect this CSG with another CSG
  133691. * @param csg The CSG to intersect against this CSG
  133692. * @returns A new CSG
  133693. */
  133694. intersect(csg: CSG): CSG;
  133695. /**
  133696. * Intersects this CSG with another CSG in place
  133697. * @param csg The CSG to intersect against this CSG
  133698. */
  133699. intersectInPlace(csg: CSG): void;
  133700. /**
  133701. * Return a new CSG solid with solid and empty space switched. This solid is
  133702. * not modified.
  133703. * @returns A new CSG solid with solid and empty space switched
  133704. */
  133705. inverse(): CSG;
  133706. /**
  133707. * Inverses the CSG in place
  133708. */
  133709. inverseInPlace(): void;
  133710. /**
  133711. * This is used to keep meshes transformations so they can be restored
  133712. * when we build back a Babylon Mesh
  133713. * NB : All CSG operations are performed in world coordinates
  133714. * @param csg The CSG to copy the transform attributes from
  133715. * @returns This CSG
  133716. */
  133717. copyTransformAttributes(csg: CSG): CSG;
  133718. /**
  133719. * Build Raw mesh from CSG
  133720. * Coordinates here are in world space
  133721. * @param name The name of the mesh geometry
  133722. * @param scene The Scene
  133723. * @param keepSubMeshes Specifies if the submeshes should be kept
  133724. * @returns A new Mesh
  133725. */
  133726. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133727. /**
  133728. * Build Mesh from CSG taking material and transforms into account
  133729. * @param name The name of the Mesh
  133730. * @param material The material of the Mesh
  133731. * @param scene The Scene
  133732. * @param keepSubMeshes Specifies if submeshes should be kept
  133733. * @returns The new Mesh
  133734. */
  133735. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133736. }
  133737. }
  133738. declare module BABYLON {
  133739. /**
  133740. * Class used to create a trail following a mesh
  133741. */
  133742. export class TrailMesh extends Mesh {
  133743. private _generator;
  133744. private _autoStart;
  133745. private _running;
  133746. private _diameter;
  133747. private _length;
  133748. private _sectionPolygonPointsCount;
  133749. private _sectionVectors;
  133750. private _sectionNormalVectors;
  133751. private _beforeRenderObserver;
  133752. /**
  133753. * @constructor
  133754. * @param name The value used by scene.getMeshByName() to do a lookup.
  133755. * @param generator The mesh or transform node to generate a trail.
  133756. * @param scene The scene to add this mesh to.
  133757. * @param diameter Diameter of trailing mesh. Default is 1.
  133758. * @param length Length of trailing mesh. Default is 60.
  133759. * @param autoStart Automatically start trailing mesh. Default true.
  133760. */
  133761. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  133762. /**
  133763. * "TrailMesh"
  133764. * @returns "TrailMesh"
  133765. */
  133766. getClassName(): string;
  133767. private _createMesh;
  133768. /**
  133769. * Start trailing mesh.
  133770. */
  133771. start(): void;
  133772. /**
  133773. * Stop trailing mesh.
  133774. */
  133775. stop(): void;
  133776. /**
  133777. * Update trailing mesh geometry.
  133778. */
  133779. update(): void;
  133780. /**
  133781. * Returns a new TrailMesh object.
  133782. * @param name is a string, the name given to the new mesh
  133783. * @param newGenerator use new generator object for cloned trail mesh
  133784. * @returns a new mesh
  133785. */
  133786. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  133787. /**
  133788. * Serializes this trail mesh
  133789. * @param serializationObject object to write serialization to
  133790. */
  133791. serialize(serializationObject: any): void;
  133792. /**
  133793. * Parses a serialized trail mesh
  133794. * @param parsedMesh the serialized mesh
  133795. * @param scene the scene to create the trail mesh in
  133796. * @returns the created trail mesh
  133797. */
  133798. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  133799. }
  133800. }
  133801. declare module BABYLON {
  133802. /**
  133803. * Class containing static functions to help procedurally build meshes
  133804. */
  133805. export class TiledBoxBuilder {
  133806. /**
  133807. * Creates a box mesh
  133808. * 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)
  133809. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  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 box mesh
  133817. */
  133818. static CreateTiledBox(name: string, options: {
  133819. pattern?: number;
  133820. width?: number;
  133821. height?: number;
  133822. depth?: number;
  133823. tileSize?: number;
  133824. tileWidth?: number;
  133825. tileHeight?: number;
  133826. alignHorizontal?: number;
  133827. alignVertical?: number;
  133828. faceUV?: Vector4[];
  133829. faceColors?: Color4[];
  133830. sideOrientation?: number;
  133831. updatable?: boolean;
  133832. }, scene?: Nullable<Scene>): Mesh;
  133833. }
  133834. }
  133835. declare module BABYLON {
  133836. /**
  133837. * Class containing static functions to help procedurally build meshes
  133838. */
  133839. export class TorusKnotBuilder {
  133840. /**
  133841. * Creates a torus knot mesh
  133842. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133843. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133844. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133845. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133847. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133849. * @param name defines the name of the mesh
  133850. * @param options defines the options used to create the mesh
  133851. * @param scene defines the hosting scene
  133852. * @returns the torus knot mesh
  133853. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133854. */
  133855. static CreateTorusKnot(name: string, options: {
  133856. radius?: number;
  133857. tube?: number;
  133858. radialSegments?: number;
  133859. tubularSegments?: number;
  133860. p?: number;
  133861. q?: number;
  133862. updatable?: boolean;
  133863. sideOrientation?: number;
  133864. frontUVs?: Vector4;
  133865. backUVs?: Vector4;
  133866. }, scene: any): Mesh;
  133867. }
  133868. }
  133869. declare module BABYLON {
  133870. /**
  133871. * Polygon
  133872. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  133873. */
  133874. export class Polygon {
  133875. /**
  133876. * Creates a rectangle
  133877. * @param xmin bottom X coord
  133878. * @param ymin bottom Y coord
  133879. * @param xmax top X coord
  133880. * @param ymax top Y coord
  133881. * @returns points that make the resulting rectation
  133882. */
  133883. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  133884. /**
  133885. * Creates a circle
  133886. * @param radius radius of circle
  133887. * @param cx scale in x
  133888. * @param cy scale in y
  133889. * @param numberOfSides number of sides that make up the circle
  133890. * @returns points that make the resulting circle
  133891. */
  133892. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  133893. /**
  133894. * Creates a polygon from input string
  133895. * @param input Input polygon data
  133896. * @returns the parsed points
  133897. */
  133898. static Parse(input: string): Vector2[];
  133899. /**
  133900. * Starts building a polygon from x and y coordinates
  133901. * @param x x coordinate
  133902. * @param y y coordinate
  133903. * @returns the started path2
  133904. */
  133905. static StartingAt(x: number, y: number): Path2;
  133906. }
  133907. /**
  133908. * Builds a polygon
  133909. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  133910. */
  133911. export class PolygonMeshBuilder {
  133912. private _points;
  133913. private _outlinepoints;
  133914. private _holes;
  133915. private _name;
  133916. private _scene;
  133917. private _epoints;
  133918. private _eholes;
  133919. private _addToepoint;
  133920. /**
  133921. * Babylon reference to the earcut plugin.
  133922. */
  133923. bjsEarcut: any;
  133924. /**
  133925. * Creates a PolygonMeshBuilder
  133926. * @param name name of the builder
  133927. * @param contours Path of the polygon
  133928. * @param scene scene to add to when creating the mesh
  133929. * @param earcutInjection can be used to inject your own earcut reference
  133930. */
  133931. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  133932. /**
  133933. * Adds a whole within the polygon
  133934. * @param hole Array of points defining the hole
  133935. * @returns this
  133936. */
  133937. addHole(hole: Vector2[]): PolygonMeshBuilder;
  133938. /**
  133939. * Creates the polygon
  133940. * @param updatable If the mesh should be updatable
  133941. * @param depth The depth of the mesh created
  133942. * @returns the created mesh
  133943. */
  133944. build(updatable?: boolean, depth?: number): Mesh;
  133945. /**
  133946. * Creates the polygon
  133947. * @param depth The depth of the mesh created
  133948. * @returns the created VertexData
  133949. */
  133950. buildVertexData(depth?: number): VertexData;
  133951. /**
  133952. * Adds a side to the polygon
  133953. * @param positions points that make the polygon
  133954. * @param normals normals of the polygon
  133955. * @param uvs uvs of the polygon
  133956. * @param indices indices of the polygon
  133957. * @param bounds bounds of the polygon
  133958. * @param points points of the polygon
  133959. * @param depth depth of the polygon
  133960. * @param flip flip of the polygon
  133961. */
  133962. private addSide;
  133963. }
  133964. }
  133965. declare module BABYLON {
  133966. /**
  133967. * Class containing static functions to help procedurally build meshes
  133968. */
  133969. export class PolygonBuilder {
  133970. /**
  133971. * Creates a polygon mesh
  133972. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  133973. * * 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
  133974. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133976. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  133977. * * Remember you can only change the shape positions, not their number when updating a polygon
  133978. * @param name defines the name of the mesh
  133979. * @param options defines the options used to create the mesh
  133980. * @param scene defines the hosting scene
  133981. * @param earcutInjection can be used to inject your own earcut reference
  133982. * @returns the polygon mesh
  133983. */
  133984. static CreatePolygon(name: string, options: {
  133985. shape: Vector3[];
  133986. holes?: Vector3[][];
  133987. depth?: number;
  133988. faceUV?: Vector4[];
  133989. faceColors?: Color4[];
  133990. updatable?: boolean;
  133991. sideOrientation?: number;
  133992. frontUVs?: Vector4;
  133993. backUVs?: Vector4;
  133994. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133995. /**
  133996. * Creates an extruded polygon mesh, with depth in the Y direction.
  133997. * * 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)
  133998. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133999. * @param name defines the name of the mesh
  134000. * @param options defines the options used to create the mesh
  134001. * @param scene defines the hosting scene
  134002. * @param earcutInjection can be used to inject your own earcut reference
  134003. * @returns the polygon mesh
  134004. */
  134005. static ExtrudePolygon(name: string, options: {
  134006. shape: Vector3[];
  134007. holes?: Vector3[][];
  134008. depth?: number;
  134009. faceUV?: Vector4[];
  134010. faceColors?: Color4[];
  134011. updatable?: boolean;
  134012. sideOrientation?: number;
  134013. frontUVs?: Vector4;
  134014. backUVs?: Vector4;
  134015. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134016. }
  134017. }
  134018. declare module BABYLON {
  134019. /**
  134020. * Class containing static functions to help procedurally build meshes
  134021. */
  134022. export class LatheBuilder {
  134023. /**
  134024. * Creates lathe mesh.
  134025. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134026. * * 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
  134027. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134028. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134029. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134030. * * 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
  134031. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134032. * * 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
  134033. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134034. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134035. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134037. * @param name defines the name of the mesh
  134038. * @param options defines the options used to create the mesh
  134039. * @param scene defines the hosting scene
  134040. * @returns the lathe mesh
  134041. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134042. */
  134043. static CreateLathe(name: string, options: {
  134044. shape: Vector3[];
  134045. radius?: number;
  134046. tessellation?: number;
  134047. clip?: number;
  134048. arc?: number;
  134049. closed?: boolean;
  134050. updatable?: boolean;
  134051. sideOrientation?: number;
  134052. frontUVs?: Vector4;
  134053. backUVs?: Vector4;
  134054. cap?: number;
  134055. invertUV?: boolean;
  134056. }, scene?: Nullable<Scene>): Mesh;
  134057. }
  134058. }
  134059. declare module BABYLON {
  134060. /**
  134061. * Class containing static functions to help procedurally build meshes
  134062. */
  134063. export class TiledPlaneBuilder {
  134064. /**
  134065. * Creates a tiled plane mesh
  134066. * * The parameter `pattern` will, depending on value, do nothing or
  134067. * * * flip (reflect about central vertical) alternate tiles across and up
  134068. * * * flip every tile on alternate rows
  134069. * * * rotate (180 degs) alternate tiles across and up
  134070. * * * rotate every tile on alternate rows
  134071. * * * flip and rotate alternate tiles across and up
  134072. * * * flip and rotate every tile on alternate rows
  134073. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  134074. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  134075. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134076. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134077. * * 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)
  134078. * * 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)
  134079. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134080. * @param name defines the name of the mesh
  134081. * @param options defines the options used to create the mesh
  134082. * @param scene defines the hosting scene
  134083. * @returns the box mesh
  134084. */
  134085. static CreateTiledPlane(name: string, options: {
  134086. pattern?: number;
  134087. tileSize?: number;
  134088. tileWidth?: number;
  134089. tileHeight?: number;
  134090. size?: number;
  134091. width?: number;
  134092. height?: number;
  134093. alignHorizontal?: number;
  134094. alignVertical?: number;
  134095. sideOrientation?: number;
  134096. frontUVs?: Vector4;
  134097. backUVs?: Vector4;
  134098. updatable?: boolean;
  134099. }, scene?: Nullable<Scene>): Mesh;
  134100. }
  134101. }
  134102. declare module BABYLON {
  134103. /**
  134104. * Class containing static functions to help procedurally build meshes
  134105. */
  134106. export class TubeBuilder {
  134107. /**
  134108. * Creates a tube mesh.
  134109. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134110. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134111. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134112. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134113. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134114. * * 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)
  134115. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134116. * * 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
  134117. * * 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
  134118. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134119. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134120. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134122. * @param name defines the name of the mesh
  134123. * @param options defines the options used to create the mesh
  134124. * @param scene defines the hosting scene
  134125. * @returns the tube mesh
  134126. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134127. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134128. */
  134129. static CreateTube(name: string, options: {
  134130. path: Vector3[];
  134131. radius?: number;
  134132. tessellation?: number;
  134133. radiusFunction?: {
  134134. (i: number, distance: number): number;
  134135. };
  134136. cap?: number;
  134137. arc?: number;
  134138. updatable?: boolean;
  134139. sideOrientation?: number;
  134140. frontUVs?: Vector4;
  134141. backUVs?: Vector4;
  134142. instance?: Mesh;
  134143. invertUV?: boolean;
  134144. }, scene?: Nullable<Scene>): Mesh;
  134145. }
  134146. }
  134147. declare module BABYLON {
  134148. /**
  134149. * Class containing static functions to help procedurally build meshes
  134150. */
  134151. export class IcoSphereBuilder {
  134152. /**
  134153. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134154. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134155. * * 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`)
  134156. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134157. * * 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
  134158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134159. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134161. * @param name defines the name of the mesh
  134162. * @param options defines the options used to create the mesh
  134163. * @param scene defines the hosting scene
  134164. * @returns the icosahedron mesh
  134165. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134166. */
  134167. static CreateIcoSphere(name: string, options: {
  134168. radius?: number;
  134169. radiusX?: number;
  134170. radiusY?: number;
  134171. radiusZ?: number;
  134172. flat?: boolean;
  134173. subdivisions?: number;
  134174. sideOrientation?: number;
  134175. frontUVs?: Vector4;
  134176. backUVs?: Vector4;
  134177. updatable?: boolean;
  134178. }, scene?: Nullable<Scene>): Mesh;
  134179. }
  134180. }
  134181. declare module BABYLON {
  134182. /**
  134183. * Class containing static functions to help procedurally build meshes
  134184. */
  134185. export class DecalBuilder {
  134186. /**
  134187. * Creates a decal mesh.
  134188. * 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
  134189. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134190. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134191. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134192. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134193. * @param name defines the name of the mesh
  134194. * @param sourceMesh defines the mesh where the decal must be applied
  134195. * @param options defines the options used to create the mesh
  134196. * @param scene defines the hosting scene
  134197. * @returns the decal mesh
  134198. * @see https://doc.babylonjs.com/how_to/decals
  134199. */
  134200. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134201. position?: Vector3;
  134202. normal?: Vector3;
  134203. size?: Vector3;
  134204. angle?: number;
  134205. }): Mesh;
  134206. }
  134207. }
  134208. declare module BABYLON {
  134209. /**
  134210. * Class containing static functions to help procedurally build meshes
  134211. */
  134212. export class MeshBuilder {
  134213. /**
  134214. * Creates a box mesh
  134215. * * The parameter `size` sets the size (float) of each box side (default 1)
  134216. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134217. * * 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)
  134218. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134220. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134222. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134223. * @param name defines the name of the mesh
  134224. * @param options defines the options used to create the mesh
  134225. * @param scene defines the hosting scene
  134226. * @returns the box mesh
  134227. */
  134228. static CreateBox(name: string, options: {
  134229. size?: number;
  134230. width?: number;
  134231. height?: number;
  134232. depth?: number;
  134233. faceUV?: Vector4[];
  134234. faceColors?: Color4[];
  134235. sideOrientation?: number;
  134236. frontUVs?: Vector4;
  134237. backUVs?: Vector4;
  134238. updatable?: boolean;
  134239. }, scene?: Nullable<Scene>): Mesh;
  134240. /**
  134241. * Creates a tiled box mesh
  134242. * * faceTiles sets the pattern, tile size and number of tiles for a face
  134243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134244. * @param name defines the name of the mesh
  134245. * @param options defines the options used to create the mesh
  134246. * @param scene defines the hosting scene
  134247. * @returns the tiled box mesh
  134248. */
  134249. static CreateTiledBox(name: string, options: {
  134250. pattern?: number;
  134251. size?: number;
  134252. width?: number;
  134253. height?: number;
  134254. depth: number;
  134255. tileSize?: number;
  134256. tileWidth?: number;
  134257. tileHeight?: number;
  134258. faceUV?: Vector4[];
  134259. faceColors?: Color4[];
  134260. alignHorizontal?: number;
  134261. alignVertical?: number;
  134262. sideOrientation?: number;
  134263. updatable?: boolean;
  134264. }, scene?: Nullable<Scene>): Mesh;
  134265. /**
  134266. * Creates a sphere mesh
  134267. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  134268. * * 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`)
  134269. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  134270. * * 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
  134271. * * 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)
  134272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134273. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134275. * @param name defines the name of the mesh
  134276. * @param options defines the options used to create the mesh
  134277. * @param scene defines the hosting scene
  134278. * @returns the sphere mesh
  134279. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  134280. */
  134281. static CreateSphere(name: string, options: {
  134282. segments?: number;
  134283. diameter?: number;
  134284. diameterX?: number;
  134285. diameterY?: number;
  134286. diameterZ?: number;
  134287. arc?: number;
  134288. slice?: number;
  134289. sideOrientation?: number;
  134290. frontUVs?: Vector4;
  134291. backUVs?: Vector4;
  134292. updatable?: boolean;
  134293. }, scene?: Nullable<Scene>): Mesh;
  134294. /**
  134295. * Creates a plane polygonal mesh. By default, this is a disc
  134296. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  134297. * * 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
  134298. * * 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
  134299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134302. * @param name defines the name of the mesh
  134303. * @param options defines the options used to create the mesh
  134304. * @param scene defines the hosting scene
  134305. * @returns the plane polygonal mesh
  134306. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  134307. */
  134308. static CreateDisc(name: string, options: {
  134309. radius?: number;
  134310. tessellation?: number;
  134311. arc?: number;
  134312. updatable?: boolean;
  134313. sideOrientation?: number;
  134314. frontUVs?: Vector4;
  134315. backUVs?: Vector4;
  134316. }, scene?: Nullable<Scene>): Mesh;
  134317. /**
  134318. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134319. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134320. * * 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`)
  134321. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134322. * * 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
  134323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134324. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134326. * @param name defines the name of the mesh
  134327. * @param options defines the options used to create the mesh
  134328. * @param scene defines the hosting scene
  134329. * @returns the icosahedron mesh
  134330. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134331. */
  134332. static CreateIcoSphere(name: string, options: {
  134333. radius?: number;
  134334. radiusX?: number;
  134335. radiusY?: number;
  134336. radiusZ?: number;
  134337. flat?: boolean;
  134338. subdivisions?: number;
  134339. sideOrientation?: number;
  134340. frontUVs?: Vector4;
  134341. backUVs?: Vector4;
  134342. updatable?: boolean;
  134343. }, scene?: Nullable<Scene>): Mesh;
  134344. /**
  134345. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134346. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134347. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134348. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134349. * * 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
  134350. * * 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
  134351. * * 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
  134352. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134353. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134354. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134355. * * 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
  134356. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134357. * * 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
  134358. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134360. * @param name defines the name of the mesh
  134361. * @param options defines the options used to create the mesh
  134362. * @param scene defines the hosting scene
  134363. * @returns the ribbon mesh
  134364. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134365. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134366. */
  134367. static CreateRibbon(name: string, options: {
  134368. pathArray: Vector3[][];
  134369. closeArray?: boolean;
  134370. closePath?: boolean;
  134371. offset?: number;
  134372. updatable?: boolean;
  134373. sideOrientation?: number;
  134374. frontUVs?: Vector4;
  134375. backUVs?: Vector4;
  134376. instance?: Mesh;
  134377. invertUV?: boolean;
  134378. uvs?: Vector2[];
  134379. colors?: Color4[];
  134380. }, scene?: Nullable<Scene>): Mesh;
  134381. /**
  134382. * Creates a cylinder or a cone mesh
  134383. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  134384. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  134385. * * 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.
  134386. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  134387. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  134388. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  134389. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  134390. * * 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).
  134391. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  134392. * * 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).
  134393. * * 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
  134394. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  134395. * * 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
  134396. * * 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.
  134397. * * If `enclose` is false, a ring surface is one element.
  134398. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  134399. * * 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
  134400. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134401. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134403. * @param name defines the name of the mesh
  134404. * @param options defines the options used to create the mesh
  134405. * @param scene defines the hosting scene
  134406. * @returns the cylinder mesh
  134407. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  134408. */
  134409. static CreateCylinder(name: string, options: {
  134410. height?: number;
  134411. diameterTop?: number;
  134412. diameterBottom?: number;
  134413. diameter?: number;
  134414. tessellation?: number;
  134415. subdivisions?: number;
  134416. arc?: number;
  134417. faceColors?: Color4[];
  134418. faceUV?: Vector4[];
  134419. updatable?: boolean;
  134420. hasRings?: boolean;
  134421. enclose?: boolean;
  134422. cap?: number;
  134423. sideOrientation?: number;
  134424. frontUVs?: Vector4;
  134425. backUVs?: Vector4;
  134426. }, scene?: Nullable<Scene>): Mesh;
  134427. /**
  134428. * Creates a torus mesh
  134429. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  134430. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  134431. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  134432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134433. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134435. * @param name defines the name of the mesh
  134436. * @param options defines the options used to create the mesh
  134437. * @param scene defines the hosting scene
  134438. * @returns the torus mesh
  134439. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  134440. */
  134441. static CreateTorus(name: string, options: {
  134442. diameter?: number;
  134443. thickness?: number;
  134444. tessellation?: number;
  134445. updatable?: boolean;
  134446. sideOrientation?: number;
  134447. frontUVs?: Vector4;
  134448. backUVs?: Vector4;
  134449. }, scene?: Nullable<Scene>): Mesh;
  134450. /**
  134451. * Creates a torus knot mesh
  134452. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134453. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134454. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134455. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134459. * @param name defines the name of the mesh
  134460. * @param options defines the options used to create the mesh
  134461. * @param scene defines the hosting scene
  134462. * @returns the torus knot mesh
  134463. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134464. */
  134465. static CreateTorusKnot(name: string, options: {
  134466. radius?: number;
  134467. tube?: number;
  134468. radialSegments?: number;
  134469. tubularSegments?: number;
  134470. p?: number;
  134471. q?: number;
  134472. updatable?: boolean;
  134473. sideOrientation?: number;
  134474. frontUVs?: Vector4;
  134475. backUVs?: Vector4;
  134476. }, scene?: Nullable<Scene>): Mesh;
  134477. /**
  134478. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134479. * * 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
  134480. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134481. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134482. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134483. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134484. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134485. * * 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
  134486. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134488. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134489. * @param name defines the name of the new line system
  134490. * @param options defines the options used to create the line system
  134491. * @param scene defines the hosting scene
  134492. * @returns a new line system mesh
  134493. */
  134494. static CreateLineSystem(name: string, options: {
  134495. lines: Vector3[][];
  134496. updatable?: boolean;
  134497. instance?: Nullable<LinesMesh>;
  134498. colors?: Nullable<Color4[][]>;
  134499. useVertexAlpha?: boolean;
  134500. }, scene: Nullable<Scene>): LinesMesh;
  134501. /**
  134502. * Creates a line mesh
  134503. * 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
  134504. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134505. * * The parameter `points` is an array successive Vector3
  134506. * * 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
  134507. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134508. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134509. * * When updating an instance, remember that only point positions can change, not the number of points
  134510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134511. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134512. * @param name defines the name of the new line system
  134513. * @param options defines the options used to create the line system
  134514. * @param scene defines the hosting scene
  134515. * @returns a new line mesh
  134516. */
  134517. static CreateLines(name: string, options: {
  134518. points: Vector3[];
  134519. updatable?: boolean;
  134520. instance?: Nullable<LinesMesh>;
  134521. colors?: Color4[];
  134522. useVertexAlpha?: boolean;
  134523. }, scene?: Nullable<Scene>): LinesMesh;
  134524. /**
  134525. * Creates a dashed line mesh
  134526. * * 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
  134527. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134528. * * The parameter `points` is an array successive Vector3
  134529. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134530. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134531. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134532. * * 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
  134533. * * When updating an instance, remember that only point positions can change, not the number of points
  134534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134535. * @param name defines the name of the mesh
  134536. * @param options defines the options used to create the mesh
  134537. * @param scene defines the hosting scene
  134538. * @returns the dashed line mesh
  134539. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134540. */
  134541. static CreateDashedLines(name: string, options: {
  134542. points: Vector3[];
  134543. dashSize?: number;
  134544. gapSize?: number;
  134545. dashNb?: number;
  134546. updatable?: boolean;
  134547. instance?: LinesMesh;
  134548. }, scene?: Nullable<Scene>): LinesMesh;
  134549. /**
  134550. * 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.
  134551. * * 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.
  134552. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134553. * * 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.
  134554. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134555. * * 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
  134556. * * 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
  134557. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134559. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134560. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134562. * @param name defines the name of the mesh
  134563. * @param options defines the options used to create the mesh
  134564. * @param scene defines the hosting scene
  134565. * @returns the extruded shape mesh
  134566. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134567. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134568. */
  134569. static ExtrudeShape(name: string, options: {
  134570. shape: Vector3[];
  134571. path: Vector3[];
  134572. scale?: number;
  134573. rotation?: number;
  134574. cap?: number;
  134575. updatable?: boolean;
  134576. sideOrientation?: number;
  134577. frontUVs?: Vector4;
  134578. backUVs?: Vector4;
  134579. instance?: Mesh;
  134580. invertUV?: boolean;
  134581. }, scene?: Nullable<Scene>): Mesh;
  134582. /**
  134583. * Creates an custom extruded shape mesh.
  134584. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134585. * * 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.
  134586. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134587. * * 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
  134588. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134589. * * 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
  134590. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134591. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134592. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134593. * * 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
  134594. * * 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
  134595. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134597. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134598. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134600. * @param name defines the name of the mesh
  134601. * @param options defines the options used to create the mesh
  134602. * @param scene defines the hosting scene
  134603. * @returns the custom extruded shape mesh
  134604. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134605. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134606. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134607. */
  134608. static ExtrudeShapeCustom(name: string, options: {
  134609. shape: Vector3[];
  134610. path: Vector3[];
  134611. scaleFunction?: any;
  134612. rotationFunction?: any;
  134613. ribbonCloseArray?: boolean;
  134614. ribbonClosePath?: boolean;
  134615. cap?: number;
  134616. updatable?: boolean;
  134617. sideOrientation?: number;
  134618. frontUVs?: Vector4;
  134619. backUVs?: Vector4;
  134620. instance?: Mesh;
  134621. invertUV?: boolean;
  134622. }, scene?: Nullable<Scene>): Mesh;
  134623. /**
  134624. * Creates lathe mesh.
  134625. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134626. * * 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
  134627. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134628. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134629. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134630. * * 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
  134631. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134632. * * 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
  134633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134634. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134635. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134637. * @param name defines the name of the mesh
  134638. * @param options defines the options used to create the mesh
  134639. * @param scene defines the hosting scene
  134640. * @returns the lathe mesh
  134641. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134642. */
  134643. static CreateLathe(name: string, options: {
  134644. shape: Vector3[];
  134645. radius?: number;
  134646. tessellation?: number;
  134647. clip?: number;
  134648. arc?: number;
  134649. closed?: boolean;
  134650. updatable?: boolean;
  134651. sideOrientation?: number;
  134652. frontUVs?: Vector4;
  134653. backUVs?: Vector4;
  134654. cap?: number;
  134655. invertUV?: boolean;
  134656. }, scene?: Nullable<Scene>): Mesh;
  134657. /**
  134658. * Creates a tiled plane mesh
  134659. * * You can set a limited pattern arrangement with the tiles
  134660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134661. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134663. * @param name defines the name of the mesh
  134664. * @param options defines the options used to create the mesh
  134665. * @param scene defines the hosting scene
  134666. * @returns the plane mesh
  134667. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134668. */
  134669. static CreateTiledPlane(name: string, options: {
  134670. pattern?: number;
  134671. tileSize?: number;
  134672. tileWidth?: number;
  134673. tileHeight?: number;
  134674. size?: number;
  134675. width?: number;
  134676. height?: number;
  134677. alignHorizontal?: number;
  134678. alignVertical?: number;
  134679. sideOrientation?: number;
  134680. frontUVs?: Vector4;
  134681. backUVs?: Vector4;
  134682. updatable?: boolean;
  134683. }, scene?: Nullable<Scene>): Mesh;
  134684. /**
  134685. * Creates a plane mesh
  134686. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  134687. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  134688. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  134689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134690. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134692. * @param name defines the name of the mesh
  134693. * @param options defines the options used to create the mesh
  134694. * @param scene defines the hosting scene
  134695. * @returns the plane mesh
  134696. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134697. */
  134698. static CreatePlane(name: string, options: {
  134699. size?: number;
  134700. width?: number;
  134701. height?: number;
  134702. sideOrientation?: number;
  134703. frontUVs?: Vector4;
  134704. backUVs?: Vector4;
  134705. updatable?: boolean;
  134706. sourcePlane?: Plane;
  134707. }, scene?: Nullable<Scene>): Mesh;
  134708. /**
  134709. * Creates a ground mesh
  134710. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  134711. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  134712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134713. * @param name defines the name of the mesh
  134714. * @param options defines the options used to create the mesh
  134715. * @param scene defines the hosting scene
  134716. * @returns the ground mesh
  134717. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  134718. */
  134719. static CreateGround(name: string, options: {
  134720. width?: number;
  134721. height?: number;
  134722. subdivisions?: number;
  134723. subdivisionsX?: number;
  134724. subdivisionsY?: number;
  134725. updatable?: boolean;
  134726. }, scene?: Nullable<Scene>): Mesh;
  134727. /**
  134728. * Creates a tiled ground mesh
  134729. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  134730. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  134731. * * 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
  134732. * * 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
  134733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134734. * @param name defines the name of the mesh
  134735. * @param options defines the options used to create the mesh
  134736. * @param scene defines the hosting scene
  134737. * @returns the tiled ground mesh
  134738. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  134739. */
  134740. static CreateTiledGround(name: string, options: {
  134741. xmin: number;
  134742. zmin: number;
  134743. xmax: number;
  134744. zmax: number;
  134745. subdivisions?: {
  134746. w: number;
  134747. h: number;
  134748. };
  134749. precision?: {
  134750. w: number;
  134751. h: number;
  134752. };
  134753. updatable?: boolean;
  134754. }, scene?: Nullable<Scene>): Mesh;
  134755. /**
  134756. * Creates a ground mesh from a height map
  134757. * * The parameter `url` sets the URL of the height map image resource.
  134758. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  134759. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  134760. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  134761. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  134762. * * 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.
  134763. * * 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).
  134764. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  134765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134766. * @param name defines the name of the mesh
  134767. * @param url defines the url to the height map
  134768. * @param options defines the options used to create the mesh
  134769. * @param scene defines the hosting scene
  134770. * @returns the ground mesh
  134771. * @see https://doc.babylonjs.com/babylon101/height_map
  134772. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  134773. */
  134774. static CreateGroundFromHeightMap(name: string, url: string, options: {
  134775. width?: number;
  134776. height?: number;
  134777. subdivisions?: number;
  134778. minHeight?: number;
  134779. maxHeight?: number;
  134780. colorFilter?: Color3;
  134781. alphaFilter?: number;
  134782. updatable?: boolean;
  134783. onReady?: (mesh: GroundMesh) => void;
  134784. }, scene?: Nullable<Scene>): GroundMesh;
  134785. /**
  134786. * Creates a polygon mesh
  134787. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134788. * * 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
  134789. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134791. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134792. * * Remember you can only change the shape positions, not their number when updating a polygon
  134793. * @param name defines the name of the mesh
  134794. * @param options defines the options used to create the mesh
  134795. * @param scene defines the hosting scene
  134796. * @param earcutInjection can be used to inject your own earcut reference
  134797. * @returns the polygon mesh
  134798. */
  134799. static CreatePolygon(name: string, options: {
  134800. shape: Vector3[];
  134801. holes?: Vector3[][];
  134802. depth?: number;
  134803. faceUV?: Vector4[];
  134804. faceColors?: Color4[];
  134805. updatable?: boolean;
  134806. sideOrientation?: number;
  134807. frontUVs?: Vector4;
  134808. backUVs?: Vector4;
  134809. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134810. /**
  134811. * Creates an extruded polygon mesh, with depth in the Y direction.
  134812. * * 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)
  134813. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134814. * @param name defines the name of the mesh
  134815. * @param options defines the options used to create the mesh
  134816. * @param scene defines the hosting scene
  134817. * @param earcutInjection can be used to inject your own earcut reference
  134818. * @returns the polygon mesh
  134819. */
  134820. static ExtrudePolygon(name: string, options: {
  134821. shape: Vector3[];
  134822. holes?: Vector3[][];
  134823. depth?: number;
  134824. faceUV?: Vector4[];
  134825. faceColors?: Color4[];
  134826. updatable?: boolean;
  134827. sideOrientation?: number;
  134828. frontUVs?: Vector4;
  134829. backUVs?: Vector4;
  134830. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134831. /**
  134832. * Creates a tube mesh.
  134833. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134834. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134835. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134836. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134837. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134838. * * 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)
  134839. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134840. * * 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
  134841. * * 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
  134842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134843. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134844. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134846. * @param name defines the name of the mesh
  134847. * @param options defines the options used to create the mesh
  134848. * @param scene defines the hosting scene
  134849. * @returns the tube mesh
  134850. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134851. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134852. */
  134853. static CreateTube(name: string, options: {
  134854. path: Vector3[];
  134855. radius?: number;
  134856. tessellation?: number;
  134857. radiusFunction?: {
  134858. (i: number, distance: number): number;
  134859. };
  134860. cap?: number;
  134861. arc?: number;
  134862. updatable?: boolean;
  134863. sideOrientation?: number;
  134864. frontUVs?: Vector4;
  134865. backUVs?: Vector4;
  134866. instance?: Mesh;
  134867. invertUV?: boolean;
  134868. }, scene?: Nullable<Scene>): Mesh;
  134869. /**
  134870. * Creates a polyhedron mesh
  134871. * * 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
  134872. * * The parameter `size` (positive float, default 1) sets the polygon size
  134873. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  134874. * * 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`
  134875. * * 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
  134876. * * 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)`)
  134877. * * 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
  134878. * * 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
  134879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134880. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134882. * @param name defines the name of the mesh
  134883. * @param options defines the options used to create the mesh
  134884. * @param scene defines the hosting scene
  134885. * @returns the polyhedron mesh
  134886. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  134887. */
  134888. static CreatePolyhedron(name: string, options: {
  134889. type?: number;
  134890. size?: number;
  134891. sizeX?: number;
  134892. sizeY?: number;
  134893. sizeZ?: number;
  134894. custom?: any;
  134895. faceUV?: Vector4[];
  134896. faceColors?: Color4[];
  134897. flat?: boolean;
  134898. updatable?: boolean;
  134899. sideOrientation?: number;
  134900. frontUVs?: Vector4;
  134901. backUVs?: Vector4;
  134902. }, scene?: Nullable<Scene>): Mesh;
  134903. /**
  134904. * Creates a decal mesh.
  134905. * 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
  134906. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134907. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134908. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134909. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134910. * @param name defines the name of the mesh
  134911. * @param sourceMesh defines the mesh where the decal must be applied
  134912. * @param options defines the options used to create the mesh
  134913. * @param scene defines the hosting scene
  134914. * @returns the decal mesh
  134915. * @see https://doc.babylonjs.com/how_to/decals
  134916. */
  134917. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134918. position?: Vector3;
  134919. normal?: Vector3;
  134920. size?: Vector3;
  134921. angle?: number;
  134922. }): Mesh;
  134923. }
  134924. }
  134925. declare module BABYLON {
  134926. /**
  134927. * A simplifier interface for future simplification implementations
  134928. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134929. */
  134930. export interface ISimplifier {
  134931. /**
  134932. * Simplification of a given mesh according to the given settings.
  134933. * Since this requires computation, it is assumed that the function runs async.
  134934. * @param settings The settings of the simplification, including quality and distance
  134935. * @param successCallback A callback that will be called after the mesh was simplified.
  134936. * @param errorCallback in case of an error, this callback will be called. optional.
  134937. */
  134938. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  134939. }
  134940. /**
  134941. * Expected simplification settings.
  134942. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  134943. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134944. */
  134945. export interface ISimplificationSettings {
  134946. /**
  134947. * Gets or sets the expected quality
  134948. */
  134949. quality: number;
  134950. /**
  134951. * Gets or sets the distance when this optimized version should be used
  134952. */
  134953. distance: number;
  134954. /**
  134955. * Gets an already optimized mesh
  134956. */
  134957. optimizeMesh?: boolean;
  134958. }
  134959. /**
  134960. * Class used to specify simplification options
  134961. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134962. */
  134963. export class SimplificationSettings implements ISimplificationSettings {
  134964. /** expected quality */
  134965. quality: number;
  134966. /** distance when this optimized version should be used */
  134967. distance: number;
  134968. /** already optimized mesh */
  134969. optimizeMesh?: boolean | undefined;
  134970. /**
  134971. * Creates a SimplificationSettings
  134972. * @param quality expected quality
  134973. * @param distance distance when this optimized version should be used
  134974. * @param optimizeMesh already optimized mesh
  134975. */
  134976. constructor(
  134977. /** expected quality */
  134978. quality: number,
  134979. /** distance when this optimized version should be used */
  134980. distance: number,
  134981. /** already optimized mesh */
  134982. optimizeMesh?: boolean | undefined);
  134983. }
  134984. /**
  134985. * Interface used to define a simplification task
  134986. */
  134987. export interface ISimplificationTask {
  134988. /**
  134989. * Array of settings
  134990. */
  134991. settings: Array<ISimplificationSettings>;
  134992. /**
  134993. * Simplification type
  134994. */
  134995. simplificationType: SimplificationType;
  134996. /**
  134997. * Mesh to simplify
  134998. */
  134999. mesh: Mesh;
  135000. /**
  135001. * Callback called on success
  135002. */
  135003. successCallback?: () => void;
  135004. /**
  135005. * Defines if parallel processing can be used
  135006. */
  135007. parallelProcessing: boolean;
  135008. }
  135009. /**
  135010. * Queue used to order the simplification tasks
  135011. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135012. */
  135013. export class SimplificationQueue {
  135014. private _simplificationArray;
  135015. /**
  135016. * Gets a boolean indicating that the process is still running
  135017. */
  135018. running: boolean;
  135019. /**
  135020. * Creates a new queue
  135021. */
  135022. constructor();
  135023. /**
  135024. * Adds a new simplification task
  135025. * @param task defines a task to add
  135026. */
  135027. addTask(task: ISimplificationTask): void;
  135028. /**
  135029. * Execute next task
  135030. */
  135031. executeNext(): void;
  135032. /**
  135033. * Execute a simplification task
  135034. * @param task defines the task to run
  135035. */
  135036. runSimplification(task: ISimplificationTask): void;
  135037. private getSimplifier;
  135038. }
  135039. /**
  135040. * The implemented types of simplification
  135041. * At the moment only Quadratic Error Decimation is implemented
  135042. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135043. */
  135044. export enum SimplificationType {
  135045. /** Quadratic error decimation */
  135046. QUADRATIC = 0
  135047. }
  135048. }
  135049. declare module BABYLON {
  135050. interface Scene {
  135051. /** @hidden (Backing field) */
  135052. _simplificationQueue: SimplificationQueue;
  135053. /**
  135054. * Gets or sets the simplification queue attached to the scene
  135055. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135056. */
  135057. simplificationQueue: SimplificationQueue;
  135058. }
  135059. interface Mesh {
  135060. /**
  135061. * Simplify the mesh according to the given array of settings.
  135062. * Function will return immediately and will simplify async
  135063. * @param settings a collection of simplification settings
  135064. * @param parallelProcessing should all levels calculate parallel or one after the other
  135065. * @param simplificationType the type of simplification to run
  135066. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  135067. * @returns the current mesh
  135068. */
  135069. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  135070. }
  135071. /**
  135072. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  135073. * created in a scene
  135074. */
  135075. export class SimplicationQueueSceneComponent implements ISceneComponent {
  135076. /**
  135077. * The component name helpfull to identify the component in the list of scene components.
  135078. */
  135079. readonly name: string;
  135080. /**
  135081. * The scene the component belongs to.
  135082. */
  135083. scene: Scene;
  135084. /**
  135085. * Creates a new instance of the component for the given scene
  135086. * @param scene Defines the scene to register the component in
  135087. */
  135088. constructor(scene: Scene);
  135089. /**
  135090. * Registers the component in a given scene
  135091. */
  135092. register(): void;
  135093. /**
  135094. * Rebuilds the elements related to this component in case of
  135095. * context lost for instance.
  135096. */
  135097. rebuild(): void;
  135098. /**
  135099. * Disposes the component and the associated ressources
  135100. */
  135101. dispose(): void;
  135102. private _beforeCameraUpdate;
  135103. }
  135104. }
  135105. declare module BABYLON {
  135106. /**
  135107. * Navigation plugin interface to add navigation constrained by a navigation mesh
  135108. */
  135109. export interface INavigationEnginePlugin {
  135110. /**
  135111. * plugin name
  135112. */
  135113. name: string;
  135114. /**
  135115. * Creates a navigation mesh
  135116. * @param meshes array of all the geometry used to compute the navigatio mesh
  135117. * @param parameters bunch of parameters used to filter geometry
  135118. */
  135119. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135120. /**
  135121. * Create a navigation mesh debug mesh
  135122. * @param scene is where the mesh will be added
  135123. * @returns debug display mesh
  135124. */
  135125. createDebugNavMesh(scene: Scene): Mesh;
  135126. /**
  135127. * Get a navigation mesh constrained position, closest to the parameter position
  135128. * @param position world position
  135129. * @returns the closest point to position constrained by the navigation mesh
  135130. */
  135131. getClosestPoint(position: Vector3): Vector3;
  135132. /**
  135133. * Get a navigation mesh constrained position, within a particular radius
  135134. * @param position world position
  135135. * @param maxRadius the maximum distance to the constrained world position
  135136. * @returns the closest point to position constrained by the navigation mesh
  135137. */
  135138. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135139. /**
  135140. * Compute the final position from a segment made of destination-position
  135141. * @param position world position
  135142. * @param destination world position
  135143. * @returns the resulting point along the navmesh
  135144. */
  135145. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135146. /**
  135147. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135148. * @param start world position
  135149. * @param end world position
  135150. * @returns array containing world position composing the path
  135151. */
  135152. computePath(start: Vector3, end: Vector3): Vector3[];
  135153. /**
  135154. * If this plugin is supported
  135155. * @returns true if plugin is supported
  135156. */
  135157. isSupported(): boolean;
  135158. /**
  135159. * Create a new Crowd so you can add agents
  135160. * @param maxAgents the maximum agent count in the crowd
  135161. * @param maxAgentRadius the maximum radius an agent can have
  135162. * @param scene to attach the crowd to
  135163. * @returns the crowd you can add agents to
  135164. */
  135165. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135166. /**
  135167. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135168. * The queries will try to find a solution within those bounds
  135169. * default is (1,1,1)
  135170. * @param extent x,y,z value that define the extent around the queries point of reference
  135171. */
  135172. setDefaultQueryExtent(extent: Vector3): void;
  135173. /**
  135174. * Get the Bounding box extent specified by setDefaultQueryExtent
  135175. * @returns the box extent values
  135176. */
  135177. getDefaultQueryExtent(): Vector3;
  135178. /**
  135179. * Release all resources
  135180. */
  135181. dispose(): void;
  135182. }
  135183. /**
  135184. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  135185. */
  135186. export interface ICrowd {
  135187. /**
  135188. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135189. * You can attach anything to that node. The node position is updated in the scene update tick.
  135190. * @param pos world position that will be constrained by the navigation mesh
  135191. * @param parameters agent parameters
  135192. * @param transform hooked to the agent that will be update by the scene
  135193. * @returns agent index
  135194. */
  135195. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135196. /**
  135197. * Returns the agent position in world space
  135198. * @param index agent index returned by addAgent
  135199. * @returns world space position
  135200. */
  135201. getAgentPosition(index: number): Vector3;
  135202. /**
  135203. * Gets the agent velocity in world space
  135204. * @param index agent index returned by addAgent
  135205. * @returns world space velocity
  135206. */
  135207. getAgentVelocity(index: number): Vector3;
  135208. /**
  135209. * remove a particular agent previously created
  135210. * @param index agent index returned by addAgent
  135211. */
  135212. removeAgent(index: number): void;
  135213. /**
  135214. * get the list of all agents attached to this crowd
  135215. * @returns list of agent indices
  135216. */
  135217. getAgents(): number[];
  135218. /**
  135219. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135220. * @param deltaTime in seconds
  135221. */
  135222. update(deltaTime: number): void;
  135223. /**
  135224. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135225. * @param index agent index returned by addAgent
  135226. * @param destination targeted world position
  135227. */
  135228. agentGoto(index: number, destination: Vector3): void;
  135229. /**
  135230. * Teleport the agent to a new position
  135231. * @param index agent index returned by addAgent
  135232. * @param destination targeted world position
  135233. */
  135234. agentTeleport(index: number, destination: Vector3): void;
  135235. /**
  135236. * Update agent parameters
  135237. * @param index agent index returned by addAgent
  135238. * @param parameters agent parameters
  135239. */
  135240. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135241. /**
  135242. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135243. * The queries will try to find a solution within those bounds
  135244. * default is (1,1,1)
  135245. * @param extent x,y,z value that define the extent around the queries point of reference
  135246. */
  135247. setDefaultQueryExtent(extent: Vector3): void;
  135248. /**
  135249. * Get the Bounding box extent specified by setDefaultQueryExtent
  135250. * @returns the box extent values
  135251. */
  135252. getDefaultQueryExtent(): Vector3;
  135253. /**
  135254. * Release all resources
  135255. */
  135256. dispose(): void;
  135257. }
  135258. /**
  135259. * Configures an agent
  135260. */
  135261. export interface IAgentParameters {
  135262. /**
  135263. * Agent radius. [Limit: >= 0]
  135264. */
  135265. radius: number;
  135266. /**
  135267. * Agent height. [Limit: > 0]
  135268. */
  135269. height: number;
  135270. /**
  135271. * Maximum allowed acceleration. [Limit: >= 0]
  135272. */
  135273. maxAcceleration: number;
  135274. /**
  135275. * Maximum allowed speed. [Limit: >= 0]
  135276. */
  135277. maxSpeed: number;
  135278. /**
  135279. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  135280. */
  135281. collisionQueryRange: number;
  135282. /**
  135283. * The path visibility optimization range. [Limit: > 0]
  135284. */
  135285. pathOptimizationRange: number;
  135286. /**
  135287. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  135288. */
  135289. separationWeight: number;
  135290. }
  135291. /**
  135292. * Configures the navigation mesh creation
  135293. */
  135294. export interface INavMeshParameters {
  135295. /**
  135296. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  135297. */
  135298. cs: number;
  135299. /**
  135300. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  135301. */
  135302. ch: number;
  135303. /**
  135304. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  135305. */
  135306. walkableSlopeAngle: number;
  135307. /**
  135308. * Minimum floor to 'ceiling' height that will still allow the floor area to
  135309. * be considered walkable. [Limit: >= 3] [Units: vx]
  135310. */
  135311. walkableHeight: number;
  135312. /**
  135313. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  135314. */
  135315. walkableClimb: number;
  135316. /**
  135317. * The distance to erode/shrink the walkable area of the heightfield away from
  135318. * obstructions. [Limit: >=0] [Units: vx]
  135319. */
  135320. walkableRadius: number;
  135321. /**
  135322. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  135323. */
  135324. maxEdgeLen: number;
  135325. /**
  135326. * The maximum distance a simplfied contour's border edges should deviate
  135327. * the original raw contour. [Limit: >=0] [Units: vx]
  135328. */
  135329. maxSimplificationError: number;
  135330. /**
  135331. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  135332. */
  135333. minRegionArea: number;
  135334. /**
  135335. * Any regions with a span count smaller than this value will, if possible,
  135336. * be merged with larger regions. [Limit: >=0] [Units: vx]
  135337. */
  135338. mergeRegionArea: number;
  135339. /**
  135340. * The maximum number of vertices allowed for polygons generated during the
  135341. * contour to polygon conversion process. [Limit: >= 3]
  135342. */
  135343. maxVertsPerPoly: number;
  135344. /**
  135345. * Sets the sampling distance to use when generating the detail mesh.
  135346. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  135347. */
  135348. detailSampleDist: number;
  135349. /**
  135350. * The maximum distance the detail mesh surface should deviate from heightfield
  135351. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  135352. */
  135353. detailSampleMaxError: number;
  135354. }
  135355. }
  135356. declare module BABYLON {
  135357. /**
  135358. * RecastJS navigation plugin
  135359. */
  135360. export class RecastJSPlugin implements INavigationEnginePlugin {
  135361. /**
  135362. * Reference to the Recast library
  135363. */
  135364. bjsRECAST: any;
  135365. /**
  135366. * plugin name
  135367. */
  135368. name: string;
  135369. /**
  135370. * the first navmesh created. We might extend this to support multiple navmeshes
  135371. */
  135372. navMesh: any;
  135373. /**
  135374. * Initializes the recastJS plugin
  135375. * @param recastInjection can be used to inject your own recast reference
  135376. */
  135377. constructor(recastInjection?: any);
  135378. /**
  135379. * Creates a navigation mesh
  135380. * @param meshes array of all the geometry used to compute the navigatio mesh
  135381. * @param parameters bunch of parameters used to filter geometry
  135382. */
  135383. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135384. /**
  135385. * Create a navigation mesh debug mesh
  135386. * @param scene is where the mesh will be added
  135387. * @returns debug display mesh
  135388. */
  135389. createDebugNavMesh(scene: Scene): Mesh;
  135390. /**
  135391. * Get a navigation mesh constrained position, closest to the parameter position
  135392. * @param position world position
  135393. * @returns the closest point to position constrained by the navigation mesh
  135394. */
  135395. getClosestPoint(position: Vector3): Vector3;
  135396. /**
  135397. * Get a navigation mesh constrained position, within a particular radius
  135398. * @param position world position
  135399. * @param maxRadius the maximum distance to the constrained world position
  135400. * @returns the closest point to position constrained by the navigation mesh
  135401. */
  135402. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135403. /**
  135404. * Compute the final position from a segment made of destination-position
  135405. * @param position world position
  135406. * @param destination world position
  135407. * @returns the resulting point along the navmesh
  135408. */
  135409. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135410. /**
  135411. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135412. * @param start world position
  135413. * @param end world position
  135414. * @returns array containing world position composing the path
  135415. */
  135416. computePath(start: Vector3, end: Vector3): Vector3[];
  135417. /**
  135418. * Create a new Crowd so you can add agents
  135419. * @param maxAgents the maximum agent count in the crowd
  135420. * @param maxAgentRadius the maximum radius an agent can have
  135421. * @param scene to attach the crowd to
  135422. * @returns the crowd you can add agents to
  135423. */
  135424. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135425. /**
  135426. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135427. * The queries will try to find a solution within those bounds
  135428. * default is (1,1,1)
  135429. * @param extent x,y,z value that define the extent around the queries point of reference
  135430. */
  135431. setDefaultQueryExtent(extent: Vector3): void;
  135432. /**
  135433. * Get the Bounding box extent specified by setDefaultQueryExtent
  135434. * @returns the box extent values
  135435. */
  135436. getDefaultQueryExtent(): Vector3;
  135437. /**
  135438. * Disposes
  135439. */
  135440. dispose(): void;
  135441. /**
  135442. * If this plugin is supported
  135443. * @returns true if plugin is supported
  135444. */
  135445. isSupported(): boolean;
  135446. }
  135447. /**
  135448. * Recast detour crowd implementation
  135449. */
  135450. export class RecastJSCrowd implements ICrowd {
  135451. /**
  135452. * Recast/detour plugin
  135453. */
  135454. bjsRECASTPlugin: RecastJSPlugin;
  135455. /**
  135456. * Link to the detour crowd
  135457. */
  135458. recastCrowd: any;
  135459. /**
  135460. * One transform per agent
  135461. */
  135462. transforms: TransformNode[];
  135463. /**
  135464. * All agents created
  135465. */
  135466. agents: number[];
  135467. /**
  135468. * Link to the scene is kept to unregister the crowd from the scene
  135469. */
  135470. private _scene;
  135471. /**
  135472. * Observer for crowd updates
  135473. */
  135474. private _onBeforeAnimationsObserver;
  135475. /**
  135476. * Constructor
  135477. * @param plugin recastJS plugin
  135478. * @param maxAgents the maximum agent count in the crowd
  135479. * @param maxAgentRadius the maximum radius an agent can have
  135480. * @param scene to attach the crowd to
  135481. * @returns the crowd you can add agents to
  135482. */
  135483. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  135484. /**
  135485. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135486. * You can attach anything to that node. The node position is updated in the scene update tick.
  135487. * @param pos world position that will be constrained by the navigation mesh
  135488. * @param parameters agent parameters
  135489. * @param transform hooked to the agent that will be update by the scene
  135490. * @returns agent index
  135491. */
  135492. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135493. /**
  135494. * Returns the agent position in world space
  135495. * @param index agent index returned by addAgent
  135496. * @returns world space position
  135497. */
  135498. getAgentPosition(index: number): Vector3;
  135499. /**
  135500. * Returns the agent velocity in world space
  135501. * @param index agent index returned by addAgent
  135502. * @returns world space velocity
  135503. */
  135504. getAgentVelocity(index: number): Vector3;
  135505. /**
  135506. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135507. * @param index agent index returned by addAgent
  135508. * @param destination targeted world position
  135509. */
  135510. agentGoto(index: number, destination: Vector3): void;
  135511. /**
  135512. * Teleport the agent to a new position
  135513. * @param index agent index returned by addAgent
  135514. * @param destination targeted world position
  135515. */
  135516. agentTeleport(index: number, destination: Vector3): void;
  135517. /**
  135518. * Update agent parameters
  135519. * @param index agent index returned by addAgent
  135520. * @param parameters agent parameters
  135521. */
  135522. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135523. /**
  135524. * remove a particular agent previously created
  135525. * @param index agent index returned by addAgent
  135526. */
  135527. removeAgent(index: number): void;
  135528. /**
  135529. * get the list of all agents attached to this crowd
  135530. * @returns list of agent indices
  135531. */
  135532. getAgents(): number[];
  135533. /**
  135534. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135535. * @param deltaTime in seconds
  135536. */
  135537. update(deltaTime: number): void;
  135538. /**
  135539. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135540. * The queries will try to find a solution within those bounds
  135541. * default is (1,1,1)
  135542. * @param extent x,y,z value that define the extent around the queries point of reference
  135543. */
  135544. setDefaultQueryExtent(extent: Vector3): void;
  135545. /**
  135546. * Get the Bounding box extent specified by setDefaultQueryExtent
  135547. * @returns the box extent values
  135548. */
  135549. getDefaultQueryExtent(): Vector3;
  135550. /**
  135551. * Release all resources
  135552. */
  135553. dispose(): void;
  135554. }
  135555. }
  135556. declare module BABYLON {
  135557. /**
  135558. * Class used to enable access to IndexedDB
  135559. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  135560. */
  135561. export class Database implements IOfflineProvider {
  135562. private _callbackManifestChecked;
  135563. private _currentSceneUrl;
  135564. private _db;
  135565. private _enableSceneOffline;
  135566. private _enableTexturesOffline;
  135567. private _manifestVersionFound;
  135568. private _mustUpdateRessources;
  135569. private _hasReachedQuota;
  135570. private _isSupported;
  135571. private _idbFactory;
  135572. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  135573. private static IsUASupportingBlobStorage;
  135574. /**
  135575. * Gets a boolean indicating if Database storate is enabled (off by default)
  135576. */
  135577. static IDBStorageEnabled: boolean;
  135578. /**
  135579. * Gets a boolean indicating if scene must be saved in the database
  135580. */
  135581. get enableSceneOffline(): boolean;
  135582. /**
  135583. * Gets a boolean indicating if textures must be saved in the database
  135584. */
  135585. get enableTexturesOffline(): boolean;
  135586. /**
  135587. * Creates a new Database
  135588. * @param urlToScene defines the url to load the scene
  135589. * @param callbackManifestChecked defines the callback to use when manifest is checked
  135590. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  135591. */
  135592. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  135593. private static _ParseURL;
  135594. private static _ReturnFullUrlLocation;
  135595. private _checkManifestFile;
  135596. /**
  135597. * Open the database and make it available
  135598. * @param successCallback defines the callback to call on success
  135599. * @param errorCallback defines the callback to call on error
  135600. */
  135601. open(successCallback: () => void, errorCallback: () => void): void;
  135602. /**
  135603. * Loads an image from the database
  135604. * @param url defines the url to load from
  135605. * @param image defines the target DOM image
  135606. */
  135607. loadImage(url: string, image: HTMLImageElement): void;
  135608. private _loadImageFromDBAsync;
  135609. private _saveImageIntoDBAsync;
  135610. private _checkVersionFromDB;
  135611. private _loadVersionFromDBAsync;
  135612. private _saveVersionIntoDBAsync;
  135613. /**
  135614. * Loads a file from database
  135615. * @param url defines the URL to load from
  135616. * @param sceneLoaded defines a callback to call on success
  135617. * @param progressCallBack defines a callback to call when progress changed
  135618. * @param errorCallback defines a callback to call on error
  135619. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  135620. */
  135621. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  135622. private _loadFileAsync;
  135623. private _saveFileAsync;
  135624. /**
  135625. * Validates if xhr data is correct
  135626. * @param xhr defines the request to validate
  135627. * @param dataType defines the expected data type
  135628. * @returns true if data is correct
  135629. */
  135630. private static _ValidateXHRData;
  135631. }
  135632. }
  135633. declare module BABYLON {
  135634. /** @hidden */
  135635. export var gpuUpdateParticlesPixelShader: {
  135636. name: string;
  135637. shader: string;
  135638. };
  135639. }
  135640. declare module BABYLON {
  135641. /** @hidden */
  135642. export var gpuUpdateParticlesVertexShader: {
  135643. name: string;
  135644. shader: string;
  135645. };
  135646. }
  135647. declare module BABYLON {
  135648. /** @hidden */
  135649. export var clipPlaneFragmentDeclaration2: {
  135650. name: string;
  135651. shader: string;
  135652. };
  135653. }
  135654. declare module BABYLON {
  135655. /** @hidden */
  135656. export var gpuRenderParticlesPixelShader: {
  135657. name: string;
  135658. shader: string;
  135659. };
  135660. }
  135661. declare module BABYLON {
  135662. /** @hidden */
  135663. export var clipPlaneVertexDeclaration2: {
  135664. name: string;
  135665. shader: string;
  135666. };
  135667. }
  135668. declare module BABYLON {
  135669. /** @hidden */
  135670. export var gpuRenderParticlesVertexShader: {
  135671. name: string;
  135672. shader: string;
  135673. };
  135674. }
  135675. declare module BABYLON {
  135676. /**
  135677. * This represents a GPU particle system in Babylon
  135678. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  135679. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  135680. */
  135681. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  135682. /**
  135683. * The layer mask we are rendering the particles through.
  135684. */
  135685. layerMask: number;
  135686. private _capacity;
  135687. private _activeCount;
  135688. private _currentActiveCount;
  135689. private _accumulatedCount;
  135690. private _renderEffect;
  135691. private _updateEffect;
  135692. private _buffer0;
  135693. private _buffer1;
  135694. private _spriteBuffer;
  135695. private _updateVAO;
  135696. private _renderVAO;
  135697. private _targetIndex;
  135698. private _sourceBuffer;
  135699. private _targetBuffer;
  135700. private _engine;
  135701. private _currentRenderId;
  135702. private _started;
  135703. private _stopped;
  135704. private _timeDelta;
  135705. private _randomTexture;
  135706. private _randomTexture2;
  135707. private _attributesStrideSize;
  135708. private _updateEffectOptions;
  135709. private _randomTextureSize;
  135710. private _actualFrame;
  135711. private readonly _rawTextureWidth;
  135712. /**
  135713. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  135714. */
  135715. static get IsSupported(): boolean;
  135716. /**
  135717. * An event triggered when the system is disposed.
  135718. */
  135719. onDisposeObservable: Observable<GPUParticleSystem>;
  135720. /**
  135721. * Gets the maximum number of particles active at the same time.
  135722. * @returns The max number of active particles.
  135723. */
  135724. getCapacity(): number;
  135725. /**
  135726. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  135727. * to override the particles.
  135728. */
  135729. forceDepthWrite: boolean;
  135730. /**
  135731. * Gets or set the number of active particles
  135732. */
  135733. get activeParticleCount(): number;
  135734. set activeParticleCount(value: number);
  135735. private _preWarmDone;
  135736. /**
  135737. * Specifies if the particles are updated in emitter local space or world space.
  135738. * This is always false for GPU particles
  135739. */
  135740. get isLocal(): boolean;
  135741. set isLocal(value: boolean);
  135742. /**
  135743. * Is this system ready to be used/rendered
  135744. * @return true if the system is ready
  135745. */
  135746. isReady(): boolean;
  135747. /**
  135748. * Gets if the system has been started. (Note: this will still be true after stop is called)
  135749. * @returns True if it has been started, otherwise false.
  135750. */
  135751. isStarted(): boolean;
  135752. /**
  135753. * Starts the particle system and begins to emit
  135754. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  135755. */
  135756. start(delay?: number): void;
  135757. /**
  135758. * Stops the particle system.
  135759. */
  135760. stop(): void;
  135761. /**
  135762. * Remove all active particles
  135763. */
  135764. reset(): void;
  135765. /**
  135766. * Returns the string "GPUParticleSystem"
  135767. * @returns a string containing the class name
  135768. */
  135769. getClassName(): string;
  135770. private _colorGradientsTexture;
  135771. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  135772. /**
  135773. * Adds a new color gradient
  135774. * @param gradient defines the gradient to use (between 0 and 1)
  135775. * @param color1 defines the color to affect to the specified gradient
  135776. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  135777. * @returns the current particle system
  135778. */
  135779. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  135780. /**
  135781. * Remove a specific color gradient
  135782. * @param gradient defines the gradient to remove
  135783. * @returns the current particle system
  135784. */
  135785. removeColorGradient(gradient: number): GPUParticleSystem;
  135786. private _angularSpeedGradientsTexture;
  135787. private _sizeGradientsTexture;
  135788. private _velocityGradientsTexture;
  135789. private _limitVelocityGradientsTexture;
  135790. private _dragGradientsTexture;
  135791. private _addFactorGradient;
  135792. /**
  135793. * Adds a new size gradient
  135794. * @param gradient defines the gradient to use (between 0 and 1)
  135795. * @param factor defines the size factor to affect to the specified gradient
  135796. * @returns the current particle system
  135797. */
  135798. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  135799. /**
  135800. * Remove a specific size gradient
  135801. * @param gradient defines the gradient to remove
  135802. * @returns the current particle system
  135803. */
  135804. removeSizeGradient(gradient: number): GPUParticleSystem;
  135805. /**
  135806. * Adds a new angular speed gradient
  135807. * @param gradient defines the gradient to use (between 0 and 1)
  135808. * @param factor defines the angular speed to affect to the specified gradient
  135809. * @returns the current particle system
  135810. */
  135811. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  135812. /**
  135813. * Remove a specific angular speed gradient
  135814. * @param gradient defines the gradient to remove
  135815. * @returns the current particle system
  135816. */
  135817. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  135818. /**
  135819. * Adds a new velocity gradient
  135820. * @param gradient defines the gradient to use (between 0 and 1)
  135821. * @param factor defines the velocity to affect to the specified gradient
  135822. * @returns the current particle system
  135823. */
  135824. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135825. /**
  135826. * Remove a specific velocity gradient
  135827. * @param gradient defines the gradient to remove
  135828. * @returns the current particle system
  135829. */
  135830. removeVelocityGradient(gradient: number): GPUParticleSystem;
  135831. /**
  135832. * Adds a new limit velocity gradient
  135833. * @param gradient defines the gradient to use (between 0 and 1)
  135834. * @param factor defines the limit velocity value to affect to the specified gradient
  135835. * @returns the current particle system
  135836. */
  135837. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135838. /**
  135839. * Remove a specific limit velocity gradient
  135840. * @param gradient defines the gradient to remove
  135841. * @returns the current particle system
  135842. */
  135843. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  135844. /**
  135845. * Adds a new drag gradient
  135846. * @param gradient defines the gradient to use (between 0 and 1)
  135847. * @param factor defines the drag value to affect to the specified gradient
  135848. * @returns the current particle system
  135849. */
  135850. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  135851. /**
  135852. * Remove a specific drag gradient
  135853. * @param gradient defines the gradient to remove
  135854. * @returns the current particle system
  135855. */
  135856. removeDragGradient(gradient: number): GPUParticleSystem;
  135857. /**
  135858. * Not supported by GPUParticleSystem
  135859. * @param gradient defines the gradient to use (between 0 and 1)
  135860. * @param factor defines the emit rate value to affect to the specified gradient
  135861. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135862. * @returns the current particle system
  135863. */
  135864. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135865. /**
  135866. * Not supported by GPUParticleSystem
  135867. * @param gradient defines the gradient to remove
  135868. * @returns the current particle system
  135869. */
  135870. removeEmitRateGradient(gradient: number): IParticleSystem;
  135871. /**
  135872. * Not supported by GPUParticleSystem
  135873. * @param gradient defines the gradient to use (between 0 and 1)
  135874. * @param factor defines the start size value to affect to the specified gradient
  135875. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135876. * @returns the current particle system
  135877. */
  135878. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135879. /**
  135880. * Not supported by GPUParticleSystem
  135881. * @param gradient defines the gradient to remove
  135882. * @returns the current particle system
  135883. */
  135884. removeStartSizeGradient(gradient: number): IParticleSystem;
  135885. /**
  135886. * Not supported by GPUParticleSystem
  135887. * @param gradient defines the gradient to use (between 0 and 1)
  135888. * @param min defines the color remap minimal range
  135889. * @param max defines the color remap maximal range
  135890. * @returns the current particle system
  135891. */
  135892. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135893. /**
  135894. * Not supported by GPUParticleSystem
  135895. * @param gradient defines the gradient to remove
  135896. * @returns the current particle system
  135897. */
  135898. removeColorRemapGradient(): IParticleSystem;
  135899. /**
  135900. * Not supported by GPUParticleSystem
  135901. * @param gradient defines the gradient to use (between 0 and 1)
  135902. * @param min defines the alpha remap minimal range
  135903. * @param max defines the alpha remap maximal range
  135904. * @returns the current particle system
  135905. */
  135906. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135907. /**
  135908. * Not supported by GPUParticleSystem
  135909. * @param gradient defines the gradient to remove
  135910. * @returns the current particle system
  135911. */
  135912. removeAlphaRemapGradient(): IParticleSystem;
  135913. /**
  135914. * Not supported by GPUParticleSystem
  135915. * @param gradient defines the gradient to use (between 0 and 1)
  135916. * @param color defines the color to affect to the specified gradient
  135917. * @returns the current particle system
  135918. */
  135919. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  135920. /**
  135921. * Not supported by GPUParticleSystem
  135922. * @param gradient defines the gradient to remove
  135923. * @returns the current particle system
  135924. */
  135925. removeRampGradient(): IParticleSystem;
  135926. /**
  135927. * Not supported by GPUParticleSystem
  135928. * @returns the list of ramp gradients
  135929. */
  135930. getRampGradients(): Nullable<Array<Color3Gradient>>;
  135931. /**
  135932. * Not supported by GPUParticleSystem
  135933. * Gets or sets a boolean indicating that ramp gradients must be used
  135934. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  135935. */
  135936. get useRampGradients(): boolean;
  135937. set useRampGradients(value: boolean);
  135938. /**
  135939. * Not supported by GPUParticleSystem
  135940. * @param gradient defines the gradient to use (between 0 and 1)
  135941. * @param factor defines the life time factor to affect to the specified gradient
  135942. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135943. * @returns the current particle system
  135944. */
  135945. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135946. /**
  135947. * Not supported by GPUParticleSystem
  135948. * @param gradient defines the gradient to remove
  135949. * @returns the current particle system
  135950. */
  135951. removeLifeTimeGradient(gradient: number): IParticleSystem;
  135952. /**
  135953. * Instantiates a GPU particle system.
  135954. * 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.
  135955. * @param name The name of the particle system
  135956. * @param options The options used to create the system
  135957. * @param scene The scene the particle system belongs to
  135958. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  135959. */
  135960. constructor(name: string, options: Partial<{
  135961. capacity: number;
  135962. randomTextureSize: number;
  135963. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  135964. protected _reset(): void;
  135965. private _createUpdateVAO;
  135966. private _createRenderVAO;
  135967. private _initialize;
  135968. /** @hidden */
  135969. _recreateUpdateEffect(): void;
  135970. /** @hidden */
  135971. _recreateRenderEffect(): void;
  135972. /**
  135973. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  135974. * @param preWarm defines if we are in the pre-warmimg phase
  135975. */
  135976. animate(preWarm?: boolean): void;
  135977. private _createFactorGradientTexture;
  135978. private _createSizeGradientTexture;
  135979. private _createAngularSpeedGradientTexture;
  135980. private _createVelocityGradientTexture;
  135981. private _createLimitVelocityGradientTexture;
  135982. private _createDragGradientTexture;
  135983. private _createColorGradientTexture;
  135984. /**
  135985. * Renders the particle system in its current state
  135986. * @param preWarm defines if the system should only update the particles but not render them
  135987. * @returns the current number of particles
  135988. */
  135989. render(preWarm?: boolean): number;
  135990. /**
  135991. * Rebuilds the particle system
  135992. */
  135993. rebuild(): void;
  135994. private _releaseBuffers;
  135995. private _releaseVAOs;
  135996. /**
  135997. * Disposes the particle system and free the associated resources
  135998. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  135999. */
  136000. dispose(disposeTexture?: boolean): void;
  136001. /**
  136002. * Clones the particle system.
  136003. * @param name The name of the cloned object
  136004. * @param newEmitter The new emitter to use
  136005. * @returns the cloned particle system
  136006. */
  136007. clone(name: string, newEmitter: any): GPUParticleSystem;
  136008. /**
  136009. * Serializes the particle system to a JSON object.
  136010. * @returns the JSON object
  136011. */
  136012. serialize(): any;
  136013. /**
  136014. * Parses a JSON object to create a GPU particle system.
  136015. * @param parsedParticleSystem The JSON object to parse
  136016. * @param scene The scene to create the particle system in
  136017. * @param rootUrl The root url to use to load external dependencies like texture
  136018. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  136019. * @returns the parsed GPU particle system
  136020. */
  136021. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  136022. }
  136023. }
  136024. declare module BABYLON {
  136025. /**
  136026. * Represents a set of particle systems working together to create a specific effect
  136027. */
  136028. export class ParticleSystemSet implements IDisposable {
  136029. /**
  136030. * Gets or sets base Assets URL
  136031. */
  136032. static BaseAssetsUrl: string;
  136033. private _emitterCreationOptions;
  136034. private _emitterNode;
  136035. /**
  136036. * Gets the particle system list
  136037. */
  136038. systems: IParticleSystem[];
  136039. /**
  136040. * Gets the emitter node used with this set
  136041. */
  136042. get emitterNode(): Nullable<TransformNode>;
  136043. /**
  136044. * Creates a new emitter mesh as a sphere
  136045. * @param options defines the options used to create the sphere
  136046. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  136047. * @param scene defines the hosting scene
  136048. */
  136049. setEmitterAsSphere(options: {
  136050. diameter: number;
  136051. segments: number;
  136052. color: Color3;
  136053. }, renderingGroupId: number, scene: Scene): void;
  136054. /**
  136055. * Starts all particle systems of the set
  136056. * @param emitter defines an optional mesh to use as emitter for the particle systems
  136057. */
  136058. start(emitter?: AbstractMesh): void;
  136059. /**
  136060. * Release all associated resources
  136061. */
  136062. dispose(): void;
  136063. /**
  136064. * Serialize the set into a JSON compatible object
  136065. * @returns a JSON compatible representation of the set
  136066. */
  136067. serialize(): any;
  136068. /**
  136069. * Parse a new ParticleSystemSet from a serialized source
  136070. * @param data defines a JSON compatible representation of the set
  136071. * @param scene defines the hosting scene
  136072. * @param gpu defines if we want GPU particles or CPU particles
  136073. * @returns a new ParticleSystemSet
  136074. */
  136075. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  136076. }
  136077. }
  136078. declare module BABYLON {
  136079. /**
  136080. * This class is made for on one-liner static method to help creating particle system set.
  136081. */
  136082. export class ParticleHelper {
  136083. /**
  136084. * Gets or sets base Assets URL
  136085. */
  136086. static BaseAssetsUrl: string;
  136087. /**
  136088. * Create a default particle system that you can tweak
  136089. * @param emitter defines the emitter to use
  136090. * @param capacity defines the system capacity (default is 500 particles)
  136091. * @param scene defines the hosting scene
  136092. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  136093. * @returns the new Particle system
  136094. */
  136095. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  136096. /**
  136097. * This is the main static method (one-liner) of this helper to create different particle systems
  136098. * @param type This string represents the type to the particle system to create
  136099. * @param scene The scene where the particle system should live
  136100. * @param gpu If the system will use gpu
  136101. * @returns the ParticleSystemSet created
  136102. */
  136103. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  136104. /**
  136105. * Static function used to export a particle system to a ParticleSystemSet variable.
  136106. * Please note that the emitter shape is not exported
  136107. * @param systems defines the particle systems to export
  136108. * @returns the created particle system set
  136109. */
  136110. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  136111. }
  136112. }
  136113. declare module BABYLON {
  136114. interface Engine {
  136115. /**
  136116. * Create an effect to use with particle systems.
  136117. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  136118. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  136119. * @param uniformsNames defines a list of attribute names
  136120. * @param samplers defines an array of string used to represent textures
  136121. * @param defines defines the string containing the defines to use to compile the shaders
  136122. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  136123. * @param onCompiled defines a function to call when the effect creation is successful
  136124. * @param onError defines a function to call when the effect creation has failed
  136125. * @returns the new Effect
  136126. */
  136127. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  136128. }
  136129. interface Mesh {
  136130. /**
  136131. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  136132. * @returns an array of IParticleSystem
  136133. */
  136134. getEmittedParticleSystems(): IParticleSystem[];
  136135. /**
  136136. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  136137. * @returns an array of IParticleSystem
  136138. */
  136139. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  136140. }
  136141. /**
  136142. * @hidden
  136143. */
  136144. export var _IDoNeedToBeInTheBuild: number;
  136145. }
  136146. declare module BABYLON {
  136147. /** Defines the 4 color options */
  136148. export enum PointColor {
  136149. /** color value */
  136150. Color = 2,
  136151. /** uv value */
  136152. UV = 1,
  136153. /** random value */
  136154. Random = 0,
  136155. /** stated value */
  136156. Stated = 3
  136157. }
  136158. /**
  136159. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  136160. * 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.
  136161. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  136162. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  136163. *
  136164. * Full documentation here : TO BE ENTERED
  136165. */
  136166. export class PointsCloudSystem implements IDisposable {
  136167. /**
  136168. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  136169. * Example : var p = SPS.particles[i];
  136170. */
  136171. particles: CloudPoint[];
  136172. /**
  136173. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  136174. */
  136175. nbParticles: number;
  136176. /**
  136177. * This a counter for your own usage. It's not set by any SPS functions.
  136178. */
  136179. counter: number;
  136180. /**
  136181. * The PCS name. This name is also given to the underlying mesh.
  136182. */
  136183. name: string;
  136184. /**
  136185. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  136186. */
  136187. mesh: Mesh;
  136188. /**
  136189. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  136190. * Please read :
  136191. */
  136192. vars: any;
  136193. /**
  136194. * @hidden
  136195. */
  136196. _size: number;
  136197. private _scene;
  136198. private _promises;
  136199. private _positions;
  136200. private _indices;
  136201. private _normals;
  136202. private _colors;
  136203. private _uvs;
  136204. private _indices32;
  136205. private _positions32;
  136206. private _colors32;
  136207. private _uvs32;
  136208. private _updatable;
  136209. private _isVisibilityBoxLocked;
  136210. private _alwaysVisible;
  136211. private _groups;
  136212. private _groupCounter;
  136213. private _computeParticleColor;
  136214. private _computeParticleTexture;
  136215. private _computeParticleRotation;
  136216. private _computeBoundingBox;
  136217. private _isReady;
  136218. /**
  136219. * Creates a PCS (Points Cloud System) object
  136220. * @param name (String) is the PCS name, this will be the underlying mesh name
  136221. * @param pointSize (number) is the size for each point
  136222. * @param scene (Scene) is the scene in which the PCS is added
  136223. * @param options defines the options of the PCS e.g.
  136224. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  136225. */
  136226. constructor(name: string, pointSize: number, scene: Scene, options?: {
  136227. updatable?: boolean;
  136228. });
  136229. /**
  136230. * Builds the PCS underlying mesh. Returns a standard Mesh.
  136231. * If no points were added to the PCS, the returned mesh is just a single point.
  136232. * @returns a promise for the created mesh
  136233. */
  136234. buildMeshAsync(): Promise<Mesh>;
  136235. /**
  136236. * @hidden
  136237. */
  136238. private _buildMesh;
  136239. private _addParticle;
  136240. private _randomUnitVector;
  136241. private _getColorIndicesForCoord;
  136242. private _setPointsColorOrUV;
  136243. private _colorFromTexture;
  136244. private _calculateDensity;
  136245. /**
  136246. * Adds points to the PCS in random positions within a unit sphere
  136247. * @param nb (positive integer) the number of particles to be created from this model
  136248. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  136249. * @returns the number of groups in the system
  136250. */
  136251. addPoints(nb: number, pointFunction?: any): number;
  136252. /**
  136253. * Adds points to the PCS from the surface of the model shape
  136254. * @param mesh is any Mesh object that will be used as a surface model for the points
  136255. * @param nb (positive integer) the number of particles to be created from this model
  136256. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136257. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136258. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136259. * @returns the number of groups in the system
  136260. */
  136261. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136262. /**
  136263. * Adds points to the PCS inside the model shape
  136264. * @param mesh is any Mesh object that will be used as a surface model for the points
  136265. * @param nb (positive integer) the number of particles to be created from this model
  136266. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136267. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136268. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136269. * @returns the number of groups in the system
  136270. */
  136271. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136272. /**
  136273. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  136274. * This method calls `updateParticle()` for each particle of the SPS.
  136275. * For an animated SPS, it is usually called within the render loop.
  136276. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  136277. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  136278. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  136279. * @returns the PCS.
  136280. */
  136281. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  136282. /**
  136283. * Disposes the PCS.
  136284. */
  136285. dispose(): void;
  136286. /**
  136287. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  136288. * doc :
  136289. * @returns the PCS.
  136290. */
  136291. refreshVisibleSize(): PointsCloudSystem;
  136292. /**
  136293. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  136294. * @param size the size (float) of the visibility box
  136295. * note : this doesn't lock the PCS mesh bounding box.
  136296. * doc :
  136297. */
  136298. setVisibilityBox(size: number): void;
  136299. /**
  136300. * Gets whether the PCS is always visible or not
  136301. * doc :
  136302. */
  136303. get isAlwaysVisible(): boolean;
  136304. /**
  136305. * Sets the PCS as always visible or not
  136306. * doc :
  136307. */
  136308. set isAlwaysVisible(val: boolean);
  136309. /**
  136310. * Tells to `setParticles()` to compute the particle rotations or not
  136311. * Default value : false. The PCS is faster when it's set to false
  136312. * Note : particle rotations are only applied to parent particles
  136313. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  136314. */
  136315. set computeParticleRotation(val: boolean);
  136316. /**
  136317. * Tells to `setParticles()` to compute the particle colors or not.
  136318. * Default value : true. The PCS is faster when it's set to false.
  136319. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136320. */
  136321. set computeParticleColor(val: boolean);
  136322. set computeParticleTexture(val: boolean);
  136323. /**
  136324. * Gets if `setParticles()` computes the particle colors or not.
  136325. * Default value : false. The PCS is faster when it's set to false.
  136326. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136327. */
  136328. get computeParticleColor(): boolean;
  136329. /**
  136330. * Gets if `setParticles()` computes the particle textures or not.
  136331. * Default value : false. The PCS is faster when it's set to false.
  136332. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  136333. */
  136334. get computeParticleTexture(): boolean;
  136335. /**
  136336. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  136337. */
  136338. set computeBoundingBox(val: boolean);
  136339. /**
  136340. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  136341. */
  136342. get computeBoundingBox(): boolean;
  136343. /**
  136344. * This function does nothing. It may be overwritten to set all the particle first values.
  136345. * The PCS doesn't call this function, you may have to call it by your own.
  136346. * doc :
  136347. */
  136348. initParticles(): void;
  136349. /**
  136350. * This function does nothing. It may be overwritten to recycle a particle
  136351. * The PCS doesn't call this function, you can to call it
  136352. * doc :
  136353. * @param particle The particle to recycle
  136354. * @returns the recycled particle
  136355. */
  136356. recycleParticle(particle: CloudPoint): CloudPoint;
  136357. /**
  136358. * Updates a particle : this function should be overwritten by the user.
  136359. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  136360. * doc :
  136361. * @example : just set a particle position or velocity and recycle conditions
  136362. * @param particle The particle to update
  136363. * @returns the updated particle
  136364. */
  136365. updateParticle(particle: CloudPoint): CloudPoint;
  136366. /**
  136367. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  136368. * This does nothing and may be overwritten by the user.
  136369. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136370. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136371. * @param update the boolean update value actually passed to setParticles()
  136372. */
  136373. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136374. /**
  136375. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  136376. * This will be passed three parameters.
  136377. * This does nothing and may be overwritten by the user.
  136378. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136379. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136380. * @param update the boolean update value actually passed to setParticles()
  136381. */
  136382. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136383. }
  136384. }
  136385. declare module BABYLON {
  136386. /**
  136387. * Represents one particle of a points cloud system.
  136388. */
  136389. export class CloudPoint {
  136390. /**
  136391. * particle global index
  136392. */
  136393. idx: number;
  136394. /**
  136395. * The color of the particle
  136396. */
  136397. color: Nullable<Color4>;
  136398. /**
  136399. * The world space position of the particle.
  136400. */
  136401. position: Vector3;
  136402. /**
  136403. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  136404. */
  136405. rotation: Vector3;
  136406. /**
  136407. * The world space rotation quaternion of the particle.
  136408. */
  136409. rotationQuaternion: Nullable<Quaternion>;
  136410. /**
  136411. * The uv of the particle.
  136412. */
  136413. uv: Nullable<Vector2>;
  136414. /**
  136415. * The current speed of the particle.
  136416. */
  136417. velocity: Vector3;
  136418. /**
  136419. * The pivot point in the particle local space.
  136420. */
  136421. pivot: Vector3;
  136422. /**
  136423. * Must the particle be translated from its pivot point in its local space ?
  136424. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  136425. * Default : false
  136426. */
  136427. translateFromPivot: boolean;
  136428. /**
  136429. * Index of this particle in the global "positions" array (Internal use)
  136430. * @hidden
  136431. */
  136432. _pos: number;
  136433. /**
  136434. * @hidden Index of this particle in the global "indices" array (Internal use)
  136435. */
  136436. _ind: number;
  136437. /**
  136438. * Group this particle belongs to
  136439. */
  136440. _group: PointsGroup;
  136441. /**
  136442. * Group id of this particle
  136443. */
  136444. groupId: number;
  136445. /**
  136446. * Index of the particle in its group id (Internal use)
  136447. */
  136448. idxInGroup: number;
  136449. /**
  136450. * @hidden Particle BoundingInfo object (Internal use)
  136451. */
  136452. _boundingInfo: BoundingInfo;
  136453. /**
  136454. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  136455. */
  136456. _pcs: PointsCloudSystem;
  136457. /**
  136458. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  136459. */
  136460. _stillInvisible: boolean;
  136461. /**
  136462. * @hidden Last computed particle rotation matrix
  136463. */
  136464. _rotationMatrix: number[];
  136465. /**
  136466. * Parent particle Id, if any.
  136467. * Default null.
  136468. */
  136469. parentId: Nullable<number>;
  136470. /**
  136471. * @hidden Internal global position in the PCS.
  136472. */
  136473. _globalPosition: Vector3;
  136474. /**
  136475. * Creates a Point Cloud object.
  136476. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  136477. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  136478. * @param group (PointsGroup) is the group the particle belongs to
  136479. * @param groupId (integer) is the group identifier in the PCS.
  136480. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  136481. * @param pcs defines the PCS it is associated to
  136482. */
  136483. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  136484. /**
  136485. * get point size
  136486. */
  136487. get size(): Vector3;
  136488. /**
  136489. * Set point size
  136490. */
  136491. set size(scale: Vector3);
  136492. /**
  136493. * Legacy support, changed quaternion to rotationQuaternion
  136494. */
  136495. get quaternion(): Nullable<Quaternion>;
  136496. /**
  136497. * Legacy support, changed quaternion to rotationQuaternion
  136498. */
  136499. set quaternion(q: Nullable<Quaternion>);
  136500. /**
  136501. * Returns a boolean. True if the particle intersects a mesh, else false
  136502. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  136503. * @param target is the object (point or mesh) what the intersection is computed against
  136504. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  136505. * @returns true if it intersects
  136506. */
  136507. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  136508. /**
  136509. * get the rotation matrix of the particle
  136510. * @hidden
  136511. */
  136512. getRotationMatrix(m: Matrix): void;
  136513. }
  136514. /**
  136515. * Represents a group of points in a points cloud system
  136516. * * PCS internal tool, don't use it manually.
  136517. */
  136518. export class PointsGroup {
  136519. /**
  136520. * The group id
  136521. * @hidden
  136522. */
  136523. groupID: number;
  136524. /**
  136525. * image data for group (internal use)
  136526. * @hidden
  136527. */
  136528. _groupImageData: Nullable<ArrayBufferView>;
  136529. /**
  136530. * Image Width (internal use)
  136531. * @hidden
  136532. */
  136533. _groupImgWidth: number;
  136534. /**
  136535. * Image Height (internal use)
  136536. * @hidden
  136537. */
  136538. _groupImgHeight: number;
  136539. /**
  136540. * Custom position function (internal use)
  136541. * @hidden
  136542. */
  136543. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  136544. /**
  136545. * density per facet for surface points
  136546. * @hidden
  136547. */
  136548. _groupDensity: number[];
  136549. /**
  136550. * Only when points are colored by texture carries pointer to texture list array
  136551. * @hidden
  136552. */
  136553. _textureNb: number;
  136554. /**
  136555. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  136556. * PCS internal tool, don't use it manually.
  136557. * @hidden
  136558. */
  136559. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  136560. }
  136561. }
  136562. declare module BABYLON {
  136563. interface Scene {
  136564. /** @hidden (Backing field) */
  136565. _physicsEngine: Nullable<IPhysicsEngine>;
  136566. /** @hidden */
  136567. _physicsTimeAccumulator: number;
  136568. /**
  136569. * Gets the current physics engine
  136570. * @returns a IPhysicsEngine or null if none attached
  136571. */
  136572. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  136573. /**
  136574. * Enables physics to the current scene
  136575. * @param gravity defines the scene's gravity for the physics engine
  136576. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  136577. * @return a boolean indicating if the physics engine was initialized
  136578. */
  136579. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  136580. /**
  136581. * Disables and disposes the physics engine associated with the scene
  136582. */
  136583. disablePhysicsEngine(): void;
  136584. /**
  136585. * Gets a boolean indicating if there is an active physics engine
  136586. * @returns a boolean indicating if there is an active physics engine
  136587. */
  136588. isPhysicsEnabled(): boolean;
  136589. /**
  136590. * Deletes a physics compound impostor
  136591. * @param compound defines the compound to delete
  136592. */
  136593. deleteCompoundImpostor(compound: any): void;
  136594. /**
  136595. * An event triggered when physic simulation is about to be run
  136596. */
  136597. onBeforePhysicsObservable: Observable<Scene>;
  136598. /**
  136599. * An event triggered when physic simulation has been done
  136600. */
  136601. onAfterPhysicsObservable: Observable<Scene>;
  136602. }
  136603. interface AbstractMesh {
  136604. /** @hidden */
  136605. _physicsImpostor: Nullable<PhysicsImpostor>;
  136606. /**
  136607. * Gets or sets impostor used for physic simulation
  136608. * @see http://doc.babylonjs.com/features/physics_engine
  136609. */
  136610. physicsImpostor: Nullable<PhysicsImpostor>;
  136611. /**
  136612. * Gets the current physics impostor
  136613. * @see http://doc.babylonjs.com/features/physics_engine
  136614. * @returns a physics impostor or null
  136615. */
  136616. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  136617. /** Apply a physic impulse to the mesh
  136618. * @param force defines the force to apply
  136619. * @param contactPoint defines where to apply the force
  136620. * @returns the current mesh
  136621. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136622. */
  136623. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  136624. /**
  136625. * Creates a physic joint between two meshes
  136626. * @param otherMesh defines the other mesh to use
  136627. * @param pivot1 defines the pivot to use on this mesh
  136628. * @param pivot2 defines the pivot to use on the other mesh
  136629. * @param options defines additional options (can be plugin dependent)
  136630. * @returns the current mesh
  136631. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  136632. */
  136633. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  136634. /** @hidden */
  136635. _disposePhysicsObserver: Nullable<Observer<Node>>;
  136636. }
  136637. /**
  136638. * Defines the physics engine scene component responsible to manage a physics engine
  136639. */
  136640. export class PhysicsEngineSceneComponent implements ISceneComponent {
  136641. /**
  136642. * The component name helpful to identify the component in the list of scene components.
  136643. */
  136644. readonly name: string;
  136645. /**
  136646. * The scene the component belongs to.
  136647. */
  136648. scene: Scene;
  136649. /**
  136650. * Creates a new instance of the component for the given scene
  136651. * @param scene Defines the scene to register the component in
  136652. */
  136653. constructor(scene: Scene);
  136654. /**
  136655. * Registers the component in a given scene
  136656. */
  136657. register(): void;
  136658. /**
  136659. * Rebuilds the elements related to this component in case of
  136660. * context lost for instance.
  136661. */
  136662. rebuild(): void;
  136663. /**
  136664. * Disposes the component and the associated ressources
  136665. */
  136666. dispose(): void;
  136667. }
  136668. }
  136669. declare module BABYLON {
  136670. /**
  136671. * A helper for physics simulations
  136672. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136673. */
  136674. export class PhysicsHelper {
  136675. private _scene;
  136676. private _physicsEngine;
  136677. /**
  136678. * Initializes the Physics helper
  136679. * @param scene Babylon.js scene
  136680. */
  136681. constructor(scene: Scene);
  136682. /**
  136683. * Applies a radial explosion impulse
  136684. * @param origin the origin of the explosion
  136685. * @param radiusOrEventOptions the radius or the options of radial explosion
  136686. * @param strength the explosion strength
  136687. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136688. * @returns A physics radial explosion event, or null
  136689. */
  136690. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136691. /**
  136692. * Applies a radial explosion force
  136693. * @param origin the origin of the explosion
  136694. * @param radiusOrEventOptions the radius or the options of radial explosion
  136695. * @param strength the explosion strength
  136696. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136697. * @returns A physics radial explosion event, or null
  136698. */
  136699. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136700. /**
  136701. * Creates a gravitational field
  136702. * @param origin the origin of the explosion
  136703. * @param radiusOrEventOptions the radius or the options of radial explosion
  136704. * @param strength the explosion strength
  136705. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136706. * @returns A physics gravitational field event, or null
  136707. */
  136708. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  136709. /**
  136710. * Creates a physics updraft event
  136711. * @param origin the origin of the updraft
  136712. * @param radiusOrEventOptions the radius or the options of the updraft
  136713. * @param strength the strength of the updraft
  136714. * @param height the height of the updraft
  136715. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  136716. * @returns A physics updraft event, or null
  136717. */
  136718. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  136719. /**
  136720. * Creates a physics vortex event
  136721. * @param origin the of the vortex
  136722. * @param radiusOrEventOptions the radius or the options of the vortex
  136723. * @param strength the strength of the vortex
  136724. * @param height the height of the vortex
  136725. * @returns a Physics vortex event, or null
  136726. * A physics vortex event or null
  136727. */
  136728. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  136729. }
  136730. /**
  136731. * Represents a physics radial explosion event
  136732. */
  136733. class PhysicsRadialExplosionEvent {
  136734. private _scene;
  136735. private _options;
  136736. private _sphere;
  136737. private _dataFetched;
  136738. /**
  136739. * Initializes a radial explosioin event
  136740. * @param _scene BabylonJS scene
  136741. * @param _options The options for the vortex event
  136742. */
  136743. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  136744. /**
  136745. * Returns the data related to the radial explosion event (sphere).
  136746. * @returns The radial explosion event data
  136747. */
  136748. getData(): PhysicsRadialExplosionEventData;
  136749. /**
  136750. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  136751. * @param impostor A physics imposter
  136752. * @param origin the origin of the explosion
  136753. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  136754. */
  136755. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  136756. /**
  136757. * Triggers affecterd impostors callbacks
  136758. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  136759. */
  136760. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  136761. /**
  136762. * Disposes the sphere.
  136763. * @param force Specifies if the sphere should be disposed by force
  136764. */
  136765. dispose(force?: boolean): void;
  136766. /*** Helpers ***/
  136767. private _prepareSphere;
  136768. private _intersectsWithSphere;
  136769. }
  136770. /**
  136771. * Represents a gravitational field event
  136772. */
  136773. class PhysicsGravitationalFieldEvent {
  136774. private _physicsHelper;
  136775. private _scene;
  136776. private _origin;
  136777. private _options;
  136778. private _tickCallback;
  136779. private _sphere;
  136780. private _dataFetched;
  136781. /**
  136782. * Initializes the physics gravitational field event
  136783. * @param _physicsHelper A physics helper
  136784. * @param _scene BabylonJS scene
  136785. * @param _origin The origin position of the gravitational field event
  136786. * @param _options The options for the vortex event
  136787. */
  136788. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  136789. /**
  136790. * Returns the data related to the gravitational field event (sphere).
  136791. * @returns A gravitational field event
  136792. */
  136793. getData(): PhysicsGravitationalFieldEventData;
  136794. /**
  136795. * Enables the gravitational field.
  136796. */
  136797. enable(): void;
  136798. /**
  136799. * Disables the gravitational field.
  136800. */
  136801. disable(): void;
  136802. /**
  136803. * Disposes the sphere.
  136804. * @param force The force to dispose from the gravitational field event
  136805. */
  136806. dispose(force?: boolean): void;
  136807. private _tick;
  136808. }
  136809. /**
  136810. * Represents a physics updraft event
  136811. */
  136812. class PhysicsUpdraftEvent {
  136813. private _scene;
  136814. private _origin;
  136815. private _options;
  136816. private _physicsEngine;
  136817. private _originTop;
  136818. private _originDirection;
  136819. private _tickCallback;
  136820. private _cylinder;
  136821. private _cylinderPosition;
  136822. private _dataFetched;
  136823. /**
  136824. * Initializes the physics updraft event
  136825. * @param _scene BabylonJS scene
  136826. * @param _origin The origin position of the updraft
  136827. * @param _options The options for the updraft event
  136828. */
  136829. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  136830. /**
  136831. * Returns the data related to the updraft event (cylinder).
  136832. * @returns A physics updraft event
  136833. */
  136834. getData(): PhysicsUpdraftEventData;
  136835. /**
  136836. * Enables the updraft.
  136837. */
  136838. enable(): void;
  136839. /**
  136840. * Disables the updraft.
  136841. */
  136842. disable(): void;
  136843. /**
  136844. * Disposes the cylinder.
  136845. * @param force Specifies if the updraft should be disposed by force
  136846. */
  136847. dispose(force?: boolean): void;
  136848. private getImpostorHitData;
  136849. private _tick;
  136850. /*** Helpers ***/
  136851. private _prepareCylinder;
  136852. private _intersectsWithCylinder;
  136853. }
  136854. /**
  136855. * Represents a physics vortex event
  136856. */
  136857. class PhysicsVortexEvent {
  136858. private _scene;
  136859. private _origin;
  136860. private _options;
  136861. private _physicsEngine;
  136862. private _originTop;
  136863. private _tickCallback;
  136864. private _cylinder;
  136865. private _cylinderPosition;
  136866. private _dataFetched;
  136867. /**
  136868. * Initializes the physics vortex event
  136869. * @param _scene The BabylonJS scene
  136870. * @param _origin The origin position of the vortex
  136871. * @param _options The options for the vortex event
  136872. */
  136873. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  136874. /**
  136875. * Returns the data related to the vortex event (cylinder).
  136876. * @returns The physics vortex event data
  136877. */
  136878. getData(): PhysicsVortexEventData;
  136879. /**
  136880. * Enables the vortex.
  136881. */
  136882. enable(): void;
  136883. /**
  136884. * Disables the cortex.
  136885. */
  136886. disable(): void;
  136887. /**
  136888. * Disposes the sphere.
  136889. * @param force
  136890. */
  136891. dispose(force?: boolean): void;
  136892. private getImpostorHitData;
  136893. private _tick;
  136894. /*** Helpers ***/
  136895. private _prepareCylinder;
  136896. private _intersectsWithCylinder;
  136897. }
  136898. /**
  136899. * Options fot the radial explosion event
  136900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136901. */
  136902. export class PhysicsRadialExplosionEventOptions {
  136903. /**
  136904. * The radius of the sphere for the radial explosion.
  136905. */
  136906. radius: number;
  136907. /**
  136908. * The strenth of the explosion.
  136909. */
  136910. strength: number;
  136911. /**
  136912. * The strenght of the force in correspondence to the distance of the affected object
  136913. */
  136914. falloff: PhysicsRadialImpulseFalloff;
  136915. /**
  136916. * Sphere options for the radial explosion.
  136917. */
  136918. sphere: {
  136919. segments: number;
  136920. diameter: number;
  136921. };
  136922. /**
  136923. * Sphere options for the radial explosion.
  136924. */
  136925. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  136926. }
  136927. /**
  136928. * Options fot the updraft event
  136929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136930. */
  136931. export class PhysicsUpdraftEventOptions {
  136932. /**
  136933. * The radius of the cylinder for the vortex
  136934. */
  136935. radius: number;
  136936. /**
  136937. * The strenth of the updraft.
  136938. */
  136939. strength: number;
  136940. /**
  136941. * The height of the cylinder for the updraft.
  136942. */
  136943. height: number;
  136944. /**
  136945. * The mode for the the updraft.
  136946. */
  136947. updraftMode: PhysicsUpdraftMode;
  136948. }
  136949. /**
  136950. * Options fot the vortex event
  136951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136952. */
  136953. export class PhysicsVortexEventOptions {
  136954. /**
  136955. * The radius of the cylinder for the vortex
  136956. */
  136957. radius: number;
  136958. /**
  136959. * The strenth of the vortex.
  136960. */
  136961. strength: number;
  136962. /**
  136963. * The height of the cylinder for the vortex.
  136964. */
  136965. height: number;
  136966. /**
  136967. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  136968. */
  136969. centripetalForceThreshold: number;
  136970. /**
  136971. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  136972. */
  136973. centripetalForceMultiplier: number;
  136974. /**
  136975. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  136976. */
  136977. centrifugalForceMultiplier: number;
  136978. /**
  136979. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  136980. */
  136981. updraftForceMultiplier: number;
  136982. }
  136983. /**
  136984. * The strenght of the force in correspondence to the distance of the affected object
  136985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136986. */
  136987. export enum PhysicsRadialImpulseFalloff {
  136988. /** Defines that impulse is constant in strength across it's whole radius */
  136989. Constant = 0,
  136990. /** Defines that impulse gets weaker if it's further from the origin */
  136991. Linear = 1
  136992. }
  136993. /**
  136994. * The strength of the force in correspondence to the distance of the affected object
  136995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136996. */
  136997. export enum PhysicsUpdraftMode {
  136998. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  136999. Center = 0,
  137000. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  137001. Perpendicular = 1
  137002. }
  137003. /**
  137004. * Interface for a physics hit data
  137005. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137006. */
  137007. export interface PhysicsHitData {
  137008. /**
  137009. * The force applied at the contact point
  137010. */
  137011. force: Vector3;
  137012. /**
  137013. * The contact point
  137014. */
  137015. contactPoint: Vector3;
  137016. /**
  137017. * The distance from the origin to the contact point
  137018. */
  137019. distanceFromOrigin: number;
  137020. }
  137021. /**
  137022. * Interface for radial explosion event data
  137023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137024. */
  137025. export interface PhysicsRadialExplosionEventData {
  137026. /**
  137027. * A sphere used for the radial explosion event
  137028. */
  137029. sphere: Mesh;
  137030. }
  137031. /**
  137032. * Interface for gravitational field event data
  137033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137034. */
  137035. export interface PhysicsGravitationalFieldEventData {
  137036. /**
  137037. * A sphere mesh used for the gravitational field event
  137038. */
  137039. sphere: Mesh;
  137040. }
  137041. /**
  137042. * Interface for updraft event data
  137043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137044. */
  137045. export interface PhysicsUpdraftEventData {
  137046. /**
  137047. * A cylinder used for the updraft event
  137048. */
  137049. cylinder: Mesh;
  137050. }
  137051. /**
  137052. * Interface for vortex event data
  137053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137054. */
  137055. export interface PhysicsVortexEventData {
  137056. /**
  137057. * A cylinder used for the vortex event
  137058. */
  137059. cylinder: Mesh;
  137060. }
  137061. /**
  137062. * Interface for an affected physics impostor
  137063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137064. */
  137065. export interface PhysicsAffectedImpostorWithData {
  137066. /**
  137067. * The impostor affected by the effect
  137068. */
  137069. impostor: PhysicsImpostor;
  137070. /**
  137071. * The data about the hit/horce from the explosion
  137072. */
  137073. hitData: PhysicsHitData;
  137074. }
  137075. }
  137076. declare module BABYLON {
  137077. /** @hidden */
  137078. export var blackAndWhitePixelShader: {
  137079. name: string;
  137080. shader: string;
  137081. };
  137082. }
  137083. declare module BABYLON {
  137084. /**
  137085. * Post process used to render in black and white
  137086. */
  137087. export class BlackAndWhitePostProcess extends PostProcess {
  137088. /**
  137089. * Linear about to convert he result to black and white (default: 1)
  137090. */
  137091. degree: number;
  137092. /**
  137093. * Creates a black and white post process
  137094. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  137095. * @param name The name of the effect.
  137096. * @param options The required width/height ratio to downsize to before computing the render pass.
  137097. * @param camera The camera to apply the render pass to.
  137098. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137099. * @param engine The engine which the post process will be applied. (default: current engine)
  137100. * @param reusable If the post process can be reused on the same frame. (default: false)
  137101. */
  137102. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137103. }
  137104. }
  137105. declare module BABYLON {
  137106. /**
  137107. * This represents a set of one or more post processes in Babylon.
  137108. * A post process can be used to apply a shader to a texture after it is rendered.
  137109. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137110. */
  137111. export class PostProcessRenderEffect {
  137112. private _postProcesses;
  137113. private _getPostProcesses;
  137114. private _singleInstance;
  137115. private _cameras;
  137116. private _indicesForCamera;
  137117. /**
  137118. * Name of the effect
  137119. * @hidden
  137120. */
  137121. _name: string;
  137122. /**
  137123. * Instantiates a post process render effect.
  137124. * A post process can be used to apply a shader to a texture after it is rendered.
  137125. * @param engine The engine the effect is tied to
  137126. * @param name The name of the effect
  137127. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  137128. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  137129. */
  137130. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  137131. /**
  137132. * Checks if all the post processes in the effect are supported.
  137133. */
  137134. get isSupported(): boolean;
  137135. /**
  137136. * Updates the current state of the effect
  137137. * @hidden
  137138. */
  137139. _update(): void;
  137140. /**
  137141. * Attaches the effect on cameras
  137142. * @param cameras The camera to attach to.
  137143. * @hidden
  137144. */
  137145. _attachCameras(cameras: Camera): void;
  137146. /**
  137147. * Attaches the effect on cameras
  137148. * @param cameras The camera to attach to.
  137149. * @hidden
  137150. */
  137151. _attachCameras(cameras: Camera[]): void;
  137152. /**
  137153. * Detaches the effect on cameras
  137154. * @param cameras The camera to detatch from.
  137155. * @hidden
  137156. */
  137157. _detachCameras(cameras: Camera): void;
  137158. /**
  137159. * Detatches the effect on cameras
  137160. * @param cameras The camera to detatch from.
  137161. * @hidden
  137162. */
  137163. _detachCameras(cameras: Camera[]): void;
  137164. /**
  137165. * Enables the effect on given cameras
  137166. * @param cameras The camera to enable.
  137167. * @hidden
  137168. */
  137169. _enable(cameras: Camera): void;
  137170. /**
  137171. * Enables the effect on given cameras
  137172. * @param cameras The camera to enable.
  137173. * @hidden
  137174. */
  137175. _enable(cameras: Nullable<Camera[]>): void;
  137176. /**
  137177. * Disables the effect on the given cameras
  137178. * @param cameras The camera to disable.
  137179. * @hidden
  137180. */
  137181. _disable(cameras: Camera): void;
  137182. /**
  137183. * Disables the effect on the given cameras
  137184. * @param cameras The camera to disable.
  137185. * @hidden
  137186. */
  137187. _disable(cameras: Nullable<Camera[]>): void;
  137188. /**
  137189. * Gets a list of the post processes contained in the effect.
  137190. * @param camera The camera to get the post processes on.
  137191. * @returns The list of the post processes in the effect.
  137192. */
  137193. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  137194. }
  137195. }
  137196. declare module BABYLON {
  137197. /** @hidden */
  137198. export var extractHighlightsPixelShader: {
  137199. name: string;
  137200. shader: string;
  137201. };
  137202. }
  137203. declare module BABYLON {
  137204. /**
  137205. * 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.
  137206. */
  137207. export class ExtractHighlightsPostProcess extends PostProcess {
  137208. /**
  137209. * The luminance threshold, pixels below this value will be set to black.
  137210. */
  137211. threshold: number;
  137212. /** @hidden */
  137213. _exposure: number;
  137214. /**
  137215. * Post process which has the input texture to be used when performing highlight extraction
  137216. * @hidden
  137217. */
  137218. _inputPostProcess: Nullable<PostProcess>;
  137219. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137220. }
  137221. }
  137222. declare module BABYLON {
  137223. /** @hidden */
  137224. export var bloomMergePixelShader: {
  137225. name: string;
  137226. shader: string;
  137227. };
  137228. }
  137229. declare module BABYLON {
  137230. /**
  137231. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137232. */
  137233. export class BloomMergePostProcess extends PostProcess {
  137234. /** Weight of the bloom to be added to the original input. */
  137235. weight: number;
  137236. /**
  137237. * Creates a new instance of @see BloomMergePostProcess
  137238. * @param name The name of the effect.
  137239. * @param originalFromInput Post process which's input will be used for the merge.
  137240. * @param blurred Blurred highlights post process which's output will be used.
  137241. * @param weight Weight of the bloom to be added to the original input.
  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. * @param textureType Type of textures used when performing the post process. (default: 0)
  137248. * @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)
  137249. */
  137250. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  137251. /** Weight of the bloom to be added to the original input. */
  137252. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137253. }
  137254. }
  137255. declare module BABYLON {
  137256. /**
  137257. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  137258. */
  137259. export class BloomEffect extends PostProcessRenderEffect {
  137260. private bloomScale;
  137261. /**
  137262. * @hidden Internal
  137263. */
  137264. _effects: Array<PostProcess>;
  137265. /**
  137266. * @hidden Internal
  137267. */
  137268. _downscale: ExtractHighlightsPostProcess;
  137269. private _blurX;
  137270. private _blurY;
  137271. private _merge;
  137272. /**
  137273. * The luminance threshold to find bright areas of the image to bloom.
  137274. */
  137275. get threshold(): number;
  137276. set threshold(value: number);
  137277. /**
  137278. * The strength of the bloom.
  137279. */
  137280. get weight(): number;
  137281. set weight(value: number);
  137282. /**
  137283. * Specifies the size of the bloom blur kernel, relative to the final output size
  137284. */
  137285. get kernel(): number;
  137286. set kernel(value: number);
  137287. /**
  137288. * Creates a new instance of @see BloomEffect
  137289. * @param scene The scene the effect belongs to.
  137290. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  137291. * @param bloomKernel The size of the kernel to be used when applying the blur.
  137292. * @param bloomWeight The the strength of bloom.
  137293. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137294. * @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)
  137295. */
  137296. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  137297. /**
  137298. * Disposes each of the internal effects for a given camera.
  137299. * @param camera The camera to dispose the effect on.
  137300. */
  137301. disposeEffects(camera: Camera): void;
  137302. /**
  137303. * @hidden Internal
  137304. */
  137305. _updateEffects(): void;
  137306. /**
  137307. * Internal
  137308. * @returns if all the contained post processes are ready.
  137309. * @hidden
  137310. */
  137311. _isReady(): boolean;
  137312. }
  137313. }
  137314. declare module BABYLON {
  137315. /** @hidden */
  137316. export var chromaticAberrationPixelShader: {
  137317. name: string;
  137318. shader: string;
  137319. };
  137320. }
  137321. declare module BABYLON {
  137322. /**
  137323. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  137324. */
  137325. export class ChromaticAberrationPostProcess extends PostProcess {
  137326. /**
  137327. * The amount of seperation of rgb channels (default: 30)
  137328. */
  137329. aberrationAmount: number;
  137330. /**
  137331. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  137332. */
  137333. radialIntensity: number;
  137334. /**
  137335. * 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))
  137336. */
  137337. direction: Vector2;
  137338. /**
  137339. * 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))
  137340. */
  137341. centerPosition: Vector2;
  137342. /**
  137343. * Creates a new instance ChromaticAberrationPostProcess
  137344. * @param name The name of the effect.
  137345. * @param screenWidth The width of the screen to apply the effect on.
  137346. * @param screenHeight The height of the screen to apply the effect on.
  137347. * @param options The required width/height ratio to downsize to before computing the render pass.
  137348. * @param camera The camera to apply the render pass to.
  137349. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137350. * @param engine The engine which the post process will be applied. (default: current engine)
  137351. * @param reusable If the post process can be reused on the same frame. (default: false)
  137352. * @param textureType Type of textures used when performing the post process. (default: 0)
  137353. * @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)
  137354. */
  137355. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137356. }
  137357. }
  137358. declare module BABYLON {
  137359. /** @hidden */
  137360. export var circleOfConfusionPixelShader: {
  137361. name: string;
  137362. shader: string;
  137363. };
  137364. }
  137365. declare module BABYLON {
  137366. /**
  137367. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  137368. */
  137369. export class CircleOfConfusionPostProcess extends PostProcess {
  137370. /**
  137371. * 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.
  137372. */
  137373. lensSize: number;
  137374. /**
  137375. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137376. */
  137377. fStop: number;
  137378. /**
  137379. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137380. */
  137381. focusDistance: number;
  137382. /**
  137383. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  137384. */
  137385. focalLength: number;
  137386. private _depthTexture;
  137387. /**
  137388. * Creates a new instance CircleOfConfusionPostProcess
  137389. * @param name The name of the effect.
  137390. * @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.
  137391. * @param options The required width/height ratio to downsize to before computing the render pass.
  137392. * @param camera The camera to apply the render pass to.
  137393. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137394. * @param engine The engine which the post process will be applied. (default: current engine)
  137395. * @param reusable If the post process can be reused on the same frame. (default: false)
  137396. * @param textureType Type of textures used when performing the post process. (default: 0)
  137397. * @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)
  137398. */
  137399. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137400. /**
  137401. * 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.
  137402. */
  137403. set depthTexture(value: RenderTargetTexture);
  137404. }
  137405. }
  137406. declare module BABYLON {
  137407. /** @hidden */
  137408. export var colorCorrectionPixelShader: {
  137409. name: string;
  137410. shader: string;
  137411. };
  137412. }
  137413. declare module BABYLON {
  137414. /**
  137415. *
  137416. * This post-process allows the modification of rendered colors by using
  137417. * a 'look-up table' (LUT). This effect is also called Color Grading.
  137418. *
  137419. * The object needs to be provided an url to a texture containing the color
  137420. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  137421. * Use an image editing software to tweak the LUT to match your needs.
  137422. *
  137423. * For an example of a color LUT, see here:
  137424. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  137425. * For explanations on color grading, see here:
  137426. * @see http://udn.epicgames.com/Three/ColorGrading.html
  137427. *
  137428. */
  137429. export class ColorCorrectionPostProcess extends PostProcess {
  137430. private _colorTableTexture;
  137431. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137432. }
  137433. }
  137434. declare module BABYLON {
  137435. /** @hidden */
  137436. export var convolutionPixelShader: {
  137437. name: string;
  137438. shader: string;
  137439. };
  137440. }
  137441. declare module BABYLON {
  137442. /**
  137443. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  137444. * input texture to perform effects such as edge detection or sharpening
  137445. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137446. */
  137447. export class ConvolutionPostProcess extends PostProcess {
  137448. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137449. kernel: number[];
  137450. /**
  137451. * Creates a new instance ConvolutionPostProcess
  137452. * @param name The name of the effect.
  137453. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  137454. * @param options The required width/height ratio to downsize to before computing the render pass.
  137455. * @param camera The camera to apply the render pass to.
  137456. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137457. * @param engine The engine which the post process will be applied. (default: current engine)
  137458. * @param reusable If the post process can be reused on the same frame. (default: false)
  137459. * @param textureType Type of textures used when performing the post process. (default: 0)
  137460. */
  137461. constructor(name: string,
  137462. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137463. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137464. /**
  137465. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137466. */
  137467. static EdgeDetect0Kernel: number[];
  137468. /**
  137469. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137470. */
  137471. static EdgeDetect1Kernel: number[];
  137472. /**
  137473. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137474. */
  137475. static EdgeDetect2Kernel: number[];
  137476. /**
  137477. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137478. */
  137479. static SharpenKernel: number[];
  137480. /**
  137481. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137482. */
  137483. static EmbossKernel: number[];
  137484. /**
  137485. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137486. */
  137487. static GaussianKernel: number[];
  137488. }
  137489. }
  137490. declare module BABYLON {
  137491. /**
  137492. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  137493. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  137494. * based on samples that have a large difference in distance than the center pixel.
  137495. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  137496. */
  137497. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  137498. direction: Vector2;
  137499. /**
  137500. * Creates a new instance CircleOfConfusionPostProcess
  137501. * @param name The name of the effect.
  137502. * @param scene The scene the effect belongs to.
  137503. * @param direction The direction the blur should be applied.
  137504. * @param kernel The size of the kernel used to blur.
  137505. * @param options The required width/height ratio to downsize to before computing the render pass.
  137506. * @param camera The camera to apply the render pass to.
  137507. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  137508. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  137509. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137510. * @param engine The engine which the post process will be applied. (default: current engine)
  137511. * @param reusable If the post process can be reused on the same frame. (default: false)
  137512. * @param textureType Type of textures used when performing the post process. (default: 0)
  137513. * @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)
  137514. */
  137515. 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);
  137516. }
  137517. }
  137518. declare module BABYLON {
  137519. /** @hidden */
  137520. export var depthOfFieldMergePixelShader: {
  137521. name: string;
  137522. shader: string;
  137523. };
  137524. }
  137525. declare module BABYLON {
  137526. /**
  137527. * Options to be set when merging outputs from the default pipeline.
  137528. */
  137529. export class DepthOfFieldMergePostProcessOptions {
  137530. /**
  137531. * The original image to merge on top of
  137532. */
  137533. originalFromInput: PostProcess;
  137534. /**
  137535. * Parameters to perform the merge of the depth of field effect
  137536. */
  137537. depthOfField?: {
  137538. circleOfConfusion: PostProcess;
  137539. blurSteps: Array<PostProcess>;
  137540. };
  137541. /**
  137542. * Parameters to perform the merge of bloom effect
  137543. */
  137544. bloom?: {
  137545. blurred: PostProcess;
  137546. weight: number;
  137547. };
  137548. }
  137549. /**
  137550. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137551. */
  137552. export class DepthOfFieldMergePostProcess extends PostProcess {
  137553. private blurSteps;
  137554. /**
  137555. * Creates a new instance of DepthOfFieldMergePostProcess
  137556. * @param name The name of the effect.
  137557. * @param originalFromInput Post process which's input will be used for the merge.
  137558. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  137559. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  137560. * @param options The required width/height ratio to downsize to before computing the render pass.
  137561. * @param camera The camera to apply the render pass to.
  137562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137563. * @param engine The engine which the post process will be applied. (default: current engine)
  137564. * @param reusable If the post process can be reused on the same frame. (default: false)
  137565. * @param textureType Type of textures used when performing the post process. (default: 0)
  137566. * @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)
  137567. */
  137568. 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);
  137569. /**
  137570. * Updates the effect with the current post process compile time values and recompiles the shader.
  137571. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  137572. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  137573. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  137574. * @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
  137575. * @param onCompiled Called when the shader has been compiled.
  137576. * @param onError Called if there is an error when compiling a shader.
  137577. */
  137578. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  137579. }
  137580. }
  137581. declare module BABYLON {
  137582. /**
  137583. * Specifies the level of max blur that should be applied when using the depth of field effect
  137584. */
  137585. export enum DepthOfFieldEffectBlurLevel {
  137586. /**
  137587. * Subtle blur
  137588. */
  137589. Low = 0,
  137590. /**
  137591. * Medium blur
  137592. */
  137593. Medium = 1,
  137594. /**
  137595. * Large blur
  137596. */
  137597. High = 2
  137598. }
  137599. /**
  137600. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  137601. */
  137602. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  137603. private _circleOfConfusion;
  137604. /**
  137605. * @hidden Internal, blurs from high to low
  137606. */
  137607. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  137608. private _depthOfFieldBlurY;
  137609. private _dofMerge;
  137610. /**
  137611. * @hidden Internal post processes in depth of field effect
  137612. */
  137613. _effects: Array<PostProcess>;
  137614. /**
  137615. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  137616. */
  137617. set focalLength(value: number);
  137618. get focalLength(): number;
  137619. /**
  137620. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137621. */
  137622. set fStop(value: number);
  137623. get fStop(): number;
  137624. /**
  137625. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137626. */
  137627. set focusDistance(value: number);
  137628. get focusDistance(): number;
  137629. /**
  137630. * 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.
  137631. */
  137632. set lensSize(value: number);
  137633. get lensSize(): number;
  137634. /**
  137635. * Creates a new instance DepthOfFieldEffect
  137636. * @param scene The scene the effect belongs to.
  137637. * @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.
  137638. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137639. * @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)
  137640. */
  137641. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  137642. /**
  137643. * Get the current class name of the current effet
  137644. * @returns "DepthOfFieldEffect"
  137645. */
  137646. getClassName(): string;
  137647. /**
  137648. * 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.
  137649. */
  137650. set depthTexture(value: RenderTargetTexture);
  137651. /**
  137652. * Disposes each of the internal effects for a given camera.
  137653. * @param camera The camera to dispose the effect on.
  137654. */
  137655. disposeEffects(camera: Camera): void;
  137656. /**
  137657. * @hidden Internal
  137658. */
  137659. _updateEffects(): void;
  137660. /**
  137661. * Internal
  137662. * @returns if all the contained post processes are ready.
  137663. * @hidden
  137664. */
  137665. _isReady(): boolean;
  137666. }
  137667. }
  137668. declare module BABYLON {
  137669. /** @hidden */
  137670. export var displayPassPixelShader: {
  137671. name: string;
  137672. shader: string;
  137673. };
  137674. }
  137675. declare module BABYLON {
  137676. /**
  137677. * DisplayPassPostProcess which produces an output the same as it's input
  137678. */
  137679. export class DisplayPassPostProcess extends PostProcess {
  137680. /**
  137681. * Creates the DisplayPassPostProcess
  137682. * @param name The name of the effect.
  137683. * @param options The required width/height ratio to downsize to before computing the render pass.
  137684. * @param camera The camera to apply the render pass to.
  137685. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137686. * @param engine The engine which the post process will be applied. (default: current engine)
  137687. * @param reusable If the post process can be reused on the same frame. (default: false)
  137688. */
  137689. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137690. }
  137691. }
  137692. declare module BABYLON {
  137693. /** @hidden */
  137694. export var filterPixelShader: {
  137695. name: string;
  137696. shader: string;
  137697. };
  137698. }
  137699. declare module BABYLON {
  137700. /**
  137701. * Applies a kernel filter to the image
  137702. */
  137703. export class FilterPostProcess extends PostProcess {
  137704. /** The matrix to be applied to the image */
  137705. kernelMatrix: Matrix;
  137706. /**
  137707. *
  137708. * @param name The name of the effect.
  137709. * @param kernelMatrix The matrix to be applied to the image
  137710. * @param options The required width/height ratio to downsize to before computing the render pass.
  137711. * @param camera The camera to apply the render pass to.
  137712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137713. * @param engine The engine which the post process will be applied. (default: current engine)
  137714. * @param reusable If the post process can be reused on the same frame. (default: false)
  137715. */
  137716. constructor(name: string,
  137717. /** The matrix to be applied to the image */
  137718. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137719. }
  137720. }
  137721. declare module BABYLON {
  137722. /** @hidden */
  137723. export var fxaaPixelShader: {
  137724. name: string;
  137725. shader: string;
  137726. };
  137727. }
  137728. declare module BABYLON {
  137729. /** @hidden */
  137730. export var fxaaVertexShader: {
  137731. name: string;
  137732. shader: string;
  137733. };
  137734. }
  137735. declare module BABYLON {
  137736. /**
  137737. * Fxaa post process
  137738. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  137739. */
  137740. export class FxaaPostProcess extends PostProcess {
  137741. /** @hidden */
  137742. texelWidth: number;
  137743. /** @hidden */
  137744. texelHeight: number;
  137745. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137746. private _getDefines;
  137747. }
  137748. }
  137749. declare module BABYLON {
  137750. /** @hidden */
  137751. export var grainPixelShader: {
  137752. name: string;
  137753. shader: string;
  137754. };
  137755. }
  137756. declare module BABYLON {
  137757. /**
  137758. * The GrainPostProcess adds noise to the image at mid luminance levels
  137759. */
  137760. export class GrainPostProcess extends PostProcess {
  137761. /**
  137762. * The intensity of the grain added (default: 30)
  137763. */
  137764. intensity: number;
  137765. /**
  137766. * If the grain should be randomized on every frame
  137767. */
  137768. animated: boolean;
  137769. /**
  137770. * Creates a new instance of @see GrainPostProcess
  137771. * @param name The name of the effect.
  137772. * @param options The required width/height ratio to downsize to before computing the render pass.
  137773. * @param camera The camera to apply the render pass to.
  137774. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137775. * @param engine The engine which the post process will be applied. (default: current engine)
  137776. * @param reusable If the post process can be reused on the same frame. (default: false)
  137777. * @param textureType Type of textures used when performing the post process. (default: 0)
  137778. * @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)
  137779. */
  137780. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137781. }
  137782. }
  137783. declare module BABYLON {
  137784. /** @hidden */
  137785. export var highlightsPixelShader: {
  137786. name: string;
  137787. shader: string;
  137788. };
  137789. }
  137790. declare module BABYLON {
  137791. /**
  137792. * Extracts highlights from the image
  137793. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137794. */
  137795. export class HighlightsPostProcess extends PostProcess {
  137796. /**
  137797. * Extracts highlights from the image
  137798. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137799. * @param name The name of the effect.
  137800. * @param options The required width/height ratio to downsize to before computing the render pass.
  137801. * @param camera The camera to apply the render pass to.
  137802. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137803. * @param engine The engine which the post process will be applied. (default: current engine)
  137804. * @param reusable If the post process can be reused on the same frame. (default: false)
  137805. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  137806. */
  137807. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137808. }
  137809. }
  137810. declare module BABYLON {
  137811. /** @hidden */
  137812. export var mrtFragmentDeclaration: {
  137813. name: string;
  137814. shader: string;
  137815. };
  137816. }
  137817. declare module BABYLON {
  137818. /** @hidden */
  137819. export var geometryPixelShader: {
  137820. name: string;
  137821. shader: string;
  137822. };
  137823. }
  137824. declare module BABYLON {
  137825. /** @hidden */
  137826. export var geometryVertexShader: {
  137827. name: string;
  137828. shader: string;
  137829. };
  137830. }
  137831. declare module BABYLON {
  137832. /** @hidden */
  137833. interface ISavedTransformationMatrix {
  137834. world: Matrix;
  137835. viewProjection: Matrix;
  137836. }
  137837. /**
  137838. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  137839. */
  137840. export class GeometryBufferRenderer {
  137841. /**
  137842. * Constant used to retrieve the position texture index in the G-Buffer textures array
  137843. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  137844. */
  137845. static readonly POSITION_TEXTURE_TYPE: number;
  137846. /**
  137847. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  137848. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  137849. */
  137850. static readonly VELOCITY_TEXTURE_TYPE: number;
  137851. /**
  137852. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  137853. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  137854. */
  137855. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  137856. /**
  137857. * Dictionary used to store the previous transformation matrices of each rendered mesh
  137858. * in order to compute objects velocities when enableVelocity is set to "true"
  137859. * @hidden
  137860. */
  137861. _previousTransformationMatrices: {
  137862. [index: number]: ISavedTransformationMatrix;
  137863. };
  137864. /**
  137865. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  137866. * in order to compute objects velocities when enableVelocity is set to "true"
  137867. * @hidden
  137868. */
  137869. _previousBonesTransformationMatrices: {
  137870. [index: number]: Float32Array;
  137871. };
  137872. /**
  137873. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  137874. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  137875. */
  137876. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  137877. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  137878. renderTransparentMeshes: boolean;
  137879. private _scene;
  137880. private _multiRenderTarget;
  137881. private _ratio;
  137882. private _enablePosition;
  137883. private _enableVelocity;
  137884. private _enableReflectivity;
  137885. private _positionIndex;
  137886. private _velocityIndex;
  137887. private _reflectivityIndex;
  137888. protected _effect: Effect;
  137889. protected _cachedDefines: string;
  137890. /**
  137891. * Set the render list (meshes to be rendered) used in the G buffer.
  137892. */
  137893. set renderList(meshes: Mesh[]);
  137894. /**
  137895. * Gets wether or not G buffer are supported by the running hardware.
  137896. * This requires draw buffer supports
  137897. */
  137898. get isSupported(): boolean;
  137899. /**
  137900. * Returns the index of the given texture type in the G-Buffer textures array
  137901. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  137902. * @returns the index of the given texture type in the G-Buffer textures array
  137903. */
  137904. getTextureIndex(textureType: number): number;
  137905. /**
  137906. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  137907. */
  137908. get enablePosition(): boolean;
  137909. /**
  137910. * Sets whether or not objects positions are enabled for the G buffer.
  137911. */
  137912. set enablePosition(enable: boolean);
  137913. /**
  137914. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  137915. */
  137916. get enableVelocity(): boolean;
  137917. /**
  137918. * Sets wether or not objects velocities are enabled for the G buffer.
  137919. */
  137920. set enableVelocity(enable: boolean);
  137921. /**
  137922. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  137923. */
  137924. get enableReflectivity(): boolean;
  137925. /**
  137926. * Sets wether or not objects roughness are enabled for the G buffer.
  137927. */
  137928. set enableReflectivity(enable: boolean);
  137929. /**
  137930. * Gets the scene associated with the buffer.
  137931. */
  137932. get scene(): Scene;
  137933. /**
  137934. * Gets the ratio used by the buffer during its creation.
  137935. * How big is the buffer related to the main canvas.
  137936. */
  137937. get ratio(): number;
  137938. /** @hidden */
  137939. static _SceneComponentInitialization: (scene: Scene) => void;
  137940. /**
  137941. * Creates a new G Buffer for the scene
  137942. * @param scene The scene the buffer belongs to
  137943. * @param ratio How big is the buffer related to the main canvas.
  137944. */
  137945. constructor(scene: Scene, ratio?: number);
  137946. /**
  137947. * Checks wether everything is ready to render a submesh to the G buffer.
  137948. * @param subMesh the submesh to check readiness for
  137949. * @param useInstances is the mesh drawn using instance or not
  137950. * @returns true if ready otherwise false
  137951. */
  137952. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137953. /**
  137954. * Gets the current underlying G Buffer.
  137955. * @returns the buffer
  137956. */
  137957. getGBuffer(): MultiRenderTarget;
  137958. /**
  137959. * Gets the number of samples used to render the buffer (anti aliasing).
  137960. */
  137961. get samples(): number;
  137962. /**
  137963. * Sets the number of samples used to render the buffer (anti aliasing).
  137964. */
  137965. set samples(value: number);
  137966. /**
  137967. * Disposes the renderer and frees up associated resources.
  137968. */
  137969. dispose(): void;
  137970. protected _createRenderTargets(): void;
  137971. private _copyBonesTransformationMatrices;
  137972. }
  137973. }
  137974. declare module BABYLON {
  137975. interface Scene {
  137976. /** @hidden (Backing field) */
  137977. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137978. /**
  137979. * Gets or Sets the current geometry buffer associated to the scene.
  137980. */
  137981. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137982. /**
  137983. * Enables a GeometryBufferRender and associates it with the scene
  137984. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  137985. * @returns the GeometryBufferRenderer
  137986. */
  137987. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  137988. /**
  137989. * Disables the GeometryBufferRender associated with the scene
  137990. */
  137991. disableGeometryBufferRenderer(): void;
  137992. }
  137993. /**
  137994. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  137995. * in several rendering techniques.
  137996. */
  137997. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  137998. /**
  137999. * The component name helpful to identify the component in the list of scene components.
  138000. */
  138001. readonly name: string;
  138002. /**
  138003. * The scene the component belongs to.
  138004. */
  138005. scene: Scene;
  138006. /**
  138007. * Creates a new instance of the component for the given scene
  138008. * @param scene Defines the scene to register the component in
  138009. */
  138010. constructor(scene: Scene);
  138011. /**
  138012. * Registers the component in a given scene
  138013. */
  138014. register(): void;
  138015. /**
  138016. * Rebuilds the elements related to this component in case of
  138017. * context lost for instance.
  138018. */
  138019. rebuild(): void;
  138020. /**
  138021. * Disposes the component and the associated ressources
  138022. */
  138023. dispose(): void;
  138024. private _gatherRenderTargets;
  138025. }
  138026. }
  138027. declare module BABYLON {
  138028. /** @hidden */
  138029. export var motionBlurPixelShader: {
  138030. name: string;
  138031. shader: string;
  138032. };
  138033. }
  138034. declare module BABYLON {
  138035. /**
  138036. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  138037. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  138038. * As an example, all you have to do is to create the post-process:
  138039. * var mb = new BABYLON.MotionBlurPostProcess(
  138040. * 'mb', // The name of the effect.
  138041. * scene, // The scene containing the objects to blur according to their velocity.
  138042. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  138043. * camera // The camera to apply the render pass to.
  138044. * );
  138045. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  138046. */
  138047. export class MotionBlurPostProcess extends PostProcess {
  138048. /**
  138049. * Defines how much the image is blurred by the movement. Default value is equal to 1
  138050. */
  138051. motionStrength: number;
  138052. /**
  138053. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  138054. */
  138055. get motionBlurSamples(): number;
  138056. /**
  138057. * Sets the number of iterations to be used for motion blur quality
  138058. */
  138059. set motionBlurSamples(samples: number);
  138060. private _motionBlurSamples;
  138061. private _geometryBufferRenderer;
  138062. /**
  138063. * Creates a new instance MotionBlurPostProcess
  138064. * @param name The name of the effect.
  138065. * @param scene The scene containing the objects to blur according to their velocity.
  138066. * @param options The required width/height ratio to downsize to before computing the render pass.
  138067. * @param camera The camera to apply the render pass to.
  138068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138069. * @param engine The engine which the post process will be applied. (default: current engine)
  138070. * @param reusable If the post process can be reused on the same frame. (default: false)
  138071. * @param textureType Type of textures used when performing the post process. (default: 0)
  138072. * @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)
  138073. */
  138074. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138075. /**
  138076. * Excludes the given skinned mesh from computing bones velocities.
  138077. * 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.
  138078. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  138079. */
  138080. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138081. /**
  138082. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  138083. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  138084. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  138085. */
  138086. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138087. /**
  138088. * Disposes the post process.
  138089. * @param camera The camera to dispose the post process on.
  138090. */
  138091. dispose(camera?: Camera): void;
  138092. }
  138093. }
  138094. declare module BABYLON {
  138095. /** @hidden */
  138096. export var refractionPixelShader: {
  138097. name: string;
  138098. shader: string;
  138099. };
  138100. }
  138101. declare module BABYLON {
  138102. /**
  138103. * Post process which applies a refractin texture
  138104. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138105. */
  138106. export class RefractionPostProcess extends PostProcess {
  138107. /** the base color of the refraction (used to taint the rendering) */
  138108. color: Color3;
  138109. /** simulated refraction depth */
  138110. depth: number;
  138111. /** the coefficient of the base color (0 to remove base color tainting) */
  138112. colorLevel: number;
  138113. private _refTexture;
  138114. private _ownRefractionTexture;
  138115. /**
  138116. * Gets or sets the refraction texture
  138117. * Please note that you are responsible for disposing the texture if you set it manually
  138118. */
  138119. get refractionTexture(): Texture;
  138120. set refractionTexture(value: Texture);
  138121. /**
  138122. * Initializes the RefractionPostProcess
  138123. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138124. * @param name The name of the effect.
  138125. * @param refractionTextureUrl Url of the refraction texture to use
  138126. * @param color the base color of the refraction (used to taint the rendering)
  138127. * @param depth simulated refraction depth
  138128. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  138129. * @param camera The camera to apply the render pass to.
  138130. * @param options The required width/height ratio to downsize to before computing the render pass.
  138131. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138132. * @param engine The engine which the post process will be applied. (default: current engine)
  138133. * @param reusable If the post process can be reused on the same frame. (default: false)
  138134. */
  138135. constructor(name: string, refractionTextureUrl: string,
  138136. /** the base color of the refraction (used to taint the rendering) */
  138137. color: Color3,
  138138. /** simulated refraction depth */
  138139. depth: number,
  138140. /** the coefficient of the base color (0 to remove base color tainting) */
  138141. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138142. /**
  138143. * Disposes of the post process
  138144. * @param camera Camera to dispose post process on
  138145. */
  138146. dispose(camera: Camera): void;
  138147. }
  138148. }
  138149. declare module BABYLON {
  138150. /** @hidden */
  138151. export var sharpenPixelShader: {
  138152. name: string;
  138153. shader: string;
  138154. };
  138155. }
  138156. declare module BABYLON {
  138157. /**
  138158. * The SharpenPostProcess applies a sharpen kernel to every pixel
  138159. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138160. */
  138161. export class SharpenPostProcess extends PostProcess {
  138162. /**
  138163. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  138164. */
  138165. colorAmount: number;
  138166. /**
  138167. * How much sharpness should be applied (default: 0.3)
  138168. */
  138169. edgeAmount: number;
  138170. /**
  138171. * Creates a new instance ConvolutionPostProcess
  138172. * @param name The name of the effect.
  138173. * @param options The required width/height ratio to downsize to before computing the render pass.
  138174. * @param camera The camera to apply the render pass to.
  138175. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138176. * @param engine The engine which the post process will be applied. (default: current engine)
  138177. * @param reusable If the post process can be reused on the same frame. (default: false)
  138178. * @param textureType Type of textures used when performing the post process. (default: 0)
  138179. * @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)
  138180. */
  138181. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138182. }
  138183. }
  138184. declare module BABYLON {
  138185. /**
  138186. * PostProcessRenderPipeline
  138187. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138188. */
  138189. export class PostProcessRenderPipeline {
  138190. private engine;
  138191. private _renderEffects;
  138192. private _renderEffectsForIsolatedPass;
  138193. /**
  138194. * List of inspectable custom properties (used by the Inspector)
  138195. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  138196. */
  138197. inspectableCustomProperties: IInspectable[];
  138198. /**
  138199. * @hidden
  138200. */
  138201. protected _cameras: Camera[];
  138202. /** @hidden */
  138203. _name: string;
  138204. /**
  138205. * Gets pipeline name
  138206. */
  138207. get name(): string;
  138208. /** Gets the list of attached cameras */
  138209. get cameras(): Camera[];
  138210. /**
  138211. * Initializes a PostProcessRenderPipeline
  138212. * @param engine engine to add the pipeline to
  138213. * @param name name of the pipeline
  138214. */
  138215. constructor(engine: Engine, name: string);
  138216. /**
  138217. * Gets the class name
  138218. * @returns "PostProcessRenderPipeline"
  138219. */
  138220. getClassName(): string;
  138221. /**
  138222. * If all the render effects in the pipeline are supported
  138223. */
  138224. get isSupported(): boolean;
  138225. /**
  138226. * Adds an effect to the pipeline
  138227. * @param renderEffect the effect to add
  138228. */
  138229. addEffect(renderEffect: PostProcessRenderEffect): void;
  138230. /** @hidden */
  138231. _rebuild(): void;
  138232. /** @hidden */
  138233. _enableEffect(renderEffectName: string, cameras: Camera): void;
  138234. /** @hidden */
  138235. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  138236. /** @hidden */
  138237. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138238. /** @hidden */
  138239. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138240. /** @hidden */
  138241. _attachCameras(cameras: Camera, unique: boolean): void;
  138242. /** @hidden */
  138243. _attachCameras(cameras: Camera[], unique: boolean): void;
  138244. /** @hidden */
  138245. _detachCameras(cameras: Camera): void;
  138246. /** @hidden */
  138247. _detachCameras(cameras: Nullable<Camera[]>): void;
  138248. /** @hidden */
  138249. _update(): void;
  138250. /** @hidden */
  138251. _reset(): void;
  138252. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  138253. /**
  138254. * Disposes of the pipeline
  138255. */
  138256. dispose(): void;
  138257. }
  138258. }
  138259. declare module BABYLON {
  138260. /**
  138261. * PostProcessRenderPipelineManager class
  138262. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138263. */
  138264. export class PostProcessRenderPipelineManager {
  138265. private _renderPipelines;
  138266. /**
  138267. * Initializes a PostProcessRenderPipelineManager
  138268. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138269. */
  138270. constructor();
  138271. /**
  138272. * Gets the list of supported render pipelines
  138273. */
  138274. get supportedPipelines(): PostProcessRenderPipeline[];
  138275. /**
  138276. * Adds a pipeline to the manager
  138277. * @param renderPipeline The pipeline to add
  138278. */
  138279. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  138280. /**
  138281. * Attaches a camera to the pipeline
  138282. * @param renderPipelineName The name of the pipeline to attach to
  138283. * @param cameras the camera to attach
  138284. * @param unique if the camera can be attached multiple times to the pipeline
  138285. */
  138286. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  138287. /**
  138288. * Detaches a camera from the pipeline
  138289. * @param renderPipelineName The name of the pipeline to detach from
  138290. * @param cameras the camera to detach
  138291. */
  138292. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  138293. /**
  138294. * Enables an effect by name on a pipeline
  138295. * @param renderPipelineName the name of the pipeline to enable the effect in
  138296. * @param renderEffectName the name of the effect to enable
  138297. * @param cameras the cameras that the effect should be enabled on
  138298. */
  138299. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138300. /**
  138301. * Disables an effect by name on a pipeline
  138302. * @param renderPipelineName the name of the pipeline to disable the effect in
  138303. * @param renderEffectName the name of the effect to disable
  138304. * @param cameras the cameras that the effect should be disabled on
  138305. */
  138306. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138307. /**
  138308. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  138309. */
  138310. update(): void;
  138311. /** @hidden */
  138312. _rebuild(): void;
  138313. /**
  138314. * Disposes of the manager and pipelines
  138315. */
  138316. dispose(): void;
  138317. }
  138318. }
  138319. declare module BABYLON {
  138320. interface Scene {
  138321. /** @hidden (Backing field) */
  138322. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138323. /**
  138324. * Gets the postprocess render pipeline manager
  138325. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138326. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138327. */
  138328. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138329. }
  138330. /**
  138331. * Defines the Render Pipeline scene component responsible to rendering pipelines
  138332. */
  138333. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  138334. /**
  138335. * The component name helpfull to identify the component in the list of scene components.
  138336. */
  138337. readonly name: string;
  138338. /**
  138339. * The scene the component belongs to.
  138340. */
  138341. scene: Scene;
  138342. /**
  138343. * Creates a new instance of the component for the given scene
  138344. * @param scene Defines the scene to register the component in
  138345. */
  138346. constructor(scene: Scene);
  138347. /**
  138348. * Registers the component in a given scene
  138349. */
  138350. register(): void;
  138351. /**
  138352. * Rebuilds the elements related to this component in case of
  138353. * context lost for instance.
  138354. */
  138355. rebuild(): void;
  138356. /**
  138357. * Disposes the component and the associated ressources
  138358. */
  138359. dispose(): void;
  138360. private _gatherRenderTargets;
  138361. }
  138362. }
  138363. declare module BABYLON {
  138364. /**
  138365. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  138366. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138367. */
  138368. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138369. private _scene;
  138370. private _camerasToBeAttached;
  138371. /**
  138372. * ID of the sharpen post process,
  138373. */
  138374. private readonly SharpenPostProcessId;
  138375. /**
  138376. * @ignore
  138377. * ID of the image processing post process;
  138378. */
  138379. readonly ImageProcessingPostProcessId: string;
  138380. /**
  138381. * @ignore
  138382. * ID of the Fast Approximate Anti-Aliasing post process;
  138383. */
  138384. readonly FxaaPostProcessId: string;
  138385. /**
  138386. * ID of the chromatic aberration post process,
  138387. */
  138388. private readonly ChromaticAberrationPostProcessId;
  138389. /**
  138390. * ID of the grain post process
  138391. */
  138392. private readonly GrainPostProcessId;
  138393. /**
  138394. * Sharpen post process which will apply a sharpen convolution to enhance edges
  138395. */
  138396. sharpen: SharpenPostProcess;
  138397. private _sharpenEffect;
  138398. private bloom;
  138399. /**
  138400. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  138401. */
  138402. depthOfField: DepthOfFieldEffect;
  138403. /**
  138404. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138405. */
  138406. fxaa: FxaaPostProcess;
  138407. /**
  138408. * Image post processing pass used to perform operations such as tone mapping or color grading.
  138409. */
  138410. imageProcessing: ImageProcessingPostProcess;
  138411. /**
  138412. * Chromatic aberration post process which will shift rgb colors in the image
  138413. */
  138414. chromaticAberration: ChromaticAberrationPostProcess;
  138415. private _chromaticAberrationEffect;
  138416. /**
  138417. * Grain post process which add noise to the image
  138418. */
  138419. grain: GrainPostProcess;
  138420. private _grainEffect;
  138421. /**
  138422. * Glow post process which adds a glow to emissive areas of the image
  138423. */
  138424. private _glowLayer;
  138425. /**
  138426. * Animations which can be used to tweak settings over a period of time
  138427. */
  138428. animations: Animation[];
  138429. private _imageProcessingConfigurationObserver;
  138430. private _sharpenEnabled;
  138431. private _bloomEnabled;
  138432. private _depthOfFieldEnabled;
  138433. private _depthOfFieldBlurLevel;
  138434. private _fxaaEnabled;
  138435. private _imageProcessingEnabled;
  138436. private _defaultPipelineTextureType;
  138437. private _bloomScale;
  138438. private _chromaticAberrationEnabled;
  138439. private _grainEnabled;
  138440. private _buildAllowed;
  138441. /**
  138442. * Gets active scene
  138443. */
  138444. get scene(): Scene;
  138445. /**
  138446. * Enable or disable the sharpen process from the pipeline
  138447. */
  138448. set sharpenEnabled(enabled: boolean);
  138449. get sharpenEnabled(): boolean;
  138450. private _resizeObserver;
  138451. private _hardwareScaleLevel;
  138452. private _bloomKernel;
  138453. /**
  138454. * Specifies the size of the bloom blur kernel, relative to the final output size
  138455. */
  138456. get bloomKernel(): number;
  138457. set bloomKernel(value: number);
  138458. /**
  138459. * Specifies the weight of the bloom in the final rendering
  138460. */
  138461. private _bloomWeight;
  138462. /**
  138463. * Specifies the luma threshold for the area that will be blurred by the bloom
  138464. */
  138465. private _bloomThreshold;
  138466. private _hdr;
  138467. /**
  138468. * The strength of the bloom.
  138469. */
  138470. set bloomWeight(value: number);
  138471. get bloomWeight(): number;
  138472. /**
  138473. * The strength of the bloom.
  138474. */
  138475. set bloomThreshold(value: number);
  138476. get bloomThreshold(): number;
  138477. /**
  138478. * The scale of the bloom, lower value will provide better performance.
  138479. */
  138480. set bloomScale(value: number);
  138481. get bloomScale(): number;
  138482. /**
  138483. * Enable or disable the bloom from the pipeline
  138484. */
  138485. set bloomEnabled(enabled: boolean);
  138486. get bloomEnabled(): boolean;
  138487. private _rebuildBloom;
  138488. /**
  138489. * If the depth of field is enabled.
  138490. */
  138491. get depthOfFieldEnabled(): boolean;
  138492. set depthOfFieldEnabled(enabled: boolean);
  138493. /**
  138494. * Blur level of the depth of field effect. (Higher blur will effect performance)
  138495. */
  138496. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  138497. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  138498. /**
  138499. * If the anti aliasing is enabled.
  138500. */
  138501. set fxaaEnabled(enabled: boolean);
  138502. get fxaaEnabled(): boolean;
  138503. private _samples;
  138504. /**
  138505. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138506. */
  138507. set samples(sampleCount: number);
  138508. get samples(): number;
  138509. /**
  138510. * If image processing is enabled.
  138511. */
  138512. set imageProcessingEnabled(enabled: boolean);
  138513. get imageProcessingEnabled(): boolean;
  138514. /**
  138515. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  138516. */
  138517. set glowLayerEnabled(enabled: boolean);
  138518. get glowLayerEnabled(): boolean;
  138519. /**
  138520. * Gets the glow layer (or null if not defined)
  138521. */
  138522. get glowLayer(): Nullable<GlowLayer>;
  138523. /**
  138524. * Enable or disable the chromaticAberration process from the pipeline
  138525. */
  138526. set chromaticAberrationEnabled(enabled: boolean);
  138527. get chromaticAberrationEnabled(): boolean;
  138528. /**
  138529. * Enable or disable the grain process from the pipeline
  138530. */
  138531. set grainEnabled(enabled: boolean);
  138532. get grainEnabled(): boolean;
  138533. /**
  138534. * @constructor
  138535. * @param name - The rendering pipeline name (default: "")
  138536. * @param hdr - If high dynamic range textures should be used (default: true)
  138537. * @param scene - The scene linked to this pipeline (default: the last created scene)
  138538. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  138539. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  138540. */
  138541. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  138542. /**
  138543. * Get the class name
  138544. * @returns "DefaultRenderingPipeline"
  138545. */
  138546. getClassName(): string;
  138547. /**
  138548. * Force the compilation of the entire pipeline.
  138549. */
  138550. prepare(): void;
  138551. private _hasCleared;
  138552. private _prevPostProcess;
  138553. private _prevPrevPostProcess;
  138554. private _setAutoClearAndTextureSharing;
  138555. private _depthOfFieldSceneObserver;
  138556. private _buildPipeline;
  138557. private _disposePostProcesses;
  138558. /**
  138559. * Adds a camera to the pipeline
  138560. * @param camera the camera to be added
  138561. */
  138562. addCamera(camera: Camera): void;
  138563. /**
  138564. * Removes a camera from the pipeline
  138565. * @param camera the camera to remove
  138566. */
  138567. removeCamera(camera: Camera): void;
  138568. /**
  138569. * Dispose of the pipeline and stop all post processes
  138570. */
  138571. dispose(): void;
  138572. /**
  138573. * Serialize the rendering pipeline (Used when exporting)
  138574. * @returns the serialized object
  138575. */
  138576. serialize(): any;
  138577. /**
  138578. * Parse the serialized pipeline
  138579. * @param source Source pipeline.
  138580. * @param scene The scene to load the pipeline to.
  138581. * @param rootUrl The URL of the serialized pipeline.
  138582. * @returns An instantiated pipeline from the serialized object.
  138583. */
  138584. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  138585. }
  138586. }
  138587. declare module BABYLON {
  138588. /** @hidden */
  138589. export var lensHighlightsPixelShader: {
  138590. name: string;
  138591. shader: string;
  138592. };
  138593. }
  138594. declare module BABYLON {
  138595. /** @hidden */
  138596. export var depthOfFieldPixelShader: {
  138597. name: string;
  138598. shader: string;
  138599. };
  138600. }
  138601. declare module BABYLON {
  138602. /**
  138603. * BABYLON.JS Chromatic Aberration GLSL Shader
  138604. * Author: Olivier Guyot
  138605. * Separates very slightly R, G and B colors on the edges of the screen
  138606. * Inspired by Francois Tarlier & Martins Upitis
  138607. */
  138608. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  138609. /**
  138610. * @ignore
  138611. * The chromatic aberration PostProcess id in the pipeline
  138612. */
  138613. LensChromaticAberrationEffect: string;
  138614. /**
  138615. * @ignore
  138616. * The highlights enhancing PostProcess id in the pipeline
  138617. */
  138618. HighlightsEnhancingEffect: string;
  138619. /**
  138620. * @ignore
  138621. * The depth-of-field PostProcess id in the pipeline
  138622. */
  138623. LensDepthOfFieldEffect: string;
  138624. private _scene;
  138625. private _depthTexture;
  138626. private _grainTexture;
  138627. private _chromaticAberrationPostProcess;
  138628. private _highlightsPostProcess;
  138629. private _depthOfFieldPostProcess;
  138630. private _edgeBlur;
  138631. private _grainAmount;
  138632. private _chromaticAberration;
  138633. private _distortion;
  138634. private _highlightsGain;
  138635. private _highlightsThreshold;
  138636. private _dofDistance;
  138637. private _dofAperture;
  138638. private _dofDarken;
  138639. private _dofPentagon;
  138640. private _blurNoise;
  138641. /**
  138642. * @constructor
  138643. *
  138644. * Effect parameters are as follow:
  138645. * {
  138646. * chromatic_aberration: number; // from 0 to x (1 for realism)
  138647. * edge_blur: number; // from 0 to x (1 for realism)
  138648. * distortion: number; // from 0 to x (1 for realism)
  138649. * grain_amount: number; // from 0 to 1
  138650. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  138651. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  138652. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  138653. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  138654. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  138655. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  138656. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  138657. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  138658. * }
  138659. * Note: if an effect parameter is unset, effect is disabled
  138660. *
  138661. * @param name The rendering pipeline name
  138662. * @param parameters - An object containing all parameters (see above)
  138663. * @param scene The scene linked to this pipeline
  138664. * @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)
  138665. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138666. */
  138667. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  138668. /**
  138669. * Get the class name
  138670. * @returns "LensRenderingPipeline"
  138671. */
  138672. getClassName(): string;
  138673. /**
  138674. * Gets associated scene
  138675. */
  138676. get scene(): Scene;
  138677. /**
  138678. * Gets or sets the edge blur
  138679. */
  138680. get edgeBlur(): number;
  138681. set edgeBlur(value: number);
  138682. /**
  138683. * Gets or sets the grain amount
  138684. */
  138685. get grainAmount(): number;
  138686. set grainAmount(value: number);
  138687. /**
  138688. * Gets or sets the chromatic aberration amount
  138689. */
  138690. get chromaticAberration(): number;
  138691. set chromaticAberration(value: number);
  138692. /**
  138693. * Gets or sets the depth of field aperture
  138694. */
  138695. get dofAperture(): number;
  138696. set dofAperture(value: number);
  138697. /**
  138698. * Gets or sets the edge distortion
  138699. */
  138700. get edgeDistortion(): number;
  138701. set edgeDistortion(value: number);
  138702. /**
  138703. * Gets or sets the depth of field distortion
  138704. */
  138705. get dofDistortion(): number;
  138706. set dofDistortion(value: number);
  138707. /**
  138708. * Gets or sets the darken out of focus amount
  138709. */
  138710. get darkenOutOfFocus(): number;
  138711. set darkenOutOfFocus(value: number);
  138712. /**
  138713. * Gets or sets a boolean indicating if blur noise is enabled
  138714. */
  138715. get blurNoise(): boolean;
  138716. set blurNoise(value: boolean);
  138717. /**
  138718. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  138719. */
  138720. get pentagonBokeh(): boolean;
  138721. set pentagonBokeh(value: boolean);
  138722. /**
  138723. * Gets or sets the highlight grain amount
  138724. */
  138725. get highlightsGain(): number;
  138726. set highlightsGain(value: number);
  138727. /**
  138728. * Gets or sets the highlight threshold
  138729. */
  138730. get highlightsThreshold(): number;
  138731. set highlightsThreshold(value: number);
  138732. /**
  138733. * Sets the amount of blur at the edges
  138734. * @param amount blur amount
  138735. */
  138736. setEdgeBlur(amount: number): void;
  138737. /**
  138738. * Sets edge blur to 0
  138739. */
  138740. disableEdgeBlur(): void;
  138741. /**
  138742. * Sets the amout of grain
  138743. * @param amount Amount of grain
  138744. */
  138745. setGrainAmount(amount: number): void;
  138746. /**
  138747. * Set grain amount to 0
  138748. */
  138749. disableGrain(): void;
  138750. /**
  138751. * Sets the chromatic aberration amount
  138752. * @param amount amount of chromatic aberration
  138753. */
  138754. setChromaticAberration(amount: number): void;
  138755. /**
  138756. * Sets chromatic aberration amount to 0
  138757. */
  138758. disableChromaticAberration(): void;
  138759. /**
  138760. * Sets the EdgeDistortion amount
  138761. * @param amount amount of EdgeDistortion
  138762. */
  138763. setEdgeDistortion(amount: number): void;
  138764. /**
  138765. * Sets edge distortion to 0
  138766. */
  138767. disableEdgeDistortion(): void;
  138768. /**
  138769. * Sets the FocusDistance amount
  138770. * @param amount amount of FocusDistance
  138771. */
  138772. setFocusDistance(amount: number): void;
  138773. /**
  138774. * Disables depth of field
  138775. */
  138776. disableDepthOfField(): void;
  138777. /**
  138778. * Sets the Aperture amount
  138779. * @param amount amount of Aperture
  138780. */
  138781. setAperture(amount: number): void;
  138782. /**
  138783. * Sets the DarkenOutOfFocus amount
  138784. * @param amount amount of DarkenOutOfFocus
  138785. */
  138786. setDarkenOutOfFocus(amount: number): void;
  138787. private _pentagonBokehIsEnabled;
  138788. /**
  138789. * Creates a pentagon bokeh effect
  138790. */
  138791. enablePentagonBokeh(): void;
  138792. /**
  138793. * Disables the pentagon bokeh effect
  138794. */
  138795. disablePentagonBokeh(): void;
  138796. /**
  138797. * Enables noise blur
  138798. */
  138799. enableNoiseBlur(): void;
  138800. /**
  138801. * Disables noise blur
  138802. */
  138803. disableNoiseBlur(): void;
  138804. /**
  138805. * Sets the HighlightsGain amount
  138806. * @param amount amount of HighlightsGain
  138807. */
  138808. setHighlightsGain(amount: number): void;
  138809. /**
  138810. * Sets the HighlightsThreshold amount
  138811. * @param amount amount of HighlightsThreshold
  138812. */
  138813. setHighlightsThreshold(amount: number): void;
  138814. /**
  138815. * Disables highlights
  138816. */
  138817. disableHighlights(): void;
  138818. /**
  138819. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  138820. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  138821. */
  138822. dispose(disableDepthRender?: boolean): void;
  138823. private _createChromaticAberrationPostProcess;
  138824. private _createHighlightsPostProcess;
  138825. private _createDepthOfFieldPostProcess;
  138826. private _createGrainTexture;
  138827. }
  138828. }
  138829. declare module BABYLON {
  138830. /** @hidden */
  138831. export var ssao2PixelShader: {
  138832. name: string;
  138833. shader: string;
  138834. };
  138835. }
  138836. declare module BABYLON {
  138837. /** @hidden */
  138838. export var ssaoCombinePixelShader: {
  138839. name: string;
  138840. shader: string;
  138841. };
  138842. }
  138843. declare module BABYLON {
  138844. /**
  138845. * Render pipeline to produce ssao effect
  138846. */
  138847. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  138848. /**
  138849. * @ignore
  138850. * The PassPostProcess id in the pipeline that contains the original scene color
  138851. */
  138852. SSAOOriginalSceneColorEffect: string;
  138853. /**
  138854. * @ignore
  138855. * The SSAO PostProcess id in the pipeline
  138856. */
  138857. SSAORenderEffect: string;
  138858. /**
  138859. * @ignore
  138860. * The horizontal blur PostProcess id in the pipeline
  138861. */
  138862. SSAOBlurHRenderEffect: string;
  138863. /**
  138864. * @ignore
  138865. * The vertical blur PostProcess id in the pipeline
  138866. */
  138867. SSAOBlurVRenderEffect: string;
  138868. /**
  138869. * @ignore
  138870. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138871. */
  138872. SSAOCombineRenderEffect: string;
  138873. /**
  138874. * The output strength of the SSAO post-process. Default value is 1.0.
  138875. */
  138876. totalStrength: number;
  138877. /**
  138878. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  138879. */
  138880. maxZ: number;
  138881. /**
  138882. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  138883. */
  138884. minZAspect: number;
  138885. private _samples;
  138886. /**
  138887. * Number of samples used for the SSAO calculations. Default value is 8
  138888. */
  138889. set samples(n: number);
  138890. get samples(): number;
  138891. private _textureSamples;
  138892. /**
  138893. * Number of samples to use for antialiasing
  138894. */
  138895. set textureSamples(n: number);
  138896. get textureSamples(): number;
  138897. /**
  138898. * Ratio object used for SSAO ratio and blur ratio
  138899. */
  138900. private _ratio;
  138901. /**
  138902. * Dynamically generated sphere sampler.
  138903. */
  138904. private _sampleSphere;
  138905. /**
  138906. * Blur filter offsets
  138907. */
  138908. private _samplerOffsets;
  138909. private _expensiveBlur;
  138910. /**
  138911. * If bilateral blur should be used
  138912. */
  138913. set expensiveBlur(b: boolean);
  138914. get expensiveBlur(): boolean;
  138915. /**
  138916. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  138917. */
  138918. radius: number;
  138919. /**
  138920. * The base color of the SSAO post-process
  138921. * The final result is "base + ssao" between [0, 1]
  138922. */
  138923. base: number;
  138924. /**
  138925. * Support test.
  138926. */
  138927. static get IsSupported(): boolean;
  138928. private _scene;
  138929. private _depthTexture;
  138930. private _normalTexture;
  138931. private _randomTexture;
  138932. private _originalColorPostProcess;
  138933. private _ssaoPostProcess;
  138934. private _blurHPostProcess;
  138935. private _blurVPostProcess;
  138936. private _ssaoCombinePostProcess;
  138937. /**
  138938. * Gets active scene
  138939. */
  138940. get scene(): Scene;
  138941. /**
  138942. * @constructor
  138943. * @param name The rendering pipeline name
  138944. * @param scene The scene linked to this pipeline
  138945. * @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 }
  138946. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138947. */
  138948. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138949. /**
  138950. * Get the class name
  138951. * @returns "SSAO2RenderingPipeline"
  138952. */
  138953. getClassName(): string;
  138954. /**
  138955. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138956. */
  138957. dispose(disableGeometryBufferRenderer?: boolean): void;
  138958. private _createBlurPostProcess;
  138959. /** @hidden */
  138960. _rebuild(): void;
  138961. private _bits;
  138962. private _radicalInverse_VdC;
  138963. private _hammersley;
  138964. private _hemisphereSample_uniform;
  138965. private _generateHemisphere;
  138966. private _createSSAOPostProcess;
  138967. private _createSSAOCombinePostProcess;
  138968. private _createRandomTexture;
  138969. /**
  138970. * Serialize the rendering pipeline (Used when exporting)
  138971. * @returns the serialized object
  138972. */
  138973. serialize(): any;
  138974. /**
  138975. * Parse the serialized pipeline
  138976. * @param source Source pipeline.
  138977. * @param scene The scene to load the pipeline to.
  138978. * @param rootUrl The URL of the serialized pipeline.
  138979. * @returns An instantiated pipeline from the serialized object.
  138980. */
  138981. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  138982. }
  138983. }
  138984. declare module BABYLON {
  138985. /** @hidden */
  138986. export var ssaoPixelShader: {
  138987. name: string;
  138988. shader: string;
  138989. };
  138990. }
  138991. declare module BABYLON {
  138992. /**
  138993. * Render pipeline to produce ssao effect
  138994. */
  138995. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  138996. /**
  138997. * @ignore
  138998. * The PassPostProcess id in the pipeline that contains the original scene color
  138999. */
  139000. SSAOOriginalSceneColorEffect: string;
  139001. /**
  139002. * @ignore
  139003. * The SSAO PostProcess id in the pipeline
  139004. */
  139005. SSAORenderEffect: string;
  139006. /**
  139007. * @ignore
  139008. * The horizontal blur PostProcess id in the pipeline
  139009. */
  139010. SSAOBlurHRenderEffect: string;
  139011. /**
  139012. * @ignore
  139013. * The vertical blur PostProcess id in the pipeline
  139014. */
  139015. SSAOBlurVRenderEffect: string;
  139016. /**
  139017. * @ignore
  139018. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  139019. */
  139020. SSAOCombineRenderEffect: string;
  139021. /**
  139022. * The output strength of the SSAO post-process. Default value is 1.0.
  139023. */
  139024. totalStrength: number;
  139025. /**
  139026. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  139027. */
  139028. radius: number;
  139029. /**
  139030. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  139031. * Must not be equal to fallOff and superior to fallOff.
  139032. * Default value is 0.0075
  139033. */
  139034. area: number;
  139035. /**
  139036. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  139037. * Must not be equal to area and inferior to area.
  139038. * Default value is 0.000001
  139039. */
  139040. fallOff: number;
  139041. /**
  139042. * The base color of the SSAO post-process
  139043. * The final result is "base + ssao" between [0, 1]
  139044. */
  139045. base: number;
  139046. private _scene;
  139047. private _depthTexture;
  139048. private _randomTexture;
  139049. private _originalColorPostProcess;
  139050. private _ssaoPostProcess;
  139051. private _blurHPostProcess;
  139052. private _blurVPostProcess;
  139053. private _ssaoCombinePostProcess;
  139054. private _firstUpdate;
  139055. /**
  139056. * Gets active scene
  139057. */
  139058. get scene(): Scene;
  139059. /**
  139060. * @constructor
  139061. * @param name - The rendering pipeline name
  139062. * @param scene - The scene linked to this pipeline
  139063. * @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 }
  139064. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  139065. */
  139066. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139067. /**
  139068. * Get the class name
  139069. * @returns "SSAORenderingPipeline"
  139070. */
  139071. getClassName(): string;
  139072. /**
  139073. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139074. */
  139075. dispose(disableDepthRender?: boolean): void;
  139076. private _createBlurPostProcess;
  139077. /** @hidden */
  139078. _rebuild(): void;
  139079. private _createSSAOPostProcess;
  139080. private _createSSAOCombinePostProcess;
  139081. private _createRandomTexture;
  139082. }
  139083. }
  139084. declare module BABYLON {
  139085. /** @hidden */
  139086. export var screenSpaceReflectionPixelShader: {
  139087. name: string;
  139088. shader: string;
  139089. };
  139090. }
  139091. declare module BABYLON {
  139092. /**
  139093. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  139094. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  139095. */
  139096. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  139097. /**
  139098. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  139099. */
  139100. threshold: number;
  139101. /**
  139102. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  139103. */
  139104. strength: number;
  139105. /**
  139106. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  139107. */
  139108. reflectionSpecularFalloffExponent: number;
  139109. /**
  139110. * 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]
  139111. */
  139112. step: number;
  139113. /**
  139114. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  139115. */
  139116. roughnessFactor: number;
  139117. private _geometryBufferRenderer;
  139118. private _enableSmoothReflections;
  139119. private _reflectionSamples;
  139120. private _smoothSteps;
  139121. /**
  139122. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  139123. * @param name The name of the effect.
  139124. * @param scene The scene containing the objects to calculate reflections.
  139125. * @param options The required width/height ratio to downsize to before computing the render pass.
  139126. * @param camera The camera to apply the render pass to.
  139127. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139128. * @param engine The engine which the post process will be applied. (default: current engine)
  139129. * @param reusable If the post process can be reused on the same frame. (default: false)
  139130. * @param textureType Type of textures used when performing the post process. (default: 0)
  139131. * @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)
  139132. */
  139133. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139134. /**
  139135. * Gets wether or not smoothing reflections is enabled.
  139136. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139137. */
  139138. get enableSmoothReflections(): boolean;
  139139. /**
  139140. * Sets wether or not smoothing reflections is enabled.
  139141. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139142. */
  139143. set enableSmoothReflections(enabled: boolean);
  139144. /**
  139145. * Gets the number of samples taken while computing reflections. More samples count is high,
  139146. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139147. */
  139148. get reflectionSamples(): number;
  139149. /**
  139150. * Sets the number of samples taken while computing reflections. More samples count is high,
  139151. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139152. */
  139153. set reflectionSamples(samples: number);
  139154. /**
  139155. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  139156. * more the post-process will require GPU power and can generate a drop in FPS.
  139157. * Default value (5.0) work pretty well in all cases but can be adjusted.
  139158. */
  139159. get smoothSteps(): number;
  139160. set smoothSteps(steps: number);
  139161. private _updateEffectDefines;
  139162. }
  139163. }
  139164. declare module BABYLON {
  139165. /** @hidden */
  139166. export var standardPixelShader: {
  139167. name: string;
  139168. shader: string;
  139169. };
  139170. }
  139171. declare module BABYLON {
  139172. /**
  139173. * Standard rendering pipeline
  139174. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139175. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  139176. */
  139177. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139178. /**
  139179. * Public members
  139180. */
  139181. /**
  139182. * Post-process which contains the original scene color before the pipeline applies all the effects
  139183. */
  139184. originalPostProcess: Nullable<PostProcess>;
  139185. /**
  139186. * Post-process used to down scale an image x4
  139187. */
  139188. downSampleX4PostProcess: Nullable<PostProcess>;
  139189. /**
  139190. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  139191. */
  139192. brightPassPostProcess: Nullable<PostProcess>;
  139193. /**
  139194. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  139195. */
  139196. blurHPostProcesses: PostProcess[];
  139197. /**
  139198. * Post-process array storing all the vertical blur post-processes used by the pipeline
  139199. */
  139200. blurVPostProcesses: PostProcess[];
  139201. /**
  139202. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  139203. */
  139204. textureAdderPostProcess: Nullable<PostProcess>;
  139205. /**
  139206. * Post-process used to create volumetric lighting effect
  139207. */
  139208. volumetricLightPostProcess: Nullable<PostProcess>;
  139209. /**
  139210. * Post-process used to smooth the previous volumetric light post-process on the X axis
  139211. */
  139212. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  139213. /**
  139214. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  139215. */
  139216. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  139217. /**
  139218. * Post-process used to merge the volumetric light effect and the real scene color
  139219. */
  139220. volumetricLightMergePostProces: Nullable<PostProcess>;
  139221. /**
  139222. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  139223. */
  139224. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  139225. /**
  139226. * Base post-process used to calculate the average luminance of the final image for HDR
  139227. */
  139228. luminancePostProcess: Nullable<PostProcess>;
  139229. /**
  139230. * Post-processes used to create down sample post-processes in order to get
  139231. * the average luminance of the final image for HDR
  139232. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  139233. */
  139234. luminanceDownSamplePostProcesses: PostProcess[];
  139235. /**
  139236. * Post-process used to create a HDR effect (light adaptation)
  139237. */
  139238. hdrPostProcess: Nullable<PostProcess>;
  139239. /**
  139240. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  139241. */
  139242. textureAdderFinalPostProcess: Nullable<PostProcess>;
  139243. /**
  139244. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  139245. */
  139246. lensFlareFinalPostProcess: Nullable<PostProcess>;
  139247. /**
  139248. * Post-process used to merge the final HDR post-process and the real scene color
  139249. */
  139250. hdrFinalPostProcess: Nullable<PostProcess>;
  139251. /**
  139252. * Post-process used to create a lens flare effect
  139253. */
  139254. lensFlarePostProcess: Nullable<PostProcess>;
  139255. /**
  139256. * Post-process that merges the result of the lens flare post-process and the real scene color
  139257. */
  139258. lensFlareComposePostProcess: Nullable<PostProcess>;
  139259. /**
  139260. * Post-process used to create a motion blur effect
  139261. */
  139262. motionBlurPostProcess: Nullable<PostProcess>;
  139263. /**
  139264. * Post-process used to create a depth of field effect
  139265. */
  139266. depthOfFieldPostProcess: Nullable<PostProcess>;
  139267. /**
  139268. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  139269. */
  139270. fxaaPostProcess: Nullable<FxaaPostProcess>;
  139271. /**
  139272. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  139273. */
  139274. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  139275. /**
  139276. * Represents the brightness threshold in order to configure the illuminated surfaces
  139277. */
  139278. brightThreshold: number;
  139279. /**
  139280. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  139281. */
  139282. blurWidth: number;
  139283. /**
  139284. * Sets if the blur for highlighted surfaces must be only horizontal
  139285. */
  139286. horizontalBlur: boolean;
  139287. /**
  139288. * Gets the overall exposure used by the pipeline
  139289. */
  139290. get exposure(): number;
  139291. /**
  139292. * Sets the overall exposure used by the pipeline
  139293. */
  139294. set exposure(value: number);
  139295. /**
  139296. * Texture used typically to simulate "dirty" on camera lens
  139297. */
  139298. lensTexture: Nullable<Texture>;
  139299. /**
  139300. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  139301. */
  139302. volumetricLightCoefficient: number;
  139303. /**
  139304. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  139305. */
  139306. volumetricLightPower: number;
  139307. /**
  139308. * Used the set the blur intensity to smooth the volumetric lights
  139309. */
  139310. volumetricLightBlurScale: number;
  139311. /**
  139312. * Light (spot or directional) used to generate the volumetric lights rays
  139313. * The source light must have a shadow generate so the pipeline can get its
  139314. * depth map
  139315. */
  139316. sourceLight: Nullable<SpotLight | DirectionalLight>;
  139317. /**
  139318. * For eye adaptation, represents the minimum luminance the eye can see
  139319. */
  139320. hdrMinimumLuminance: number;
  139321. /**
  139322. * For eye adaptation, represents the decrease luminance speed
  139323. */
  139324. hdrDecreaseRate: number;
  139325. /**
  139326. * For eye adaptation, represents the increase luminance speed
  139327. */
  139328. hdrIncreaseRate: number;
  139329. /**
  139330. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139331. */
  139332. get hdrAutoExposure(): boolean;
  139333. /**
  139334. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139335. */
  139336. set hdrAutoExposure(value: boolean);
  139337. /**
  139338. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  139339. */
  139340. lensColorTexture: Nullable<Texture>;
  139341. /**
  139342. * The overall strengh for the lens flare effect
  139343. */
  139344. lensFlareStrength: number;
  139345. /**
  139346. * Dispersion coefficient for lens flare ghosts
  139347. */
  139348. lensFlareGhostDispersal: number;
  139349. /**
  139350. * Main lens flare halo width
  139351. */
  139352. lensFlareHaloWidth: number;
  139353. /**
  139354. * Based on the lens distortion effect, defines how much the lens flare result
  139355. * is distorted
  139356. */
  139357. lensFlareDistortionStrength: number;
  139358. /**
  139359. * Configures the blur intensity used for for lens flare (halo)
  139360. */
  139361. lensFlareBlurWidth: number;
  139362. /**
  139363. * Lens star texture must be used to simulate rays on the flares and is available
  139364. * in the documentation
  139365. */
  139366. lensStarTexture: Nullable<Texture>;
  139367. /**
  139368. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  139369. * flare effect by taking account of the dirt texture
  139370. */
  139371. lensFlareDirtTexture: Nullable<Texture>;
  139372. /**
  139373. * Represents the focal length for the depth of field effect
  139374. */
  139375. depthOfFieldDistance: number;
  139376. /**
  139377. * Represents the blur intensity for the blurred part of the depth of field effect
  139378. */
  139379. depthOfFieldBlurWidth: number;
  139380. /**
  139381. * Gets how much the image is blurred by the movement while using the motion blur post-process
  139382. */
  139383. get motionStrength(): number;
  139384. /**
  139385. * Sets how much the image is blurred by the movement while using the motion blur post-process
  139386. */
  139387. set motionStrength(strength: number);
  139388. /**
  139389. * Gets wether or not the motion blur post-process is object based or screen based.
  139390. */
  139391. get objectBasedMotionBlur(): boolean;
  139392. /**
  139393. * Sets wether or not the motion blur post-process should be object based or screen based
  139394. */
  139395. set objectBasedMotionBlur(value: boolean);
  139396. /**
  139397. * List of animations for the pipeline (IAnimatable implementation)
  139398. */
  139399. animations: Animation[];
  139400. /**
  139401. * Private members
  139402. */
  139403. private _scene;
  139404. private _currentDepthOfFieldSource;
  139405. private _basePostProcess;
  139406. private _fixedExposure;
  139407. private _currentExposure;
  139408. private _hdrAutoExposure;
  139409. private _hdrCurrentLuminance;
  139410. private _motionStrength;
  139411. private _isObjectBasedMotionBlur;
  139412. private _floatTextureType;
  139413. private _camerasToBeAttached;
  139414. private _ratio;
  139415. private _bloomEnabled;
  139416. private _depthOfFieldEnabled;
  139417. private _vlsEnabled;
  139418. private _lensFlareEnabled;
  139419. private _hdrEnabled;
  139420. private _motionBlurEnabled;
  139421. private _fxaaEnabled;
  139422. private _screenSpaceReflectionsEnabled;
  139423. private _motionBlurSamples;
  139424. private _volumetricLightStepsCount;
  139425. private _samples;
  139426. /**
  139427. * @ignore
  139428. * Specifies if the bloom pipeline is enabled
  139429. */
  139430. get BloomEnabled(): boolean;
  139431. set BloomEnabled(enabled: boolean);
  139432. /**
  139433. * @ignore
  139434. * Specifies if the depth of field pipeline is enabed
  139435. */
  139436. get DepthOfFieldEnabled(): boolean;
  139437. set DepthOfFieldEnabled(enabled: boolean);
  139438. /**
  139439. * @ignore
  139440. * Specifies if the lens flare pipeline is enabed
  139441. */
  139442. get LensFlareEnabled(): boolean;
  139443. set LensFlareEnabled(enabled: boolean);
  139444. /**
  139445. * @ignore
  139446. * Specifies if the HDR pipeline is enabled
  139447. */
  139448. get HDREnabled(): boolean;
  139449. set HDREnabled(enabled: boolean);
  139450. /**
  139451. * @ignore
  139452. * Specifies if the volumetric lights scattering effect is enabled
  139453. */
  139454. get VLSEnabled(): boolean;
  139455. set VLSEnabled(enabled: boolean);
  139456. /**
  139457. * @ignore
  139458. * Specifies if the motion blur effect is enabled
  139459. */
  139460. get MotionBlurEnabled(): boolean;
  139461. set MotionBlurEnabled(enabled: boolean);
  139462. /**
  139463. * Specifies if anti-aliasing is enabled
  139464. */
  139465. get fxaaEnabled(): boolean;
  139466. set fxaaEnabled(enabled: boolean);
  139467. /**
  139468. * Specifies if screen space reflections are enabled.
  139469. */
  139470. get screenSpaceReflectionsEnabled(): boolean;
  139471. set screenSpaceReflectionsEnabled(enabled: boolean);
  139472. /**
  139473. * Specifies the number of steps used to calculate the volumetric lights
  139474. * Typically in interval [50, 200]
  139475. */
  139476. get volumetricLightStepsCount(): number;
  139477. set volumetricLightStepsCount(count: number);
  139478. /**
  139479. * Specifies the number of samples used for the motion blur effect
  139480. * Typically in interval [16, 64]
  139481. */
  139482. get motionBlurSamples(): number;
  139483. set motionBlurSamples(samples: number);
  139484. /**
  139485. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139486. */
  139487. get samples(): number;
  139488. set samples(sampleCount: number);
  139489. /**
  139490. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139491. * @constructor
  139492. * @param name The rendering pipeline name
  139493. * @param scene The scene linked to this pipeline
  139494. * @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)
  139495. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  139496. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139497. */
  139498. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  139499. private _buildPipeline;
  139500. private _createDownSampleX4PostProcess;
  139501. private _createBrightPassPostProcess;
  139502. private _createBlurPostProcesses;
  139503. private _createTextureAdderPostProcess;
  139504. private _createVolumetricLightPostProcess;
  139505. private _createLuminancePostProcesses;
  139506. private _createHdrPostProcess;
  139507. private _createLensFlarePostProcess;
  139508. private _createDepthOfFieldPostProcess;
  139509. private _createMotionBlurPostProcess;
  139510. private _getDepthTexture;
  139511. private _disposePostProcesses;
  139512. /**
  139513. * Dispose of the pipeline and stop all post processes
  139514. */
  139515. dispose(): void;
  139516. /**
  139517. * Serialize the rendering pipeline (Used when exporting)
  139518. * @returns the serialized object
  139519. */
  139520. serialize(): any;
  139521. /**
  139522. * Parse the serialized pipeline
  139523. * @param source Source pipeline.
  139524. * @param scene The scene to load the pipeline to.
  139525. * @param rootUrl The URL of the serialized pipeline.
  139526. * @returns An instantiated pipeline from the serialized object.
  139527. */
  139528. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  139529. /**
  139530. * Luminance steps
  139531. */
  139532. static LuminanceSteps: number;
  139533. }
  139534. }
  139535. declare module BABYLON {
  139536. /** @hidden */
  139537. export var tonemapPixelShader: {
  139538. name: string;
  139539. shader: string;
  139540. };
  139541. }
  139542. declare module BABYLON {
  139543. /** Defines operator used for tonemapping */
  139544. export enum TonemappingOperator {
  139545. /** Hable */
  139546. Hable = 0,
  139547. /** Reinhard */
  139548. Reinhard = 1,
  139549. /** HejiDawson */
  139550. HejiDawson = 2,
  139551. /** Photographic */
  139552. Photographic = 3
  139553. }
  139554. /**
  139555. * Defines a post process to apply tone mapping
  139556. */
  139557. export class TonemapPostProcess extends PostProcess {
  139558. private _operator;
  139559. /** Defines the required exposure adjustement */
  139560. exposureAdjustment: number;
  139561. /**
  139562. * Creates a new TonemapPostProcess
  139563. * @param name defines the name of the postprocess
  139564. * @param _operator defines the operator to use
  139565. * @param exposureAdjustment defines the required exposure adjustement
  139566. * @param camera defines the camera to use (can be null)
  139567. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  139568. * @param engine defines the hosting engine (can be ignore if camera is set)
  139569. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139570. */
  139571. constructor(name: string, _operator: TonemappingOperator,
  139572. /** Defines the required exposure adjustement */
  139573. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  139574. }
  139575. }
  139576. declare module BABYLON {
  139577. /** @hidden */
  139578. export var volumetricLightScatteringPixelShader: {
  139579. name: string;
  139580. shader: string;
  139581. };
  139582. }
  139583. declare module BABYLON {
  139584. /** @hidden */
  139585. export var volumetricLightScatteringPassVertexShader: {
  139586. name: string;
  139587. shader: string;
  139588. };
  139589. }
  139590. declare module BABYLON {
  139591. /** @hidden */
  139592. export var volumetricLightScatteringPassPixelShader: {
  139593. name: string;
  139594. shader: string;
  139595. };
  139596. }
  139597. declare module BABYLON {
  139598. /**
  139599. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  139600. */
  139601. export class VolumetricLightScatteringPostProcess extends PostProcess {
  139602. private _volumetricLightScatteringPass;
  139603. private _volumetricLightScatteringRTT;
  139604. private _viewPort;
  139605. private _screenCoordinates;
  139606. private _cachedDefines;
  139607. /**
  139608. * If not undefined, the mesh position is computed from the attached node position
  139609. */
  139610. attachedNode: {
  139611. position: Vector3;
  139612. };
  139613. /**
  139614. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  139615. */
  139616. customMeshPosition: Vector3;
  139617. /**
  139618. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  139619. */
  139620. useCustomMeshPosition: boolean;
  139621. /**
  139622. * If the post-process should inverse the light scattering direction
  139623. */
  139624. invert: boolean;
  139625. /**
  139626. * The internal mesh used by the post-process
  139627. */
  139628. mesh: Mesh;
  139629. /**
  139630. * @hidden
  139631. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  139632. */
  139633. get useDiffuseColor(): boolean;
  139634. set useDiffuseColor(useDiffuseColor: boolean);
  139635. /**
  139636. * Array containing the excluded meshes not rendered in the internal pass
  139637. */
  139638. excludedMeshes: AbstractMesh[];
  139639. /**
  139640. * Controls the overall intensity of the post-process
  139641. */
  139642. exposure: number;
  139643. /**
  139644. * Dissipates each sample's contribution in range [0, 1]
  139645. */
  139646. decay: number;
  139647. /**
  139648. * Controls the overall intensity of each sample
  139649. */
  139650. weight: number;
  139651. /**
  139652. * Controls the density of each sample
  139653. */
  139654. density: number;
  139655. /**
  139656. * @constructor
  139657. * @param name The post-process name
  139658. * @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)
  139659. * @param camera The camera that the post-process will be attached to
  139660. * @param mesh The mesh used to create the light scattering
  139661. * @param samples The post-process quality, default 100
  139662. * @param samplingModeThe post-process filtering mode
  139663. * @param engine The babylon engine
  139664. * @param reusable If the post-process is reusable
  139665. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  139666. */
  139667. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  139668. /**
  139669. * Returns the string "VolumetricLightScatteringPostProcess"
  139670. * @returns "VolumetricLightScatteringPostProcess"
  139671. */
  139672. getClassName(): string;
  139673. private _isReady;
  139674. /**
  139675. * Sets the new light position for light scattering effect
  139676. * @param position The new custom light position
  139677. */
  139678. setCustomMeshPosition(position: Vector3): void;
  139679. /**
  139680. * Returns the light position for light scattering effect
  139681. * @return Vector3 The custom light position
  139682. */
  139683. getCustomMeshPosition(): Vector3;
  139684. /**
  139685. * Disposes the internal assets and detaches the post-process from the camera
  139686. */
  139687. dispose(camera: Camera): void;
  139688. /**
  139689. * Returns the render target texture used by the post-process
  139690. * @return the render target texture used by the post-process
  139691. */
  139692. getPass(): RenderTargetTexture;
  139693. private _meshExcluded;
  139694. private _createPass;
  139695. private _updateMeshScreenCoordinates;
  139696. /**
  139697. * Creates a default mesh for the Volumeric Light Scattering post-process
  139698. * @param name The mesh name
  139699. * @param scene The scene where to create the mesh
  139700. * @return the default mesh
  139701. */
  139702. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  139703. }
  139704. }
  139705. declare module BABYLON {
  139706. interface Scene {
  139707. /** @hidden (Backing field) */
  139708. _boundingBoxRenderer: BoundingBoxRenderer;
  139709. /** @hidden (Backing field) */
  139710. _forceShowBoundingBoxes: boolean;
  139711. /**
  139712. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  139713. */
  139714. forceShowBoundingBoxes: boolean;
  139715. /**
  139716. * Gets the bounding box renderer associated with the scene
  139717. * @returns a BoundingBoxRenderer
  139718. */
  139719. getBoundingBoxRenderer(): BoundingBoxRenderer;
  139720. }
  139721. interface AbstractMesh {
  139722. /** @hidden (Backing field) */
  139723. _showBoundingBox: boolean;
  139724. /**
  139725. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  139726. */
  139727. showBoundingBox: boolean;
  139728. }
  139729. /**
  139730. * Component responsible of rendering the bounding box of the meshes in a scene.
  139731. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  139732. */
  139733. export class BoundingBoxRenderer implements ISceneComponent {
  139734. /**
  139735. * The component name helpfull to identify the component in the list of scene components.
  139736. */
  139737. readonly name: string;
  139738. /**
  139739. * The scene the component belongs to.
  139740. */
  139741. scene: Scene;
  139742. /**
  139743. * Color of the bounding box lines placed in front of an object
  139744. */
  139745. frontColor: Color3;
  139746. /**
  139747. * Color of the bounding box lines placed behind an object
  139748. */
  139749. backColor: Color3;
  139750. /**
  139751. * Defines if the renderer should show the back lines or not
  139752. */
  139753. showBackLines: boolean;
  139754. /**
  139755. * @hidden
  139756. */
  139757. renderList: SmartArray<BoundingBox>;
  139758. private _colorShader;
  139759. private _vertexBuffers;
  139760. private _indexBuffer;
  139761. private _fillIndexBuffer;
  139762. private _fillIndexData;
  139763. /**
  139764. * Instantiates a new bounding box renderer in a scene.
  139765. * @param scene the scene the renderer renders in
  139766. */
  139767. constructor(scene: Scene);
  139768. /**
  139769. * Registers the component in a given scene
  139770. */
  139771. register(): void;
  139772. private _evaluateSubMesh;
  139773. private _activeMesh;
  139774. private _prepareRessources;
  139775. private _createIndexBuffer;
  139776. /**
  139777. * Rebuilds the elements related to this component in case of
  139778. * context lost for instance.
  139779. */
  139780. rebuild(): void;
  139781. /**
  139782. * @hidden
  139783. */
  139784. reset(): void;
  139785. /**
  139786. * Render the bounding boxes of a specific rendering group
  139787. * @param renderingGroupId defines the rendering group to render
  139788. */
  139789. render(renderingGroupId: number): void;
  139790. /**
  139791. * In case of occlusion queries, we can render the occlusion bounding box through this method
  139792. * @param mesh Define the mesh to render the occlusion bounding box for
  139793. */
  139794. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  139795. /**
  139796. * Dispose and release the resources attached to this renderer.
  139797. */
  139798. dispose(): void;
  139799. }
  139800. }
  139801. declare module BABYLON {
  139802. interface Scene {
  139803. /** @hidden (Backing field) */
  139804. _depthRenderer: {
  139805. [id: string]: DepthRenderer;
  139806. };
  139807. /**
  139808. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  139809. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  139810. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139811. * @returns the created depth renderer
  139812. */
  139813. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  139814. /**
  139815. * Disables a depth renderer for a given camera
  139816. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  139817. */
  139818. disableDepthRenderer(camera?: Nullable<Camera>): void;
  139819. }
  139820. /**
  139821. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  139822. * in several rendering techniques.
  139823. */
  139824. export class DepthRendererSceneComponent implements ISceneComponent {
  139825. /**
  139826. * The component name helpfull to identify the component in the list of scene components.
  139827. */
  139828. readonly name: string;
  139829. /**
  139830. * The scene the component belongs to.
  139831. */
  139832. scene: Scene;
  139833. /**
  139834. * Creates a new instance of the component for the given scene
  139835. * @param scene Defines the scene to register the component in
  139836. */
  139837. constructor(scene: Scene);
  139838. /**
  139839. * Registers the component in a given scene
  139840. */
  139841. register(): void;
  139842. /**
  139843. * Rebuilds the elements related to this component in case of
  139844. * context lost for instance.
  139845. */
  139846. rebuild(): void;
  139847. /**
  139848. * Disposes the component and the associated ressources
  139849. */
  139850. dispose(): void;
  139851. private _gatherRenderTargets;
  139852. private _gatherActiveCameraRenderTargets;
  139853. }
  139854. }
  139855. declare module BABYLON {
  139856. /** @hidden */
  139857. export var outlinePixelShader: {
  139858. name: string;
  139859. shader: string;
  139860. };
  139861. }
  139862. declare module BABYLON {
  139863. /** @hidden */
  139864. export var outlineVertexShader: {
  139865. name: string;
  139866. shader: string;
  139867. };
  139868. }
  139869. declare module BABYLON {
  139870. interface Scene {
  139871. /** @hidden */
  139872. _outlineRenderer: OutlineRenderer;
  139873. /**
  139874. * Gets the outline renderer associated with the scene
  139875. * @returns a OutlineRenderer
  139876. */
  139877. getOutlineRenderer(): OutlineRenderer;
  139878. }
  139879. interface AbstractMesh {
  139880. /** @hidden (Backing field) */
  139881. _renderOutline: boolean;
  139882. /**
  139883. * Gets or sets a boolean indicating if the outline must be rendered as well
  139884. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  139885. */
  139886. renderOutline: boolean;
  139887. /** @hidden (Backing field) */
  139888. _renderOverlay: boolean;
  139889. /**
  139890. * Gets or sets a boolean indicating if the overlay must be rendered as well
  139891. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  139892. */
  139893. renderOverlay: boolean;
  139894. }
  139895. /**
  139896. * This class is responsible to draw bothe outline/overlay of meshes.
  139897. * It should not be used directly but through the available method on mesh.
  139898. */
  139899. export class OutlineRenderer implements ISceneComponent {
  139900. /**
  139901. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  139902. */
  139903. private static _StencilReference;
  139904. /**
  139905. * The name of the component. Each component must have a unique name.
  139906. */
  139907. name: string;
  139908. /**
  139909. * The scene the component belongs to.
  139910. */
  139911. scene: Scene;
  139912. /**
  139913. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  139914. */
  139915. zOffset: number;
  139916. private _engine;
  139917. private _effect;
  139918. private _cachedDefines;
  139919. private _savedDepthWrite;
  139920. /**
  139921. * Instantiates a new outline renderer. (There could be only one per scene).
  139922. * @param scene Defines the scene it belongs to
  139923. */
  139924. constructor(scene: Scene);
  139925. /**
  139926. * Register the component to one instance of a scene.
  139927. */
  139928. register(): void;
  139929. /**
  139930. * Rebuilds the elements related to this component in case of
  139931. * context lost for instance.
  139932. */
  139933. rebuild(): void;
  139934. /**
  139935. * Disposes the component and the associated ressources.
  139936. */
  139937. dispose(): void;
  139938. /**
  139939. * Renders the outline in the canvas.
  139940. * @param subMesh Defines the sumesh to render
  139941. * @param batch Defines the batch of meshes in case of instances
  139942. * @param useOverlay Defines if the rendering is for the overlay or the outline
  139943. */
  139944. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  139945. /**
  139946. * Returns whether or not the outline renderer is ready for a given submesh.
  139947. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  139948. * @param subMesh Defines the submesh to check readyness for
  139949. * @param useInstances Defines wheter wee are trying to render instances or not
  139950. * @returns true if ready otherwise false
  139951. */
  139952. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139953. private _beforeRenderingMesh;
  139954. private _afterRenderingMesh;
  139955. }
  139956. }
  139957. declare module BABYLON {
  139958. /**
  139959. * Defines the basic options interface of a Sprite Frame Source Size.
  139960. */
  139961. export interface ISpriteJSONSpriteSourceSize {
  139962. /**
  139963. * number of the original width of the Frame
  139964. */
  139965. w: number;
  139966. /**
  139967. * number of the original height of the Frame
  139968. */
  139969. h: number;
  139970. }
  139971. /**
  139972. * Defines the basic options interface of a Sprite Frame Data.
  139973. */
  139974. export interface ISpriteJSONSpriteFrameData {
  139975. /**
  139976. * number of the x offset of the Frame
  139977. */
  139978. x: number;
  139979. /**
  139980. * number of the y offset of the Frame
  139981. */
  139982. y: number;
  139983. /**
  139984. * number of the width of the Frame
  139985. */
  139986. w: number;
  139987. /**
  139988. * number of the height of the Frame
  139989. */
  139990. h: number;
  139991. }
  139992. /**
  139993. * Defines the basic options interface of a JSON Sprite.
  139994. */
  139995. export interface ISpriteJSONSprite {
  139996. /**
  139997. * string name of the Frame
  139998. */
  139999. filename: string;
  140000. /**
  140001. * ISpriteJSONSpriteFrame basic object of the frame data
  140002. */
  140003. frame: ISpriteJSONSpriteFrameData;
  140004. /**
  140005. * boolean to flag is the frame was rotated.
  140006. */
  140007. rotated: boolean;
  140008. /**
  140009. * boolean to flag is the frame was trimmed.
  140010. */
  140011. trimmed: boolean;
  140012. /**
  140013. * ISpriteJSONSpriteFrame basic object of the source data
  140014. */
  140015. spriteSourceSize: ISpriteJSONSpriteFrameData;
  140016. /**
  140017. * ISpriteJSONSpriteFrame basic object of the source data
  140018. */
  140019. sourceSize: ISpriteJSONSpriteSourceSize;
  140020. }
  140021. /**
  140022. * Defines the basic options interface of a JSON atlas.
  140023. */
  140024. export interface ISpriteJSONAtlas {
  140025. /**
  140026. * Array of objects that contain the frame data.
  140027. */
  140028. frames: Array<ISpriteJSONSprite>;
  140029. /**
  140030. * object basic object containing the sprite meta data.
  140031. */
  140032. meta?: object;
  140033. }
  140034. }
  140035. declare module BABYLON {
  140036. /** @hidden */
  140037. export var spriteMapPixelShader: {
  140038. name: string;
  140039. shader: string;
  140040. };
  140041. }
  140042. declare module BABYLON {
  140043. /** @hidden */
  140044. export var spriteMapVertexShader: {
  140045. name: string;
  140046. shader: string;
  140047. };
  140048. }
  140049. declare module BABYLON {
  140050. /**
  140051. * Defines the basic options interface of a SpriteMap
  140052. */
  140053. export interface ISpriteMapOptions {
  140054. /**
  140055. * Vector2 of the number of cells in the grid.
  140056. */
  140057. stageSize?: Vector2;
  140058. /**
  140059. * Vector2 of the size of the output plane in World Units.
  140060. */
  140061. outputSize?: Vector2;
  140062. /**
  140063. * Vector3 of the position of the output plane in World Units.
  140064. */
  140065. outputPosition?: Vector3;
  140066. /**
  140067. * Vector3 of the rotation of the output plane.
  140068. */
  140069. outputRotation?: Vector3;
  140070. /**
  140071. * number of layers that the system will reserve in resources.
  140072. */
  140073. layerCount?: number;
  140074. /**
  140075. * number of max animation frames a single cell will reserve in resources.
  140076. */
  140077. maxAnimationFrames?: number;
  140078. /**
  140079. * number cell index of the base tile when the system compiles.
  140080. */
  140081. baseTile?: number;
  140082. /**
  140083. * boolean flip the sprite after its been repositioned by the framing data.
  140084. */
  140085. flipU?: boolean;
  140086. /**
  140087. * Vector3 scalar of the global RGB values of the SpriteMap.
  140088. */
  140089. colorMultiply?: Vector3;
  140090. }
  140091. /**
  140092. * Defines the IDisposable interface in order to be cleanable from resources.
  140093. */
  140094. export interface ISpriteMap extends IDisposable {
  140095. /**
  140096. * String name of the SpriteMap.
  140097. */
  140098. name: string;
  140099. /**
  140100. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  140101. */
  140102. atlasJSON: ISpriteJSONAtlas;
  140103. /**
  140104. * Texture of the SpriteMap.
  140105. */
  140106. spriteSheet: Texture;
  140107. /**
  140108. * The parameters to initialize the SpriteMap with.
  140109. */
  140110. options: ISpriteMapOptions;
  140111. }
  140112. /**
  140113. * Class used to manage a grid restricted sprite deployment on an Output plane.
  140114. */
  140115. export class SpriteMap implements ISpriteMap {
  140116. /** The Name of the spriteMap */
  140117. name: string;
  140118. /** The JSON file with the frame and meta data */
  140119. atlasJSON: ISpriteJSONAtlas;
  140120. /** The systems Sprite Sheet Texture */
  140121. spriteSheet: Texture;
  140122. /** Arguments passed with the Constructor */
  140123. options: ISpriteMapOptions;
  140124. /** Public Sprite Storage array, parsed from atlasJSON */
  140125. sprites: Array<ISpriteJSONSprite>;
  140126. /** Returns the Number of Sprites in the System */
  140127. get spriteCount(): number;
  140128. /** Returns the Position of Output Plane*/
  140129. get position(): Vector3;
  140130. /** Returns the Position of Output Plane*/
  140131. set position(v: Vector3);
  140132. /** Returns the Rotation of Output Plane*/
  140133. get rotation(): Vector3;
  140134. /** Returns the Rotation of Output Plane*/
  140135. set rotation(v: Vector3);
  140136. /** Sets the AnimationMap*/
  140137. get animationMap(): RawTexture;
  140138. /** Sets the AnimationMap*/
  140139. set animationMap(v: RawTexture);
  140140. /** Scene that the SpriteMap was created in */
  140141. private _scene;
  140142. /** Texture Buffer of Float32 that holds tile frame data*/
  140143. private _frameMap;
  140144. /** Texture Buffers of Float32 that holds tileMap data*/
  140145. private _tileMaps;
  140146. /** Texture Buffer of Float32 that holds Animation Data*/
  140147. private _animationMap;
  140148. /** Custom ShaderMaterial Central to the System*/
  140149. private _material;
  140150. /** Custom ShaderMaterial Central to the System*/
  140151. private _output;
  140152. /** Systems Time Ticker*/
  140153. private _time;
  140154. /**
  140155. * Creates a new SpriteMap
  140156. * @param name defines the SpriteMaps Name
  140157. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  140158. * @param spriteSheet is the Texture that the Sprites are on.
  140159. * @param options a basic deployment configuration
  140160. * @param scene The Scene that the map is deployed on
  140161. */
  140162. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  140163. /**
  140164. * Returns tileID location
  140165. * @returns Vector2 the cell position ID
  140166. */
  140167. getTileID(): Vector2;
  140168. /**
  140169. * Gets the UV location of the mouse over the SpriteMap.
  140170. * @returns Vector2 the UV position of the mouse interaction
  140171. */
  140172. getMousePosition(): Vector2;
  140173. /**
  140174. * Creates the "frame" texture Buffer
  140175. * -------------------------------------
  140176. * Structure of frames
  140177. * "filename": "Falling-Water-2.png",
  140178. * "frame": {"x":69,"y":103,"w":24,"h":32},
  140179. * "rotated": true,
  140180. * "trimmed": true,
  140181. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  140182. * "sourceSize": {"w":32,"h":32}
  140183. * @returns RawTexture of the frameMap
  140184. */
  140185. private _createFrameBuffer;
  140186. /**
  140187. * Creates the tileMap texture Buffer
  140188. * @param buffer normally and array of numbers, or a false to generate from scratch
  140189. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  140190. * @returns RawTexture of the tileMap
  140191. */
  140192. private _createTileBuffer;
  140193. /**
  140194. * Modifies the data of the tileMaps
  140195. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  140196. * @param pos is the iVector2 Coordinates of the Tile
  140197. * @param tile The SpriteIndex of the new Tile
  140198. */
  140199. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  140200. /**
  140201. * Creates the animationMap texture Buffer
  140202. * @param buffer normally and array of numbers, or a false to generate from scratch
  140203. * @returns RawTexture of the animationMap
  140204. */
  140205. private _createTileAnimationBuffer;
  140206. /**
  140207. * Modifies the data of the animationMap
  140208. * @param cellID is the Index of the Sprite
  140209. * @param _frame is the target Animation frame
  140210. * @param toCell is the Target Index of the next frame of the animation
  140211. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  140212. * @param speed is a global scalar of the time variable on the map.
  140213. */
  140214. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  140215. /**
  140216. * Exports the .tilemaps file
  140217. */
  140218. saveTileMaps(): void;
  140219. /**
  140220. * Imports the .tilemaps file
  140221. * @param url of the .tilemaps file
  140222. */
  140223. loadTileMaps(url: string): void;
  140224. /**
  140225. * Release associated resources
  140226. */
  140227. dispose(): void;
  140228. }
  140229. }
  140230. declare module BABYLON {
  140231. /**
  140232. * Class used to manage multiple sprites of different sizes on the same spritesheet
  140233. * @see http://doc.babylonjs.com/babylon101/sprites
  140234. */
  140235. export class SpritePackedManager extends SpriteManager {
  140236. /** defines the packed manager's name */
  140237. name: string;
  140238. /**
  140239. * Creates a new sprite manager from a packed sprite sheet
  140240. * @param name defines the manager's name
  140241. * @param imgUrl defines the sprite sheet url
  140242. * @param capacity defines the maximum allowed number of sprites
  140243. * @param scene defines the hosting scene
  140244. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  140245. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  140246. * @param samplingMode defines the smapling mode to use with spritesheet
  140247. * @param fromPacked set to true; do not alter
  140248. */
  140249. constructor(
  140250. /** defines the packed manager's name */
  140251. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  140252. }
  140253. }
  140254. declare module BABYLON {
  140255. /**
  140256. * Defines the list of states available for a task inside a AssetsManager
  140257. */
  140258. export enum AssetTaskState {
  140259. /**
  140260. * Initialization
  140261. */
  140262. INIT = 0,
  140263. /**
  140264. * Running
  140265. */
  140266. RUNNING = 1,
  140267. /**
  140268. * Done
  140269. */
  140270. DONE = 2,
  140271. /**
  140272. * Error
  140273. */
  140274. ERROR = 3
  140275. }
  140276. /**
  140277. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  140278. */
  140279. export abstract class AbstractAssetTask {
  140280. /**
  140281. * Task name
  140282. */ name: string;
  140283. /**
  140284. * Callback called when the task is successful
  140285. */
  140286. onSuccess: (task: any) => void;
  140287. /**
  140288. * Callback called when the task is not successful
  140289. */
  140290. onError: (task: any, message?: string, exception?: any) => void;
  140291. /**
  140292. * Creates a new AssetsManager
  140293. * @param name defines the name of the task
  140294. */
  140295. constructor(
  140296. /**
  140297. * Task name
  140298. */ name: string);
  140299. private _isCompleted;
  140300. private _taskState;
  140301. private _errorObject;
  140302. /**
  140303. * Get if the task is completed
  140304. */
  140305. get isCompleted(): boolean;
  140306. /**
  140307. * Gets the current state of the task
  140308. */
  140309. get taskState(): AssetTaskState;
  140310. /**
  140311. * Gets the current error object (if task is in error)
  140312. */
  140313. get errorObject(): {
  140314. message?: string;
  140315. exception?: any;
  140316. };
  140317. /**
  140318. * Internal only
  140319. * @hidden
  140320. */
  140321. _setErrorObject(message?: string, exception?: any): void;
  140322. /**
  140323. * Execute the current task
  140324. * @param scene defines the scene where you want your assets to be loaded
  140325. * @param onSuccess is a callback called when the task is successfully executed
  140326. * @param onError is a callback called if an error occurs
  140327. */
  140328. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140329. /**
  140330. * Execute the current task
  140331. * @param scene defines the scene where you want your assets to be loaded
  140332. * @param onSuccess is a callback called when the task is successfully executed
  140333. * @param onError is a callback called if an error occurs
  140334. */
  140335. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140336. /**
  140337. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  140338. * This can be used with failed tasks that have the reason for failure fixed.
  140339. */
  140340. reset(): void;
  140341. private onErrorCallback;
  140342. private onDoneCallback;
  140343. }
  140344. /**
  140345. * Define the interface used by progress events raised during assets loading
  140346. */
  140347. export interface IAssetsProgressEvent {
  140348. /**
  140349. * Defines the number of remaining tasks to process
  140350. */
  140351. remainingCount: number;
  140352. /**
  140353. * Defines the total number of tasks
  140354. */
  140355. totalCount: number;
  140356. /**
  140357. * Defines the task that was just processed
  140358. */
  140359. task: AbstractAssetTask;
  140360. }
  140361. /**
  140362. * Class used to share progress information about assets loading
  140363. */
  140364. export class AssetsProgressEvent implements IAssetsProgressEvent {
  140365. /**
  140366. * Defines the number of remaining tasks to process
  140367. */
  140368. remainingCount: number;
  140369. /**
  140370. * Defines the total number of tasks
  140371. */
  140372. totalCount: number;
  140373. /**
  140374. * Defines the task that was just processed
  140375. */
  140376. task: AbstractAssetTask;
  140377. /**
  140378. * Creates a AssetsProgressEvent
  140379. * @param remainingCount defines the number of remaining tasks to process
  140380. * @param totalCount defines the total number of tasks
  140381. * @param task defines the task that was just processed
  140382. */
  140383. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  140384. }
  140385. /**
  140386. * Define a task used by AssetsManager to load meshes
  140387. */
  140388. export class MeshAssetTask extends AbstractAssetTask {
  140389. /**
  140390. * Defines the name of the task
  140391. */
  140392. name: string;
  140393. /**
  140394. * Defines the list of mesh's names you want to load
  140395. */
  140396. meshesNames: any;
  140397. /**
  140398. * Defines the root url to use as a base to load your meshes and associated resources
  140399. */
  140400. rootUrl: string;
  140401. /**
  140402. * Defines the filename of the scene to load from
  140403. */
  140404. sceneFilename: string;
  140405. /**
  140406. * Gets the list of loaded meshes
  140407. */
  140408. loadedMeshes: Array<AbstractMesh>;
  140409. /**
  140410. * Gets the list of loaded particle systems
  140411. */
  140412. loadedParticleSystems: Array<IParticleSystem>;
  140413. /**
  140414. * Gets the list of loaded skeletons
  140415. */
  140416. loadedSkeletons: Array<Skeleton>;
  140417. /**
  140418. * Gets the list of loaded animation groups
  140419. */
  140420. loadedAnimationGroups: Array<AnimationGroup>;
  140421. /**
  140422. * Callback called when the task is successful
  140423. */
  140424. onSuccess: (task: MeshAssetTask) => void;
  140425. /**
  140426. * Callback called when the task is successful
  140427. */
  140428. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  140429. /**
  140430. * Creates a new MeshAssetTask
  140431. * @param name defines the name of the task
  140432. * @param meshesNames defines the list of mesh's names you want to load
  140433. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  140434. * @param sceneFilename defines the filename of the scene to load from
  140435. */
  140436. constructor(
  140437. /**
  140438. * Defines the name of the task
  140439. */
  140440. name: string,
  140441. /**
  140442. * Defines the list of mesh's names you want to load
  140443. */
  140444. meshesNames: any,
  140445. /**
  140446. * Defines the root url to use as a base to load your meshes and associated resources
  140447. */
  140448. rootUrl: string,
  140449. /**
  140450. * Defines the filename of the scene to load from
  140451. */
  140452. sceneFilename: string);
  140453. /**
  140454. * Execute the current task
  140455. * @param scene defines the scene where you want your assets to be loaded
  140456. * @param onSuccess is a callback called when the task is successfully executed
  140457. * @param onError is a callback called if an error occurs
  140458. */
  140459. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140460. }
  140461. /**
  140462. * Define a task used by AssetsManager to load text content
  140463. */
  140464. export class TextFileAssetTask extends AbstractAssetTask {
  140465. /**
  140466. * Defines the name of the task
  140467. */
  140468. name: string;
  140469. /**
  140470. * Defines the location of the file to load
  140471. */
  140472. url: string;
  140473. /**
  140474. * Gets the loaded text string
  140475. */
  140476. text: string;
  140477. /**
  140478. * Callback called when the task is successful
  140479. */
  140480. onSuccess: (task: TextFileAssetTask) => void;
  140481. /**
  140482. * Callback called when the task is successful
  140483. */
  140484. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  140485. /**
  140486. * Creates a new TextFileAssetTask object
  140487. * @param name defines the name of the task
  140488. * @param url defines the location of the file to load
  140489. */
  140490. constructor(
  140491. /**
  140492. * Defines the name of the task
  140493. */
  140494. name: string,
  140495. /**
  140496. * Defines the location of the file to load
  140497. */
  140498. url: string);
  140499. /**
  140500. * Execute the current task
  140501. * @param scene defines the scene where you want your assets to be loaded
  140502. * @param onSuccess is a callback called when the task is successfully executed
  140503. * @param onError is a callback called if an error occurs
  140504. */
  140505. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140506. }
  140507. /**
  140508. * Define a task used by AssetsManager to load binary data
  140509. */
  140510. export class BinaryFileAssetTask extends AbstractAssetTask {
  140511. /**
  140512. * Defines the name of the task
  140513. */
  140514. name: string;
  140515. /**
  140516. * Defines the location of the file to load
  140517. */
  140518. url: string;
  140519. /**
  140520. * Gets the lodaded data (as an array buffer)
  140521. */
  140522. data: ArrayBuffer;
  140523. /**
  140524. * Callback called when the task is successful
  140525. */
  140526. onSuccess: (task: BinaryFileAssetTask) => void;
  140527. /**
  140528. * Callback called when the task is successful
  140529. */
  140530. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  140531. /**
  140532. * Creates a new BinaryFileAssetTask object
  140533. * @param name defines the name of the new task
  140534. * @param url defines the location of the file to load
  140535. */
  140536. constructor(
  140537. /**
  140538. * Defines the name of the task
  140539. */
  140540. name: string,
  140541. /**
  140542. * Defines the location of the file to load
  140543. */
  140544. url: string);
  140545. /**
  140546. * Execute the current task
  140547. * @param scene defines the scene where you want your assets to be loaded
  140548. * @param onSuccess is a callback called when the task is successfully executed
  140549. * @param onError is a callback called if an error occurs
  140550. */
  140551. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140552. }
  140553. /**
  140554. * Define a task used by AssetsManager to load images
  140555. */
  140556. export class ImageAssetTask extends AbstractAssetTask {
  140557. /**
  140558. * Defines the name of the task
  140559. */
  140560. name: string;
  140561. /**
  140562. * Defines the location of the image to load
  140563. */
  140564. url: string;
  140565. /**
  140566. * Gets the loaded images
  140567. */
  140568. image: HTMLImageElement;
  140569. /**
  140570. * Callback called when the task is successful
  140571. */
  140572. onSuccess: (task: ImageAssetTask) => void;
  140573. /**
  140574. * Callback called when the task is successful
  140575. */
  140576. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  140577. /**
  140578. * Creates a new ImageAssetTask
  140579. * @param name defines the name of the task
  140580. * @param url defines the location of the image to load
  140581. */
  140582. constructor(
  140583. /**
  140584. * Defines the name of the task
  140585. */
  140586. name: string,
  140587. /**
  140588. * Defines the location of the image to load
  140589. */
  140590. url: string);
  140591. /**
  140592. * Execute the current task
  140593. * @param scene defines the scene where you want your assets to be loaded
  140594. * @param onSuccess is a callback called when the task is successfully executed
  140595. * @param onError is a callback called if an error occurs
  140596. */
  140597. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140598. }
  140599. /**
  140600. * Defines the interface used by texture loading tasks
  140601. */
  140602. export interface ITextureAssetTask<TEX extends BaseTexture> {
  140603. /**
  140604. * Gets the loaded texture
  140605. */
  140606. texture: TEX;
  140607. }
  140608. /**
  140609. * Define a task used by AssetsManager to load 2D textures
  140610. */
  140611. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  140612. /**
  140613. * Defines the name of the task
  140614. */
  140615. name: string;
  140616. /**
  140617. * Defines the location of the file to load
  140618. */
  140619. url: string;
  140620. /**
  140621. * Defines if mipmap should not be generated (default is false)
  140622. */
  140623. noMipmap?: boolean | undefined;
  140624. /**
  140625. * Defines if texture must be inverted on Y axis (default is false)
  140626. */
  140627. invertY?: boolean | undefined;
  140628. /**
  140629. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140630. */
  140631. samplingMode: number;
  140632. /**
  140633. * Gets the loaded texture
  140634. */
  140635. texture: Texture;
  140636. /**
  140637. * Callback called when the task is successful
  140638. */
  140639. onSuccess: (task: TextureAssetTask) => void;
  140640. /**
  140641. * Callback called when the task is successful
  140642. */
  140643. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  140644. /**
  140645. * Creates a new TextureAssetTask object
  140646. * @param name defines the name of the task
  140647. * @param url defines the location of the file to load
  140648. * @param noMipmap defines if mipmap should not be generated (default is false)
  140649. * @param invertY defines if texture must be inverted on Y axis (default is false)
  140650. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140651. */
  140652. constructor(
  140653. /**
  140654. * Defines the name of the task
  140655. */
  140656. name: string,
  140657. /**
  140658. * Defines the location of the file to load
  140659. */
  140660. url: string,
  140661. /**
  140662. * Defines if mipmap should not be generated (default is false)
  140663. */
  140664. noMipmap?: boolean | undefined,
  140665. /**
  140666. * Defines if texture must be inverted on Y axis (default is false)
  140667. */
  140668. invertY?: boolean | undefined,
  140669. /**
  140670. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140671. */
  140672. samplingMode?: number);
  140673. /**
  140674. * Execute the current task
  140675. * @param scene defines the scene where you want your assets to be loaded
  140676. * @param onSuccess is a callback called when the task is successfully executed
  140677. * @param onError is a callback called if an error occurs
  140678. */
  140679. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140680. }
  140681. /**
  140682. * Define a task used by AssetsManager to load cube textures
  140683. */
  140684. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  140685. /**
  140686. * Defines the name of the task
  140687. */
  140688. name: string;
  140689. /**
  140690. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140691. */
  140692. url: string;
  140693. /**
  140694. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140695. */
  140696. extensions?: string[] | undefined;
  140697. /**
  140698. * Defines if mipmaps should not be generated (default is false)
  140699. */
  140700. noMipmap?: boolean | undefined;
  140701. /**
  140702. * Defines the explicit list of files (undefined by default)
  140703. */
  140704. files?: string[] | undefined;
  140705. /**
  140706. * Gets the loaded texture
  140707. */
  140708. texture: CubeTexture;
  140709. /**
  140710. * Callback called when the task is successful
  140711. */
  140712. onSuccess: (task: CubeTextureAssetTask) => void;
  140713. /**
  140714. * Callback called when the task is successful
  140715. */
  140716. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  140717. /**
  140718. * Creates a new CubeTextureAssetTask
  140719. * @param name defines the name of the task
  140720. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140721. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140722. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140723. * @param files defines the explicit list of files (undefined by default)
  140724. */
  140725. constructor(
  140726. /**
  140727. * Defines the name of the task
  140728. */
  140729. name: string,
  140730. /**
  140731. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140732. */
  140733. url: string,
  140734. /**
  140735. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140736. */
  140737. extensions?: string[] | undefined,
  140738. /**
  140739. * Defines if mipmaps should not be generated (default is false)
  140740. */
  140741. noMipmap?: boolean | undefined,
  140742. /**
  140743. * Defines the explicit list of files (undefined by default)
  140744. */
  140745. files?: string[] | undefined);
  140746. /**
  140747. * Execute the current task
  140748. * @param scene defines the scene where you want your assets to be loaded
  140749. * @param onSuccess is a callback called when the task is successfully executed
  140750. * @param onError is a callback called if an error occurs
  140751. */
  140752. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140753. }
  140754. /**
  140755. * Define a task used by AssetsManager to load HDR cube textures
  140756. */
  140757. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  140758. /**
  140759. * Defines the name of the task
  140760. */
  140761. name: string;
  140762. /**
  140763. * Defines the location of the file to load
  140764. */
  140765. url: string;
  140766. /**
  140767. * Defines the desired size (the more it increases the longer the generation will be)
  140768. */
  140769. size: number;
  140770. /**
  140771. * Defines if mipmaps should not be generated (default is false)
  140772. */
  140773. noMipmap: boolean;
  140774. /**
  140775. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140776. */
  140777. generateHarmonics: boolean;
  140778. /**
  140779. * 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)
  140780. */
  140781. gammaSpace: boolean;
  140782. /**
  140783. * Internal Use Only
  140784. */
  140785. reserved: boolean;
  140786. /**
  140787. * Gets the loaded texture
  140788. */
  140789. texture: HDRCubeTexture;
  140790. /**
  140791. * Callback called when the task is successful
  140792. */
  140793. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  140794. /**
  140795. * Callback called when the task is successful
  140796. */
  140797. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  140798. /**
  140799. * Creates a new HDRCubeTextureAssetTask object
  140800. * @param name defines the name of the task
  140801. * @param url defines the location of the file to load
  140802. * @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.
  140803. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140804. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140805. * @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)
  140806. * @param reserved Internal use only
  140807. */
  140808. constructor(
  140809. /**
  140810. * Defines the name of the task
  140811. */
  140812. name: string,
  140813. /**
  140814. * Defines the location of the file to load
  140815. */
  140816. url: string,
  140817. /**
  140818. * Defines the desired size (the more it increases the longer the generation will be)
  140819. */
  140820. size: number,
  140821. /**
  140822. * Defines if mipmaps should not be generated (default is false)
  140823. */
  140824. noMipmap?: boolean,
  140825. /**
  140826. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140827. */
  140828. generateHarmonics?: boolean,
  140829. /**
  140830. * 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)
  140831. */
  140832. gammaSpace?: boolean,
  140833. /**
  140834. * Internal Use Only
  140835. */
  140836. reserved?: boolean);
  140837. /**
  140838. * Execute the current task
  140839. * @param scene defines the scene where you want your assets to be loaded
  140840. * @param onSuccess is a callback called when the task is successfully executed
  140841. * @param onError is a callback called if an error occurs
  140842. */
  140843. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140844. }
  140845. /**
  140846. * Define a task used by AssetsManager to load Equirectangular cube textures
  140847. */
  140848. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  140849. /**
  140850. * Defines the name of the task
  140851. */
  140852. name: string;
  140853. /**
  140854. * Defines the location of the file to load
  140855. */
  140856. url: string;
  140857. /**
  140858. * Defines the desired size (the more it increases the longer the generation will be)
  140859. */
  140860. size: number;
  140861. /**
  140862. * Defines if mipmaps should not be generated (default is false)
  140863. */
  140864. noMipmap: boolean;
  140865. /**
  140866. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140867. * but the standard material would require them in Gamma space) (default is true)
  140868. */
  140869. gammaSpace: boolean;
  140870. /**
  140871. * Gets the loaded texture
  140872. */
  140873. texture: EquiRectangularCubeTexture;
  140874. /**
  140875. * Callback called when the task is successful
  140876. */
  140877. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  140878. /**
  140879. * Callback called when the task is successful
  140880. */
  140881. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  140882. /**
  140883. * Creates a new EquiRectangularCubeTextureAssetTask object
  140884. * @param name defines the name of the task
  140885. * @param url defines the location of the file to load
  140886. * @param size defines the desired size (the more it increases the longer the generation will be)
  140887. * If the size is omitted this implies you are using a preprocessed cubemap.
  140888. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140889. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  140890. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  140891. * (default is true)
  140892. */
  140893. constructor(
  140894. /**
  140895. * Defines the name of the task
  140896. */
  140897. name: string,
  140898. /**
  140899. * Defines the location of the file to load
  140900. */
  140901. url: string,
  140902. /**
  140903. * Defines the desired size (the more it increases the longer the generation will be)
  140904. */
  140905. size: number,
  140906. /**
  140907. * Defines if mipmaps should not be generated (default is false)
  140908. */
  140909. noMipmap?: boolean,
  140910. /**
  140911. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140912. * but the standard material would require them in Gamma space) (default is true)
  140913. */
  140914. gammaSpace?: boolean);
  140915. /**
  140916. * Execute the current task
  140917. * @param scene defines the scene where you want your assets to be loaded
  140918. * @param onSuccess is a callback called when the task is successfully executed
  140919. * @param onError is a callback called if an error occurs
  140920. */
  140921. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140922. }
  140923. /**
  140924. * This class can be used to easily import assets into a scene
  140925. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  140926. */
  140927. export class AssetsManager {
  140928. private _scene;
  140929. private _isLoading;
  140930. protected _tasks: AbstractAssetTask[];
  140931. protected _waitingTasksCount: number;
  140932. protected _totalTasksCount: number;
  140933. /**
  140934. * Callback called when all tasks are processed
  140935. */
  140936. onFinish: (tasks: AbstractAssetTask[]) => void;
  140937. /**
  140938. * Callback called when a task is successful
  140939. */
  140940. onTaskSuccess: (task: AbstractAssetTask) => void;
  140941. /**
  140942. * Callback called when a task had an error
  140943. */
  140944. onTaskError: (task: AbstractAssetTask) => void;
  140945. /**
  140946. * Callback called when a task is done (whatever the result is)
  140947. */
  140948. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  140949. /**
  140950. * Observable called when all tasks are processed
  140951. */
  140952. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  140953. /**
  140954. * Observable called when a task had an error
  140955. */
  140956. onTaskErrorObservable: Observable<AbstractAssetTask>;
  140957. /**
  140958. * Observable called when all tasks were executed
  140959. */
  140960. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  140961. /**
  140962. * Observable called when a task is done (whatever the result is)
  140963. */
  140964. onProgressObservable: Observable<IAssetsProgressEvent>;
  140965. /**
  140966. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  140967. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  140968. */
  140969. useDefaultLoadingScreen: boolean;
  140970. /**
  140971. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  140972. * when all assets have been downloaded.
  140973. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  140974. */
  140975. autoHideLoadingUI: boolean;
  140976. /**
  140977. * Creates a new AssetsManager
  140978. * @param scene defines the scene to work on
  140979. */
  140980. constructor(scene: Scene);
  140981. /**
  140982. * Add a MeshAssetTask to the list of active tasks
  140983. * @param taskName defines the name of the new task
  140984. * @param meshesNames defines the name of meshes to load
  140985. * @param rootUrl defines the root url to use to locate files
  140986. * @param sceneFilename defines the filename of the scene file
  140987. * @returns a new MeshAssetTask object
  140988. */
  140989. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  140990. /**
  140991. * Add a TextFileAssetTask to the list of active tasks
  140992. * @param taskName defines the name of the new task
  140993. * @param url defines the url of the file to load
  140994. * @returns a new TextFileAssetTask object
  140995. */
  140996. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  140997. /**
  140998. * Add a BinaryFileAssetTask to the list of active tasks
  140999. * @param taskName defines the name of the new task
  141000. * @param url defines the url of the file to load
  141001. * @returns a new BinaryFileAssetTask object
  141002. */
  141003. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  141004. /**
  141005. * Add a ImageAssetTask to the list of active tasks
  141006. * @param taskName defines the name of the new task
  141007. * @param url defines the url of the file to load
  141008. * @returns a new ImageAssetTask object
  141009. */
  141010. addImageTask(taskName: string, url: string): ImageAssetTask;
  141011. /**
  141012. * Add a TextureAssetTask to the list of active tasks
  141013. * @param taskName defines the name of the new task
  141014. * @param url defines the url of the file to load
  141015. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141016. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  141017. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141018. * @returns a new TextureAssetTask object
  141019. */
  141020. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  141021. /**
  141022. * Add a CubeTextureAssetTask to the list of active tasks
  141023. * @param taskName defines the name of the new task
  141024. * @param url defines the url of the file to load
  141025. * @param extensions defines the extension to use to load the cube map (can be null)
  141026. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141027. * @param files defines the list of files to load (can be null)
  141028. * @returns a new CubeTextureAssetTask object
  141029. */
  141030. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  141031. /**
  141032. *
  141033. * Add a HDRCubeTextureAssetTask to the list of active tasks
  141034. * @param taskName defines the name of the new task
  141035. * @param url defines the url of the file to load
  141036. * @param size defines the size you want for the cubemap (can be null)
  141037. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141038. * @param generateHarmonics defines if you want to automatically generate (true by default)
  141039. * @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)
  141040. * @param reserved Internal use only
  141041. * @returns a new HDRCubeTextureAssetTask object
  141042. */
  141043. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  141044. /**
  141045. *
  141046. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  141047. * @param taskName defines the name of the new task
  141048. * @param url defines the url of the file to load
  141049. * @param size defines the size you want for the cubemap (can be null)
  141050. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141051. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141052. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141053. * @returns a new EquiRectangularCubeTextureAssetTask object
  141054. */
  141055. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  141056. /**
  141057. * Remove a task from the assets manager.
  141058. * @param task the task to remove
  141059. */
  141060. removeTask(task: AbstractAssetTask): void;
  141061. private _decreaseWaitingTasksCount;
  141062. private _runTask;
  141063. /**
  141064. * Reset the AssetsManager and remove all tasks
  141065. * @return the current instance of the AssetsManager
  141066. */
  141067. reset(): AssetsManager;
  141068. /**
  141069. * Start the loading process
  141070. * @return the current instance of the AssetsManager
  141071. */
  141072. load(): AssetsManager;
  141073. /**
  141074. * Start the loading process as an async operation
  141075. * @return a promise returning the list of failed tasks
  141076. */
  141077. loadAsync(): Promise<void>;
  141078. }
  141079. }
  141080. declare module BABYLON {
  141081. /**
  141082. * Wrapper class for promise with external resolve and reject.
  141083. */
  141084. export class Deferred<T> {
  141085. /**
  141086. * The promise associated with this deferred object.
  141087. */
  141088. readonly promise: Promise<T>;
  141089. private _resolve;
  141090. private _reject;
  141091. /**
  141092. * The resolve method of the promise associated with this deferred object.
  141093. */
  141094. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  141095. /**
  141096. * The reject method of the promise associated with this deferred object.
  141097. */
  141098. get reject(): (reason?: any) => void;
  141099. /**
  141100. * Constructor for this deferred object.
  141101. */
  141102. constructor();
  141103. }
  141104. }
  141105. declare module BABYLON {
  141106. /**
  141107. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  141108. */
  141109. export class MeshExploder {
  141110. private _centerMesh;
  141111. private _meshes;
  141112. private _meshesOrigins;
  141113. private _toCenterVectors;
  141114. private _scaledDirection;
  141115. private _newPosition;
  141116. private _centerPosition;
  141117. /**
  141118. * Explodes meshes from a center mesh.
  141119. * @param meshes The meshes to explode.
  141120. * @param centerMesh The mesh to be center of explosion.
  141121. */
  141122. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  141123. private _setCenterMesh;
  141124. /**
  141125. * Get class name
  141126. * @returns "MeshExploder"
  141127. */
  141128. getClassName(): string;
  141129. /**
  141130. * "Exploded meshes"
  141131. * @returns Array of meshes with the centerMesh at index 0.
  141132. */
  141133. getMeshes(): Array<Mesh>;
  141134. /**
  141135. * Explodes meshes giving a specific direction
  141136. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  141137. */
  141138. explode(direction?: number): void;
  141139. }
  141140. }
  141141. declare module BABYLON {
  141142. /**
  141143. * Class used to help managing file picking and drag'n'drop
  141144. */
  141145. export class FilesInput {
  141146. /**
  141147. * List of files ready to be loaded
  141148. */
  141149. static get FilesToLoad(): {
  141150. [key: string]: File;
  141151. };
  141152. /**
  141153. * Callback called when a file is processed
  141154. */
  141155. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  141156. private _engine;
  141157. private _currentScene;
  141158. private _sceneLoadedCallback;
  141159. private _progressCallback;
  141160. private _additionalRenderLoopLogicCallback;
  141161. private _textureLoadingCallback;
  141162. private _startingProcessingFilesCallback;
  141163. private _onReloadCallback;
  141164. private _errorCallback;
  141165. private _elementToMonitor;
  141166. private _sceneFileToLoad;
  141167. private _filesToLoad;
  141168. /**
  141169. * Creates a new FilesInput
  141170. * @param engine defines the rendering engine
  141171. * @param scene defines the hosting scene
  141172. * @param sceneLoadedCallback callback called when scene is loaded
  141173. * @param progressCallback callback called to track progress
  141174. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  141175. * @param textureLoadingCallback callback called when a texture is loading
  141176. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  141177. * @param onReloadCallback callback called when a reload is requested
  141178. * @param errorCallback callback call if an error occurs
  141179. */
  141180. 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);
  141181. private _dragEnterHandler;
  141182. private _dragOverHandler;
  141183. private _dropHandler;
  141184. /**
  141185. * Calls this function to listen to drag'n'drop events on a specific DOM element
  141186. * @param elementToMonitor defines the DOM element to track
  141187. */
  141188. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  141189. /**
  141190. * Release all associated resources
  141191. */
  141192. dispose(): void;
  141193. private renderFunction;
  141194. private drag;
  141195. private drop;
  141196. private _traverseFolder;
  141197. private _processFiles;
  141198. /**
  141199. * Load files from a drop event
  141200. * @param event defines the drop event to use as source
  141201. */
  141202. loadFiles(event: any): void;
  141203. private _processReload;
  141204. /**
  141205. * Reload the current scene from the loaded files
  141206. */
  141207. reload(): void;
  141208. }
  141209. }
  141210. declare module BABYLON {
  141211. /**
  141212. * Defines the root class used to create scene optimization to use with SceneOptimizer
  141213. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141214. */
  141215. export class SceneOptimization {
  141216. /**
  141217. * Defines the priority of this optimization (0 by default which means first in the list)
  141218. */
  141219. priority: number;
  141220. /**
  141221. * Gets a string describing the action executed by the current optimization
  141222. * @returns description string
  141223. */
  141224. getDescription(): string;
  141225. /**
  141226. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141227. * @param scene defines the current scene where to apply this optimization
  141228. * @param optimizer defines the current optimizer
  141229. * @returns true if everything that can be done was applied
  141230. */
  141231. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141232. /**
  141233. * Creates the SceneOptimization object
  141234. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141235. * @param desc defines the description associated with the optimization
  141236. */
  141237. constructor(
  141238. /**
  141239. * Defines the priority of this optimization (0 by default which means first in the list)
  141240. */
  141241. priority?: number);
  141242. }
  141243. /**
  141244. * Defines an optimization used to reduce the size of render target textures
  141245. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141246. */
  141247. export class TextureOptimization extends SceneOptimization {
  141248. /**
  141249. * Defines the priority of this optimization (0 by default which means first in the list)
  141250. */
  141251. priority: number;
  141252. /**
  141253. * 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
  141254. */
  141255. maximumSize: number;
  141256. /**
  141257. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141258. */
  141259. step: number;
  141260. /**
  141261. * Gets a string describing the action executed by the current optimization
  141262. * @returns description string
  141263. */
  141264. getDescription(): string;
  141265. /**
  141266. * Creates the TextureOptimization object
  141267. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141268. * @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
  141269. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141270. */
  141271. constructor(
  141272. /**
  141273. * Defines the priority of this optimization (0 by default which means first in the list)
  141274. */
  141275. priority?: number,
  141276. /**
  141277. * 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
  141278. */
  141279. maximumSize?: number,
  141280. /**
  141281. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141282. */
  141283. step?: number);
  141284. /**
  141285. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141286. * @param scene defines the current scene where to apply this optimization
  141287. * @param optimizer defines the current optimizer
  141288. * @returns true if everything that can be done was applied
  141289. */
  141290. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141291. }
  141292. /**
  141293. * Defines an optimization used to increase or decrease the rendering resolution
  141294. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141295. */
  141296. export class HardwareScalingOptimization extends SceneOptimization {
  141297. /**
  141298. * Defines the priority of this optimization (0 by default which means first in the list)
  141299. */
  141300. priority: number;
  141301. /**
  141302. * Defines the maximum scale to use (2 by default)
  141303. */
  141304. maximumScale: number;
  141305. /**
  141306. * Defines the step to use between two passes (0.5 by default)
  141307. */
  141308. step: number;
  141309. private _currentScale;
  141310. private _directionOffset;
  141311. /**
  141312. * Gets a string describing the action executed by the current optimization
  141313. * @return description string
  141314. */
  141315. getDescription(): string;
  141316. /**
  141317. * Creates the HardwareScalingOptimization object
  141318. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141319. * @param maximumScale defines the maximum scale to use (2 by default)
  141320. * @param step defines the step to use between two passes (0.5 by default)
  141321. */
  141322. constructor(
  141323. /**
  141324. * Defines the priority of this optimization (0 by default which means first in the list)
  141325. */
  141326. priority?: number,
  141327. /**
  141328. * Defines the maximum scale to use (2 by default)
  141329. */
  141330. maximumScale?: number,
  141331. /**
  141332. * Defines the step to use between two passes (0.5 by default)
  141333. */
  141334. step?: number);
  141335. /**
  141336. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141337. * @param scene defines the current scene where to apply this optimization
  141338. * @param optimizer defines the current optimizer
  141339. * @returns true if everything that can be done was applied
  141340. */
  141341. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141342. }
  141343. /**
  141344. * Defines an optimization used to remove shadows
  141345. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141346. */
  141347. export class ShadowsOptimization extends SceneOptimization {
  141348. /**
  141349. * Gets a string describing the action executed by the current optimization
  141350. * @return description string
  141351. */
  141352. getDescription(): string;
  141353. /**
  141354. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141355. * @param scene defines the current scene where to apply this optimization
  141356. * @param optimizer defines the current optimizer
  141357. * @returns true if everything that can be done was applied
  141358. */
  141359. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141360. }
  141361. /**
  141362. * Defines an optimization used to turn post-processes off
  141363. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141364. */
  141365. export class PostProcessesOptimization extends SceneOptimization {
  141366. /**
  141367. * Gets a string describing the action executed by the current optimization
  141368. * @return description string
  141369. */
  141370. getDescription(): string;
  141371. /**
  141372. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141373. * @param scene defines the current scene where to apply this optimization
  141374. * @param optimizer defines the current optimizer
  141375. * @returns true if everything that can be done was applied
  141376. */
  141377. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141378. }
  141379. /**
  141380. * Defines an optimization used to turn lens flares off
  141381. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141382. */
  141383. export class LensFlaresOptimization extends SceneOptimization {
  141384. /**
  141385. * Gets a string describing the action executed by the current optimization
  141386. * @return description string
  141387. */
  141388. getDescription(): string;
  141389. /**
  141390. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141391. * @param scene defines the current scene where to apply this optimization
  141392. * @param optimizer defines the current optimizer
  141393. * @returns true if everything that can be done was applied
  141394. */
  141395. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141396. }
  141397. /**
  141398. * Defines an optimization based on user defined callback.
  141399. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141400. */
  141401. export class CustomOptimization extends SceneOptimization {
  141402. /**
  141403. * Callback called to apply the custom optimization.
  141404. */
  141405. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  141406. /**
  141407. * Callback called to get custom description
  141408. */
  141409. onGetDescription: () => string;
  141410. /**
  141411. * Gets a string describing the action executed by the current optimization
  141412. * @returns description string
  141413. */
  141414. getDescription(): string;
  141415. /**
  141416. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141417. * @param scene defines the current scene where to apply this optimization
  141418. * @param optimizer defines the current optimizer
  141419. * @returns true if everything that can be done was applied
  141420. */
  141421. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141422. }
  141423. /**
  141424. * Defines an optimization used to turn particles off
  141425. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141426. */
  141427. export class ParticlesOptimization extends SceneOptimization {
  141428. /**
  141429. * Gets a string describing the action executed by the current optimization
  141430. * @return description string
  141431. */
  141432. getDescription(): string;
  141433. /**
  141434. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141435. * @param scene defines the current scene where to apply this optimization
  141436. * @param optimizer defines the current optimizer
  141437. * @returns true if everything that can be done was applied
  141438. */
  141439. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141440. }
  141441. /**
  141442. * Defines an optimization used to turn render targets off
  141443. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141444. */
  141445. export class RenderTargetsOptimization extends SceneOptimization {
  141446. /**
  141447. * Gets a string describing the action executed by the current optimization
  141448. * @return description string
  141449. */
  141450. getDescription(): string;
  141451. /**
  141452. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141453. * @param scene defines the current scene where to apply this optimization
  141454. * @param optimizer defines the current optimizer
  141455. * @returns true if everything that can be done was applied
  141456. */
  141457. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141458. }
  141459. /**
  141460. * Defines an optimization used to merge meshes with compatible materials
  141461. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141462. */
  141463. export class MergeMeshesOptimization extends SceneOptimization {
  141464. private static _UpdateSelectionTree;
  141465. /**
  141466. * Gets or sets a boolean which defines if optimization octree has to be updated
  141467. */
  141468. static get UpdateSelectionTree(): boolean;
  141469. /**
  141470. * Gets or sets a boolean which defines if optimization octree has to be updated
  141471. */
  141472. static set UpdateSelectionTree(value: boolean);
  141473. /**
  141474. * Gets a string describing the action executed by the current optimization
  141475. * @return description string
  141476. */
  141477. getDescription(): string;
  141478. private _canBeMerged;
  141479. /**
  141480. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141481. * @param scene defines the current scene where to apply this optimization
  141482. * @param optimizer defines the current optimizer
  141483. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  141484. * @returns true if everything that can be done was applied
  141485. */
  141486. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  141487. }
  141488. /**
  141489. * Defines a list of options used by SceneOptimizer
  141490. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141491. */
  141492. export class SceneOptimizerOptions {
  141493. /**
  141494. * Defines the target frame rate to reach (60 by default)
  141495. */
  141496. targetFrameRate: number;
  141497. /**
  141498. * Defines the interval between two checkes (2000ms by default)
  141499. */
  141500. trackerDuration: number;
  141501. /**
  141502. * Gets the list of optimizations to apply
  141503. */
  141504. optimizations: SceneOptimization[];
  141505. /**
  141506. * Creates a new list of options used by SceneOptimizer
  141507. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  141508. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  141509. */
  141510. constructor(
  141511. /**
  141512. * Defines the target frame rate to reach (60 by default)
  141513. */
  141514. targetFrameRate?: number,
  141515. /**
  141516. * Defines the interval between two checkes (2000ms by default)
  141517. */
  141518. trackerDuration?: number);
  141519. /**
  141520. * Add a new optimization
  141521. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  141522. * @returns the current SceneOptimizerOptions
  141523. */
  141524. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  141525. /**
  141526. * Add a new custom optimization
  141527. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  141528. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  141529. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141530. * @returns the current SceneOptimizerOptions
  141531. */
  141532. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  141533. /**
  141534. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  141535. * @param targetFrameRate defines the target frame rate (60 by default)
  141536. * @returns a SceneOptimizerOptions object
  141537. */
  141538. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141539. /**
  141540. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  141541. * @param targetFrameRate defines the target frame rate (60 by default)
  141542. * @returns a SceneOptimizerOptions object
  141543. */
  141544. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141545. /**
  141546. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  141547. * @param targetFrameRate defines the target frame rate (60 by default)
  141548. * @returns a SceneOptimizerOptions object
  141549. */
  141550. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141551. }
  141552. /**
  141553. * Class used to run optimizations in order to reach a target frame rate
  141554. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141555. */
  141556. export class SceneOptimizer implements IDisposable {
  141557. private _isRunning;
  141558. private _options;
  141559. private _scene;
  141560. private _currentPriorityLevel;
  141561. private _targetFrameRate;
  141562. private _trackerDuration;
  141563. private _currentFrameRate;
  141564. private _sceneDisposeObserver;
  141565. private _improvementMode;
  141566. /**
  141567. * Defines an observable called when the optimizer reaches the target frame rate
  141568. */
  141569. onSuccessObservable: Observable<SceneOptimizer>;
  141570. /**
  141571. * Defines an observable called when the optimizer enables an optimization
  141572. */
  141573. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  141574. /**
  141575. * Defines an observable called when the optimizer is not able to reach the target frame rate
  141576. */
  141577. onFailureObservable: Observable<SceneOptimizer>;
  141578. /**
  141579. * Gets a boolean indicating if the optimizer is in improvement mode
  141580. */
  141581. get isInImprovementMode(): boolean;
  141582. /**
  141583. * Gets the current priority level (0 at start)
  141584. */
  141585. get currentPriorityLevel(): number;
  141586. /**
  141587. * Gets the current frame rate checked by the SceneOptimizer
  141588. */
  141589. get currentFrameRate(): number;
  141590. /**
  141591. * Gets or sets the current target frame rate (60 by default)
  141592. */
  141593. get targetFrameRate(): number;
  141594. /**
  141595. * Gets or sets the current target frame rate (60 by default)
  141596. */
  141597. set targetFrameRate(value: number);
  141598. /**
  141599. * Gets or sets the current interval between two checks (every 2000ms by default)
  141600. */
  141601. get trackerDuration(): number;
  141602. /**
  141603. * Gets or sets the current interval between two checks (every 2000ms by default)
  141604. */
  141605. set trackerDuration(value: number);
  141606. /**
  141607. * Gets the list of active optimizations
  141608. */
  141609. get optimizations(): SceneOptimization[];
  141610. /**
  141611. * Creates a new SceneOptimizer
  141612. * @param scene defines the scene to work on
  141613. * @param options defines the options to use with the SceneOptimizer
  141614. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  141615. * @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)
  141616. */
  141617. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  141618. /**
  141619. * Stops the current optimizer
  141620. */
  141621. stop(): void;
  141622. /**
  141623. * Reset the optimizer to initial step (current priority level = 0)
  141624. */
  141625. reset(): void;
  141626. /**
  141627. * Start the optimizer. By default it will try to reach a specific framerate
  141628. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  141629. */
  141630. start(): void;
  141631. private _checkCurrentState;
  141632. /**
  141633. * Release all resources
  141634. */
  141635. dispose(): void;
  141636. /**
  141637. * Helper function to create a SceneOptimizer with one single line of code
  141638. * @param scene defines the scene to work on
  141639. * @param options defines the options to use with the SceneOptimizer
  141640. * @param onSuccess defines a callback to call on success
  141641. * @param onFailure defines a callback to call on failure
  141642. * @returns the new SceneOptimizer object
  141643. */
  141644. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  141645. }
  141646. }
  141647. declare module BABYLON {
  141648. /**
  141649. * Class used to serialize a scene into a string
  141650. */
  141651. export class SceneSerializer {
  141652. /**
  141653. * Clear cache used by a previous serialization
  141654. */
  141655. static ClearCache(): void;
  141656. /**
  141657. * Serialize a scene into a JSON compatible object
  141658. * @param scene defines the scene to serialize
  141659. * @returns a JSON compatible object
  141660. */
  141661. static Serialize(scene: Scene): any;
  141662. /**
  141663. * Serialize a mesh into a JSON compatible object
  141664. * @param toSerialize defines the mesh to serialize
  141665. * @param withParents defines if parents must be serialized as well
  141666. * @param withChildren defines if children must be serialized as well
  141667. * @returns a JSON compatible object
  141668. */
  141669. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  141670. }
  141671. }
  141672. declare module BABYLON {
  141673. /**
  141674. * Class used to host texture specific utilities
  141675. */
  141676. export class TextureTools {
  141677. /**
  141678. * Uses the GPU to create a copy texture rescaled at a given size
  141679. * @param texture Texture to copy from
  141680. * @param width defines the desired width
  141681. * @param height defines the desired height
  141682. * @param useBilinearMode defines if bilinear mode has to be used
  141683. * @return the generated texture
  141684. */
  141685. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  141686. }
  141687. }
  141688. declare module BABYLON {
  141689. /**
  141690. * This represents the different options available for the video capture.
  141691. */
  141692. export interface VideoRecorderOptions {
  141693. /** Defines the mime type of the video. */
  141694. mimeType: string;
  141695. /** Defines the FPS the video should be recorded at. */
  141696. fps: number;
  141697. /** Defines the chunk size for the recording data. */
  141698. recordChunckSize: number;
  141699. /** The audio tracks to attach to the recording. */
  141700. audioTracks?: MediaStreamTrack[];
  141701. }
  141702. /**
  141703. * This can help with recording videos from BabylonJS.
  141704. * This is based on the available WebRTC functionalities of the browser.
  141705. *
  141706. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  141707. */
  141708. export class VideoRecorder {
  141709. private static readonly _defaultOptions;
  141710. /**
  141711. * Returns whether or not the VideoRecorder is available in your browser.
  141712. * @param engine Defines the Babylon Engine.
  141713. * @returns true if supported otherwise false.
  141714. */
  141715. static IsSupported(engine: Engine): boolean;
  141716. private readonly _options;
  141717. private _canvas;
  141718. private _mediaRecorder;
  141719. private _recordedChunks;
  141720. private _fileName;
  141721. private _resolve;
  141722. private _reject;
  141723. /**
  141724. * True when a recording is already in progress.
  141725. */
  141726. get isRecording(): boolean;
  141727. /**
  141728. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  141729. * @param engine Defines the BabylonJS Engine you wish to record.
  141730. * @param options Defines options that can be used to customize the capture.
  141731. */
  141732. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  141733. /**
  141734. * Stops the current recording before the default capture timeout passed in the startRecording function.
  141735. */
  141736. stopRecording(): void;
  141737. /**
  141738. * Starts recording the canvas for a max duration specified in parameters.
  141739. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  141740. * If null no automatic download will start and you can rely on the promise to get the data back.
  141741. * @param maxDuration Defines the maximum recording time in seconds.
  141742. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  141743. * @return A promise callback at the end of the recording with the video data in Blob.
  141744. */
  141745. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  141746. /**
  141747. * Releases internal resources used during the recording.
  141748. */
  141749. dispose(): void;
  141750. private _handleDataAvailable;
  141751. private _handleError;
  141752. private _handleStop;
  141753. }
  141754. }
  141755. declare module BABYLON {
  141756. /**
  141757. * Class containing a set of static utilities functions for screenshots
  141758. */
  141759. export class ScreenshotTools {
  141760. /**
  141761. * Captures a screenshot of the current rendering
  141762. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141763. * @param engine defines the rendering engine
  141764. * @param camera defines the source camera
  141765. * @param size This parameter can be set to a single number or to an object with the
  141766. * following (optional) properties: precision, width, height. If a single number is passed,
  141767. * it will be used for both width and height. If an object is passed, the screenshot size
  141768. * will be derived from the parameters. The precision property is a multiplier allowing
  141769. * rendering at a higher or lower resolution
  141770. * @param successCallback defines the callback receives a single parameter which contains the
  141771. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141772. * src parameter of an <img> to display it
  141773. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141774. * Check your browser for supported MIME types
  141775. */
  141776. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  141777. /**
  141778. * Captures a screenshot of the current rendering
  141779. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141780. * @param engine defines the rendering engine
  141781. * @param camera defines the source camera
  141782. * @param size This parameter can be set to a single number or to an object with the
  141783. * following (optional) properties: precision, width, height. If a single number is passed,
  141784. * it will be used for both width and height. If an object is passed, the screenshot size
  141785. * will be derived from the parameters. The precision property is a multiplier allowing
  141786. * rendering at a higher or lower resolution
  141787. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141788. * Check your browser for supported MIME types
  141789. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141790. * to the src parameter of an <img> to display it
  141791. */
  141792. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  141793. /**
  141794. * Generates an image screenshot from the specified camera.
  141795. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141796. * @param engine The engine to use for rendering
  141797. * @param camera The camera to use for rendering
  141798. * @param size This parameter can be set to a single number or to an object with the
  141799. * following (optional) properties: precision, width, height. If a single number is passed,
  141800. * it will be used for both width and height. If an object is passed, the screenshot size
  141801. * will be derived from the parameters. The precision property is a multiplier allowing
  141802. * rendering at a higher or lower resolution
  141803. * @param successCallback The callback receives a single parameter which contains the
  141804. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141805. * src parameter of an <img> to display it
  141806. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141807. * Check your browser for supported MIME types
  141808. * @param samples Texture samples (default: 1)
  141809. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141810. * @param fileName A name for for the downloaded file.
  141811. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  141812. */
  141813. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  141814. /**
  141815. * Generates an image screenshot from the specified camera.
  141816. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141817. * @param engine The engine to use for rendering
  141818. * @param camera The camera to use for rendering
  141819. * @param size This parameter can be set to a single number or to an object with the
  141820. * following (optional) properties: precision, width, height. If a single number is passed,
  141821. * it will be used for both width and height. If an object is passed, the screenshot size
  141822. * will be derived from the parameters. The precision property is a multiplier allowing
  141823. * rendering at a higher or lower resolution
  141824. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141825. * Check your browser for supported MIME types
  141826. * @param samples Texture samples (default: 1)
  141827. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141828. * @param fileName A name for for the downloaded file.
  141829. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  141830. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141831. * to the src parameter of an <img> to display it
  141832. */
  141833. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  141834. /**
  141835. * Gets height and width for screenshot size
  141836. * @private
  141837. */
  141838. private static _getScreenshotSize;
  141839. }
  141840. }
  141841. declare module BABYLON {
  141842. /**
  141843. * Interface for a data buffer
  141844. */
  141845. export interface IDataBuffer {
  141846. /**
  141847. * Reads bytes from the data buffer.
  141848. * @param byteOffset The byte offset to read
  141849. * @param byteLength The byte length to read
  141850. * @returns A promise that resolves when the bytes are read
  141851. */
  141852. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  141853. /**
  141854. * The byte length of the buffer.
  141855. */
  141856. readonly byteLength: number;
  141857. }
  141858. /**
  141859. * Utility class for reading from a data buffer
  141860. */
  141861. export class DataReader {
  141862. /**
  141863. * The data buffer associated with this data reader.
  141864. */
  141865. readonly buffer: IDataBuffer;
  141866. /**
  141867. * The current byte offset from the beginning of the data buffer.
  141868. */
  141869. byteOffset: number;
  141870. private _dataView;
  141871. private _dataByteOffset;
  141872. /**
  141873. * Constructor
  141874. * @param buffer The buffer to read
  141875. */
  141876. constructor(buffer: IDataBuffer);
  141877. /**
  141878. * Loads the given byte length.
  141879. * @param byteLength The byte length to load
  141880. * @returns A promise that resolves when the load is complete
  141881. */
  141882. loadAsync(byteLength: number): Promise<void>;
  141883. /**
  141884. * Read a unsigned 32-bit integer from the currently loaded data range.
  141885. * @returns The 32-bit integer read
  141886. */
  141887. readUint32(): number;
  141888. /**
  141889. * Read a byte array from the currently loaded data range.
  141890. * @param byteLength The byte length to read
  141891. * @returns The byte array read
  141892. */
  141893. readUint8Array(byteLength: number): Uint8Array;
  141894. /**
  141895. * Read a string from the currently loaded data range.
  141896. * @param byteLength The byte length to read
  141897. * @returns The string read
  141898. */
  141899. readString(byteLength: number): string;
  141900. /**
  141901. * Skips the given byte length the currently loaded data range.
  141902. * @param byteLength The byte length to skip
  141903. */
  141904. skipBytes(byteLength: number): void;
  141905. }
  141906. }
  141907. declare module BABYLON {
  141908. /**
  141909. * Options used for hit testing
  141910. */
  141911. export interface IWebXRHitTestOptions {
  141912. /**
  141913. * Only test when user interacted with the scene. Default - hit test every frame
  141914. */
  141915. testOnPointerDownOnly?: boolean;
  141916. /**
  141917. * The node to use to transform the local results to world coordinates
  141918. */
  141919. worldParentNode?: TransformNode;
  141920. }
  141921. /**
  141922. * Interface defining the babylon result of raycasting/hit-test
  141923. */
  141924. export interface IWebXRHitResult {
  141925. /**
  141926. * Transformation matrix that can be applied to a node that will put it in the hit point location
  141927. */
  141928. transformationMatrix: Matrix;
  141929. /**
  141930. * The native hit test result
  141931. */
  141932. xrHitResult: XRHitResult;
  141933. }
  141934. /**
  141935. * The currently-working hit-test module.
  141936. * Hit test (or Ray-casting) is used to interact with the real world.
  141937. * For further information read here - https://github.com/immersive-web/hit-test
  141938. */
  141939. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  141940. /**
  141941. * options to use when constructing this feature
  141942. */
  141943. readonly options: IWebXRHitTestOptions;
  141944. private _direction;
  141945. private _mat;
  141946. private _onSelectEnabled;
  141947. private _origin;
  141948. /**
  141949. * The module's name
  141950. */
  141951. static readonly Name: string;
  141952. /**
  141953. * The (Babylon) version of this module.
  141954. * This is an integer representing the implementation version.
  141955. * This number does not correspond to the WebXR specs version
  141956. */
  141957. static readonly Version: number;
  141958. /**
  141959. * Populated with the last native XR Hit Results
  141960. */
  141961. lastNativeXRHitResults: XRHitResult[];
  141962. /**
  141963. * Triggered when new babylon (transformed) hit test results are available
  141964. */
  141965. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  141966. /**
  141967. * Creates a new instance of the (legacy version) hit test feature
  141968. * @param _xrSessionManager an instance of WebXRSessionManager
  141969. * @param options options to use when constructing this feature
  141970. */
  141971. constructor(_xrSessionManager: WebXRSessionManager,
  141972. /**
  141973. * options to use when constructing this feature
  141974. */
  141975. options?: IWebXRHitTestOptions);
  141976. /**
  141977. * execute a hit test with an XR Ray
  141978. *
  141979. * @param xrSession a native xrSession that will execute this hit test
  141980. * @param xrRay the ray (position and direction) to use for ray-casting
  141981. * @param referenceSpace native XR reference space to use for the hit-test
  141982. * @param filter filter function that will filter the results
  141983. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141984. */
  141985. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  141986. /**
  141987. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  141988. * @param event the (select) event to use to select with
  141989. * @param referenceSpace the reference space to use for this hit test
  141990. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141991. */
  141992. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  141993. /**
  141994. * attach this feature
  141995. * Will usually be called by the features manager
  141996. *
  141997. * @returns true if successful.
  141998. */
  141999. attach(): boolean;
  142000. /**
  142001. * detach this feature.
  142002. * Will usually be called by the features manager
  142003. *
  142004. * @returns true if successful.
  142005. */
  142006. detach(): boolean;
  142007. /**
  142008. * Dispose this feature and all of the resources attached
  142009. */
  142010. dispose(): void;
  142011. protected _onXRFrame(frame: XRFrame): void;
  142012. private _onHitTestResults;
  142013. private _onSelect;
  142014. }
  142015. }
  142016. declare module BABYLON {
  142017. /**
  142018. * Options used in the plane detector module
  142019. */
  142020. export interface IWebXRPlaneDetectorOptions {
  142021. /**
  142022. * The node to use to transform the local results to world coordinates
  142023. */
  142024. worldParentNode?: TransformNode;
  142025. }
  142026. /**
  142027. * A babylon interface for a WebXR plane.
  142028. * A Plane is actually a polygon, built from N points in space
  142029. *
  142030. * Supported in chrome 79, not supported in canary 81 ATM
  142031. */
  142032. export interface IWebXRPlane {
  142033. /**
  142034. * a babylon-assigned ID for this polygon
  142035. */
  142036. id: number;
  142037. /**
  142038. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  142039. */
  142040. polygonDefinition: Array<Vector3>;
  142041. /**
  142042. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  142043. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  142044. */
  142045. transformationMatrix: Matrix;
  142046. /**
  142047. * the native xr-plane object
  142048. */
  142049. xrPlane: XRPlane;
  142050. }
  142051. /**
  142052. * The plane detector is used to detect planes in the real world when in AR
  142053. * For more information see https://github.com/immersive-web/real-world-geometry/
  142054. */
  142055. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  142056. private _options;
  142057. private _detectedPlanes;
  142058. private _enabled;
  142059. private _lastFrameDetected;
  142060. /**
  142061. * The module's name
  142062. */
  142063. static readonly Name: string;
  142064. /**
  142065. * The (Babylon) version of this module.
  142066. * This is an integer representing the implementation version.
  142067. * This number does not correspond to the WebXR specs version
  142068. */
  142069. static readonly Version: number;
  142070. /**
  142071. * Observers registered here will be executed when a new plane was added to the session
  142072. */
  142073. onPlaneAddedObservable: Observable<IWebXRPlane>;
  142074. /**
  142075. * Observers registered here will be executed when a plane is no longer detected in the session
  142076. */
  142077. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  142078. /**
  142079. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  142080. * This can execute N times every frame
  142081. */
  142082. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  142083. /**
  142084. * construct a new Plane Detector
  142085. * @param _xrSessionManager an instance of xr Session manager
  142086. * @param _options configuration to use when constructing this feature
  142087. */
  142088. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  142089. /**
  142090. * Dispose this feature and all of the resources attached
  142091. */
  142092. dispose(): void;
  142093. protected _onXRFrame(frame: XRFrame): void;
  142094. private _init;
  142095. private _updatePlaneWithXRPlane;
  142096. /**
  142097. * avoiding using Array.find for global support.
  142098. * @param xrPlane the plane to find in the array
  142099. */
  142100. private findIndexInPlaneArray;
  142101. }
  142102. }
  142103. declare module BABYLON {
  142104. /**
  142105. * Configuration options of the anchor system
  142106. */
  142107. export interface IWebXRAnchorSystemOptions {
  142108. /**
  142109. * Should a new anchor be added every time a select event is triggered
  142110. */
  142111. addAnchorOnSelect?: boolean;
  142112. /**
  142113. * should the anchor system use plane detection.
  142114. * If set to true, the plane-detection feature should be set using setPlaneDetector
  142115. */
  142116. usePlaneDetection?: boolean;
  142117. /**
  142118. * a node that will be used to convert local to world coordinates
  142119. */
  142120. worldParentNode?: TransformNode;
  142121. }
  142122. /**
  142123. * A babylon container for an XR Anchor
  142124. */
  142125. export interface IWebXRAnchor {
  142126. /**
  142127. * A babylon-assigned ID for this anchor
  142128. */
  142129. id: number;
  142130. /**
  142131. * Transformation matrix to apply to an object attached to this anchor
  142132. */
  142133. transformationMatrix: Matrix;
  142134. /**
  142135. * The native anchor object
  142136. */
  142137. xrAnchor: XRAnchor;
  142138. }
  142139. /**
  142140. * An implementation of the anchor system of WebXR.
  142141. * Note that the current documented implementation is not available in any browser. Future implementations
  142142. * will use the frame to create an anchor and not the session or a detected plane
  142143. * For further information see https://github.com/immersive-web/anchors/
  142144. */
  142145. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  142146. private _options;
  142147. private _enabled;
  142148. private _hitTestModule;
  142149. private _lastFrameDetected;
  142150. private _onSelect;
  142151. private _planeDetector;
  142152. private _trackedAnchors;
  142153. /**
  142154. * The module's name
  142155. */
  142156. static readonly Name: string;
  142157. /**
  142158. * The (Babylon) version of this module.
  142159. * This is an integer representing the implementation version.
  142160. * This number does not correspond to the WebXR specs version
  142161. */
  142162. static readonly Version: number;
  142163. /**
  142164. * Observers registered here will be executed when a new anchor was added to the session
  142165. */
  142166. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  142167. /**
  142168. * Observers registered here will be executed when an anchor was removed from the session
  142169. */
  142170. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  142171. /**
  142172. * Observers registered here will be executed when an existing anchor updates
  142173. * This can execute N times every frame
  142174. */
  142175. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  142176. /**
  142177. * constructs a new anchor system
  142178. * @param _xrSessionManager an instance of WebXRSessionManager
  142179. * @param _options configuration object for this feature
  142180. */
  142181. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  142182. /**
  142183. * Add anchor at a specific XR point.
  142184. *
  142185. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  142186. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  142187. * @returns a promise the fulfills when the anchor was created
  142188. */
  142189. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  142190. /**
  142191. * attach this feature
  142192. * Will usually be called by the features manager
  142193. *
  142194. * @returns true if successful.
  142195. */
  142196. attach(): boolean;
  142197. /**
  142198. * detach this feature.
  142199. * Will usually be called by the features manager
  142200. *
  142201. * @returns true if successful.
  142202. */
  142203. detach(): boolean;
  142204. /**
  142205. * Dispose this feature and all of the resources attached
  142206. */
  142207. dispose(): void;
  142208. /**
  142209. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  142210. * @param hitTestModule the hit-test module to use.
  142211. */
  142212. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  142213. /**
  142214. * set the plane detector to use in order to create anchors from frames
  142215. * @param planeDetector the plane-detector module to use
  142216. * @param enable enable plane-anchors. default is true
  142217. */
  142218. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  142219. protected _onXRFrame(frame: XRFrame): void;
  142220. /**
  142221. * avoiding using Array.find for global support.
  142222. * @param xrAnchor the plane to find in the array
  142223. */
  142224. private _findIndexInAnchorArray;
  142225. private _updateAnchorWithXRFrame;
  142226. }
  142227. }
  142228. declare module BABYLON {
  142229. /**
  142230. * Options interface for the background remover plugin
  142231. */
  142232. export interface IWebXRBackgroundRemoverOptions {
  142233. /**
  142234. * Further background meshes to disable when entering AR
  142235. */
  142236. backgroundMeshes?: AbstractMesh[];
  142237. /**
  142238. * flags to configure the removal of the environment helper.
  142239. * If not set, the entire background will be removed. If set, flags should be set as well.
  142240. */
  142241. environmentHelperRemovalFlags?: {
  142242. /**
  142243. * Should the skybox be removed (default false)
  142244. */
  142245. skyBox?: boolean;
  142246. /**
  142247. * Should the ground be removed (default false)
  142248. */
  142249. ground?: boolean;
  142250. };
  142251. /**
  142252. * don't disable the environment helper
  142253. */
  142254. ignoreEnvironmentHelper?: boolean;
  142255. }
  142256. /**
  142257. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  142258. */
  142259. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  142260. /**
  142261. * read-only options to be used in this module
  142262. */
  142263. readonly options: IWebXRBackgroundRemoverOptions;
  142264. /**
  142265. * The module's name
  142266. */
  142267. static readonly Name: string;
  142268. /**
  142269. * The (Babylon) version of this module.
  142270. * This is an integer representing the implementation version.
  142271. * This number does not correspond to the WebXR specs version
  142272. */
  142273. static readonly Version: number;
  142274. /**
  142275. * registered observers will be triggered when the background state changes
  142276. */
  142277. onBackgroundStateChangedObservable: Observable<boolean>;
  142278. /**
  142279. * constructs a new background remover module
  142280. * @param _xrSessionManager the session manager for this module
  142281. * @param options read-only options to be used in this module
  142282. */
  142283. constructor(_xrSessionManager: WebXRSessionManager,
  142284. /**
  142285. * read-only options to be used in this module
  142286. */
  142287. options?: IWebXRBackgroundRemoverOptions);
  142288. /**
  142289. * attach this feature
  142290. * Will usually be called by the features manager
  142291. *
  142292. * @returns true if successful.
  142293. */
  142294. attach(): boolean;
  142295. /**
  142296. * detach this feature.
  142297. * Will usually be called by the features manager
  142298. *
  142299. * @returns true if successful.
  142300. */
  142301. detach(): boolean;
  142302. /**
  142303. * Dispose this feature and all of the resources attached
  142304. */
  142305. dispose(): void;
  142306. protected _onXRFrame(_xrFrame: XRFrame): void;
  142307. private _setBackgroundState;
  142308. }
  142309. }
  142310. declare module BABYLON {
  142311. /**
  142312. * Options for the controller physics feature
  142313. */
  142314. export class IWebXRControllerPhysicsOptions {
  142315. /**
  142316. * Should the headset get its own impostor
  142317. */
  142318. enableHeadsetImpostor?: boolean;
  142319. /**
  142320. * Optional parameters for the headset impostor
  142321. */
  142322. headsetImpostorParams?: {
  142323. /**
  142324. * The type of impostor to create. Default is sphere
  142325. */
  142326. impostorType: number;
  142327. /**
  142328. * the size of the impostor. Defaults to 10cm
  142329. */
  142330. impostorSize?: number | {
  142331. width: number;
  142332. height: number;
  142333. depth: number;
  142334. };
  142335. /**
  142336. * Friction definitions
  142337. */
  142338. friction?: number;
  142339. /**
  142340. * Restitution
  142341. */
  142342. restitution?: number;
  142343. };
  142344. /**
  142345. * The physics properties of the future impostors
  142346. */
  142347. physicsProperties?: {
  142348. /**
  142349. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  142350. * Note that this requires a physics engine that supports mesh impostors!
  142351. */
  142352. useControllerMesh?: boolean;
  142353. /**
  142354. * The type of impostor to create. Default is sphere
  142355. */
  142356. impostorType?: number;
  142357. /**
  142358. * the size of the impostor. Defaults to 10cm
  142359. */
  142360. impostorSize?: number | {
  142361. width: number;
  142362. height: number;
  142363. depth: number;
  142364. };
  142365. /**
  142366. * Friction definitions
  142367. */
  142368. friction?: number;
  142369. /**
  142370. * Restitution
  142371. */
  142372. restitution?: number;
  142373. };
  142374. /**
  142375. * the xr input to use with this pointer selection
  142376. */
  142377. xrInput: WebXRInput;
  142378. }
  142379. /**
  142380. * Add physics impostor to your webxr controllers,
  142381. * including naive calculation of their linear and angular velocity
  142382. */
  142383. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  142384. private readonly _options;
  142385. private _attachController;
  142386. private _controllers;
  142387. private _debugMode;
  142388. private _delta;
  142389. private _headsetImpostor?;
  142390. private _headsetMesh?;
  142391. private _lastTimestamp;
  142392. private _tmpQuaternion;
  142393. private _tmpVector;
  142394. /**
  142395. * The module's name
  142396. */
  142397. static readonly Name: string;
  142398. /**
  142399. * The (Babylon) version of this module.
  142400. * This is an integer representing the implementation version.
  142401. * This number does not correspond to the webxr specs version
  142402. */
  142403. static readonly Version: number;
  142404. /**
  142405. * Construct a new Controller Physics Feature
  142406. * @param _xrSessionManager the corresponding xr session manager
  142407. * @param _options options to create this feature with
  142408. */
  142409. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  142410. /**
  142411. * @hidden
  142412. * enable debugging - will show console outputs and the impostor mesh
  142413. */
  142414. _enablePhysicsDebug(): void;
  142415. /**
  142416. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  142417. * @param xrController the controller to add
  142418. */
  142419. addController(xrController: WebXRInputSource): void;
  142420. /**
  142421. * attach this feature
  142422. * Will usually be called by the features manager
  142423. *
  142424. * @returns true if successful.
  142425. */
  142426. attach(): boolean;
  142427. /**
  142428. * detach this feature.
  142429. * Will usually be called by the features manager
  142430. *
  142431. * @returns true if successful.
  142432. */
  142433. detach(): boolean;
  142434. /**
  142435. * Get the headset impostor, if enabled
  142436. * @returns the impostor
  142437. */
  142438. getHeadsetImpostor(): PhysicsImpostor | undefined;
  142439. /**
  142440. * Get the physics impostor of a specific controller.
  142441. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  142442. * @param controller the controller or the controller id of which to get the impostor
  142443. * @returns the impostor or null
  142444. */
  142445. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  142446. /**
  142447. * Update the physics properties provided in the constructor
  142448. * @param newProperties the new properties object
  142449. */
  142450. setPhysicsProperties(newProperties: {
  142451. impostorType?: number;
  142452. impostorSize?: number | {
  142453. width: number;
  142454. height: number;
  142455. depth: number;
  142456. };
  142457. friction?: number;
  142458. restitution?: number;
  142459. }): void;
  142460. protected _onXRFrame(_xrFrame: any): void;
  142461. private _detachController;
  142462. }
  142463. }
  142464. declare module BABYLON {
  142465. /**
  142466. * The motion controller class for all microsoft mixed reality controllers
  142467. */
  142468. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  142469. protected readonly _mapping: {
  142470. defaultButton: {
  142471. "valueNodeName": string;
  142472. "unpressedNodeName": string;
  142473. "pressedNodeName": string;
  142474. };
  142475. defaultAxis: {
  142476. "valueNodeName": string;
  142477. "minNodeName": string;
  142478. "maxNodeName": string;
  142479. };
  142480. buttons: {
  142481. "xr-standard-trigger": {
  142482. "rootNodeName": string;
  142483. "componentProperty": string;
  142484. "states": string[];
  142485. };
  142486. "xr-standard-squeeze": {
  142487. "rootNodeName": string;
  142488. "componentProperty": string;
  142489. "states": string[];
  142490. };
  142491. "xr-standard-touchpad": {
  142492. "rootNodeName": string;
  142493. "labelAnchorNodeName": string;
  142494. "touchPointNodeName": string;
  142495. };
  142496. "xr-standard-thumbstick": {
  142497. "rootNodeName": string;
  142498. "componentProperty": string;
  142499. "states": string[];
  142500. };
  142501. };
  142502. axes: {
  142503. "xr-standard-touchpad": {
  142504. "x-axis": {
  142505. "rootNodeName": string;
  142506. };
  142507. "y-axis": {
  142508. "rootNodeName": string;
  142509. };
  142510. };
  142511. "xr-standard-thumbstick": {
  142512. "x-axis": {
  142513. "rootNodeName": string;
  142514. };
  142515. "y-axis": {
  142516. "rootNodeName": string;
  142517. };
  142518. };
  142519. };
  142520. };
  142521. /**
  142522. * The base url used to load the left and right controller models
  142523. */
  142524. static MODEL_BASE_URL: string;
  142525. /**
  142526. * The name of the left controller model file
  142527. */
  142528. static MODEL_LEFT_FILENAME: string;
  142529. /**
  142530. * The name of the right controller model file
  142531. */
  142532. static MODEL_RIGHT_FILENAME: string;
  142533. profileId: string;
  142534. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142535. protected _getFilenameAndPath(): {
  142536. filename: string;
  142537. path: string;
  142538. };
  142539. protected _getModelLoadingConstraints(): boolean;
  142540. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142541. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142542. protected _updateModel(): void;
  142543. }
  142544. }
  142545. declare module BABYLON {
  142546. /**
  142547. * The motion controller class for oculus touch (quest, rift).
  142548. * This class supports legacy mapping as well the standard xr mapping
  142549. */
  142550. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  142551. private _forceLegacyControllers;
  142552. private _modelRootNode;
  142553. /**
  142554. * The base url used to load the left and right controller models
  142555. */
  142556. static MODEL_BASE_URL: string;
  142557. /**
  142558. * The name of the left controller model file
  142559. */
  142560. static MODEL_LEFT_FILENAME: string;
  142561. /**
  142562. * The name of the right controller model file
  142563. */
  142564. static MODEL_RIGHT_FILENAME: string;
  142565. /**
  142566. * Base Url for the Quest controller model.
  142567. */
  142568. static QUEST_MODEL_BASE_URL: string;
  142569. profileId: string;
  142570. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  142571. protected _getFilenameAndPath(): {
  142572. filename: string;
  142573. path: string;
  142574. };
  142575. protected _getModelLoadingConstraints(): boolean;
  142576. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142577. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142578. protected _updateModel(): void;
  142579. /**
  142580. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  142581. * between the touch and touch 2.
  142582. */
  142583. private _isQuest;
  142584. }
  142585. }
  142586. declare module BABYLON {
  142587. /**
  142588. * The motion controller class for the standard HTC-Vive controllers
  142589. */
  142590. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  142591. private _modelRootNode;
  142592. /**
  142593. * The base url used to load the left and right controller models
  142594. */
  142595. static MODEL_BASE_URL: string;
  142596. /**
  142597. * File name for the controller model.
  142598. */
  142599. static MODEL_FILENAME: string;
  142600. profileId: string;
  142601. /**
  142602. * Create a new Vive motion controller object
  142603. * @param scene the scene to use to create this controller
  142604. * @param gamepadObject the corresponding gamepad object
  142605. * @param handness the handness of the controller
  142606. */
  142607. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142608. protected _getFilenameAndPath(): {
  142609. filename: string;
  142610. path: string;
  142611. };
  142612. protected _getModelLoadingConstraints(): boolean;
  142613. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142614. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142615. protected _updateModel(): void;
  142616. }
  142617. }
  142618. declare module BABYLON {
  142619. /**
  142620. * A cursor which tracks a point on a path
  142621. */
  142622. export class PathCursor {
  142623. private path;
  142624. /**
  142625. * Stores path cursor callbacks for when an onchange event is triggered
  142626. */
  142627. private _onchange;
  142628. /**
  142629. * The value of the path cursor
  142630. */
  142631. value: number;
  142632. /**
  142633. * The animation array of the path cursor
  142634. */
  142635. animations: Animation[];
  142636. /**
  142637. * Initializes the path cursor
  142638. * @param path The path to track
  142639. */
  142640. constructor(path: Path2);
  142641. /**
  142642. * Gets the cursor point on the path
  142643. * @returns A point on the path cursor at the cursor location
  142644. */
  142645. getPoint(): Vector3;
  142646. /**
  142647. * Moves the cursor ahead by the step amount
  142648. * @param step The amount to move the cursor forward
  142649. * @returns This path cursor
  142650. */
  142651. moveAhead(step?: number): PathCursor;
  142652. /**
  142653. * Moves the cursor behind by the step amount
  142654. * @param step The amount to move the cursor back
  142655. * @returns This path cursor
  142656. */
  142657. moveBack(step?: number): PathCursor;
  142658. /**
  142659. * Moves the cursor by the step amount
  142660. * If the step amount is greater than one, an exception is thrown
  142661. * @param step The amount to move the cursor
  142662. * @returns This path cursor
  142663. */
  142664. move(step: number): PathCursor;
  142665. /**
  142666. * Ensures that the value is limited between zero and one
  142667. * @returns This path cursor
  142668. */
  142669. private ensureLimits;
  142670. /**
  142671. * Runs onchange callbacks on change (used by the animation engine)
  142672. * @returns This path cursor
  142673. */
  142674. private raiseOnChange;
  142675. /**
  142676. * Executes a function on change
  142677. * @param f A path cursor onchange callback
  142678. * @returns This path cursor
  142679. */
  142680. onchange(f: (cursor: PathCursor) => void): PathCursor;
  142681. }
  142682. }
  142683. declare module BABYLON {
  142684. /** @hidden */
  142685. export var blurPixelShader: {
  142686. name: string;
  142687. shader: string;
  142688. };
  142689. }
  142690. declare module BABYLON {
  142691. /** @hidden */
  142692. export var pointCloudVertexDeclaration: {
  142693. name: string;
  142694. shader: string;
  142695. };
  142696. }
  142697. // Mixins
  142698. interface Window {
  142699. mozIndexedDB: IDBFactory;
  142700. webkitIndexedDB: IDBFactory;
  142701. msIndexedDB: IDBFactory;
  142702. webkitURL: typeof URL;
  142703. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  142704. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  142705. WebGLRenderingContext: WebGLRenderingContext;
  142706. MSGesture: MSGesture;
  142707. CANNON: any;
  142708. AudioContext: AudioContext;
  142709. webkitAudioContext: AudioContext;
  142710. PointerEvent: any;
  142711. Math: Math;
  142712. Uint8Array: Uint8ArrayConstructor;
  142713. Float32Array: Float32ArrayConstructor;
  142714. mozURL: typeof URL;
  142715. msURL: typeof URL;
  142716. VRFrameData: any; // WebVR, from specs 1.1
  142717. DracoDecoderModule: any;
  142718. setImmediate(handler: (...args: any[]) => void): number;
  142719. }
  142720. interface HTMLCanvasElement {
  142721. requestPointerLock(): void;
  142722. msRequestPointerLock?(): void;
  142723. mozRequestPointerLock?(): void;
  142724. webkitRequestPointerLock?(): void;
  142725. /** Track wether a record is in progress */
  142726. isRecording: boolean;
  142727. /** Capture Stream method defined by some browsers */
  142728. captureStream(fps?: number): MediaStream;
  142729. }
  142730. interface CanvasRenderingContext2D {
  142731. msImageSmoothingEnabled: boolean;
  142732. }
  142733. interface MouseEvent {
  142734. mozMovementX: number;
  142735. mozMovementY: number;
  142736. webkitMovementX: number;
  142737. webkitMovementY: number;
  142738. msMovementX: number;
  142739. msMovementY: number;
  142740. }
  142741. interface Navigator {
  142742. mozGetVRDevices: (any: any) => any;
  142743. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142744. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142745. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142746. webkitGetGamepads(): Gamepad[];
  142747. msGetGamepads(): Gamepad[];
  142748. webkitGamepads(): Gamepad[];
  142749. }
  142750. interface HTMLVideoElement {
  142751. mozSrcObject: any;
  142752. }
  142753. interface Math {
  142754. fround(x: number): number;
  142755. imul(a: number, b: number): number;
  142756. }
  142757. interface WebGLRenderingContext {
  142758. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  142759. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  142760. vertexAttribDivisor(index: number, divisor: number): void;
  142761. createVertexArray(): any;
  142762. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  142763. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  142764. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  142765. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  142766. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  142767. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  142768. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  142769. // Queries
  142770. createQuery(): WebGLQuery;
  142771. deleteQuery(query: WebGLQuery): void;
  142772. beginQuery(target: number, query: WebGLQuery): void;
  142773. endQuery(target: number): void;
  142774. getQueryParameter(query: WebGLQuery, pname: number): any;
  142775. getQuery(target: number, pname: number): any;
  142776. MAX_SAMPLES: number;
  142777. RGBA8: number;
  142778. READ_FRAMEBUFFER: number;
  142779. DRAW_FRAMEBUFFER: number;
  142780. UNIFORM_BUFFER: number;
  142781. HALF_FLOAT_OES: number;
  142782. RGBA16F: number;
  142783. RGBA32F: number;
  142784. R32F: number;
  142785. RG32F: number;
  142786. RGB32F: number;
  142787. R16F: number;
  142788. RG16F: number;
  142789. RGB16F: number;
  142790. RED: number;
  142791. RG: number;
  142792. R8: number;
  142793. RG8: number;
  142794. UNSIGNED_INT_24_8: number;
  142795. DEPTH24_STENCIL8: number;
  142796. MIN: number;
  142797. MAX: number;
  142798. /* Multiple Render Targets */
  142799. drawBuffers(buffers: number[]): void;
  142800. readBuffer(src: number): void;
  142801. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  142802. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  142803. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  142804. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  142805. // Occlusion Query
  142806. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  142807. ANY_SAMPLES_PASSED: number;
  142808. QUERY_RESULT_AVAILABLE: number;
  142809. QUERY_RESULT: number;
  142810. }
  142811. interface WebGLProgram {
  142812. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  142813. }
  142814. interface EXT_disjoint_timer_query {
  142815. QUERY_COUNTER_BITS_EXT: number;
  142816. TIME_ELAPSED_EXT: number;
  142817. TIMESTAMP_EXT: number;
  142818. GPU_DISJOINT_EXT: number;
  142819. QUERY_RESULT_EXT: number;
  142820. QUERY_RESULT_AVAILABLE_EXT: number;
  142821. queryCounterEXT(query: WebGLQuery, target: number): void;
  142822. createQueryEXT(): WebGLQuery;
  142823. beginQueryEXT(target: number, query: WebGLQuery): void;
  142824. endQueryEXT(target: number): void;
  142825. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  142826. deleteQueryEXT(query: WebGLQuery): void;
  142827. }
  142828. interface WebGLUniformLocation {
  142829. _currentState: any;
  142830. }
  142831. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  142832. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  142833. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  142834. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142835. interface WebGLRenderingContext {
  142836. readonly RASTERIZER_DISCARD: number;
  142837. readonly DEPTH_COMPONENT24: number;
  142838. readonly TEXTURE_3D: number;
  142839. readonly TEXTURE_2D_ARRAY: number;
  142840. readonly TEXTURE_COMPARE_FUNC: number;
  142841. readonly TEXTURE_COMPARE_MODE: number;
  142842. readonly COMPARE_REF_TO_TEXTURE: number;
  142843. readonly TEXTURE_WRAP_R: number;
  142844. readonly HALF_FLOAT: number;
  142845. readonly RGB8: number;
  142846. readonly RED_INTEGER: number;
  142847. readonly RG_INTEGER: number;
  142848. readonly RGB_INTEGER: number;
  142849. readonly RGBA_INTEGER: number;
  142850. readonly R8_SNORM: number;
  142851. readonly RG8_SNORM: number;
  142852. readonly RGB8_SNORM: number;
  142853. readonly RGBA8_SNORM: number;
  142854. readonly R8I: number;
  142855. readonly RG8I: number;
  142856. readonly RGB8I: number;
  142857. readonly RGBA8I: number;
  142858. readonly R8UI: number;
  142859. readonly RG8UI: number;
  142860. readonly RGB8UI: number;
  142861. readonly RGBA8UI: number;
  142862. readonly R16I: number;
  142863. readonly RG16I: number;
  142864. readonly RGB16I: number;
  142865. readonly RGBA16I: number;
  142866. readonly R16UI: number;
  142867. readonly RG16UI: number;
  142868. readonly RGB16UI: number;
  142869. readonly RGBA16UI: number;
  142870. readonly R32I: number;
  142871. readonly RG32I: number;
  142872. readonly RGB32I: number;
  142873. readonly RGBA32I: number;
  142874. readonly R32UI: number;
  142875. readonly RG32UI: number;
  142876. readonly RGB32UI: number;
  142877. readonly RGBA32UI: number;
  142878. readonly RGB10_A2UI: number;
  142879. readonly R11F_G11F_B10F: number;
  142880. readonly RGB9_E5: number;
  142881. readonly RGB10_A2: number;
  142882. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  142883. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  142884. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  142885. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  142886. readonly DEPTH_COMPONENT32F: number;
  142887. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  142888. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  142889. 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;
  142890. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  142891. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  142892. readonly TRANSFORM_FEEDBACK: number;
  142893. readonly INTERLEAVED_ATTRIBS: number;
  142894. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  142895. createTransformFeedback(): WebGLTransformFeedback;
  142896. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  142897. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  142898. beginTransformFeedback(primitiveMode: number): void;
  142899. endTransformFeedback(): void;
  142900. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  142901. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142902. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142903. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142904. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  142905. }
  142906. interface ImageBitmap {
  142907. readonly width: number;
  142908. readonly height: number;
  142909. close(): void;
  142910. }
  142911. interface WebGLQuery extends WebGLObject {
  142912. }
  142913. declare var WebGLQuery: {
  142914. prototype: WebGLQuery;
  142915. new(): WebGLQuery;
  142916. };
  142917. interface WebGLSampler extends WebGLObject {
  142918. }
  142919. declare var WebGLSampler: {
  142920. prototype: WebGLSampler;
  142921. new(): WebGLSampler;
  142922. };
  142923. interface WebGLSync extends WebGLObject {
  142924. }
  142925. declare var WebGLSync: {
  142926. prototype: WebGLSync;
  142927. new(): WebGLSync;
  142928. };
  142929. interface WebGLTransformFeedback extends WebGLObject {
  142930. }
  142931. declare var WebGLTransformFeedback: {
  142932. prototype: WebGLTransformFeedback;
  142933. new(): WebGLTransformFeedback;
  142934. };
  142935. interface WebGLVertexArrayObject extends WebGLObject {
  142936. }
  142937. declare var WebGLVertexArrayObject: {
  142938. prototype: WebGLVertexArrayObject;
  142939. new(): WebGLVertexArrayObject;
  142940. };
  142941. // Type definitions for WebVR API
  142942. // Project: https://w3c.github.io/webvr/
  142943. // Definitions by: six a <https://github.com/lostfictions>
  142944. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142945. interface VRDisplay extends EventTarget {
  142946. /**
  142947. * Dictionary of capabilities describing the VRDisplay.
  142948. */
  142949. readonly capabilities: VRDisplayCapabilities;
  142950. /**
  142951. * z-depth defining the far plane of the eye view frustum
  142952. * enables mapping of values in the render target depth
  142953. * attachment to scene coordinates. Initially set to 10000.0.
  142954. */
  142955. depthFar: number;
  142956. /**
  142957. * z-depth defining the near plane of the eye view frustum
  142958. * enables mapping of values in the render target depth
  142959. * attachment to scene coordinates. Initially set to 0.01.
  142960. */
  142961. depthNear: number;
  142962. /**
  142963. * An identifier for this distinct VRDisplay. Used as an
  142964. * association point in the Gamepad API.
  142965. */
  142966. readonly displayId: number;
  142967. /**
  142968. * A display name, a user-readable name identifying it.
  142969. */
  142970. readonly displayName: string;
  142971. readonly isConnected: boolean;
  142972. readonly isPresenting: boolean;
  142973. /**
  142974. * If this VRDisplay supports room-scale experiences, the optional
  142975. * stage attribute contains details on the room-scale parameters.
  142976. */
  142977. readonly stageParameters: VRStageParameters | null;
  142978. /**
  142979. * Passing the value returned by `requestAnimationFrame` to
  142980. * `cancelAnimationFrame` will unregister the callback.
  142981. * @param handle Define the hanle of the request to cancel
  142982. */
  142983. cancelAnimationFrame(handle: number): void;
  142984. /**
  142985. * Stops presenting to the VRDisplay.
  142986. * @returns a promise to know when it stopped
  142987. */
  142988. exitPresent(): Promise<void>;
  142989. /**
  142990. * Return the current VREyeParameters for the given eye.
  142991. * @param whichEye Define the eye we want the parameter for
  142992. * @returns the eye parameters
  142993. */
  142994. getEyeParameters(whichEye: string): VREyeParameters;
  142995. /**
  142996. * Populates the passed VRFrameData with the information required to render
  142997. * the current frame.
  142998. * @param frameData Define the data structure to populate
  142999. * @returns true if ok otherwise false
  143000. */
  143001. getFrameData(frameData: VRFrameData): boolean;
  143002. /**
  143003. * Get the layers currently being presented.
  143004. * @returns the list of VR layers
  143005. */
  143006. getLayers(): VRLayer[];
  143007. /**
  143008. * Return a VRPose containing the future predicted pose of the VRDisplay
  143009. * when the current frame will be presented. The value returned will not
  143010. * change until JavaScript has returned control to the browser.
  143011. *
  143012. * The VRPose will contain the position, orientation, velocity,
  143013. * and acceleration of each of these properties.
  143014. * @returns the pose object
  143015. */
  143016. getPose(): VRPose;
  143017. /**
  143018. * Return the current instantaneous pose of the VRDisplay, with no
  143019. * prediction applied.
  143020. * @returns the current instantaneous pose
  143021. */
  143022. getImmediatePose(): VRPose;
  143023. /**
  143024. * The callback passed to `requestAnimationFrame` will be called
  143025. * any time a new frame should be rendered. When the VRDisplay is
  143026. * presenting the callback will be called at the native refresh
  143027. * rate of the HMD. When not presenting this function acts
  143028. * identically to how window.requestAnimationFrame acts. Content should
  143029. * make no assumptions of frame rate or vsync behavior as the HMD runs
  143030. * asynchronously from other displays and at differing refresh rates.
  143031. * @param callback Define the eaction to run next frame
  143032. * @returns the request handle it
  143033. */
  143034. requestAnimationFrame(callback: FrameRequestCallback): number;
  143035. /**
  143036. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  143037. * Repeat calls while already presenting will update the VRLayers being displayed.
  143038. * @param layers Define the list of layer to present
  143039. * @returns a promise to know when the request has been fulfilled
  143040. */
  143041. requestPresent(layers: VRLayer[]): Promise<void>;
  143042. /**
  143043. * Reset the pose for this display, treating its current position and
  143044. * orientation as the "origin/zero" values. VRPose.position,
  143045. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  143046. * updated when calling resetPose(). This should be called in only
  143047. * sitting-space experiences.
  143048. */
  143049. resetPose(): void;
  143050. /**
  143051. * The VRLayer provided to the VRDisplay will be captured and presented
  143052. * in the HMD. Calling this function has the same effect on the source
  143053. * canvas as any other operation that uses its source image, and canvases
  143054. * created without preserveDrawingBuffer set to true will be cleared.
  143055. * @param pose Define the pose to submit
  143056. */
  143057. submitFrame(pose?: VRPose): void;
  143058. }
  143059. declare var VRDisplay: {
  143060. prototype: VRDisplay;
  143061. new(): VRDisplay;
  143062. };
  143063. interface VRLayer {
  143064. leftBounds?: number[] | Float32Array | null;
  143065. rightBounds?: number[] | Float32Array | null;
  143066. source?: HTMLCanvasElement | null;
  143067. }
  143068. interface VRDisplayCapabilities {
  143069. readonly canPresent: boolean;
  143070. readonly hasExternalDisplay: boolean;
  143071. readonly hasOrientation: boolean;
  143072. readonly hasPosition: boolean;
  143073. readonly maxLayers: number;
  143074. }
  143075. interface VREyeParameters {
  143076. /** @deprecated */
  143077. readonly fieldOfView: VRFieldOfView;
  143078. readonly offset: Float32Array;
  143079. readonly renderHeight: number;
  143080. readonly renderWidth: number;
  143081. }
  143082. interface VRFieldOfView {
  143083. readonly downDegrees: number;
  143084. readonly leftDegrees: number;
  143085. readonly rightDegrees: number;
  143086. readonly upDegrees: number;
  143087. }
  143088. interface VRFrameData {
  143089. readonly leftProjectionMatrix: Float32Array;
  143090. readonly leftViewMatrix: Float32Array;
  143091. readonly pose: VRPose;
  143092. readonly rightProjectionMatrix: Float32Array;
  143093. readonly rightViewMatrix: Float32Array;
  143094. readonly timestamp: number;
  143095. }
  143096. interface VRPose {
  143097. readonly angularAcceleration: Float32Array | null;
  143098. readonly angularVelocity: Float32Array | null;
  143099. readonly linearAcceleration: Float32Array | null;
  143100. readonly linearVelocity: Float32Array | null;
  143101. readonly orientation: Float32Array | null;
  143102. readonly position: Float32Array | null;
  143103. readonly timestamp: number;
  143104. }
  143105. interface VRStageParameters {
  143106. sittingToStandingTransform?: Float32Array;
  143107. sizeX?: number;
  143108. sizeY?: number;
  143109. }
  143110. interface Navigator {
  143111. getVRDisplays(): Promise<VRDisplay[]>;
  143112. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  143113. }
  143114. interface Window {
  143115. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  143116. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  143117. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  143118. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143119. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143120. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  143121. }
  143122. interface Gamepad {
  143123. readonly displayId: number;
  143124. }
  143125. type XRSessionMode =
  143126. | "inline"
  143127. | "immersive-vr"
  143128. | "immersive-ar";
  143129. type XRReferenceSpaceType =
  143130. | "viewer"
  143131. | "local"
  143132. | "local-floor"
  143133. | "bounded-floor"
  143134. | "unbounded";
  143135. type XREnvironmentBlendMode =
  143136. | "opaque"
  143137. | "additive"
  143138. | "alpha-blend";
  143139. type XRVisibilityState =
  143140. | "visible"
  143141. | "visible-blurred"
  143142. | "hidden";
  143143. type XRHandedness =
  143144. | "none"
  143145. | "left"
  143146. | "right";
  143147. type XRTargetRayMode =
  143148. | "gaze"
  143149. | "tracked-pointer"
  143150. | "screen";
  143151. type XREye =
  143152. | "none"
  143153. | "left"
  143154. | "right";
  143155. interface XRSpace extends EventTarget {
  143156. }
  143157. interface XRRenderState {
  143158. depthNear?: number;
  143159. depthFar?: number;
  143160. inlineVerticalFieldOfView?: number;
  143161. baseLayer?: XRWebGLLayer;
  143162. }
  143163. interface XRInputSource {
  143164. handedness: XRHandedness;
  143165. targetRayMode: XRTargetRayMode;
  143166. targetRaySpace: XRSpace;
  143167. gripSpace: XRSpace | undefined;
  143168. gamepad: Gamepad | undefined;
  143169. profiles: Array<string>;
  143170. }
  143171. interface XRSessionInit {
  143172. optionalFeatures?: XRReferenceSpaceType[];
  143173. requiredFeatures?: XRReferenceSpaceType[];
  143174. }
  143175. interface XRSession extends XRAnchorCreator {
  143176. addEventListener: Function;
  143177. removeEventListener: Function;
  143178. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  143179. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  143180. requestAnimationFrame: Function;
  143181. end(): Promise<void>;
  143182. renderState: XRRenderState;
  143183. inputSources: Array<XRInputSource>;
  143184. // AR hit test
  143185. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143186. updateWorldTrackingState(options: {
  143187. planeDetectionState?: { enabled: boolean; }
  143188. }): void;
  143189. }
  143190. interface XRReferenceSpace extends XRSpace {
  143191. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  143192. onreset: any;
  143193. }
  143194. type XRPlaneSet = Set<XRPlane>;
  143195. type XRAnchorSet = Set<XRAnchor>;
  143196. interface XRFrame {
  143197. session: XRSession;
  143198. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  143199. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  143200. // Anchors
  143201. trackedAnchors?: XRAnchorSet;
  143202. // Planes
  143203. worldInformation: {
  143204. detectedPlanes?: XRPlaneSet;
  143205. };
  143206. }
  143207. interface XRViewerPose extends XRPose {
  143208. views: Array<XRView>;
  143209. }
  143210. interface XRPose {
  143211. transform: XRRigidTransform;
  143212. emulatedPosition: boolean;
  143213. }
  143214. interface XRWebGLLayerOptions {
  143215. antialias?: boolean;
  143216. depth?: boolean;
  143217. stencil?: boolean;
  143218. alpha?: boolean;
  143219. multiview?: boolean;
  143220. framebufferScaleFactor?: number;
  143221. }
  143222. declare var XRWebGLLayer: {
  143223. prototype: XRWebGLLayer;
  143224. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  143225. };
  143226. interface XRWebGLLayer {
  143227. framebuffer: WebGLFramebuffer;
  143228. framebufferWidth: number;
  143229. framebufferHeight: number;
  143230. getViewport: Function;
  143231. }
  143232. declare class XRRigidTransform {
  143233. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  143234. position: DOMPointReadOnly;
  143235. orientation: DOMPointReadOnly;
  143236. matrix: Float32Array;
  143237. inverse: XRRigidTransform;
  143238. }
  143239. interface XRView {
  143240. eye: XREye;
  143241. projectionMatrix: Float32Array;
  143242. transform: XRRigidTransform;
  143243. }
  143244. interface XRInputSourceChangeEvent {
  143245. session: XRSession;
  143246. removed: Array<XRInputSource>;
  143247. added: Array<XRInputSource>;
  143248. }
  143249. interface XRInputSourceEvent extends Event {
  143250. readonly frame: XRFrame;
  143251. readonly inputSource: XRInputSource;
  143252. }
  143253. // Experimental(er) features
  143254. declare class XRRay {
  143255. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  143256. origin: DOMPointReadOnly;
  143257. direction: DOMPointReadOnly;
  143258. matrix: Float32Array;
  143259. }
  143260. interface XRHitResult {
  143261. hitMatrix: Float32Array;
  143262. }
  143263. interface XRAnchor {
  143264. // remove?
  143265. id?: string;
  143266. anchorSpace: XRSpace;
  143267. lastChangedTime: number;
  143268. detach(): void;
  143269. }
  143270. interface XRPlane extends XRAnchorCreator {
  143271. orientation: "Horizontal" | "Vertical";
  143272. planeSpace: XRSpace;
  143273. polygon: Array<DOMPointReadOnly>;
  143274. lastChangedTime: number;
  143275. }
  143276. interface XRAnchorCreator {
  143277. // AR Anchors
  143278. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  143279. }